mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-17 21:13:48 -07:00
protocols: implement hyprland-ctm-control rev 2 (#9267)
* protocols: implement hyprland-ctm-control v2 * bump h-p and nix
This commit is contained in:
@@ -15,6 +15,9 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlM
|
||||
|
||||
resource->setSetCtmForOutput([this](CHyprlandCtmControlManagerV1* r, wl_resource* output, wl_fixed_t mat0, wl_fixed_t mat1, wl_fixed_t mat2, wl_fixed_t mat3, wl_fixed_t mat4,
|
||||
wl_fixed_t mat5, wl_fixed_t mat6, wl_fixed_t mat7, wl_fixed_t mat8) {
|
||||
if (blocked)
|
||||
return;
|
||||
|
||||
const auto OUTPUTRESOURCE = CWLOutputResource::fromResource(output);
|
||||
|
||||
if UNLIKELY (!OUTPUTRESOURCE)
|
||||
@@ -41,6 +44,9 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlM
|
||||
});
|
||||
|
||||
resource->setCommit([this](CHyprlandCtmControlManagerV1* r) {
|
||||
if (blocked)
|
||||
return;
|
||||
|
||||
LOGM(LOG, "Committing ctms to outputs");
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||
@@ -54,7 +60,17 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlM
|
||||
});
|
||||
}
|
||||
|
||||
void CHyprlandCTMControlResource::block() {
|
||||
blocked = true;
|
||||
|
||||
if (resource->version() >= 2)
|
||||
resource->sendBlocked();
|
||||
}
|
||||
|
||||
CHyprlandCTMControlResource::~CHyprlandCTMControlResource() {
|
||||
if (blocked)
|
||||
return;
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||
PROTO::ctm->setCTM(m, Mat3x3::identity());
|
||||
}
|
||||
@@ -69,7 +85,6 @@ CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* ifa
|
||||
}
|
||||
|
||||
void CHyprlandCTMControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CHyprlandCTMControlResource>(makeShared<CHyprlandCtmControlManagerV1>(client, ver, id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
@@ -78,6 +93,11 @@ void CHyprlandCTMControlProtocol::bindManager(wl_client* client, void* data, uin
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pManager)
|
||||
RESOURCE->block();
|
||||
else
|
||||
m_pManager = RESOURCE;
|
||||
|
||||
LOGM(LOG, "New CTM Manager at 0x{:x}", (uintptr_t)RESOURCE.get());
|
||||
}
|
||||
|
||||
|
@@ -16,11 +16,13 @@ class CHyprlandCTMControlResource {
|
||||
~CHyprlandCTMControlResource();
|
||||
|
||||
bool good();
|
||||
void block();
|
||||
|
||||
private:
|
||||
SP<CHyprlandCtmControlManagerV1> resource;
|
||||
|
||||
std::unordered_map<std::string, Mat3x3> ctms;
|
||||
bool blocked = false;
|
||||
};
|
||||
|
||||
class CHyprlandCTMControlProtocol : public IWaylandProtocol {
|
||||
@@ -37,6 +39,7 @@ class CHyprlandCTMControlProtocol : public IWaylandProtocol {
|
||||
|
||||
//
|
||||
std::vector<SP<CHyprlandCTMControlResource>> m_vManagers;
|
||||
WP<CHyprlandCTMControlResource> m_pManager;
|
||||
|
||||
//
|
||||
struct SCTMData {
|
||||
@@ -51,4 +54,4 @@ class CHyprlandCTMControlProtocol : public IWaylandProtocol {
|
||||
|
||||
namespace PROTO {
|
||||
inline UP<CHyprlandCTMControlProtocol> ctm;
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user