-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "tearing.hpp" | ||
|
||
#include "server.hpp" | ||
|
||
#include <surface/surface.hpp> | ||
|
||
void tearing_manager_new_object_notify(wl_listener* listener, void* data) { | ||
TearingManager& tearing_manager = magpie_container_of(listener, tearing_manager, new_object); | ||
auto& tearing_object_wlr = *static_cast<wlr_tearing_control_v1*>(data); | ||
|
||
tearing_manager.tearing_objects.push_back(std::make_unique<TearingObject>(tearing_manager, tearing_object_wlr)); | ||
} | ||
|
||
void tearing_object_set_hint_notify(wl_listener* listener, void*) { | ||
TearingObject& tearing_object = magpie_container_of(listener, tearing_object, set_hint); | ||
|
||
auto* surface = static_cast<Surface*>(tearing_object.wlr.surface->data); | ||
surface->tearing_hint = static_cast<wp_tearing_control_v1_presentation_hint>(tearing_object.wlr.hint); | ||
} | ||
|
||
void tearing_object_destroy_notify(wl_listener* listener, void*) { | ||
TearingObject& tearing_object = magpie_container_of(listener, tearing_object, destroy); | ||
std::erase_if(tearing_object.parent.tearing_objects, [&](const auto& other) { return other.get() == &tearing_object; }); | ||
} | ||
|
||
TearingManager::TearingManager(Server& server) noexcept : listeners(*this), server(server) { | ||
wlr = wlr_tearing_control_manager_v1_create(server.display, 1); | ||
|
||
listeners.new_object.notify = tearing_manager_new_object_notify; | ||
wl_signal_add(&wlr->events.new_object, &listeners.new_object); | ||
} | ||
|
||
TearingObject::TearingObject(TearingManager& parent, wlr_tearing_control_v1& wlr) noexcept | ||
: listeners(*this), parent(parent), wlr(wlr) { | ||
listeners.destroy.notify = tearing_object_destroy_notify; | ||
wl_signal_add(&wlr.events.destroy, &listeners.destroy); | ||
listeners.set_hint.notify = tearing_object_set_hint_notify; | ||
wl_signal_add(&wlr.events.set_hint, &listeners.set_hint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef MAGPIE_TEARING_HPP | ||
#define MAGPIE_TEARING_HPP | ||
|
||
#include "types.hpp" | ||
|
||
#include <functional> | ||
#include <list> | ||
#include <memory> | ||
|
||
#include "wlr-wrap-start.hpp" | ||
#include <wlr/types/wlr_tearing_control_v1.h> | ||
#include "wlr-wrap-end.hpp" | ||
|
||
class TearingObject { | ||
public: | ||
struct Listeners { | ||
std::reference_wrapper<TearingObject> parent; | ||
wl_listener set_hint = {}; | ||
wl_listener destroy = {}; | ||
explicit Listeners(TearingObject& parent) noexcept : parent(parent) {} | ||
}; | ||
|
||
private: | ||
Listeners listeners; | ||
|
||
public: | ||
TearingManager& parent; | ||
wlr_tearing_control_v1& wlr; | ||
|
||
explicit TearingObject(TearingManager& parent, wlr_tearing_control_v1& wlr) noexcept; | ||
}; | ||
|
||
class TearingManager { | ||
public: | ||
struct Listeners { | ||
std::reference_wrapper<TearingManager> parent; | ||
wl_listener new_object = {}; | ||
explicit Listeners(TearingManager& parent) noexcept : parent(parent) {} | ||
}; | ||
|
||
private: | ||
Listeners listeners; | ||
|
||
public: | ||
Server& server; | ||
wlr_tearing_control_manager_v1* wlr; | ||
std::list<std::unique_ptr<TearingObject>> tearing_objects; | ||
|
||
explicit TearingManager(Server& server) noexcept; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters