protocols: refactor class member vars (a-m) (#10265)

This commit is contained in:
davc0n 2025-05-04 00:13:29 +02:00 committed by GitHub
parent 46ac115bd1
commit adbae0f74d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
58 changed files with 1566 additions and 1561 deletions

View File

@ -1268,7 +1268,7 @@ void CCompositor::focusSurface(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWindo
SP<CWLSurfaceResource> CCompositor::vectorToLayerPopupSurface(const Vector2D& pos, PHLMONITOR monitor, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound) { SP<CWLSurfaceResource> CCompositor::vectorToLayerPopupSurface(const Vector2D& pos, PHLMONITOR monitor, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound) {
for (auto const& lsl : monitor->m_layerSurfaceLayers | std::views::reverse) { for (auto const& lsl : monitor->m_layerSurfaceLayers | std::views::reverse) {
for (auto const& ls : lsl | std::views::reverse) { for (auto const& ls : lsl | std::views::reverse) {
if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->mapped) || ls->m_alpha->value() == 0.f) if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->m_mapped) || ls->m_alpha->value() == 0.f)
continue; continue;
auto SURFACEAT = ls->m_popupHead->at(pos, true); auto SURFACEAT = ls->m_popupHead->at(pos, true);
@ -1288,11 +1288,11 @@ SP<CWLSurfaceResource> CCompositor::vectorToLayerSurface(const Vector2D& pos, st
bool aboveLockscreen) { bool aboveLockscreen) {
for (auto const& ls : *layerSurfaces | std::views::reverse) { for (auto const& ls : *layerSurfaces | std::views::reverse) {
if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->surface->m_mapped) || ls->m_alpha->value() == 0.f || if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->m_surface->m_mapped) || ls->m_alpha->value() == 0.f ||
(aboveLockscreen && (!ls->m_aboveLockscreen || !ls->m_aboveLockscreenInteractable))) (aboveLockscreen && (!ls->m_aboveLockscreen || !ls->m_aboveLockscreenInteractable)))
continue; continue;
auto [surf, local] = ls->m_layerSurface->surface->at(pos - ls->m_geometry.pos(), true); auto [surf, local] = ls->m_layerSurface->m_surface->at(pos - ls->m_geometry.pos(), true);
if (surf) { if (surf) {
if (surf->m_current.input.empty()) if (surf->m_current.input.empty())
@ -2554,13 +2554,13 @@ PHLLS CCompositor::getLayerSurfaceFromSurface(SP<CWLSurfaceResource> pSurface) {
std::pair<SP<CWLSurfaceResource>, bool> result = {pSurface, false}; std::pair<SP<CWLSurfaceResource>, bool> result = {pSurface, false};
for (auto const& ls : m_layers) { for (auto const& ls : m_layers) {
if (ls->m_layerSurface && ls->m_layerSurface->surface == pSurface) if (ls->m_layerSurface && ls->m_layerSurface->m_surface == pSurface)
return ls; return ls;
if (!ls->m_layerSurface || !ls->m_mapped) if (!ls->m_layerSurface || !ls->m_mapped)
continue; continue;
ls->m_layerSurface->surface->breadthfirst( ls->m_layerSurface->m_surface->breadthfirst(
[&result](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { [&result](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) {
if (surf == result.first) { if (surf == result.first) {
result.second = true; result.second = true;

View File

@ -1536,15 +1536,15 @@ std::vector<SP<CLayerRule>> CConfigManager::getMatchingRules(PHLLS pLS) {
if (lr->m_targetNamespace.starts_with("address:0x")) { if (lr->m_targetNamespace.starts_with("address:0x")) {
if (std::format("address:0x{:x}", (uintptr_t)pLS.get()) != lr->m_targetNamespace) if (std::format("address:0x{:x}", (uintptr_t)pLS.get()) != lr->m_targetNamespace)
continue; continue;
} else if (!lr->m_targetNamespaceRegex.passes(pLS->m_layerSurface->layerNamespace)) } else if (!lr->m_targetNamespaceRegex.passes(pLS->m_layerSurface->m_layerNamespace))
continue; continue;
// hit // hit
returns.emplace_back(lr); returns.emplace_back(lr);
} }
if (shouldBlurLS(pLS->m_layerSurface->layerNamespace)) if (shouldBlurLS(pLS->m_layerSurface->m_layerNamespace))
returns.emplace_back(makeShared<CLayerRule>(pLS->m_layerSurface->layerNamespace, "blur")); returns.emplace_back(makeShared<CLayerRule>(pLS->m_layerSurface->m_layerNamespace, "blur"));
return returns; return returns;
} }

View File

@ -15,9 +15,9 @@
PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) { PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
PHLLS pLS = SP<CLayerSurface>(new CLayerSurface(resource)); PHLLS pLS = SP<CLayerSurface>(new CLayerSurface(resource));
auto pMonitor = resource->monitor.empty() ? g_pCompositor->m_lastMonitor.lock() : g_pCompositor->getMonitorFromName(resource->monitor); auto pMonitor = resource->m_monitor.empty() ? g_pCompositor->m_lastMonitor.lock() : g_pCompositor->getMonitorFromName(resource->m_monitor);
pLS->m_surface->assign(resource->surface.lock(), pLS); pLS->m_surface->assign(resource->m_surface.lock(), pLS);
if (!pMonitor) { if (!pMonitor) {
Debug::log(ERR, "New LS has no monitor??"); Debug::log(ERR, "New LS has no monitor??");
@ -29,12 +29,12 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->m_self = pLS; pLS->m_self = pLS;
pLS->m_namespace = resource->layerNamespace; pLS->m_namespace = resource->m_layerNamespace;
pLS->m_layer = resource->current.layer; pLS->m_layer = resource->m_current.layer;
pLS->m_popupHead = CPopup::create(pLS); pLS->m_popupHead = CPopup::create(pLS);
pLS->m_monitor = pMonitor; pLS->m_monitor = pMonitor;
pMonitor->m_layerSurfaceLayers[resource->current.layer].emplace_back(pLS); pMonitor->m_layerSurfaceLayers[resource->m_current.layer].emplace_back(pLS);
pLS->m_forceBlur = g_pConfigManager->shouldBlurLS(pLS->m_namespace); pLS->m_forceBlur = g_pConfigManager->shouldBlurLS(pLS->m_namespace);
@ -46,7 +46,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->m_alpha->setValueAndWarp(0.f); pLS->m_alpha->setValueAndWarp(0.f);
Debug::log(LOG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", (uintptr_t)resource.get(), resource->layerNamespace, (int)pLS->m_layer, pMonitor->m_name); Debug::log(LOG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", (uintptr_t)resource.get(), resource->m_layerNamespace, (int)pLS->m_layer, pMonitor->m_name);
return pLS; return pLS;
} }
@ -59,10 +59,10 @@ void CLayerSurface::registerCallbacks() {
} }
CLayerSurface::CLayerSurface(SP<CLayerShellResource> resource_) : m_layerSurface(resource_) { CLayerSurface::CLayerSurface(SP<CLayerShellResource> resource_) : m_layerSurface(resource_) {
m_listeners.commit = m_layerSurface->events.commit.registerListener([this](std::any d) { onCommit(); }); m_listeners.commit = m_layerSurface->m_events.commit.registerListener([this](std::any d) { onCommit(); });
m_listeners.map = m_layerSurface->events.map.registerListener([this](std::any d) { onMap(); }); m_listeners.map = m_layerSurface->m_events.map.registerListener([this](std::any d) { onMap(); });
m_listeners.unmap = m_layerSurface->events.unmap.registerListener([this](std::any d) { onUnmap(); }); m_listeners.unmap = m_layerSurface->m_events.unmap.registerListener([this](std::any d) { onUnmap(); });
m_listeners.destroy = m_layerSurface->events.destroy.registerListener([this](std::any d) { onDestroy(); }); m_listeners.destroy = m_layerSurface->m_events.destroy.registerListener([this](std::any d) { onDestroy(); });
m_surface = CWLSurface::create(); m_surface = CWLSurface::create();
} }
@ -133,9 +133,9 @@ void CLayerSurface::onMap() {
Debug::log(LOG, "LayerSurface {:x} mapped", (uintptr_t)m_layerSurface.get()); Debug::log(LOG, "LayerSurface {:x} mapped", (uintptr_t)m_layerSurface.get());
m_mapped = true; m_mapped = true;
m_interactivity = m_layerSurface->current.interactivity; m_interactivity = m_layerSurface->m_current.interactivity;
m_layerSurface->surface->map(); m_layerSurface->m_surface->map();
// this layer might be re-mapped. // this layer might be re-mapped.
m_fadingOut = false; m_fadingOut = false;
@ -155,13 +155,13 @@ void CLayerSurface::onMap() {
m_surface->resource()->enter(PMONITOR->m_self.lock()); m_surface->resource()->enter(PMONITOR->m_self.lock());
const bool ISEXCLUSIVE = m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; const bool ISEXCLUSIVE = m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;
if (ISEXCLUSIVE) if (ISEXCLUSIVE)
g_pInputManager->m_exclusiveLSes.push_back(m_self); g_pInputManager->m_exclusiveLSes.push_back(m_self);
const bool GRABSFOCUS = ISEXCLUSIVE || const bool GRABSFOCUS = ISEXCLUSIVE ||
(m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE && (m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE &&
// don't focus if constrained // don't focus if constrained
(g_pSeatManager->m_mouse.expired() || !g_pInputManager->isConstrained())); (g_pSeatManager->m_mouse.expired() || !g_pInputManager->isConstrained()));
@ -196,7 +196,7 @@ void CLayerSurface::onMap() {
void CLayerSurface::onUnmap() { void CLayerSurface::onUnmap() {
Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)m_layerSurface.get()); Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)m_layerSurface.get());
g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", m_layerSurface->layerNamespace}); g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", m_layerSurface->m_layerNamespace});
EMIT_HOOK_EVENT("closeLayer", m_self.lock()); EMIT_HOOK_EVENT("closeLayer", m_self.lock());
std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; }); std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; });
@ -207,8 +207,8 @@ void CLayerSurface::onUnmap() {
g_pCompositor->addToFadingOutSafe(m_self.lock()); g_pCompositor->addToFadingOutSafe(m_self.lock());
m_mapped = false; m_mapped = false;
if (m_layerSurface && m_layerSurface->surface) if (m_layerSurface && m_layerSurface->m_surface)
m_layerSurface->surface->unmap(); m_layerSurface->m_surface->unmap();
startAnimation(false); startAnimation(false);
return; return;
@ -224,8 +224,8 @@ void CLayerSurface::onUnmap() {
startAnimation(false); startAnimation(false);
m_mapped = false; m_mapped = false;
if (m_layerSurface && m_layerSurface->surface) if (m_layerSurface && m_layerSurface->m_surface)
m_layerSurface->surface->unmap(); m_layerSurface->m_surface->unmap();
g_pCompositor->addToFadingOutSafe(m_self.lock()); g_pCompositor->addToFadingOutSafe(m_self.lock());
@ -247,8 +247,8 @@ void CLayerSurface::onUnmap() {
CBox geomFixed = {m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y, m_geometry.width, m_geometry.height}; CBox geomFixed = {m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y, m_geometry.width, m_geometry.height};
g_pHyprRenderer->damageBox(geomFixed); g_pHyprRenderer->damageBox(geomFixed);
geomFixed = {m_geometry.x + (int)PMONITOR->m_position.x, m_geometry.y + (int)PMONITOR->m_position.y, (int)m_layerSurface->surface->m_current.size.x, geomFixed = {m_geometry.x + (int)PMONITOR->m_position.x, m_geometry.y + (int)PMONITOR->m_position.y, (int)m_layerSurface->m_surface->m_current.size.x,
(int)m_layerSurface->surface->m_current.size.y}; (int)m_layerSurface->m_surface->m_current.size.y};
g_pHyprRenderer->damageBox(geomFixed); g_pHyprRenderer->damageBox(geomFixed);
g_pInputManager->simulateMouseMovement(); g_pInputManager->simulateMouseMovement();
@ -262,7 +262,7 @@ void CLayerSurface::onCommit() {
if (!m_mapped) { if (!m_mapped) {
// we're re-mapping if this is the case // we're re-mapping if this is the case
if (m_layerSurface->surface && !m_layerSurface->surface->m_current.texture) { if (m_layerSurface->m_surface && !m_layerSurface->m_surface->m_current.texture) {
m_fadingOut = false; m_fadingOut = false;
m_geometry = {}; m_geometry = {};
g_pHyprRenderer->arrangeLayersForMonitor(monitorID()); g_pHyprRenderer->arrangeLayersForMonitor(monitorID());
@ -282,20 +282,20 @@ void CLayerSurface::onCommit() {
CBox geomFixed = {m_geometry.x, m_geometry.y, m_geometry.width, m_geometry.height}; CBox geomFixed = {m_geometry.x, m_geometry.y, m_geometry.width, m_geometry.height};
g_pHyprRenderer->damageBox(geomFixed); g_pHyprRenderer->damageBox(geomFixed);
if (m_layerSurface->current.committed != 0) { if (m_layerSurface->m_current.committed != 0) {
if (m_layerSurface->current.committed & CLayerShellResource::eCommittedState::STATE_LAYER) { if (m_layerSurface->m_current.committed & CLayerShellResource::eCommittedState::STATE_LAYER) {
for (auto it = PMONITOR->m_layerSurfaceLayers[m_layer].begin(); it != PMONITOR->m_layerSurfaceLayers[m_layer].end(); it++) { for (auto it = PMONITOR->m_layerSurfaceLayers[m_layer].begin(); it != PMONITOR->m_layerSurfaceLayers[m_layer].end(); it++) {
if (*it == m_self) { if (*it == m_self) {
if (m_layerSurface->current.layer == m_layer) if (m_layerSurface->m_current.layer == m_layer)
break; break;
PMONITOR->m_layerSurfaceLayers[m_layerSurface->current.layer].emplace_back(*it); PMONITOR->m_layerSurfaceLayers[m_layerSurface->m_current.layer].emplace_back(*it);
PMONITOR->m_layerSurfaceLayers[m_layer].erase(it); PMONITOR->m_layerSurfaceLayers[m_layer].erase(it);
break; break;
} }
} }
m_layer = m_layerSurface->current.layer; m_layer = m_layerSurface->m_current.layer;
if (m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) if (m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
@ -308,12 +308,12 @@ void CLayerSurface::onCommit() {
m_position = Vector2D(m_geometry.x, m_geometry.y); m_position = Vector2D(m_geometry.x, m_geometry.y);
// update geom if it changed // update geom if it changed
if (m_layerSurface->surface->m_current.scale == 1 && PMONITOR->m_scale != 1.f && m_layerSurface->surface->m_current.viewport.hasDestination) { if (m_layerSurface->m_surface->m_current.scale == 1 && PMONITOR->m_scale != 1.f && m_layerSurface->m_surface->m_current.viewport.hasDestination) {
// fractional scaling. Dirty hack. // fractional scaling. Dirty hack.
m_geometry = {m_geometry.pos(), m_layerSurface->surface->m_current.viewport.destination}; m_geometry = {m_geometry.pos(), m_layerSurface->m_surface->m_current.viewport.destination};
} else { } else {
// this is because some apps like e.g. rofi-lbonn can't fucking use the protocol correctly. // this is because some apps like e.g. rofi-lbonn can't fucking use the protocol correctly.
m_geometry = {m_geometry.pos(), m_layerSurface->surface->m_current.size}; m_geometry = {m_geometry.pos(), m_layerSurface->m_surface->m_current.size};
} }
} }
@ -330,9 +330,9 @@ void CLayerSurface::onCommit() {
m_realSize->setValueAndWarp(m_geometry.size()); m_realSize->setValueAndWarp(m_geometry.size());
} }
if (m_mapped && (m_layerSurface->current.committed & CLayerShellResource::eCommittedState::STATE_INTERACTIVITY)) { if (m_mapped && (m_layerSurface->m_current.committed & CLayerShellResource::eCommittedState::STATE_INTERACTIVITY)) {
bool WASLASTFOCUS = false; bool WASLASTFOCUS = false;
m_layerSurface->surface->breadthfirst( m_layerSurface->m_surface->breadthfirst(
[&WASLASTFOCUS](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { WASLASTFOCUS = WASLASTFOCUS || g_pSeatManager->m_state.keyboardFocus == surf; }, [&WASLASTFOCUS](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { WASLASTFOCUS = WASLASTFOCUS || g_pSeatManager->m_state.keyboardFocus == surf; },
nullptr); nullptr);
if (!WASLASTFOCUS && m_popupHead) { if (!WASLASTFOCUS && m_popupHead) {
@ -343,7 +343,7 @@ void CLayerSurface::onCommit() {
nullptr); nullptr);
} }
const bool WASEXCLUSIVE = m_interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; const bool WASEXCLUSIVE = m_interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;
const bool ISEXCLUSIVE = m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; const bool ISEXCLUSIVE = m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;
if (!WASEXCLUSIVE && ISEXCLUSIVE) if (!WASEXCLUSIVE && ISEXCLUSIVE)
g_pInputManager->m_exclusiveLSes.push_back(m_self); g_pInputManager->m_exclusiveLSes.push_back(m_self);
@ -351,12 +351,12 @@ void CLayerSurface::onCommit() {
std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == m_self.lock(); }); std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == m_self.lock(); });
// if the surface was focused and interactive but now isn't, refocus // if the surface was focused and interactive but now isn't, refocus
if (WASLASTFOCUS && m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) { if (WASLASTFOCUS && m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) {
// moveMouseUnified won't focus non interactive layers but it won't unfocus them either, // moveMouseUnified won't focus non interactive layers but it won't unfocus them either,
// so unfocus the surface here. // so unfocus the surface here.
g_pCompositor->focusSurface(nullptr); g_pCompositor->focusSurface(nullptr);
g_pInputManager->refocusLastWindow(m_monitor.lock()); g_pInputManager->refocusLastWindow(m_monitor.lock());
} else if (WASLASTFOCUS && WASEXCLUSIVE && m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) { } else if (WASLASTFOCUS && WASEXCLUSIVE && m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) {
g_pInputManager->simulateMouseMovement(); g_pInputManager->simulateMouseMovement();
} else if (!WASEXCLUSIVE && ISEXCLUSIVE) { } else if (!WASEXCLUSIVE && ISEXCLUSIVE) {
// if now exclusive and not previously // if now exclusive and not previously
@ -370,7 +370,7 @@ void CLayerSurface::onCommit() {
} }
} }
m_interactivity = m_layerSurface->current.interactivity; m_interactivity = m_layerSurface->m_current.interactivity;
g_pHyprRenderer->damageSurface(m_surface->resource(), m_position.x, m_position.y); g_pHyprRenderer->damageSurface(m_surface->resource(), m_position.x, m_position.y);
@ -600,11 +600,11 @@ MONITORID CLayerSurface::monitorID() {
pid_t CLayerSurface::getPID() { pid_t CLayerSurface::getPID() {
pid_t PID = -1; pid_t PID = -1;
if (!m_layerSurface || !m_layerSurface->surface || !m_layerSurface->surface->getResource() || !m_layerSurface->surface->getResource()->resource() || if (!m_layerSurface || !m_layerSurface->m_surface || !m_layerSurface->m_surface->getResource() || !m_layerSurface->m_surface->getResource()->resource() ||
!m_layerSurface->surface->getResource()->resource()->client) !m_layerSurface->m_surface->getResource()->resource()->client)
return -1; return -1;
wl_client_get_credentials(m_layerSurface->surface->getResource()->resource()->client, &PID, nullptr, nullptr); wl_client_get_credentials(m_layerSurface->m_surface->getResource()->resource()->client, &PID, nullptr, nullptr);
return PID; return PID;
} }

View File

@ -57,7 +57,7 @@ void CPopup::initAllSignals() {
m_listeners.newPopup = m_windowOwner->m_xdgSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); }); m_listeners.newPopup = m_windowOwner->m_xdgSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
else if (!m_layerOwner.expired()) else if (!m_layerOwner.expired())
m_listeners.newPopup = m_listeners.newPopup =
m_layerOwner->m_layerSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); }); m_layerOwner->m_layerSurface->m_events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
else else
ASSERT(false); ASSERT(false);

View File

@ -230,6 +230,6 @@ bool CWLSurface::keyboardFocusable() const {
if (m_windowOwner || m_popupOwner || m_subsurfaceOwner) if (m_windowOwner || m_popupOwner || m_subsurfaceOwner)
return true; return true;
if (m_layerOwner && m_layerOwner->m_layerSurface) if (m_layerOwner && m_layerOwner->m_layerSurface)
return m_layerOwner->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE; return m_layerOwner->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
return false; return false;
} }

View File

@ -1775,7 +1775,7 @@ NContentType::eContentType CWindow::getContentType() {
if (!m_wlSurface || !m_wlSurface->resource() || !m_wlSurface->resource()->m_contentType.valid()) if (!m_wlSurface || !m_wlSurface->resource() || !m_wlSurface->resource()->m_contentType.valid())
return CONTENT_TYPE_NONE; return CONTENT_TYPE_NONE;
return m_wlSurface->resource()->m_contentType->value; return m_wlSurface->resource()->m_contentType->m_value;
} }
void CWindow::setContentType(NContentType::eContentType contentType) { void CWindow::setContentType(NContentType::eContentType contentType) {
@ -1784,7 +1784,7 @@ void CWindow::setContentType(NContentType::eContentType contentType) {
// else disallow content type change if proto is used? // else disallow content type change if proto is used?
Debug::log(INFO, "ContentType for window {}", (int)contentType); Debug::log(INFO, "ContentType for window {}", (int)contentType);
m_wlSurface->resource()->m_contentType->value = contentType; m_wlSurface->resource()->m_contentType->m_value = contentType;
} }
void CWindow::deactivateGroupMembers() { void CWindow::deactivateGroupMembers() {

View File

@ -593,7 +593,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
// check LS focus grab // check LS focus grab
const auto PFORCEFOCUS = g_pCompositor->getForceFocus(); const auto PFORCEFOCUS = g_pCompositor->getForceFocus();
const auto PLSFROMFOCUS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock()); const auto PLSFROMFOCUS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock());
if (PLSFROMFOCUS && PLSFROMFOCUS->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) if (PLSFROMFOCUS && PLSFROMFOCUS->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE)
PWINDOW->m_noInitialFocus = true; PWINDOW->m_noInitialFocus = true;
if (PWINDOW->m_workspace->m_hasFullscreenWindow && !requestedInternalFSMode.has_value() && !requestedClientFSMode.has_value() && !PWINDOW->m_isFloating) { if (PWINDOW->m_workspace->m_hasFullscreenWindow && !requestedInternalFSMode.has_value() && !requestedClientFSMode.has_value() && !PWINDOW->m_isFloating) {

View File

@ -8,14 +8,14 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
const auto PINHIBIT = m_idleInhibitors.emplace_back(makeUnique<SIdleInhibitor>()).get(); const auto PINHIBIT = m_idleInhibitors.emplace_back(makeUnique<SIdleInhibitor>()).get();
PINHIBIT->inhibitor = std::any_cast<SP<CIdleInhibitor>>(inhibitor); PINHIBIT->inhibitor = std::any_cast<SP<CIdleInhibitor>>(inhibitor);
Debug::log(LOG, "New idle inhibitor registered for surface {:x}", (uintptr_t)PINHIBIT->inhibitor->surface.get()); Debug::log(LOG, "New idle inhibitor registered for surface {:x}", (uintptr_t)PINHIBIT->inhibitor->m_surface.get());
PINHIBIT->inhibitor->listeners.destroy = PINHIBIT->inhibitor->resource->events.destroy.registerListener([this, PINHIBIT](std::any data) { PINHIBIT->inhibitor->m_listeners.destroy = PINHIBIT->inhibitor->m_resource->m_events.destroy.registerListener([this, PINHIBIT](std::any data) {
std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; });
recheckIdleInhibitorStatus(); recheckIdleInhibitorStatus();
}); });
auto WLSurface = CWLSurface::fromResource(PINHIBIT->inhibitor->surface.lock()); auto WLSurface = CWLSurface::fromResource(PINHIBIT->inhibitor->m_surface.lock());
if (!WLSurface) { if (!WLSurface) {
Debug::log(LOG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Assuming it's visible."); Debug::log(LOG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Assuming it's visible.");
@ -38,7 +38,7 @@ void CInputManager::recheckIdleInhibitorStatus() {
return; return;
} }
auto WLSurface = CWLSurface::fromResource(ii->inhibitor->surface.lock()); auto WLSurface = CWLSurface::fromResource(ii->inhibitor->m_surface.lock());
if (!WLSurface) if (!WLSurface)
continue; continue;
@ -80,7 +80,7 @@ bool CInputManager::isWindowInhibiting(const PHLWINDOW& w, bool onlyHl) {
bool isInhibiting = false; bool isInhibiting = false;
w->m_wlSurface->resource()->breadthfirst( w->m_wlSurface->resource()->breadthfirst(
[&ii](SP<CWLSurfaceResource> surf, const Vector2D& pos, void* data) { [&ii](SP<CWLSurfaceResource> surf, const Vector2D& pos, void* data) {
if (ii->inhibitor->surface != surf) if (ii->inhibitor->m_surface != surf)
return; return;
auto WLSurface = CWLSurface::fromResource(surf); auto WLSurface = CWLSurface::fromResource(surf);

View File

@ -42,7 +42,7 @@
#include <aquamarine/input/Input.hpp> #include <aquamarine/input/Input.hpp>
CInputManager::CInputManager() { CInputManager::CInputManager() {
m_listeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) { m_listeners.setCursorShape = PROTO::cursorShape->m_events.setShape.registerListener([this](std::any data) {
if (!cursorImageUnlocked()) if (!cursorImageUnlocked())
return; return;
@ -65,7 +65,7 @@ CInputManager::CInputManager() {
g_pHyprRenderer->setCursorFromName(m_cursorSurfaceInfo.name); g_pHyprRenderer->setCursorFromName(m_cursorSurfaceInfo.name);
}); });
m_listeners.newIdleInhibitor = PROTO::idleInhibit->events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); }); m_listeners.newIdleInhibitor = PROTO::idleInhibit->m_events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); });
m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->events.newKeyboard.registerListener([this](std::any data) { m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->events.newKeyboard.registerListener([this](std::any data) {
this->newVirtualKeyboard(std::any_cast<SP<CVirtualKeyboardV1Resource>>(data)); this->newVirtualKeyboard(std::any_cast<SP<CVirtualKeyboardV1Resource>>(data));
updateCapabilities(); updateCapabilities();
@ -504,7 +504,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
if (!refocus && g_pCompositor->m_lastFocus) { if (!refocus && g_pCompositor->m_lastFocus) {
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock()); const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock());
if (PLS && PLS->m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) if (PLS && PLS->m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
allowKeyboardRefocus = false; allowKeyboardRefocus = false;
} }
@ -589,8 +589,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
unsetCursorImage(); unsetCursorImage();
} }
if (pFoundLayerSurface && (pFoundLayerSurface->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) && FOLLOWMOUSE != 3 && if (pFoundLayerSurface && (pFoundLayerSurface->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) && FOLLOWMOUSE != 3 &&
(allowKeyboardRefocus || pFoundLayerSurface->m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)) { (allowKeyboardRefocus || pFoundLayerSurface->m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)) {
g_pCompositor->focusSurface(foundSurface); g_pCompositor->focusSurface(foundSurface);
} }

View File

@ -8,10 +8,10 @@
#include "../../render/Renderer.hpp" #include "../../render/Renderer.hpp"
CInputPopup::CInputPopup(SP<CInputMethodPopupV2> popup_) : m_popup(popup_) { CInputPopup::CInputPopup(SP<CInputMethodPopupV2> popup_) : m_popup(popup_) {
m_listeners.commit = popup_->events.commit.registerListener([this](std::any d) { onCommit(); }); m_listeners.commit = popup_->m_events.commit.registerListener([this](std::any d) { onCommit(); });
m_listeners.map = popup_->events.map.registerListener([this](std::any d) { onMap(); }); m_listeners.map = popup_->m_events.map.registerListener([this](std::any d) { onMap(); });
m_listeners.unmap = popup_->events.unmap.registerListener([this](std::any d) { onUnmap(); }); m_listeners.unmap = popup_->m_events.unmap.registerListener([this](std::any d) { onUnmap(); });
m_listeners.destroy = popup_->events.destroy.registerListener([this](std::any d) { onDestroy(); }); m_listeners.destroy = popup_->m_events.destroy.registerListener([this](std::any d) { onDestroy(); });
m_surface = CWLSurface::create(); m_surface = CWLSurface::create();
m_surface->assign(popup_->surface()); m_surface->assign(popup_->surface());
} }
@ -77,7 +77,7 @@ void CInputPopup::damageSurface() {
} }
void CInputPopup::updateBox() { void CInputPopup::updateBox() {
if (!m_popup->mapped) if (!m_popup->m_mapped)
return; return;
const auto OWNER = queryOwner(); const auto OWNER = queryOwner();

View File

@ -13,7 +13,7 @@ CInputMethodRelay::CInputMethodRelay() {
m_listeners.newTIV3 = PROTO::textInputV3->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast<WP<CTextInputV3>>(ti)); }); m_listeners.newTIV3 = PROTO::textInputV3->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast<WP<CTextInputV3>>(ti)); });
m_listeners.newTIV1 = PROTO::textInputV1->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast<WP<CTextInputV1>>(ti)); }); m_listeners.newTIV1 = PROTO::textInputV1->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast<WP<CTextInputV1>>(ti)); });
m_listeners.newIME = PROTO::ime->events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast<SP<CInputMethodV2>>(ime)); }); m_listeners.newIME = PROTO::ime->m_events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast<SP<CInputMethodV2>>(ime)); });
} }
void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) { void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
@ -27,7 +27,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
m_inputMethod = pIME; m_inputMethod = pIME;
m_listeners.commitIME = pIME->events.onCommit.registerListener([this](std::any d) { m_listeners.commitIME = pIME->m_events.onCommit.registerListener([this](std::any d) {
const auto PTI = getFocusedTextInput(); const auto PTI = getFocusedTextInput();
if (!PTI) { if (!PTI) {
@ -38,7 +38,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
PTI->updateIMEState(m_inputMethod.lock()); PTI->updateIMEState(m_inputMethod.lock());
}); });
m_listeners.destroyIME = pIME->events.destroy.registerListener([this](std::any d) { m_listeners.destroyIME = pIME->m_events.destroy.registerListener([this](std::any d) {
const auto PTI = getFocusedTextInput(); const auto PTI = getFocusedTextInput();
Debug::log(LOG, "IME Destroy"); Debug::log(LOG, "IME Destroy");
@ -49,7 +49,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
m_inputMethod.reset(); m_inputMethod.reset();
}); });
m_listeners.newPopup = pIME->events.newPopup.registerListener([this](std::any d) { m_listeners.newPopup = pIME->m_events.newPopup.registerListener([this](std::any d) {
m_inputMethodPopups.emplace_back(makeUnique<CInputPopup>(std::any_cast<SP<CInputMethodPopupV2>>(d))); m_inputMethodPopups.emplace_back(makeUnique<CInputPopup>(std::any_cast<SP<CInputMethodPopupV2>>(d)));
Debug::log(LOG, "New input popup"); Debug::log(LOG, "New input popup");

View File

@ -266,38 +266,38 @@ void CTextInput::updateIMEState(SP<CInputMethodV2> ime) {
if (isV3()) { if (isV3()) {
const auto INPUT = m_v3Input.lock(); const auto INPUT = m_v3Input.lock();
if (ime->current.preeditString.committed) if (ime->m_current.preeditString.committed)
INPUT->preeditString(ime->current.preeditString.string, ime->current.preeditString.begin, ime->current.preeditString.end); INPUT->preeditString(ime->m_current.preeditString.string, ime->m_current.preeditString.begin, ime->m_current.preeditString.end);
if (ime->current.committedString.committed) if (ime->m_current.committedString.committed)
INPUT->commitString(ime->current.committedString.string); INPUT->commitString(ime->m_current.committedString.string);
if (ime->current.deleteSurrounding.committed) if (ime->m_current.deleteSurrounding.committed)
INPUT->deleteSurroundingText(ime->current.deleteSurrounding.before, ime->current.deleteSurrounding.after); INPUT->deleteSurroundingText(ime->m_current.deleteSurrounding.before, ime->m_current.deleteSurrounding.after);
INPUT->sendDone(); INPUT->sendDone();
} else { } else {
const auto INPUT = m_v1Input.lock(); const auto INPUT = m_v1Input.lock();
if (ime->current.preeditString.committed) { if (ime->m_current.preeditString.committed) {
INPUT->preeditCursor(ime->current.preeditString.begin); INPUT->preeditCursor(ime->m_current.preeditString.begin);
INPUT->preeditStyling(0, std::string(ime->current.preeditString.string).length(), ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT); INPUT->preeditStyling(0, std::string(ime->m_current.preeditString.string).length(), ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT);
INPUT->preeditString(m_v1Input->serial, ime->current.preeditString.string.c_str(), ""); INPUT->preeditString(m_v1Input->serial, ime->m_current.preeditString.string.c_str(), "");
} else { } else {
INPUT->preeditCursor(0); INPUT->preeditCursor(0);
INPUT->preeditStyling(0, 0, ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT); INPUT->preeditStyling(0, 0, ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT);
INPUT->preeditString(m_v1Input->serial, "", ""); INPUT->preeditString(m_v1Input->serial, "", "");
} }
if (ime->current.committedString.committed) if (ime->m_current.committedString.committed)
INPUT->commitString(m_v1Input->serial, ime->current.committedString.string.c_str()); INPUT->commitString(m_v1Input->serial, ime->m_current.committedString.string.c_str());
if (ime->current.deleteSurrounding.committed) { if (ime->m_current.deleteSurrounding.committed) {
INPUT->deleteSurroundingText(std::string(ime->current.preeditString.string).length() - ime->current.deleteSurrounding.before, INPUT->deleteSurroundingText(std::string(ime->m_current.preeditString.string).length() - ime->m_current.deleteSurrounding.before,
ime->current.deleteSurrounding.after + ime->current.deleteSurrounding.before); ime->m_current.deleteSurrounding.after + ime->m_current.deleteSurrounding.before);
if (ime->current.preeditString.committed) if (ime->m_current.preeditString.committed)
INPUT->commitString(m_v1Input->serial, ime->current.preeditString.string.c_str()); INPUT->commitString(m_v1Input->serial, ime->m_current.preeditString.string.c_str());
} }
} }
} }

View File

@ -4,58 +4,58 @@
#include "alpha-modifier-v1.hpp" #include "alpha-modifier-v1.hpp"
#include "core/Compositor.hpp" #include "core/Compositor.hpp"
CAlphaModifier::CAlphaModifier(SP<CWpAlphaModifierSurfaceV1> resource, SP<CWLSurfaceResource> surface) : m_pSurface(surface) { CAlphaModifier::CAlphaModifier(SP<CWpAlphaModifierSurfaceV1> resource, SP<CWLSurfaceResource> surface) : m_surface(surface) {
setResource(std::move(resource)); setResource(std::move(resource));
} }
bool CAlphaModifier::good() { bool CAlphaModifier::good() {
return m_pResource->resource(); return m_resource->resource();
} }
void CAlphaModifier::setResource(SP<CWpAlphaModifierSurfaceV1> resource) { void CAlphaModifier::setResource(SP<CWpAlphaModifierSurfaceV1> resource) {
m_pResource = std::move(resource); m_resource = std::move(resource);
if UNLIKELY (!m_pResource->resource()) if UNLIKELY (!m_resource->resource())
return; return;
m_pResource->setDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); }); m_resource->setDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); });
m_pResource->setOnDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); }); m_resource->setOnDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); });
m_pResource->setSetMultiplier([this](CWpAlphaModifierSurfaceV1* resource, uint32_t alpha) { m_resource->setSetMultiplier([this](CWpAlphaModifierSurfaceV1* resource, uint32_t alpha) {
if (!m_pSurface) { if (!m_surface) {
m_pResource->error(WP_ALPHA_MODIFIER_SURFACE_V1_ERROR_NO_SURFACE, "set_multiplier called for destroyed wl_surface"); m_resource->error(WP_ALPHA_MODIFIER_SURFACE_V1_ERROR_NO_SURFACE, "set_multiplier called for destroyed wl_surface");
return; return;
} }
m_fAlpha = alpha / (float)UINT32_MAX; m_alpha = alpha / (float)UINT32_MAX;
}); });
listeners.surfaceCommitted = m_pSurface->m_events.commit.registerListener([this](std::any data) { m_listeners.surfaceCommitted = m_surface->m_events.commit.registerListener([this](std::any data) {
auto surface = CWLSurface::fromResource(m_pSurface.lock()); auto surface = CWLSurface::fromResource(m_surface.lock());
if (surface && surface->m_alphaModifier != m_fAlpha) { if (surface && surface->m_alphaModifier != m_alpha) {
surface->m_alphaModifier = m_fAlpha; surface->m_alphaModifier = m_alpha;
auto box = surface->getSurfaceBoxGlobal(); auto box = surface->getSurfaceBoxGlobal();
if (box.has_value()) if (box.has_value())
g_pHyprRenderer->damageBox(*box); g_pHyprRenderer->damageBox(*box);
if (!m_pResource) if (!m_resource)
PROTO::alphaModifier->destroyAlphaModifier(this); PROTO::alphaModifier->destroyAlphaModifier(this);
} }
}); });
listeners.surfaceDestroyed = m_pSurface->m_events.destroy.registerListener([this](std::any data) { m_listeners.surfaceDestroyed = m_surface->m_events.destroy.registerListener([this](std::any data) {
if (!m_pResource) if (!m_resource)
PROTO::alphaModifier->destroyAlphaModifier(this); PROTO::alphaModifier->destroyAlphaModifier(this);
}); });
} }
void CAlphaModifier::destroy() { void CAlphaModifier::destroy() {
m_pResource.reset(); m_resource.reset();
m_fAlpha = 1.F; m_alpha = 1.F;
if (!m_pSurface) if (!m_surface)
PROTO::alphaModifier->destroyAlphaModifier(this); PROTO::alphaModifier->destroyAlphaModifier(this);
} }
@ -64,7 +64,7 @@ CAlphaModifierProtocol::CAlphaModifierProtocol(const wl_interface* iface, const
} }
void CAlphaModifierProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CAlphaModifierProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CWpAlphaModifierV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CWpAlphaModifierV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CWpAlphaModifierV1* manager) { destroyManager(manager); }); RESOURCE->setOnDestroy([this](CWpAlphaModifierV1* manager) { destroyManager(manager); });
RESOURCE->setDestroy([this](CWpAlphaModifierV1* manager) { destroyManager(manager); }); RESOURCE->setDestroy([this](CWpAlphaModifierV1* manager) { destroyManager(manager); });
@ -72,19 +72,19 @@ void CAlphaModifierProtocol::bindManager(wl_client* client, void* data, uint32_t
} }
void CAlphaModifierProtocol::destroyManager(CWpAlphaModifierV1* manager) { void CAlphaModifierProtocol::destroyManager(CWpAlphaModifierV1* manager) {
std::erase_if(m_vManagers, [&](const auto& p) { return p.get() == manager; }); std::erase_if(m_managers, [&](const auto& p) { return p.get() == manager; });
} }
void CAlphaModifierProtocol::destroyAlphaModifier(CAlphaModifier* modifier) { void CAlphaModifierProtocol::destroyAlphaModifier(CAlphaModifier* modifier) {
std::erase_if(m_mAlphaModifiers, [&](const auto& entry) { return entry.second.get() == modifier; }); std::erase_if(m_alphaModifiers, [&](const auto& entry) { return entry.second.get() == modifier; });
} }
void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id, SP<CWLSurfaceResource> surface) { void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id, SP<CWLSurfaceResource> surface) {
CAlphaModifier* alphaModifier = nullptr; CAlphaModifier* alphaModifier = nullptr;
auto iter = std::find_if(m_mAlphaModifiers.begin(), m_mAlphaModifiers.end(), [&](const auto& entry) { return entry.second->m_pSurface == surface; }); auto iter = std::find_if(m_alphaModifiers.begin(), m_alphaModifiers.end(), [&](const auto& entry) { return entry.second->m_surface == surface; });
if (iter != m_mAlphaModifiers.end()) { if (iter != m_alphaModifiers.end()) {
if (iter->second->m_pResource) { if (iter->second->m_resource) {
LOGM(ERR, "AlphaModifier already present for surface {:x}", (uintptr_t)surface.get()); LOGM(ERR, "AlphaModifier already present for surface {:x}", (uintptr_t)surface.get());
manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present"); manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present");
return; return;
@ -93,12 +93,12 @@ void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id
alphaModifier = iter->second.get(); alphaModifier = iter->second.get();
} }
} else { } else {
alphaModifier = m_mAlphaModifiers.emplace(surface, makeUnique<CAlphaModifier>(makeShared<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id), surface)) alphaModifier = m_alphaModifiers.emplace(surface, makeUnique<CAlphaModifier>(makeShared<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id), surface))
.first->second.get(); .first->second.get();
} }
if UNLIKELY (!alphaModifier->good()) { if UNLIKELY (!alphaModifier->good()) {
manager->noMemory(); manager->noMemory();
m_mAlphaModifiers.erase(surface); m_alphaModifiers.erase(surface);
} }
} }

View File

@ -17,16 +17,16 @@ class CAlphaModifier {
void setResource(SP<CWpAlphaModifierSurfaceV1> resource); void setResource(SP<CWpAlphaModifierSurfaceV1> resource);
private: private:
SP<CWpAlphaModifierSurfaceV1> m_pResource; SP<CWpAlphaModifierSurfaceV1> m_resource;
WP<CWLSurfaceResource> m_pSurface; WP<CWLSurfaceResource> m_surface;
float m_fAlpha = 1.0; float m_alpha = 1.0;
void destroy(); void destroy();
struct { struct {
CHyprSignalListener surfaceCommitted; CHyprSignalListener surfaceCommitted;
CHyprSignalListener surfaceDestroyed; CHyprSignalListener surfaceDestroyed;
} listeners; } m_listeners;
friend class CAlphaModifierProtocol; friend class CAlphaModifierProtocol;
}; };
@ -43,8 +43,8 @@ class CAlphaModifierProtocol : public IWaylandProtocol {
void getSurface(CWpAlphaModifierV1* manager, uint32_t id, SP<CWLSurfaceResource> surface); void getSurface(CWpAlphaModifierV1* manager, uint32_t id, SP<CWLSurfaceResource> surface);
// //
std::vector<UP<CWpAlphaModifierV1>> m_vManagers; std::vector<UP<CWpAlphaModifierV1>> m_managers;
std::unordered_map<WP<CWLSurfaceResource>, UP<CAlphaModifier>> m_mAlphaModifiers; std::unordered_map<WP<CWLSurfaceResource>, UP<CAlphaModifier>> m_alphaModifiers;
friend class CAlphaModifier; friend class CAlphaModifier;
}; };

View File

@ -8,16 +8,16 @@
#include "../helpers/Monitor.hpp" #include "../helpers/Monitor.hpp"
#include "../helpers/MiscFunctions.hpp" #include "../helpers/MiscFunctions.hpp"
CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlManagerV1> resource_) : resource(resource_) { CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlManagerV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); }); m_resource->setDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); });
resource->setOnDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); }); m_resource->setOnDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); });
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, m_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) { wl_fixed_t mat5, wl_fixed_t mat6, wl_fixed_t mat7, wl_fixed_t mat8) {
if (blocked) if (m_blocked)
return; return;
const auto OUTPUTRESOURCE = CWLOutputResource::fromResource(output); const auto OUTPUTRESOURCE = CWLOutputResource::fromResource(output);
@ -35,42 +35,42 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlM
for (auto& el : MAT) { for (auto& el : MAT) {
if (el < 0.F) { if (el < 0.F) {
resource->error(HYPRLAND_CTM_CONTROL_MANAGER_V1_ERROR_INVALID_MATRIX, "a matrix component was < 0"); m_resource->error(HYPRLAND_CTM_CONTROL_MANAGER_V1_ERROR_INVALID_MATRIX, "a matrix component was < 0");
return; return;
} }
} }
ctms[PMONITOR->m_name] = MAT; m_ctms[PMONITOR->m_name] = MAT;
LOGM(LOG, "CTM set for output {}: {}", PMONITOR->m_name, ctms.at(PMONITOR->m_name).toString()); LOGM(LOG, "CTM set for output {}: {}", PMONITOR->m_name, m_ctms.at(PMONITOR->m_name).toString());
}); });
resource->setCommit([this](CHyprlandCtmControlManagerV1* r) { m_resource->setCommit([this](CHyprlandCtmControlManagerV1* r) {
if (blocked) if (m_blocked)
return; return;
LOGM(LOG, "Committing ctms to outputs"); LOGM(LOG, "Committing ctms to outputs");
for (auto& m : g_pCompositor->m_monitors) { for (auto& m : g_pCompositor->m_monitors) {
if (!ctms.contains(m->m_name)) { if (!m_ctms.contains(m->m_name)) {
PROTO::ctm->setCTM(m, Mat3x3::identity()); PROTO::ctm->setCTM(m, Mat3x3::identity());
continue; continue;
} }
PROTO::ctm->setCTM(m, ctms.at(m->m_name)); PROTO::ctm->setCTM(m, m_ctms.at(m->m_name));
} }
}); });
} }
void CHyprlandCTMControlResource::block() { void CHyprlandCTMControlResource::block() {
blocked = true; m_blocked = true;
if (resource->version() >= 2) if (m_resource->version() >= 2)
resource->sendBlocked(); m_resource->sendBlocked();
} }
CHyprlandCTMControlResource::~CHyprlandCTMControlResource() { CHyprlandCTMControlResource::~CHyprlandCTMControlResource() {
if (blocked) if (m_blocked)
return; return;
for (auto& m : g_pCompositor->m_monitors) { for (auto& m : g_pCompositor->m_monitors) {
@ -79,7 +79,7 @@ CHyprlandCTMControlResource::~CHyprlandCTMControlResource() {
} }
bool CHyprlandCTMControlResource::good() { bool CHyprlandCTMControlResource::good() {
return resource->resource(); return m_resource->resource();
} }
CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -87,24 +87,24 @@ CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* ifa
} }
void CHyprlandCTMControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { 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))); const auto RESOURCE = m_managers.emplace_back(makeShared<CHyprlandCTMControlResource>(makeShared<CHyprlandCtmControlManagerV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
if (m_pManager) if (m_manager)
RESOURCE->block(); RESOURCE->block();
else else
m_pManager = RESOURCE; m_manager = RESOURCE;
LOGM(LOG, "New CTM Manager at 0x{:x}", (uintptr_t)RESOURCE.get()); LOGM(LOG, "New CTM Manager at 0x{:x}", (uintptr_t)RESOURCE.get());
} }
void CHyprlandCTMControlProtocol::destroyResource(CHyprlandCTMControlResource* res) { void CHyprlandCTMControlProtocol::destroyResource(CHyprlandCTMControlResource* res) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; });
} }
bool CHyprlandCTMControlProtocol::isCTMAnimationEnabled() { bool CHyprlandCTMControlProtocol::isCTMAnimationEnabled() {
@ -129,12 +129,12 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm)
return; return;
} }
std::erase_if(m_mCTMDatas, [](const auto& el) { return !el.first; }); std::erase_if(m_ctmDatas, [](const auto& el) { return !el.first; });
if (!m_mCTMDatas.contains(monitor)) if (!m_ctmDatas.contains(monitor))
m_mCTMDatas[monitor] = makeUnique<SCTMData>(); m_ctmDatas[monitor] = makeUnique<SCTMData>();
auto& data = m_mCTMDatas.at(monitor); auto& data = m_ctmDatas.at(monitor);
data->ctmFrom = data->ctmTo; data->ctmFrom = data->ctmTo;
data->ctmTo = ctm; data->ctmTo = ctm;
@ -145,9 +145,9 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm)
monitor->setCTM(data->ctmFrom); monitor->setCTM(data->ctmFrom);
data->progress->setUpdateCallback([monitor = PHLMONITORREF{monitor}, this](auto) { data->progress->setUpdateCallback([monitor = PHLMONITORREF{monitor}, this](auto) {
if (!monitor || !m_mCTMDatas.contains(monitor)) if (!monitor || !m_ctmDatas.contains(monitor))
return; return;
auto& data = m_mCTMDatas.at(monitor); auto& data = m_ctmDatas.at(monitor);
const auto from = data->ctmFrom.getMatrix(); const auto from = data->ctmFrom.getMatrix();
const auto to = data->ctmTo.getMatrix(); const auto to = data->ctmTo.getMatrix();
const auto PROGRESS = data->progress->getPercent(); const auto PROGRESS = data->progress->getPercent();
@ -163,12 +163,12 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm)
}); });
data->progress->setCallbackOnEnd([monitor = PHLMONITORREF{monitor}, this](auto) { data->progress->setCallbackOnEnd([monitor = PHLMONITORREF{monitor}, this](auto) {
if (!monitor || !m_mCTMDatas.contains(monitor)) { if (!monitor || !m_ctmDatas.contains(monitor)) {
if (monitor) if (monitor)
monitor->setCTM(Mat3x3::identity()); monitor->setCTM(Mat3x3::identity());
return; return;
} }
auto& data = m_mCTMDatas.at(monitor); auto& data = m_ctmDatas.at(monitor);
monitor->setCTM(data->ctmTo); monitor->setCTM(data->ctmTo);
}); });
} }

View File

@ -19,10 +19,10 @@ class CHyprlandCTMControlResource {
void block(); void block();
private: private:
SP<CHyprlandCtmControlManagerV1> resource; SP<CHyprlandCtmControlManagerV1> m_resource;
std::unordered_map<std::string, Mat3x3> ctms; std::unordered_map<std::string, Mat3x3> m_ctms;
bool blocked = false; bool m_blocked = false;
}; };
class CHyprlandCTMControlProtocol : public IWaylandProtocol { class CHyprlandCTMControlProtocol : public IWaylandProtocol {
@ -38,8 +38,8 @@ class CHyprlandCTMControlProtocol : public IWaylandProtocol {
bool isCTMAnimationEnabled(); bool isCTMAnimationEnabled();
// //
std::vector<SP<CHyprlandCTMControlResource>> m_vManagers; std::vector<SP<CHyprlandCTMControlResource>> m_managers;
WP<CHyprlandCTMControlResource> m_pManager; WP<CHyprlandCTMControlResource> m_manager;
// //
struct SCTMData { struct SCTMData {
@ -47,7 +47,7 @@ class CHyprlandCTMControlProtocol : public IWaylandProtocol {
Mat3x3 ctmFrom = Mat3x3::identity(), ctmTo = Mat3x3::identity(); Mat3x3 ctmFrom = Mat3x3::identity(), ctmTo = Mat3x3::identity();
PHLANIMVAR<float> progress; PHLANIMVAR<float> progress;
}; };
std::map<PHLMONITORREF, UP<SCTMData>> m_mCTMDatas; std::map<PHLMONITORREF, UP<SCTMData>> m_ctmDatas;
friend class CHyprlandCTMControlResource; friend class CHyprlandCTMControlResource;
}; };

View File

@ -82,15 +82,15 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
} }
const auto RESOURCE = const auto RESOURCE =
PROTO::colorManagement->m_vOutputs.emplace_back(makeShared<CColorManagementOutput>(makeShared<CWpColorManagementOutputV1>(r->client(), r->version(), id), PMONITOR)); PROTO::colorManagement->m_outputs.emplace_back(makeShared<CColorManagementOutput>(makeShared<CWpColorManagementOutputV1>(r->client(), r->version(), id), PMONITOR));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vOutputs.pop_back(); PROTO::colorManagement->m_outputs.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setGetSurface([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) { m_resource->setGetSurface([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) {
LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface);
@ -108,14 +108,14 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
} }
const auto RESOURCE = const auto RESOURCE =
PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared<CColorManagementSurface>(makeShared<CWpColorManagementSurfaceV1>(r->client(), r->version(), id), SURF)); PROTO::colorManagement->m_surfaces.emplace_back(makeShared<CColorManagementSurface>(makeShared<CWpColorManagementSurfaceV1>(r->client(), r->version(), id), SURF));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vSurfaces.pop_back(); PROTO::colorManagement->m_surfaces.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
SURF->m_colorManagement = RESOURCE; SURF->m_colorManagement = RESOURCE;
}); });
@ -129,16 +129,16 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
return; return;
} }
const auto RESOURCE = PROTO::colorManagement->m_vFeedbackSurfaces.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_feedbackSurfaces.emplace_back(
makeShared<CColorManagementFeedbackSurface>(makeShared<CWpColorManagementSurfaceFeedbackV1>(r->client(), r->version(), id), SURF)); makeShared<CColorManagementFeedbackSurface>(makeShared<CWpColorManagementSurfaceFeedbackV1>(r->client(), r->version(), id), SURF));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vFeedbackSurfaces.pop_back(); PROTO::colorManagement->m_feedbackSurfaces.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setCreateIccCreator([](CWpColorManagerV1* r, uint32_t id) { m_resource->setCreateIccCreator([](CWpColorManagerV1* r, uint32_t id) {
LOGM(WARN, "New ICC creator for id={} (unsupported)", id); LOGM(WARN, "New ICC creator for id={} (unsupported)", id);
@ -148,29 +148,29 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
} }
const auto RESOURCE = const auto RESOURCE =
PROTO::colorManagement->m_vIccCreators.emplace_back(makeShared<CColorManagementIccCreator>(makeShared<CWpImageDescriptionCreatorIccV1>(r->client(), r->version(), id))); PROTO::colorManagement->m_iccCreators.emplace_back(makeShared<CColorManagementIccCreator>(makeShared<CWpImageDescriptionCreatorIccV1>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vIccCreators.pop_back(); PROTO::colorManagement->m_iccCreators.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setCreateParametricCreator([](CWpColorManagerV1* r, uint32_t id) { m_resource->setCreateParametricCreator([](CWpColorManagerV1* r, uint32_t id) {
LOGM(TRACE, "New parametric creator for id={}", id); LOGM(TRACE, "New parametric creator for id={}", id);
const auto RESOURCE = PROTO::colorManagement->m_vParametricCreators.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_parametricCreators.emplace_back(
makeShared<CColorManagementParametricCreator>(makeShared<CWpImageDescriptionCreatorParamsV1>(r->client(), r->version(), id))); makeShared<CColorManagementParametricCreator>(makeShared<CWpImageDescriptionCreatorParamsV1>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vParametricCreators.pop_back(); PROTO::colorManagement->m_parametricCreators.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
m_resource->setCreateWindowsScrgb([](CWpColorManagerV1* r, uint32_t id) { m_resource->setCreateWindowsScrgb([](CWpColorManagerV1* r, uint32_t id) {
LOGM(WARN, "New Windows scRGB description id={} (unsupported)", id); LOGM(WARN, "New Windows scRGB description id={} (unsupported)", id);
@ -179,23 +179,23 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
return; return;
} }
const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false)); makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vImageDescriptions.pop_back(); PROTO::colorManagement->m_imageDescriptions.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
RESOURCE->settings.windowsScRGB = true; RESOURCE->m_settings.windowsScRGB = true;
RESOURCE->settings.primariesNamed = NColorManagement::CM_PRIMARIES_SRGB; RESOURCE->m_settings.primariesNamed = NColorManagement::CM_PRIMARIES_SRGB;
RESOURCE->settings.primariesNameSet = true; RESOURCE->m_settings.primariesNameSet = true;
RESOURCE->settings.primaries = NColorPrimaries::BT709; RESOURCE->m_settings.primaries = NColorPrimaries::BT709;
RESOURCE->settings.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_EXT_LINEAR; RESOURCE->m_settings.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_EXT_LINEAR;
RESOURCE->settings.luminances.reference = 203; RESOURCE->m_settings.luminances.reference = 203;
RESOURCE->resource()->sendReady(RESOURCE->settings.updateId()); RESOURCE->resource()->sendReady(RESOURCE->m_settings.updateId());
}); });
m_resource->setOnDestroy([this](CWpColorManagerV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagerV1* r) { PROTO::colorManagement->destroyResource(this); });
@ -211,7 +211,7 @@ CColorManagementOutput::CColorManagementOutput(SP<CWpColorManagementOutputV1> re
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = m_resource->client(); m_client = m_resource->client();
m_resource->setDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); });
m_resource->setOnDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); });
@ -219,24 +219,24 @@ CColorManagementOutput::CColorManagementOutput(SP<CWpColorManagementOutputV1> re
m_resource->setGetImageDescription([this](CWpColorManagementOutputV1* r, uint32_t id) { m_resource->setGetImageDescription([this](CWpColorManagementOutputV1* r, uint32_t id) {
LOGM(TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id); LOGM(TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id);
if (imageDescription.valid()) if (m_imageDescription.valid())
PROTO::colorManagement->destroyResource(imageDescription.get()); PROTO::colorManagement->destroyResource(m_imageDescription.get());
const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), true)); makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), true));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vImageDescriptions.pop_back(); PROTO::colorManagement->m_imageDescriptions.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
if (!m_monitor.valid()) if (!m_monitor.valid())
RESOURCE->m_resource->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_NO_OUTPUT, "No output"); RESOURCE->m_resource->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_NO_OUTPUT, "No output");
else { else {
RESOURCE->settings = m_monitor->m_imageDescription; RESOURCE->m_settings = m_monitor->m_imageDescription;
RESOURCE->m_resource->sendReady(RESOURCE->settings.updateId()); RESOURCE->m_resource->sendReady(RESOURCE->m_settings.updateId());
} }
}); });
} }
@ -246,25 +246,25 @@ bool CColorManagementOutput::good() {
} }
wl_client* CColorManagementOutput::client() { wl_client* CColorManagementOutput::client() {
return pClient; return m_client;
} }
CColorManagementSurface::CColorManagementSurface(SP<CWLSurfaceResource> surface_) : surface(surface_) { CColorManagementSurface::CColorManagementSurface(SP<CWLSurfaceResource> surface_) : m_surface(surface_) {
// only for frog cm untill wayland cm is adopted // only for frog cm untill wayland cm is adopted
} }
CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1> resource, SP<CWLSurfaceResource> surface_) : surface(surface_), m_resource(resource) { CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1> resource, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = m_resource->client(); m_client = m_resource->client();
m_resource->setDestroy([this](CWpColorManagementSurfaceV1* r) { m_resource->setDestroy([this](CWpColorManagementSurfaceV1* r) {
LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface);
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setOnDestroy([this](CWpColorManagementSurfaceV1* r) { m_resource->setOnDestroy([this](CWpColorManagementSurfaceV1* r) {
LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface);
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
@ -281,15 +281,15 @@ CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1>
return; return;
} }
const auto imageDescription = std::find_if(PROTO::colorManagement->m_vImageDescriptions.begin(), PROTO::colorManagement->m_vImageDescriptions.end(), const auto imageDescription = std::find_if(PROTO::colorManagement->m_imageDescriptions.begin(), PROTO::colorManagement->m_imageDescriptions.end(),
[&](const auto& other) { return other->resource()->resource() == image_description; }); [&](const auto& other) { return other->resource()->resource() == image_description; });
if (imageDescription == PROTO::colorManagement->m_vImageDescriptions.end()) { if (imageDescription == PROTO::colorManagement->m_imageDescriptions.end()) {
r->error(WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "Image description not found"); r->error(WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "Image description not found");
return; return;
} }
setHasImageDescription(true); setHasImageDescription(true);
m_imageDescription = imageDescription->get()->settings; m_imageDescription = imageDescription->get()->m_settings;
}); });
m_resource->setUnsetImageDescription([this](CWpColorManagementSurfaceV1* r) { m_resource->setUnsetImageDescription([this](CWpColorManagementSurfaceV1* r) {
LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r); LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r);
@ -303,7 +303,7 @@ bool CColorManagementSurface::good() {
} }
wl_client* CColorManagementSurface::client() { wl_client* CColorManagementSurface::client() {
return pClient; return m_client;
} }
const SImageDescription& CColorManagementSurface::imageDescription() { const SImageDescription& CColorManagementSurface::imageDescription() {
@ -340,20 +340,20 @@ bool CColorManagementSurface::needsHdrMetadataUpdate() {
} }
CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorManagementSurfaceFeedbackV1> resource, SP<CWLSurfaceResource> surface_) : CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorManagementSurfaceFeedbackV1> resource, SP<CWLSurfaceResource> surface_) :
surface(surface_), m_resource(resource) { m_surface(surface_), m_resource(resource) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = m_resource->client(); m_client = m_resource->client();
m_resource->setDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { m_resource->setDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) {
LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface);
if (m_currentPreferred.valid()) if (m_currentPreferred.valid())
PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(m_currentPreferred.get());
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setOnDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { m_resource->setOnDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) {
LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface);
if (m_currentPreferred.valid()) if (m_currentPreferred.valid())
PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(m_currentPreferred.get());
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
@ -365,20 +365,20 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
if (m_currentPreferred.valid()) if (m_currentPreferred.valid())
PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(m_currentPreferred.get());
const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), true)); makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), true));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vImageDescriptions.pop_back(); PROTO::colorManagement->m_imageDescriptions.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
m_currentPreferred = RESOURCE; m_currentPreferred = RESOURCE;
m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription(); m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription();
RESOURCE->resource()->sendReady(m_currentPreferred->settings.updateId()); RESOURCE->resource()->sendReady(m_currentPreferred->m_settings.updateId());
}); });
m_resource->setGetPreferredParametric([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) { m_resource->setGetPreferredParametric([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) {
@ -392,26 +392,26 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
if (m_currentPreferred.valid()) if (m_currentPreferred.valid())
PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(m_currentPreferred.get());
const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), true)); makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), true));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vImageDescriptions.pop_back(); PROTO::colorManagement->m_imageDescriptions.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
m_currentPreferred = RESOURCE; m_currentPreferred = RESOURCE;
m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription(); m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription();
if (!PROTO::colorManagement->m_debug && m_currentPreferred->settings.icc.fd) { if (!PROTO::colorManagement->m_debug && m_currentPreferred->m_settings.icc.fd) {
LOGM(ERR, "FIXME: parse icc profile"); LOGM(ERR, "FIXME: parse icc profile");
r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported");
return; return;
} }
RESOURCE->resource()->sendReady(m_currentPreferred->settings.updateId()); RESOURCE->resource()->sendReady(m_currentPreferred->m_settings.updateId());
}); });
} }
@ -420,14 +420,14 @@ bool CColorManagementFeedbackSurface::good() {
} }
wl_client* CColorManagementFeedbackSurface::client() { wl_client* CColorManagementFeedbackSurface::client() {
return pClient; return m_client;
} }
CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCreatorIccV1> resource) : m_resource(resource) { CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCreatorIccV1> resource) : m_resource(resource) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
// //
pClient = m_resource->client(); m_client = m_resource->client();
m_resource->setOnDestroy([this](CWpImageDescriptionCreatorIccV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpImageDescriptionCreatorIccV1* r) { PROTO::colorManagement->destroyResource(this); });
@ -435,39 +435,39 @@ CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCre
LOGM(TRACE, "Create image description from icc for id {}", id); LOGM(TRACE, "Create image description from icc for id {}", id);
// FIXME actually check completeness // FIXME actually check completeness
if (settings.icc.fd < 0 || !settings.icc.length) { if (m_settings.icc.fd < 0 || !m_settings.icc.length) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET, "Missing required settings"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET, "Missing required settings");
return; return;
} }
const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false)); makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vImageDescriptions.pop_back(); PROTO::colorManagement->m_imageDescriptions.pop_back();
return; return;
} }
LOGM(ERR, "FIXME: Parse icc file {}({},{}) for id {}", settings.icc.fd, settings.icc.offset, settings.icc.length, id); LOGM(ERR, "FIXME: Parse icc file {}({},{}) for id {}", m_settings.icc.fd, m_settings.icc.offset, m_settings.icc.length, id);
// FIXME actually check support // FIXME actually check support
if (settings.icc.fd < 0 || !settings.icc.length) { if (m_settings.icc.fd < 0 || !m_settings.icc.length) {
RESOURCE->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "unsupported"); RESOURCE->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "unsupported");
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
RESOURCE->settings = settings; RESOURCE->m_settings = m_settings;
RESOURCE->resource()->sendReady(settings.updateId()); RESOURCE->resource()->sendReady(m_settings.updateId());
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setSetIccFile([this](CWpImageDescriptionCreatorIccV1* r, int fd, uint32_t offset, uint32_t length) { m_resource->setSetIccFile([this](CWpImageDescriptionCreatorIccV1* r, int fd, uint32_t offset, uint32_t length) {
settings.icc.fd = fd; m_settings.icc.fd = fd;
settings.icc.offset = offset; m_settings.icc.offset = offset;
settings.icc.length = length; m_settings.icc.length = length;
}); });
} }
@ -476,14 +476,14 @@ bool CColorManagementIccCreator::good() {
} }
wl_client* CColorManagementIccCreator::client() { wl_client* CColorManagementIccCreator::client() {
return pClient; return m_client;
} }
CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImageDescriptionCreatorParamsV1> resource) : m_resource(resource) { CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImageDescriptionCreatorParamsV1> resource) : m_resource(resource) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
// //
pClient = m_resource->client(); m_client = m_resource->client();
m_resource->setOnDestroy([this](CWpImageDescriptionCreatorParamsV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpImageDescriptionCreatorParamsV1* r) { PROTO::colorManagement->destroyResource(this); });
@ -491,35 +491,35 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
LOGM(TRACE, "Create image description from params for id {}", id); LOGM(TRACE, "Create image description from params for id {}", id);
// FIXME actually check completeness // FIXME actually check completeness
if (!valuesSet) { if (!m_valuesSet) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET, "Missing required settings"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET, "Missing required settings");
return; return;
} }
const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back(
makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false)); makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::colorManagement->m_vImageDescriptions.pop_back(); PROTO::colorManagement->m_imageDescriptions.pop_back();
return; return;
} }
// FIXME actually check support // FIXME actually check support
if (!valuesSet) { if (!m_valuesSet) {
RESOURCE->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "unsupported"); RESOURCE->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "unsupported");
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
RESOURCE->settings = settings; RESOURCE->m_settings = m_settings;
RESOURCE->resource()->sendReady(settings.updateId()); RESOURCE->resource()->sendReady(m_settings.updateId());
PROTO::colorManagement->destroyResource(this); PROTO::colorManagement->destroyResource(this);
}); });
m_resource->setSetTfNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t tf) { m_resource->setSetTfNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t tf) {
LOGM(TRACE, "Set image description transfer function to {}", tf); LOGM(TRACE, "Set image description transfer function to {}", tf);
if (valuesSet & PC_TF) { if (m_valuesSet & PC_TF) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function already set");
return; return;
} }
@ -534,12 +534,12 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
default: r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Unsupported transfer function"); return; default: r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Unsupported transfer function"); return;
} }
settings.transferFunction = convertTransferFunction((wpColorManagerV1TransferFunction)tf); m_settings.transferFunction = convertTransferFunction((wpColorManagerV1TransferFunction)tf);
valuesSet |= PC_TF; m_valuesSet |= PC_TF;
}); });
m_resource->setSetTfPower([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t eexp) { m_resource->setSetTfPower([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t eexp) {
LOGM(TRACE, "Set image description tf power to {}", eexp); LOGM(TRACE, "Set image description tf power to {}", eexp);
if (valuesSet & PC_TF_POWER) { if (m_valuesSet & PC_TF_POWER) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function power already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function power already set");
return; return;
} }
@ -547,16 +547,16 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "TF power is not supported"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "TF power is not supported");
return; return;
} }
settings.transferFunctionPower = eexp / 10000.0f; m_settings.transferFunctionPower = eexp / 10000.0f;
if (settings.transferFunctionPower < 1.0 || settings.transferFunctionPower > 10.0) { if (m_settings.transferFunctionPower < 1.0 || m_settings.transferFunctionPower > 10.0) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Power should be between 1.0 and 10.0"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Power should be between 1.0 and 10.0");
return; return;
} }
valuesSet |= PC_TF_POWER; m_valuesSet |= PC_TF_POWER;
}); });
m_resource->setSetPrimariesNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t primaries) { m_resource->setSetPrimariesNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t primaries) {
LOGM(TRACE, "Set image description primaries by name {}", primaries); LOGM(TRACE, "Set image description primaries by name {}", primaries);
if (valuesSet & PC_PRIMARIES) { if (m_valuesSet & PC_PRIMARIES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set");
return; return;
} }
@ -578,15 +578,15 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
} }
} }
settings.primariesNameSet = true; m_settings.primariesNameSet = true;
settings.primariesNamed = convertPrimaries((wpColorManagerV1Primaries)primaries); m_settings.primariesNamed = convertPrimaries((wpColorManagerV1Primaries)primaries);
settings.primaries = getPrimaries(settings.primariesNamed); m_settings.primaries = getPrimaries(m_settings.primariesNamed);
valuesSet |= PC_PRIMARIES; m_valuesSet |= PC_PRIMARIES;
}); });
m_resource->setSetPrimaries( m_resource->setSetPrimaries(
[this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { [this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) {
LOGM(TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); LOGM(TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
if (valuesSet & PC_PRIMARIES) { if (m_valuesSet & PC_PRIMARIES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set");
return; return;
} }
@ -594,17 +594,17 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Custom primaries aren't supported"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Custom primaries aren't supported");
return; return;
} }
settings.primariesNameSet = false; m_settings.primariesNameSet = false;
settings.primaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f}, m_settings.primaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f},
.green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f}, .green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f},
.blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f}, .blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f},
.white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}}; .white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}};
valuesSet |= PC_PRIMARIES; m_valuesSet |= PC_PRIMARIES;
}); });
m_resource->setSetLuminances([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { m_resource->setSetLuminances([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) {
auto min = min_lum / 10000.0f; auto min = min_lum / 10000.0f;
LOGM(TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum); LOGM(TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum);
if (valuesSet & PC_LUMINANCES) { if (m_valuesSet & PC_LUMINANCES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Luminances already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Luminances already set");
return; return;
} }
@ -612,13 +612,13 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE, "Invalid luminances"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE, "Invalid luminances");
return; return;
} }
settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum}; m_settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum};
valuesSet |= PC_LUMINANCES; m_valuesSet |= PC_LUMINANCES;
}); });
m_resource->setSetMasteringDisplayPrimaries( m_resource->setSetMasteringDisplayPrimaries(
[this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { [this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) {
LOGM(TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); LOGM(TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
if (valuesSet & PC_MASTERING_PRIMARIES) { if (m_valuesSet & PC_MASTERING_PRIMARIES) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Mastering primaries already set"); r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Mastering primaries already set");
return; return;
} }
@ -626,11 +626,11 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Mastering primaries are not supported"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Mastering primaries are not supported");
return; return;
} }
settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f}, m_settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f},
.green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f}, .green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f},
.blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f}, .blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f},
.white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}}; .white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}};
valuesSet |= PC_MASTERING_PRIMARIES; m_valuesSet |= PC_MASTERING_PRIMARIES;
// FIXME: // FIXME:
// If a compositor additionally supports target color volume exceeding the primary color volume, it must advertise wp_color_manager_v1.feature.extended_target_volume. // If a compositor additionally supports target color volume exceeding the primary color volume, it must advertise wp_color_manager_v1.feature.extended_target_volume.
@ -652,8 +652,8 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Mastering luminances are not supported"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Mastering luminances are not supported");
return; return;
} }
settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum}; m_settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum};
valuesSet |= PC_MASTERING_LUMINANCES; m_valuesSet |= PC_MASTERING_LUMINANCES;
}); });
m_resource->setSetMaxCll([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_cll) { m_resource->setSetMaxCll([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_cll) {
LOGM(TRACE, "Set image description max content light level to {}", max_cll); LOGM(TRACE, "Set image description max content light level to {}", max_cll);
@ -661,8 +661,8 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
// r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max CLL already set"); // r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max CLL already set");
// return; // return;
// } // }
settings.maxCLL = max_cll; m_settings.maxCLL = max_cll;
valuesSet |= PC_CLL; m_valuesSet |= PC_CLL;
}); });
m_resource->setSetMaxFall([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_fall) { m_resource->setSetMaxFall([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_fall) {
LOGM(TRACE, "Set image description max frame-average light level to {}", max_fall); LOGM(TRACE, "Set image description max frame-average light level to {}", max_fall);
@ -670,8 +670,8 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
// r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max FALL already set"); // r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max FALL already set");
// return; // return;
// } // }
settings.maxFALL = max_fall; m_settings.maxFALL = max_fall;
valuesSet |= PC_FALL; m_valuesSet |= PC_FALL;
}); });
} }
@ -680,7 +680,7 @@ bool CColorManagementParametricCreator::good() {
} }
wl_client* CColorManagementParametricCreator::client() { wl_client* CColorManagementParametricCreator::client() {
return pClient; return m_client;
} }
CColorManagementImageDescription::CColorManagementImageDescription(SP<CWpImageDescriptionV1> resource, bool allowGetInformation) : CColorManagementImageDescription::CColorManagementImageDescription(SP<CWpImageDescriptionV1> resource, bool allowGetInformation) :
@ -688,7 +688,7 @@ CColorManagementImageDescription::CColorManagementImageDescription(SP<CWpImageDe
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = m_resource->client(); m_client = m_resource->client();
m_resource->setDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); });
m_resource->setOnDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); });
@ -700,7 +700,7 @@ CColorManagementImageDescription::CColorManagementImageDescription(SP<CWpImageDe
return; return;
} }
auto RESOURCE = makeShared<CColorManagementImageDescriptionInfo>(makeShared<CWpImageDescriptionInfoV1>(r->client(), r->version(), id), settings); auto RESOURCE = makeShared<CColorManagementImageDescriptionInfo>(makeShared<CWpImageDescriptionInfoV1>(r->client(), r->version(), id), m_settings);
if UNLIKELY (!RESOURCE->good()) if UNLIKELY (!RESOURCE->good())
r->noMemory(); r->noMemory();
@ -715,7 +715,7 @@ bool CColorManagementImageDescription::good() {
} }
wl_client* CColorManagementImageDescription::client() { wl_client* CColorManagementImageDescription::client() {
return pClient; return m_client;
} }
SP<CWpImageDescriptionV1> CColorManagementImageDescription::resource() { SP<CWpImageDescriptionV1> CColorManagementImageDescription::resource() {
@ -723,33 +723,34 @@ SP<CWpImageDescriptionV1> CColorManagementImageDescription::resource() {
} }
CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CWpImageDescriptionInfoV1> resource, const SImageDescription& settings_) : CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CWpImageDescriptionInfoV1> resource, const SImageDescription& settings_) :
m_resource(resource), settings(settings_) { m_resource(resource), m_settings(settings_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = m_resource->client(); m_client = m_resource->client();
const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); }; const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); };
if (settings.icc.fd >= 0) if (m_settings.icc.fd >= 0)
m_resource->sendIccFile(settings.icc.fd, settings.icc.length); m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length);
// send preferred client paramateres // send preferred client paramateres
m_resource->sendPrimaries(toProto(settings.primaries.red.x), toProto(settings.primaries.red.y), toProto(settings.primaries.green.x), toProto(settings.primaries.green.y), m_resource->sendPrimaries(toProto(m_settings.primaries.red.x), toProto(m_settings.primaries.red.y), toProto(m_settings.primaries.green.x),
toProto(settings.primaries.blue.x), toProto(settings.primaries.blue.y), toProto(settings.primaries.white.x), toProto(settings.primaries.white.y)); toProto(m_settings.primaries.green.y), toProto(m_settings.primaries.blue.x), toProto(m_settings.primaries.blue.y),
if (settings.primariesNameSet) toProto(m_settings.primaries.white.x), toProto(m_settings.primaries.white.y));
m_resource->sendPrimariesNamed(settings.primariesNamed); if (m_settings.primariesNameSet)
m_resource->sendTfPower(std::round(settings.transferFunctionPower * 10000)); m_resource->sendPrimariesNamed(m_settings.primariesNamed);
m_resource->sendTfNamed(settings.transferFunction); m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000));
m_resource->sendLuminances(std::round(settings.luminances.min * 10000), settings.luminances.max, settings.luminances.reference); m_resource->sendTfNamed(m_settings.transferFunction);
m_resource->sendLuminances(std::round(m_settings.luminances.min * 10000), m_settings.luminances.max, m_settings.luminances.reference);
// send expexted display paramateres // send expexted display paramateres
m_resource->sendTargetPrimaries(toProto(settings.masteringPrimaries.red.x), toProto(settings.masteringPrimaries.red.y), toProto(settings.masteringPrimaries.green.x), m_resource->sendTargetPrimaries(toProto(m_settings.masteringPrimaries.red.x), toProto(m_settings.masteringPrimaries.red.y), toProto(m_settings.masteringPrimaries.green.x),
toProto(settings.masteringPrimaries.green.y), toProto(settings.masteringPrimaries.blue.x), toProto(settings.masteringPrimaries.blue.y), toProto(m_settings.masteringPrimaries.green.y), toProto(m_settings.masteringPrimaries.blue.x), toProto(m_settings.masteringPrimaries.blue.y),
toProto(settings.masteringPrimaries.white.x), toProto(settings.masteringPrimaries.white.y)); toProto(m_settings.masteringPrimaries.white.x), toProto(m_settings.masteringPrimaries.white.y));
m_resource->sendTargetLuminance(std::round(settings.masteringLuminances.min * 10000), settings.masteringLuminances.max); m_resource->sendTargetLuminance(std::round(m_settings.masteringLuminances.min * 10000), m_settings.masteringLuminances.max);
m_resource->sendTargetMaxCll(settings.maxCLL); m_resource->sendTargetMaxCll(m_settings.maxCLL);
m_resource->sendTargetMaxFall(settings.maxFALL); m_resource->sendTargetMaxFall(m_settings.maxFALL);
m_resource->sendDone(); m_resource->sendDone();
} }
@ -759,7 +760,7 @@ bool CColorManagementImageDescriptionInfo::good() {
} }
wl_client* CColorManagementImageDescriptionInfo::client() { wl_client* CColorManagementImageDescriptionInfo::client() {
return pClient; return m_client;
} }
CColorManagementProtocol::CColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name, bool debug) : CColorManagementProtocol::CColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name, bool debug) :
@ -768,11 +769,11 @@ CColorManagementProtocol::CColorManagementProtocol(const wl_interface* iface, co
} }
void CColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CColorManager>(makeShared<CWpColorManagerV1>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CColorManager>(makeShared<CWpColorManagerV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
@ -780,42 +781,42 @@ void CColorManagementProtocol::bindManager(wl_client* client, void* data, uint32
} }
void CColorManagementProtocol::onImagePreferredChanged(uint32_t preferredId) { void CColorManagementProtocol::onImagePreferredChanged(uint32_t preferredId) {
for (auto const& feedback : m_vFeedbackSurfaces) { for (auto const& feedback : m_feedbackSurfaces) {
feedback->m_resource->sendPreferredChanged(preferredId); feedback->m_resource->sendPreferredChanged(preferredId);
} }
} }
void CColorManagementProtocol::onMonitorImageDescriptionChanged(WP<CMonitor> monitor) { void CColorManagementProtocol::onMonitorImageDescriptionChanged(WP<CMonitor> monitor) {
for (auto const& output : m_vOutputs) { for (auto const& output : m_outputs) {
if (output->m_monitor == monitor) if (output->m_monitor == monitor)
output->m_resource->sendImageDescriptionChanged(); output->m_resource->sendImageDescriptionChanged();
} }
} }
void CColorManagementProtocol::destroyResource(CColorManager* resource) { void CColorManagementProtocol::destroyResource(CColorManager* resource) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
} }
void CColorManagementProtocol::destroyResource(CColorManagementOutput* resource) { void CColorManagementProtocol::destroyResource(CColorManagementOutput* resource) {
std::erase_if(m_vOutputs, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_outputs, [&](const auto& other) { return other.get() == resource; });
} }
void CColorManagementProtocol::destroyResource(CColorManagementSurface* resource) { void CColorManagementProtocol::destroyResource(CColorManagementSurface* resource) {
std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; });
} }
void CColorManagementProtocol::destroyResource(CColorManagementFeedbackSurface* resource) { void CColorManagementProtocol::destroyResource(CColorManagementFeedbackSurface* resource) {
std::erase_if(m_vFeedbackSurfaces, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_feedbackSurfaces, [&](const auto& other) { return other.get() == resource; });
} }
void CColorManagementProtocol::destroyResource(CColorManagementIccCreator* resource) { void CColorManagementProtocol::destroyResource(CColorManagementIccCreator* resource) {
std::erase_if(m_vIccCreators, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_iccCreators, [&](const auto& other) { return other.get() == resource; });
} }
void CColorManagementProtocol::destroyResource(CColorManagementParametricCreator* resource) { void CColorManagementProtocol::destroyResource(CColorManagementParametricCreator* resource) {
std::erase_if(m_vParametricCreators, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_parametricCreators, [&](const auto& other) { return other.get() == resource; });
} }
void CColorManagementProtocol::destroyResource(CColorManagementImageDescription* resource) { void CColorManagementProtocol::destroyResource(CColorManagementImageDescription* resource) {
std::erase_if(m_vImageDescriptions, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_imageDescriptions, [&](const auto& other) { return other.get() == resource; });
} }

View File

@ -31,12 +31,12 @@ class CColorManagementOutput {
bool good(); bool good();
wl_client* client(); wl_client* client();
WP<CColorManagementOutput> self; WP<CColorManagementOutput> m_self;
WP<CColorManagementImageDescription> imageDescription; WP<CColorManagementImageDescription> m_imageDescription;
private: private:
SP<CWpColorManagementOutputV1> m_resource; SP<CWpColorManagementOutputV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
WP<CMonitor> m_monitor; WP<CMonitor> m_monitor;
friend class CColorManagementProtocol; friend class CColorManagementProtocol;
@ -51,8 +51,8 @@ class CColorManagementSurface {
bool good(); bool good();
wl_client* client(); wl_client* client();
WP<CColorManagementSurface> self; WP<CColorManagementSurface> m_self;
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
const NColorManagement::SImageDescription& imageDescription(); const NColorManagement::SImageDescription& imageDescription();
bool hasImageDescription(); bool hasImageDescription();
@ -63,7 +63,7 @@ class CColorManagementSurface {
private: private:
SP<CWpColorManagementSurfaceV1> m_resource; SP<CWpColorManagementSurfaceV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
NColorManagement::SImageDescription m_imageDescription; NColorManagement::SImageDescription m_imageDescription;
NColorManagement::SImageDescription m_lastImageDescription; NColorManagement::SImageDescription m_lastImageDescription;
bool m_hasImageDescription = false; bool m_hasImageDescription = false;
@ -81,12 +81,12 @@ class CColorManagementFeedbackSurface {
bool good(); bool good();
wl_client* client(); wl_client* client();
WP<CColorManagementFeedbackSurface> self; WP<CColorManagementFeedbackSurface> m_self;
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
private: private:
SP<CWpColorManagementSurfaceFeedbackV1> m_resource; SP<CWpColorManagementSurfaceFeedbackV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
WP<CColorManagementImageDescription> m_currentPreferred; WP<CColorManagementImageDescription> m_currentPreferred;
@ -100,13 +100,13 @@ class CColorManagementIccCreator {
bool good(); bool good();
wl_client* client(); wl_client* client();
WP<CColorManagementIccCreator> self; WP<CColorManagementIccCreator> m_self;
NColorManagement::SImageDescription settings; NColorManagement::SImageDescription m_settings;
private: private:
SP<CWpImageDescriptionCreatorIccV1> m_resource; SP<CWpImageDescriptionCreatorIccV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
}; };
class CColorManagementParametricCreator { class CColorManagementParametricCreator {
@ -116,9 +116,9 @@ class CColorManagementParametricCreator {
bool good(); bool good();
wl_client* client(); wl_client* client();
WP<CColorManagementParametricCreator> self; WP<CColorManagementParametricCreator> m_self;
NColorManagement::SImageDescription settings; NColorManagement::SImageDescription m_settings;
private: private:
enum eValuesSet : uint32_t { // NOLINT enum eValuesSet : uint32_t { // NOLINT
@ -133,8 +133,8 @@ class CColorManagementParametricCreator {
}; };
SP<CWpImageDescriptionCreatorParamsV1> m_resource; SP<CWpImageDescriptionCreatorParamsV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
uint32_t valuesSet = 0; // enum eValuesSet uint32_t m_valuesSet = 0; // enum eValuesSet
}; };
class CColorManagementImageDescription { class CColorManagementImageDescription {
@ -145,13 +145,13 @@ class CColorManagementImageDescription {
wl_client* client(); wl_client* client();
SP<CWpImageDescriptionV1> resource(); SP<CWpImageDescriptionV1> resource();
WP<CColorManagementImageDescription> self; WP<CColorManagementImageDescription> m_self;
NColorManagement::SImageDescription settings; NColorManagement::SImageDescription m_settings;
private: private:
SP<CWpImageDescriptionV1> m_resource; SP<CWpImageDescriptionV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
bool m_allowGetInformation = false; bool m_allowGetInformation = false;
friend class CColorManagementOutput; friend class CColorManagementOutput;
@ -166,8 +166,8 @@ class CColorManagementImageDescriptionInfo {
private: private:
SP<CWpImageDescriptionInfoV1> m_resource; SP<CWpImageDescriptionInfoV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
NColorManagement::SImageDescription settings; NColorManagement::SImageDescription m_settings;
}; };
class CColorManagementProtocol : public IWaylandProtocol { class CColorManagementProtocol : public IWaylandProtocol {
@ -188,13 +188,13 @@ class CColorManagementProtocol : public IWaylandProtocol {
void destroyResource(CColorManagementParametricCreator* resource); void destroyResource(CColorManagementParametricCreator* resource);
void destroyResource(CColorManagementImageDescription* resource); void destroyResource(CColorManagementImageDescription* resource);
std::vector<SP<CColorManager>> m_vManagers; std::vector<SP<CColorManager>> m_managers;
std::vector<SP<CColorManagementOutput>> m_vOutputs; std::vector<SP<CColorManagementOutput>> m_outputs;
std::vector<SP<CColorManagementSurface>> m_vSurfaces; std::vector<SP<CColorManagementSurface>> m_surfaces;
std::vector<SP<CColorManagementFeedbackSurface>> m_vFeedbackSurfaces; std::vector<SP<CColorManagementFeedbackSurface>> m_feedbackSurfaces;
std::vector<SP<CColorManagementIccCreator>> m_vIccCreators; std::vector<SP<CColorManagementIccCreator>> m_iccCreators;
std::vector<SP<CColorManagementParametricCreator>> m_vParametricCreators; std::vector<SP<CColorManagementParametricCreator>> m_parametricCreators;
std::vector<SP<CColorManagementImageDescription>> m_vImageDescriptions; std::vector<SP<CColorManagementImageDescription>> m_imageDescriptions;
bool m_debug = false; bool m_debug = false;
friend class CColorManager; friend class CColorManager;

View File

@ -24,14 +24,14 @@ CContentTypeManager::CContentTypeManager(SP<CWpContentTypeManagerV1> resource) :
return; return;
} }
const auto RESOURCE = PROTO::contentType->m_vContentTypes.emplace_back(makeShared<CContentType>(makeShared<CWpContentTypeV1>(r->client(), r->version(), id))); const auto RESOURCE = PROTO::contentType->m_contentTypes.emplace_back(makeShared<CContentType>(makeShared<CWpContentTypeV1>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::contentType->m_vContentTypes.pop_back(); PROTO::contentType->m_contentTypes.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
SURF->m_contentType = RESOURCE; SURF->m_contentType = RESOURCE;
}); });
@ -42,19 +42,19 @@ bool CContentTypeManager::good() {
} }
CContentType::CContentType(WP<CWLSurfaceResource> surface) { CContentType::CContentType(WP<CWLSurfaceResource> surface) {
destroy = surface->m_events.destroy.registerListener([this](std::any d) { PROTO::contentType->destroyResource(this); }); m_destroy = surface->m_events.destroy.registerListener([this](std::any d) { PROTO::contentType->destroyResource(this); });
} }
CContentType::CContentType(SP<CWpContentTypeV1> resource) : m_resource(resource) { CContentType::CContentType(SP<CWpContentTypeV1> resource) : m_resource(resource) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
m_pClient = resource->client(); m_client = resource->client();
resource->setDestroy([this](CWpContentTypeV1* r) { PROTO::contentType->destroyResource(this); }); resource->setDestroy([this](CWpContentTypeV1* r) { PROTO::contentType->destroyResource(this); });
resource->setOnDestroy([this](CWpContentTypeV1* r) { PROTO::contentType->destroyResource(this); }); resource->setOnDestroy([this](CWpContentTypeV1* r) { PROTO::contentType->destroyResource(this); });
resource->setSetContentType([this](CWpContentTypeV1* r, wpContentTypeV1Type type) { value = NContentType::fromWP(type); }); resource->setSetContentType([this](CWpContentTypeV1* r, wpContentTypeV1Type type) { m_value = NContentType::fromWP(type); });
} }
bool CContentType::good() { bool CContentType::good() {
@ -62,7 +62,7 @@ bool CContentType::good() {
} }
wl_client* CContentType::client() { wl_client* CContentType::client() {
return m_pClient; return m_client;
} }
CContentTypeProtocol::CContentTypeProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CContentTypeProtocol::CContentTypeProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -70,11 +70,11 @@ CContentTypeProtocol::CContentTypeProtocol(const wl_interface* iface, const int&
} }
void CContentTypeProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CContentTypeProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CContentTypeManager>(makeShared<CWpContentTypeManagerV1>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CContentTypeManager>(makeShared<CWpContentTypeManagerV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
@ -83,13 +83,13 @@ SP<CContentType> CContentTypeProtocol::getContentType(WP<CWLSurfaceResource> sur
if (surface->m_contentType.valid()) if (surface->m_contentType.valid())
return surface->m_contentType.lock(); return surface->m_contentType.lock();
return m_vContentTypes.emplace_back(makeShared<CContentType>(surface)); return m_contentTypes.emplace_back(makeShared<CContentType>(surface));
} }
void CContentTypeProtocol::destroyResource(CContentTypeManager* resource) { void CContentTypeProtocol::destroyResource(CContentTypeManager* resource) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
} }
void CContentTypeProtocol::destroyResource(CContentType* resource) { void CContentTypeProtocol::destroyResource(CContentType* resource) {
std::erase_if(m_vContentTypes, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_contentTypes, [&](const auto& other) { return other.get() == resource; });
} }

View File

@ -22,15 +22,15 @@ class CContentType {
bool good(); bool good();
wl_client* client(); wl_client* client();
NContentType::eContentType value = NContentType::CONTENT_TYPE_NONE; NContentType::eContentType m_value = NContentType::CONTENT_TYPE_NONE;
WP<CContentType> self; WP<CContentType> m_self;
private: private:
SP<CWpContentTypeV1> m_resource; SP<CWpContentTypeV1> m_resource;
wl_client* m_pClient = nullptr; wl_client* m_client = nullptr;
CHyprSignalListener destroy; CHyprSignalListener m_destroy;
friend class CContentTypeProtocol; friend class CContentTypeProtocol;
}; };
@ -47,8 +47,8 @@ class CContentTypeProtocol : public IWaylandProtocol {
void destroyResource(CContentTypeManager* resource); void destroyResource(CContentTypeManager* resource);
void destroyResource(CContentType* resource); void destroyResource(CContentType* resource);
std::vector<SP<CContentTypeManager>> m_vManagers; std::vector<SP<CContentTypeManager>> m_managers;
std::vector<SP<CContentType>> m_vContentTypes; std::vector<SP<CContentType>> m_contentTypes;
friend class CContentTypeManager; friend class CContentTypeManager;
friend class CContentType; friend class CContentType;

View File

@ -7,15 +7,15 @@ CCursorShapeProtocol::CCursorShapeProtocol(const wl_interface* iface, const int&
} }
void CCursorShapeProtocol::onManagerResourceDestroy(wl_resource* res) { void CCursorShapeProtocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [res](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [res](const auto& other) { return other->resource() == res; });
} }
void CCursorShapeProtocol::onDeviceResourceDestroy(wl_resource* res) { void CCursorShapeProtocol::onDeviceResourceDestroy(wl_resource* res) {
std::erase_if(m_vDevices, [res](const auto& other) { return other->resource() == res; }); std::erase_if(m_devices, [res](const auto& other) { return other->resource() == res; });
} }
void CCursorShapeProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CCursorShapeProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CWpCursorShapeManagerV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CWpCursorShapeManagerV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CWpCursorShapeManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CWpCursorShapeManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CWpCursorShapeManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setDestroy([this](CWpCursorShapeManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@ -33,7 +33,7 @@ void CCursorShapeProtocol::onGetTabletToolV2(CWpCursorShapeManagerV1* pMgr, uint
void CCursorShapeProtocol::createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource) { void CCursorShapeProtocol::createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource) {
const auto CLIENT = pMgr->client(); const auto CLIENT = pMgr->client();
const auto RESOURCE = m_vDevices.emplace_back(makeShared<CWpCursorShapeDeviceV1>(CLIENT, pMgr->version(), id)); const auto RESOURCE = m_devices.emplace_back(makeShared<CWpCursorShapeDeviceV1>(CLIENT, pMgr->version(), id));
RESOURCE->setOnDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); });
@ -51,5 +51,5 @@ void CCursorShapeProtocol::onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t ser
event.shape = shape; event.shape = shape;
event.shapeName = CURSOR_SHAPE_NAMES.at(shape); event.shapeName = CURSOR_SHAPE_NAMES.at(shape);
events.setShape.emit(event); m_events.setShape.emit(event);
} }

View File

@ -19,7 +19,7 @@ class CCursorShapeProtocol : public IWaylandProtocol {
struct { struct {
CSignal setShape; CSignal setShape;
} events; } m_events;
private: private:
void onManagerResourceDestroy(wl_resource* res); void onManagerResourceDestroy(wl_resource* res);
@ -32,8 +32,8 @@ class CCursorShapeProtocol : public IWaylandProtocol {
void createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource); void createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource);
// //
std::vector<SP<CWpCursorShapeDeviceV1>> m_vDevices; std::vector<SP<CWpCursorShapeDeviceV1>> m_devices;
std::vector<UP<CWpCursorShapeManagerV1>> m_vManagers; std::vector<UP<CWpCursorShapeManagerV1>> m_managers;
}; };
namespace PROTO { namespace PROTO {

View File

@ -6,20 +6,20 @@
#include <fcntl.h> #include <fcntl.h>
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRequestResource> request) : resource(resource_) { CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRequestResource> request) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); }); m_resource->setOnDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); });
resource->setDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); }); m_resource->setDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); });
parent = request->parent; m_parent = request->m_parent;
requested = request->requested; m_requested = request->m_requested;
for (auto const& m : requested) { for (auto const& m : m_requested) {
if (!m->monitor || m->monitor->m_isBeingLeased) { if (!m->m_monitor || m->m_monitor->m_isBeingLeased) {
LOGM(ERR, "Rejecting lease: no monitor or monitor is being leased for {}", (m->monitor ? m->monitor->m_name : "null")); LOGM(ERR, "Rejecting lease: no monitor or monitor is being leased for {}", (m->m_monitor ? m->m_monitor->m_name : "null"));
resource->sendFinished(); m_resource->sendFinished();
return; return;
} }
} }
@ -28,97 +28,97 @@ CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRe
LOGM(LOG, "Leasing outputs: {}", [this]() { LOGM(LOG, "Leasing outputs: {}", [this]() {
std::string roll; std::string roll;
for (auto const& o : requested) { for (auto const& o : m_requested) {
roll += std::format("{} ", o->monitor->m_name); roll += std::format("{} ", o->m_monitor->m_name);
} }
return roll; return roll;
}()); }());
std::vector<SP<Aquamarine::IOutput>> outputs; std::vector<SP<Aquamarine::IOutput>> outputs;
// reserve to avoid reallocations // reserve to avoid reallocations
outputs.reserve(requested.size()); outputs.reserve(m_requested.size());
for (auto const& m : requested) { for (auto const& m : m_requested) {
outputs.emplace_back(m->monitor->m_output); outputs.emplace_back(m->m_monitor->m_output);
} }
auto aqlease = Aquamarine::CDRMLease::create(outputs); auto aqlease = Aquamarine::CDRMLease::create(outputs);
if (!aqlease) { if (!aqlease) {
LOGM(ERR, "Rejecting lease: backend failed to alloc a lease"); LOGM(ERR, "Rejecting lease: backend failed to alloc a lease");
resource->sendFinished(); m_resource->sendFinished();
return; return;
} }
lease = aqlease; m_lease = aqlease;
for (auto const& m : requested) { for (auto const& m : m_requested) {
m->monitor->m_isBeingLeased = true; m->m_monitor->m_isBeingLeased = true;
} }
listeners.destroyLease = lease->events.destroy.registerListener([this](std::any d) { m_listeners.destroyLease = m_lease->events.destroy.registerListener([this](std::any d) {
for (auto const& m : requested) { for (auto const& m : m_requested) {
if (m && m->monitor) if (m && m->m_monitor)
m->monitor->m_isBeingLeased = false; m->m_monitor->m_isBeingLeased = false;
} }
resource->sendFinished(); m_resource->sendFinished();
LOGM(LOG, "Revoking lease for fd {}", lease->leaseFD); LOGM(LOG, "Revoking lease for fd {}", m_lease->leaseFD);
}); });
LOGM(LOG, "Granting lease, sending fd {}", lease->leaseFD); LOGM(LOG, "Granting lease, sending fd {}", m_lease->leaseFD);
resource->sendLeaseFd(lease->leaseFD); m_resource->sendLeaseFd(m_lease->leaseFD);
close(lease->leaseFD); close(m_lease->leaseFD);
} }
bool CDRMLeaseResource::good() { bool CDRMLeaseResource::good() {
return resource->resource(); return m_resource->resource();
} }
CDRMLeaseResource::~CDRMLeaseResource() { CDRMLeaseResource::~CDRMLeaseResource() {
// destroy in this order to ensure listener gets called // destroy in this order to ensure listener gets called
lease.reset(); m_lease.reset();
listeners.destroyLease.reset(); m_listeners.destroyLease.reset();
} }
CDRMLeaseRequestResource::CDRMLeaseRequestResource(SP<CWpDrmLeaseRequestV1> resource_) : resource(resource_) { CDRMLeaseRequestResource::CDRMLeaseRequestResource(SP<CWpDrmLeaseRequestV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWpDrmLeaseRequestV1* r) { PROTO::lease->destroyResource(this); }); m_resource->setOnDestroy([this](CWpDrmLeaseRequestV1* r) { PROTO::lease->destroyResource(this); });
resource->setRequestConnector([this](CWpDrmLeaseRequestV1* r, wl_resource* conn) { m_resource->setRequestConnector([this](CWpDrmLeaseRequestV1* r, wl_resource* conn) {
if (!conn) { if (!conn) {
resource->error(-1, "Null connector"); m_resource->error(-1, "Null connector");
return; return;
} }
auto CONNECTOR = CDRMLeaseConnectorResource::fromResource(conn); auto CONNECTOR = CDRMLeaseConnectorResource::fromResource(conn);
if (std::find(requested.begin(), requested.end(), CONNECTOR) != requested.end()) { if (std::find(m_requested.begin(), m_requested.end(), CONNECTOR) != m_requested.end()) {
resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_DUPLICATE_CONNECTOR, "Connector already requested"); m_resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_DUPLICATE_CONNECTOR, "Connector already requested");
return; return;
} }
// TODO: when (if) we add multi, make sure this is from the correct device. // TODO: when (if) we add multi, make sure this is from the correct device.
requested.emplace_back(CONNECTOR); m_requested.emplace_back(CONNECTOR);
}); });
resource->setSubmit([this](CWpDrmLeaseRequestV1* r, uint32_t id) { m_resource->setSubmit([this](CWpDrmLeaseRequestV1* r, uint32_t id) {
if (requested.empty()) { if (m_requested.empty()) {
resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_EMPTY_LEASE, "No connectors added"); m_resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_EMPTY_LEASE, "No connectors added");
return; return;
} }
auto RESOURCE = makeShared<CDRMLeaseResource>(makeShared<CWpDrmLeaseV1>(resource->client(), resource->version(), id), self.lock()); auto RESOURCE = makeShared<CDRMLeaseResource>(makeShared<CWpDrmLeaseV1>(m_resource->client(), m_resource->version(), id), m_self.lock());
if UNLIKELY (!RESOURCE) { if UNLIKELY (!RESOURCE) {
resource->noMemory(); m_resource->noMemory();
return; return;
} }
PROTO::lease->m_vLeases.emplace_back(RESOURCE); PROTO::lease->m_leases.emplace_back(RESOURCE);
// per protcol, after submit, this is dead. // per protcol, after submit, this is dead.
PROTO::lease->destroyResource(this); PROTO::lease->destroyResource(this);
@ -126,111 +126,111 @@ CDRMLeaseRequestResource::CDRMLeaseRequestResource(SP<CWpDrmLeaseRequestV1> reso
} }
bool CDRMLeaseRequestResource::good() { bool CDRMLeaseRequestResource::good() {
return resource->resource(); return m_resource->resource();
} }
SP<CDRMLeaseConnectorResource> CDRMLeaseConnectorResource::fromResource(wl_resource* res) { SP<CDRMLeaseConnectorResource> CDRMLeaseConnectorResource::fromResource(wl_resource* res) {
auto data = (CDRMLeaseConnectorResource*)(((CWpDrmLeaseConnectorV1*)wl_resource_get_user_data(res))->data()); auto data = (CDRMLeaseConnectorResource*)(((CWpDrmLeaseConnectorV1*)wl_resource_get_user_data(res))->data());
return data ? data->self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
CDRMLeaseConnectorResource::CDRMLeaseConnectorResource(SP<CWpDrmLeaseConnectorV1> resource_, PHLMONITOR monitor_) : monitor(monitor_), resource(resource_) { CDRMLeaseConnectorResource::CDRMLeaseConnectorResource(SP<CWpDrmLeaseConnectorV1> resource_, PHLMONITOR monitor_) : m_monitor(monitor_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); }); m_resource->setOnDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); });
resource->setDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); }); m_resource->setDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); });
resource->setData(this); m_resource->setData(this);
listeners.destroyMonitor = monitor->m_events.destroy.registerListener([this](std::any d) { m_listeners.destroyMonitor = m_monitor->m_events.destroy.registerListener([this](std::any d) {
resource->sendWithdrawn(); m_resource->sendWithdrawn();
dead = true; m_dead = true;
}); });
} }
bool CDRMLeaseConnectorResource::good() { bool CDRMLeaseConnectorResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CDRMLeaseConnectorResource::sendData() { void CDRMLeaseConnectorResource::sendData() {
resource->sendName(monitor->m_name.c_str()); m_resource->sendName(m_monitor->m_name.c_str());
resource->sendDescription(monitor->m_description.c_str()); m_resource->sendDescription(m_monitor->m_description.c_str());
auto AQDRMOutput = (Aquamarine::CDRMOutput*)monitor->m_output.get(); auto AQDRMOutput = (Aquamarine::CDRMOutput*)m_monitor->m_output.get();
resource->sendConnectorId(AQDRMOutput->getConnectorID()); m_resource->sendConnectorId(AQDRMOutput->getConnectorID());
resource->sendDone(); m_resource->sendDone();
} }
CDRMLeaseDeviceResource::CDRMLeaseDeviceResource(SP<CWpDrmLeaseDeviceV1> resource_) : resource(resource_) { CDRMLeaseDeviceResource::CDRMLeaseDeviceResource(SP<CWpDrmLeaseDeviceV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); }); m_resource->setOnDestroy([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); });
resource->setRelease([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); }); m_resource->setRelease([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); });
resource->setCreateLeaseRequest([this](CWpDrmLeaseDeviceV1* r, uint32_t id) { m_resource->setCreateLeaseRequest([this](CWpDrmLeaseDeviceV1* r, uint32_t id) {
auto RESOURCE = makeShared<CDRMLeaseRequestResource>(makeShared<CWpDrmLeaseRequestV1>(resource->client(), resource->version(), id)); auto RESOURCE = makeShared<CDRMLeaseRequestResource>(makeShared<CWpDrmLeaseRequestV1>(m_resource->client(), m_resource->version(), id));
if UNLIKELY (!RESOURCE) { if UNLIKELY (!RESOURCE) {
resource->noMemory(); m_resource->noMemory();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
PROTO::lease->m_vRequests.emplace_back(RESOURCE); PROTO::lease->m_requests.emplace_back(RESOURCE);
LOGM(LOG, "New lease request {}", id); LOGM(LOG, "New lease request {}", id);
RESOURCE->parent = self; RESOURCE->m_parent = m_self;
}); });
CFileDescriptor fd{((Aquamarine::CDRMBackend*)PROTO::lease->primaryDevice->backend.get())->getNonMasterFD()}; CFileDescriptor fd{((Aquamarine::CDRMBackend*)PROTO::lease->m_primaryDevice->m_backend.get())->getNonMasterFD()};
if (!fd.isValid()) { if (!fd.isValid()) {
LOGM(ERR, "Failed to dup fd in lease"); LOGM(ERR, "Failed to dup fd in lease");
return; return;
} }
LOGM(LOG, "Sending DRMFD {} to new lease device", fd.get()); LOGM(LOG, "Sending DRMFD {} to new lease device", fd.get());
resource->sendDrmFd(fd.get()); m_resource->sendDrmFd(fd.get());
for (auto const& m : PROTO::lease->primaryDevice->offeredOutputs) { for (auto const& m : PROTO::lease->m_primaryDevice->m_offeredOutputs) {
if (m) if (m)
sendConnector(m.lock()); sendConnector(m.lock());
} }
resource->sendDone(); m_resource->sendDone();
} }
bool CDRMLeaseDeviceResource::good() { bool CDRMLeaseDeviceResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CDRMLeaseDeviceResource::sendConnector(PHLMONITOR monitor) { void CDRMLeaseDeviceResource::sendConnector(PHLMONITOR monitor) {
if (std::find_if(connectorsSent.begin(), connectorsSent.end(), [monitor](const auto& e) { return e && !e->dead && e->monitor == monitor; }) != connectorsSent.end()) if (std::find_if(m_connectorsSent.begin(), m_connectorsSent.end(), [monitor](const auto& e) { return e && !e->m_dead && e->m_monitor == monitor; }) != m_connectorsSent.end())
return; return;
auto RESOURCE = makeShared<CDRMLeaseConnectorResource>(makeShared<CWpDrmLeaseConnectorV1>(resource->client(), resource->version(), 0), monitor); auto RESOURCE = makeShared<CDRMLeaseConnectorResource>(makeShared<CWpDrmLeaseConnectorV1>(m_resource->client(), m_resource->version(), 0), monitor);
if UNLIKELY (!RESOURCE) { if UNLIKELY (!RESOURCE) {
resource->noMemory(); m_resource->noMemory();
return; return;
} }
RESOURCE->parent = self; RESOURCE->m_parent = m_self;
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
LOGM(LOG, "Sending new connector {}", monitor->m_name); LOGM(LOG, "Sending new connector {}", monitor->m_name);
connectorsSent.emplace_back(RESOURCE); m_connectorsSent.emplace_back(RESOURCE);
PROTO::lease->m_vConnectors.emplace_back(RESOURCE); PROTO::lease->m_connectors.emplace_back(RESOURCE);
resource->sendConnector(RESOURCE->resource.get()); m_resource->sendConnector(RESOURCE->m_resource.get());
RESOURCE->sendData(); RESOURCE->sendData();
} }
CDRMLeaseDevice::CDRMLeaseDevice(SP<Aquamarine::CDRMBackend> drmBackend) : backend(drmBackend) { CDRMLeaseDevice::CDRMLeaseDevice(SP<Aquamarine::CDRMBackend> drmBackend) : m_backend(drmBackend) {
auto drm = (Aquamarine::CDRMBackend*)drmBackend.get(); auto drm = (Aquamarine::CDRMBackend*)drmBackend.get();
CFileDescriptor fd{drm->getNonMasterFD()}; CFileDescriptor fd{drm->getNonMasterFD()};
@ -240,8 +240,8 @@ CDRMLeaseDevice::CDRMLeaseDevice(SP<Aquamarine::CDRMBackend> drmBackend) : backe
return; return;
} }
success = true; m_success = true;
name = drm->gpuName; m_name = drm->gpuName;
} }
CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -251,64 +251,64 @@ CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver,
auto drm = ((Aquamarine::CDRMBackend*)b.get())->self.lock(); auto drm = ((Aquamarine::CDRMBackend*)b.get())->self.lock();
primaryDevice = makeShared<CDRMLeaseDevice>(drm); m_primaryDevice = makeShared<CDRMLeaseDevice>(drm);
if (primaryDevice->success) if (m_primaryDevice->m_success)
break; break;
} }
if (!primaryDevice || !primaryDevice->success) if (!m_primaryDevice || !m_primaryDevice->m_success)
g_pEventLoopManager->doLater([]() { PROTO::lease.reset(); }); g_pEventLoopManager->doLater([]() { PROTO::lease.reset(); });
} }
void CDRMLeaseProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CDRMLeaseProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CDRMLeaseDeviceResource>(makeShared<CWpDrmLeaseDeviceV1>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CDRMLeaseDeviceResource>(makeShared<CWpDrmLeaseDeviceV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
} }
void CDRMLeaseProtocol::destroyResource(CDRMLeaseDeviceResource* resource) { void CDRMLeaseProtocol::destroyResource(CDRMLeaseDeviceResource* resource) {
std::erase_if(m_vManagers, [resource](const auto& e) { return e.get() == resource; }); std::erase_if(m_managers, [resource](const auto& e) { return e.get() == resource; });
} }
void CDRMLeaseProtocol::destroyResource(CDRMLeaseConnectorResource* resource) { void CDRMLeaseProtocol::destroyResource(CDRMLeaseConnectorResource* resource) {
for (const auto& m : m_vManagers) { for (const auto& m : m_managers) {
std::erase_if(m->connectorsSent, [resource](const auto& e) { return e.expired() || e->dead || e.get() == resource; }); std::erase_if(m->m_connectorsSent, [resource](const auto& e) { return e.expired() || e->m_dead || e.get() == resource; });
} }
std::erase_if(m_vConnectors, [resource](const auto& e) { return e.get() == resource; }); std::erase_if(m_connectors, [resource](const auto& e) { return e.get() == resource; });
} }
void CDRMLeaseProtocol::destroyResource(CDRMLeaseRequestResource* resource) { void CDRMLeaseProtocol::destroyResource(CDRMLeaseRequestResource* resource) {
std::erase_if(m_vRequests, [resource](const auto& e) { return e.get() == resource; }); std::erase_if(m_requests, [resource](const auto& e) { return e.get() == resource; });
} }
void CDRMLeaseProtocol::destroyResource(CDRMLeaseResource* resource) { void CDRMLeaseProtocol::destroyResource(CDRMLeaseResource* resource) {
std::erase_if(m_vLeases, [resource](const auto& e) { return e.get() == resource; }); std::erase_if(m_leases, [resource](const auto& e) { return e.get() == resource; });
} }
void CDRMLeaseProtocol::offer(PHLMONITOR monitor) { void CDRMLeaseProtocol::offer(PHLMONITOR monitor) {
std::erase_if(primaryDevice->offeredOutputs, [](const auto& e) { return e.expired(); }); std::erase_if(m_primaryDevice->m_offeredOutputs, [](const auto& e) { return e.expired(); });
if (std::find(primaryDevice->offeredOutputs.begin(), primaryDevice->offeredOutputs.end(), monitor) != primaryDevice->offeredOutputs.end()) if (std::find(m_primaryDevice->m_offeredOutputs.begin(), m_primaryDevice->m_offeredOutputs.end(), monitor) != m_primaryDevice->m_offeredOutputs.end())
return; return;
if (monitor->m_output->getBackend()->type() != Aquamarine::AQ_BACKEND_DRM) if (monitor->m_output->getBackend()->type() != Aquamarine::AQ_BACKEND_DRM)
return; return;
if (monitor->m_output->getBackend() != primaryDevice->backend) { if (monitor->m_output->getBackend() != m_primaryDevice->m_backend) {
LOGM(ERR, "Monitor {} cannot be leased: primaryDevice lease is for a different device", monitor->m_name); LOGM(ERR, "Monitor {} cannot be leased: primaryDevice lease is for a different device", monitor->m_name);
return; return;
} }
primaryDevice->offeredOutputs.emplace_back(monitor); m_primaryDevice->m_offeredOutputs.emplace_back(monitor);
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->sendConnector(monitor); m->sendConnector(monitor);
m->resource->sendDone(); m->m_resource->sendDone();
} }
} }

View File

@ -26,18 +26,16 @@ class CDRMLeaseResource {
bool good(); bool good();
WP<CDRMLeaseDeviceResource> parent; WP<CDRMLeaseDeviceResource> m_parent;
std::vector<WP<CDRMLeaseConnectorResource>> requested; std::vector<WP<CDRMLeaseConnectorResource>> m_requested;
SP<Aquamarine::CDRMLease> lease; SP<Aquamarine::CDRMLease> m_lease;
int leaseFD = -1;
struct { struct {
CHyprSignalListener destroyLease; CHyprSignalListener destroyLease;
} listeners; } m_listeners;
private: private:
SP<CWpDrmLeaseV1> resource; SP<CWpDrmLeaseV1> m_resource;
}; };
class CDRMLeaseRequestResource { class CDRMLeaseRequestResource {
@ -46,12 +44,12 @@ class CDRMLeaseRequestResource {
bool good(); bool good();
WP<CDRMLeaseDeviceResource> parent; WP<CDRMLeaseDeviceResource> m_parent;
WP<CDRMLeaseRequestResource> self; WP<CDRMLeaseRequestResource> m_self;
std::vector<WP<CDRMLeaseConnectorResource>> requested; std::vector<WP<CDRMLeaseConnectorResource>> m_requested;
private: private:
SP<CWpDrmLeaseRequestV1> resource; SP<CWpDrmLeaseRequestV1> m_resource;
}; };
class CDRMLeaseConnectorResource { class CDRMLeaseConnectorResource {
@ -62,17 +60,17 @@ class CDRMLeaseConnectorResource {
bool good(); bool good();
void sendData(); void sendData();
WP<CDRMLeaseConnectorResource> self; WP<CDRMLeaseConnectorResource> m_self;
WP<CDRMLeaseDeviceResource> parent; WP<CDRMLeaseDeviceResource> m_parent;
PHLMONITORREF monitor; PHLMONITORREF m_monitor;
bool dead = false; bool m_dead = false;
private: private:
SP<CWpDrmLeaseConnectorV1> resource; SP<CWpDrmLeaseConnectorV1> m_resource;
struct { struct {
CHyprSignalListener destroyMonitor; CHyprSignalListener destroyMonitor;
} listeners; } m_listeners;
friend class CDRMLeaseDeviceResource; friend class CDRMLeaseDeviceResource;
}; };
@ -84,12 +82,12 @@ class CDRMLeaseDeviceResource {
bool good(); bool good();
void sendConnector(PHLMONITOR monitor); void sendConnector(PHLMONITOR monitor);
std::vector<WP<CDRMLeaseConnectorResource>> connectorsSent; std::vector<WP<CDRMLeaseConnectorResource>> m_connectorsSent;
WP<CDRMLeaseDeviceResource> self; WP<CDRMLeaseDeviceResource> m_self;
private: private:
SP<CWpDrmLeaseDeviceV1> resource; SP<CWpDrmLeaseDeviceV1> m_resource;
friend class CDRMLeaseProtocol; friend class CDRMLeaseProtocol;
}; };
@ -98,11 +96,11 @@ class CDRMLeaseDevice {
public: public:
CDRMLeaseDevice(SP<Aquamarine::CDRMBackend> drmBackend); CDRMLeaseDevice(SP<Aquamarine::CDRMBackend> drmBackend);
std::string name = ""; std::string m_name = "";
bool success = false; bool m_success = false;
SP<Aquamarine::CDRMBackend> backend; SP<Aquamarine::CDRMBackend> m_backend;
std::vector<PHLMONITORREF> offeredOutputs; std::vector<PHLMONITORREF> m_offeredOutputs;
}; };
class CDRMLeaseProtocol : public IWaylandProtocol { class CDRMLeaseProtocol : public IWaylandProtocol {
@ -120,12 +118,12 @@ class CDRMLeaseProtocol : public IWaylandProtocol {
void destroyResource(CDRMLeaseResource* resource); void destroyResource(CDRMLeaseResource* resource);
// //
std::vector<SP<CDRMLeaseDeviceResource>> m_vManagers; std::vector<SP<CDRMLeaseDeviceResource>> m_managers;
std::vector<SP<CDRMLeaseConnectorResource>> m_vConnectors; std::vector<SP<CDRMLeaseConnectorResource>> m_connectors;
std::vector<SP<CDRMLeaseRequestResource>> m_vRequests; std::vector<SP<CDRMLeaseRequestResource>> m_requests;
std::vector<SP<CDRMLeaseResource>> m_vLeases; std::vector<SP<CDRMLeaseResource>> m_leases;
SP<CDRMLeaseDevice> primaryDevice; SP<CDRMLeaseDevice> m_primaryDevice;
friend class CDRMLeaseDeviceResource; friend class CDRMLeaseDeviceResource;
friend class CDRMLeaseConnectorResource; friend class CDRMLeaseConnectorResource;

View File

@ -45,95 +45,96 @@ void CDRMSyncPointState::signal() {
} }
CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurfaceV1>&& resource_, SP<CWLSurfaceResource> surface_) : CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurfaceV1>&& resource_, SP<CWLSurfaceResource> surface_) :
surface(surface_), resource(std::move(resource_)) { m_surface(surface_), m_resource(std::move(resource_)) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setData(this); m_resource->setData(this);
resource->setOnDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); }); m_resource->setOnDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); });
resource->setDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); }); m_resource->setDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); });
resource->setSetAcquirePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) { m_resource->setSetAcquirePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) {
if (!surface) { if (!m_surface) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone");
return; return;
} }
auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_);
pendingAcquire = {timeline->timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; m_pendingAcquire = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo};
}); });
resource->setSetReleasePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) { m_resource->setSetReleasePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) {
if (!surface) { if (!m_surface) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone");
return; return;
} }
auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_);
pendingRelease = {timeline->timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; m_pendingRelease = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo};
}); });
listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) { m_listeners.surfacePrecommit = m_surface->m_events.precommit.registerListener([this](std::any d) {
if (!surface->m_pending.updated.buffer || !surface->m_pending.buffer) { if (!m_surface->m_pending.updated.buffer || !m_surface->m_pending.buffer) {
if (pendingAcquire.timeline() || pendingRelease.timeline()) { if (m_pendingAcquire.timeline() || m_pendingRelease.timeline()) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER, "Missing buffer"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER, "Missing buffer");
surface->m_pending.rejected = true; m_surface->m_pending.rejected = true;
} }
return; return;
} }
if (!pendingAcquire.timeline()) { if (!m_pendingAcquire.timeline()) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_ACQUIRE_POINT, "Missing acquire timeline"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_ACQUIRE_POINT, "Missing acquire timeline");
surface->m_pending.rejected = true; m_surface->m_pending.rejected = true;
return; return;
} }
if (!pendingRelease.timeline()) { if (!m_pendingRelease.timeline()) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_RELEASE_POINT, "Missing release timeline"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_RELEASE_POINT, "Missing release timeline");
surface->m_pending.rejected = true; m_surface->m_pending.rejected = true;
return; return;
} }
if (pendingAcquire.timeline() == pendingRelease.timeline() && pendingAcquire.point() >= pendingRelease.point()) { if (m_pendingAcquire.timeline() == m_pendingRelease.timeline() && m_pendingAcquire.point() >= m_pendingRelease.point()) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_CONFLICTING_POINTS, "Acquire and release points are on the same timeline, and acquire >= release"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_CONFLICTING_POINTS, "Acquire and release points are on the same timeline, and acquire >= release");
surface->m_pending.rejected = true; m_surface->m_pending.rejected = true;
return; return;
} }
surface->m_pending.updated.acquire = true; m_surface->m_pending.updated.acquire = true;
surface->m_pending.acquire = pendingAcquire; m_surface->m_pending.acquire = m_pendingAcquire;
pendingAcquire = {}; m_pendingAcquire = {};
surface->m_pending.buffer->addReleasePoint(pendingRelease); m_surface->m_pending.buffer->addReleasePoint(m_pendingRelease);
pendingRelease = {}; m_pendingRelease = {};
}); });
} }
bool CDRMSyncobjSurfaceResource::good() { bool CDRMSyncobjSurfaceResource::good() {
return resource->resource(); return m_resource->resource();
} }
CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(UP<CWpLinuxDrmSyncobjTimelineV1>&& resource_, CFileDescriptor&& fd_) : fd(std::move(fd_)), resource(std::move(resource_)) { CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(UP<CWpLinuxDrmSyncobjTimelineV1>&& resource_, CFileDescriptor&& fd_) :
m_fd(std::move(fd_)), m_resource(std::move(resource_)) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setData(this); m_resource->setData(this);
resource->setOnDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); }); m_resource->setOnDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); });
resource->setDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); }); m_resource->setDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); });
timeline = CSyncTimeline::create(PROTO::sync->drmFD, std::move(fd)); m_timeline = CSyncTimeline::create(PROTO::sync->m_drmFD, std::move(m_fd));
if (!timeline) { if (!m_timeline) {
resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_INVALID_TIMELINE, "Timeline failed importing"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_INVALID_TIMELINE, "Timeline failed importing");
return; return;
} }
} }
WP<CDRMSyncobjTimelineResource> CDRMSyncobjTimelineResource::fromResource(wl_resource* res) { WP<CDRMSyncobjTimelineResource> CDRMSyncobjTimelineResource::fromResource(wl_resource* res) {
for (const auto& r : PROTO::sync->m_vTimelines) { for (const auto& r : PROTO::sync->m_timelines) {
if (r && r->resource && r->resource->resource() == res) if (r && r->m_resource && r->m_resource->resource() == res)
return r; return r;
} }
@ -141,38 +142,38 @@ WP<CDRMSyncobjTimelineResource> CDRMSyncobjTimelineResource::fromResource(wl_res
} }
bool CDRMSyncobjTimelineResource::good() { bool CDRMSyncobjTimelineResource::good() {
return resource->resource(); return m_resource->resource();
} }
CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjManagerV1>&& resource_) : resource(std::move(resource_)) { CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjManagerV1>&& resource_) : m_resource(std::move(resource_)) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); }); m_resource->setOnDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); });
resource->setDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); }); m_resource->setDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); });
resource->setGetSurface([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, wl_resource* surf) { m_resource->setGetSurface([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, wl_resource* surf) {
if UNLIKELY (!surf) { if UNLIKELY (!surf) {
resource->error(-1, "Invalid surface"); m_resource->error(-1, "Invalid surface");
return; return;
} }
auto SURF = CWLSurfaceResource::fromResource(surf); auto SURF = CWLSurfaceResource::fromResource(surf);
if UNLIKELY (!SURF) { if UNLIKELY (!SURF) {
resource->error(-1, "Invalid surface (2)"); m_resource->error(-1, "Invalid surface (2)");
return; return;
} }
if UNLIKELY (SURF->m_syncobj) { if UNLIKELY (SURF->m_syncobj) {
resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS, "Surface already has a syncobj attached"); m_resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS, "Surface already has a syncobj attached");
return; return;
} }
const auto& RESOURCE = PROTO::sync->m_vSurfaces.emplace_back( const auto& RESOURCE = PROTO::sync->m_surfaces.emplace_back(
makeUnique<CDRMSyncobjSurfaceResource>(makeUnique<CWpLinuxDrmSyncobjSurfaceV1>(resource->client(), resource->version(), id), SURF)); makeUnique<CDRMSyncobjSurfaceResource>(makeUnique<CWpLinuxDrmSyncobjSurfaceV1>(m_resource->client(), m_resource->version(), id), SURF));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
resource->noMemory(); m_resource->noMemory();
PROTO::sync->m_vSurfaces.pop_back(); PROTO::sync->m_surfaces.pop_back();
return; return;
} }
@ -181,12 +182,12 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjMana
LOGM(LOG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get()); LOGM(LOG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get());
}); });
resource->setImportTimeline([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, int32_t fd) { m_resource->setImportTimeline([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, int32_t fd) {
const auto& RESOURCE = PROTO::sync->m_vTimelines.emplace_back( const auto& RESOURCE = PROTO::sync->m_timelines.emplace_back(
makeUnique<CDRMSyncobjTimelineResource>(makeUnique<CWpLinuxDrmSyncobjTimelineV1>(resource->client(), resource->version(), id), CFileDescriptor{fd})); makeUnique<CDRMSyncobjTimelineResource>(makeUnique<CWpLinuxDrmSyncobjTimelineV1>(m_resource->client(), m_resource->version(), id), CFileDescriptor{fd}));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
resource->noMemory(); m_resource->noMemory();
PROTO::sync->m_vTimelines.pop_back(); PROTO::sync->m_timelines.pop_back();
return; return;
} }
@ -195,29 +196,30 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjMana
} }
bool CDRMSyncobjManagerResource::good() { bool CDRMSyncobjManagerResource::good() {
return resource->resource(); return m_resource->resource();
} }
CDRMSyncobjProtocol::CDRMSyncobjProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name), drmFD(g_pCompositor->m_drmFD) {} CDRMSyncobjProtocol::CDRMSyncobjProtocol(const wl_interface* iface, const int& ver, const std::string& name) :
IWaylandProtocol(iface, ver, name), m_drmFD(g_pCompositor->m_drmFD) {}
void CDRMSyncobjProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CDRMSyncobjProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto& RESOURCE = m_vManagers.emplace_back(makeUnique<CDRMSyncobjManagerResource>(makeUnique<CWpLinuxDrmSyncobjManagerV1>(client, ver, id))); const auto& RESOURCE = m_managers.emplace_back(makeUnique<CDRMSyncobjManagerResource>(makeUnique<CWpLinuxDrmSyncobjManagerV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjManagerResource* resource) { void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjManagerResource* resource) {
std::erase_if(m_vManagers, [resource](const auto& e) { return e.get() == resource; }); std::erase_if(m_managers, [resource](const auto& e) { return e.get() == resource; });
} }
void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjTimelineResource* resource) { void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjTimelineResource* resource) {
std::erase_if(m_vTimelines, [resource](const auto& e) { return e.get() == resource; }); std::erase_if(m_timelines, [resource](const auto& e) { return e.get() == resource; });
} }
void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjSurfaceResource* resource) { void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjSurfaceResource* resource) {
std::erase_if(m_vSurfaces, [resource](const auto& e) { return e.get() == resource; }); std::erase_if(m_surfaces, [resource](const auto& e) { return e.get() == resource; });
} }

View File

@ -43,15 +43,15 @@ class CDRMSyncobjSurfaceResource {
bool good(); bool good();
private: private:
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
UP<CWpLinuxDrmSyncobjSurfaceV1> resource; UP<CWpLinuxDrmSyncobjSurfaceV1> m_resource;
CDRMSyncPointState pendingAcquire; CDRMSyncPointState m_pendingAcquire;
CDRMSyncPointState pendingRelease; CDRMSyncPointState m_pendingRelease;
struct { struct {
CHyprSignalListener surfacePrecommit; CHyprSignalListener surfacePrecommit;
} listeners; } m_listeners;
}; };
class CDRMSyncobjTimelineResource { class CDRMSyncobjTimelineResource {
@ -62,11 +62,11 @@ class CDRMSyncobjTimelineResource {
bool good(); bool good();
Hyprutils::OS::CFileDescriptor fd; Hyprutils::OS::CFileDescriptor m_fd;
SP<CSyncTimeline> timeline; SP<CSyncTimeline> m_timeline;
private: private:
UP<CWpLinuxDrmSyncobjTimelineV1> resource; UP<CWpLinuxDrmSyncobjTimelineV1> m_resource;
}; };
class CDRMSyncobjManagerResource { class CDRMSyncobjManagerResource {
@ -77,7 +77,7 @@ class CDRMSyncobjManagerResource {
bool good(); bool good();
private: private:
UP<CWpLinuxDrmSyncobjManagerV1> resource; UP<CWpLinuxDrmSyncobjManagerV1> m_resource;
}; };
class CDRMSyncobjProtocol : public IWaylandProtocol { class CDRMSyncobjProtocol : public IWaylandProtocol {
@ -93,12 +93,12 @@ class CDRMSyncobjProtocol : public IWaylandProtocol {
void destroyResource(CDRMSyncobjSurfaceResource* resource); void destroyResource(CDRMSyncobjSurfaceResource* resource);
// //
std::vector<UP<CDRMSyncobjManagerResource>> m_vManagers; std::vector<UP<CDRMSyncobjManagerResource>> m_managers;
std::vector<UP<CDRMSyncobjTimelineResource>> m_vTimelines; std::vector<UP<CDRMSyncobjTimelineResource>> m_timelines;
std::vector<UP<CDRMSyncobjSurfaceResource>> m_vSurfaces; std::vector<UP<CDRMSyncobjSurfaceResource>> m_surfaces;
// //
int drmFD = -1; int m_drmFD = -1;
friend class CDRMSyncobjManagerResource; friend class CDRMSyncobjManagerResource;
friend class CDRMSyncobjTimelineResource; friend class CDRMSyncobjTimelineResource;

View File

@ -4,60 +4,60 @@
#include "core/Seat.hpp" #include "core/Seat.hpp"
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
CWLRDataOffer::CWLRDataOffer(SP<CZwlrDataControlOfferV1> resource_, SP<IDataSource> source_) : source(source_), resource(resource_) { CWLRDataOffer::CWLRDataOffer(SP<CZwlrDataControlOfferV1> resource_, SP<IDataSource> source_) : m_source(source_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); }); m_resource->setDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); });
resource->setOnDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); }); m_resource->setOnDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); });
resource->setReceive([this](CZwlrDataControlOfferV1* r, const char* mime, int32_t fd) { m_resource->setReceive([this](CZwlrDataControlOfferV1* r, const char* mime, int32_t fd) {
CFileDescriptor sendFd{fd}; CFileDescriptor sendFd{fd};
if (!source) { if (!m_source) {
LOGM(WARN, "Possible bug: Receive on an offer w/o a source"); LOGM(WARN, "Possible bug: Receive on an offer w/o a source");
return; return;
} }
if (dead) { if (m_dead) {
LOGM(WARN, "Possible bug: Receive on an offer that's dead"); LOGM(WARN, "Possible bug: Receive on an offer that's dead");
return; return;
} }
LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)source.get()); LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get());
source->send(mime, std::move(sendFd)); m_source->send(mime, std::move(sendFd));
}); });
} }
bool CWLRDataOffer::good() { bool CWLRDataOffer::good() {
return resource->resource(); return m_resource->resource();
} }
void CWLRDataOffer::sendData() { void CWLRDataOffer::sendData() {
if UNLIKELY (!source) if UNLIKELY (!m_source)
return; return;
for (auto const& m : source->mimes()) { for (auto const& m : m_source->mimes()) {
resource->sendOffer(m.c_str()); m_resource->sendOffer(m.c_str());
} }
} }
CWLRDataSource::CWLRDataSource(SP<CZwlrDataControlSourceV1> resource_, SP<CWLRDataDevice> device_) : device(device_), resource(resource_) { CWLRDataSource::CWLRDataSource(SP<CZwlrDataControlSourceV1> resource_, SP<CWLRDataDevice> device_) : m_device(device_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setData(this); m_resource->setData(this);
resource->setDestroy([this](CZwlrDataControlSourceV1* r) { m_resource->setDestroy([this](CZwlrDataControlSourceV1* r) {
m_events.destroy.emit(); m_events.destroy.emit();
PROTO::dataWlr->destroyResource(this); PROTO::dataWlr->destroyResource(this);
}); });
resource->setOnDestroy([this](CZwlrDataControlSourceV1* r) { m_resource->setOnDestroy([this](CZwlrDataControlSourceV1* r) {
m_events.destroy.emit(); m_events.destroy.emit();
PROTO::dataWlr->destroyResource(this); PROTO::dataWlr->destroyResource(this);
}); });
resource->setOffer([this](CZwlrDataControlSourceV1* r, const char* mime) { mimeTypes.emplace_back(mime); }); m_resource->setOffer([this](CZwlrDataControlSourceV1* r, const char* mime) { m_mimeTypes.emplace_back(mime); });
} }
CWLRDataSource::~CWLRDataSource() { CWLRDataSource::~CWLRDataSource() {
@ -66,51 +66,51 @@ CWLRDataSource::~CWLRDataSource() {
SP<CWLRDataSource> CWLRDataSource::fromResource(wl_resource* res) { SP<CWLRDataSource> CWLRDataSource::fromResource(wl_resource* res) {
auto data = (CWLRDataSource*)(((CZwlrDataControlSourceV1*)wl_resource_get_user_data(res))->data()); auto data = (CWLRDataSource*)(((CZwlrDataControlSourceV1*)wl_resource_get_user_data(res))->data());
return data ? data->self.lock() : nullptr; return data ? data->m_self.lock() : nullptr;
} }
bool CWLRDataSource::good() { bool CWLRDataSource::good() {
return resource->resource(); return m_resource->resource();
} }
std::vector<std::string> CWLRDataSource::mimes() { std::vector<std::string> CWLRDataSource::mimes() {
return mimeTypes; return m_mimeTypes;
} }
void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) { void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) {
if (std::find(mimeTypes.begin(), mimeTypes.end(), mime) == mimeTypes.end()) { if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAskSend with non-existent mime"); LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAskSend with non-existent mime");
return; return;
} }
resource->sendSend(mime.c_str(), fd.get()); m_resource->sendSend(mime.c_str(), fd.get());
} }
void CWLRDataSource::accepted(const std::string& mime) { void CWLRDataSource::accepted(const std::string& mime) {
if (std::find(mimeTypes.begin(), mimeTypes.end(), mime) == mimeTypes.end()) if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end())
LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAccepted with non-existent mime"); LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAccepted with non-existent mime");
// wlr has no accepted // wlr has no accepted
} }
void CWLRDataSource::cancelled() { void CWLRDataSource::cancelled() {
resource->sendCancelled(); m_resource->sendCancelled();
} }
void CWLRDataSource::error(uint32_t code, const std::string& msg) { void CWLRDataSource::error(uint32_t code, const std::string& msg) {
resource->error(code, msg); m_resource->error(code, msg);
} }
CWLRDataDevice::CWLRDataDevice(SP<CZwlrDataControlDeviceV1> resource_) : resource(resource_) { CWLRDataDevice::CWLRDataDevice(SP<CZwlrDataControlDeviceV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = resource->client(); m_client = m_resource->client();
resource->setDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); }); m_resource->setDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); });
resource->setOnDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); }); m_resource->setOnDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); });
resource->setSetSelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { m_resource->setSetSelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) {
auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{}; auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{};
if (!source) { if (!source) {
LOGM(LOG, "wlr reset selection received"); LOGM(LOG, "wlr reset selection received");
@ -127,7 +127,7 @@ CWLRDataDevice::CWLRDataDevice(SP<CZwlrDataControlDeviceV1> resource_) : resourc
g_pSeatManager->setCurrentSelection(source); g_pSeatManager->setCurrentSelection(source);
}); });
resource->setSetPrimarySelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { m_resource->setSetPrimarySelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) {
auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{}; auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer<CWLRDataSource>{};
if (!source) { if (!source) {
LOGM(LOG, "wlr reset primary selection received"); LOGM(LOG, "wlr reset primary selection received");
@ -146,11 +146,11 @@ CWLRDataDevice::CWLRDataDevice(SP<CZwlrDataControlDeviceV1> resource_) : resourc
} }
bool CWLRDataDevice::good() { bool CWLRDataDevice::good() {
return resource->resource(); return m_resource->resource();
} }
wl_client* CWLRDataDevice::client() { wl_client* CWLRDataDevice::client() {
return pClient; return m_client;
} }
void CWLRDataDevice::sendInitialSelections() { void CWLRDataDevice::sendInitialSelections() {
@ -159,40 +159,40 @@ void CWLRDataDevice::sendInitialSelections() {
} }
void CWLRDataDevice::sendDataOffer(SP<CWLRDataOffer> offer) { void CWLRDataDevice::sendDataOffer(SP<CWLRDataOffer> offer) {
resource->sendDataOffer(offer->resource.get()); m_resource->sendDataOffer(offer->m_resource.get());
} }
void CWLRDataDevice::sendSelection(SP<CWLRDataOffer> selection) { void CWLRDataDevice::sendSelection(SP<CWLRDataOffer> selection) {
resource->sendSelection(selection->resource.get()); m_resource->sendSelection(selection->m_resource.get());
} }
void CWLRDataDevice::sendPrimarySelection(SP<CWLRDataOffer> selection) { void CWLRDataDevice::sendPrimarySelection(SP<CWLRDataOffer> selection) {
resource->sendPrimarySelection(selection->resource.get()); m_resource->sendPrimarySelection(selection->m_resource.get());
} }
CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataControlManagerV1> resource_) : resource(resource_) { CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataControlManagerV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); }); m_resource->setDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); });
resource->setOnDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); }); m_resource->setOnDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); });
resource->setGetDataDevice([this](CZwlrDataControlManagerV1* r, uint32_t id, wl_resource* seat) { m_resource->setGetDataDevice([this](CZwlrDataControlManagerV1* r, uint32_t id, wl_resource* seat) {
const auto RESOURCE = PROTO::dataWlr->m_vDevices.emplace_back(makeShared<CWLRDataDevice>(makeShared<CZwlrDataControlDeviceV1>(r->client(), r->version(), id))); const auto RESOURCE = PROTO::dataWlr->m_devices.emplace_back(makeShared<CWLRDataDevice>(makeShared<CZwlrDataControlDeviceV1>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::dataWlr->m_vDevices.pop_back(); PROTO::dataWlr->m_devices.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->self = RESOURCE;
device = RESOURCE; m_device = RESOURCE;
for (auto const& s : sources) { for (auto const& s : m_sources) {
if (!s) if (!s)
continue; continue;
s->device = RESOURCE; s->m_device = RESOURCE;
} }
RESOURCE->sendInitialSelections(); RESOURCE->sendInitialSelections();
@ -200,31 +200,31 @@ CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataContr
LOGM(LOG, "New wlr data device bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(LOG, "New wlr data device bound at {:x}", (uintptr_t)RESOURCE.get());
}); });
resource->setCreateDataSource([this](CZwlrDataControlManagerV1* r, uint32_t id) { m_resource->setCreateDataSource([this](CZwlrDataControlManagerV1* r, uint32_t id) {
std::erase_if(sources, [](const auto& e) { return e.expired(); }); std::erase_if(m_sources, [](const auto& e) { return e.expired(); });
const auto RESOURCE = const auto RESOURCE =
PROTO::dataWlr->m_vSources.emplace_back(makeShared<CWLRDataSource>(makeShared<CZwlrDataControlSourceV1>(r->client(), r->version(), id), device.lock())); PROTO::dataWlr->m_sources.emplace_back(makeShared<CWLRDataSource>(makeShared<CZwlrDataControlSourceV1>(r->client(), r->version(), id), m_device.lock()));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::dataWlr->m_vSources.pop_back(); PROTO::dataWlr->m_sources.pop_back();
return; return;
} }
if (!device) if (!m_device)
LOGM(WARN, "New data source before a device was created"); LOGM(WARN, "New data source before a device was created");
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
sources.emplace_back(RESOURCE); m_sources.emplace_back(RESOURCE);
LOGM(LOG, "New wlr data source bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(LOG, "New wlr data source bound at {:x}", (uintptr_t)RESOURCE.get());
}); });
} }
bool CWLRDataControlManagerResource::good() { bool CWLRDataControlManagerResource::good() {
return resource->resource(); return m_resource->resource();
} }
CDataDeviceWLRProtocol::CDataDeviceWLRProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CDataDeviceWLRProtocol::CDataDeviceWLRProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -232,11 +232,11 @@ CDataDeviceWLRProtocol::CDataDeviceWLRProtocol(const wl_interface* iface, const
} }
void CDataDeviceWLRProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CDataDeviceWLRProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CWLRDataControlManagerResource>(makeShared<CZwlrDataControlManagerV1>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CWLRDataControlManagerResource>(makeShared<CZwlrDataControlManagerV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
@ -244,39 +244,39 @@ void CDataDeviceWLRProtocol::bindManager(wl_client* client, void* data, uint32_t
} }
void CDataDeviceWLRProtocol::destroyResource(CWLRDataControlManagerResource* resource) { void CDataDeviceWLRProtocol::destroyResource(CWLRDataControlManagerResource* resource) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
} }
void CDataDeviceWLRProtocol::destroyResource(CWLRDataSource* resource) { void CDataDeviceWLRProtocol::destroyResource(CWLRDataSource* resource) {
std::erase_if(m_vSources, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_sources, [&](const auto& other) { return other.get() == resource; });
} }
void CDataDeviceWLRProtocol::destroyResource(CWLRDataDevice* resource) { void CDataDeviceWLRProtocol::destroyResource(CWLRDataDevice* resource) {
std::erase_if(m_vDevices, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_devices, [&](const auto& other) { return other.get() == resource; });
} }
void CDataDeviceWLRProtocol::destroyResource(CWLRDataOffer* resource) { void CDataDeviceWLRProtocol::destroyResource(CWLRDataOffer* resource) {
std::erase_if(m_vOffers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_offers, [&](const auto& other) { return other.get() == resource; });
} }
void CDataDeviceWLRProtocol::sendSelectionToDevice(SP<CWLRDataDevice> dev, SP<IDataSource> sel, bool primary) { void CDataDeviceWLRProtocol::sendSelectionToDevice(SP<CWLRDataDevice> dev, SP<IDataSource> sel, bool primary) {
if (!sel) { if (!sel) {
if (primary) if (primary)
dev->resource->sendPrimarySelectionRaw(nullptr); dev->m_resource->sendPrimarySelectionRaw(nullptr);
else else
dev->resource->sendSelectionRaw(nullptr); dev->m_resource->sendSelectionRaw(nullptr);
return; return;
} }
const auto OFFER = m_vOffers.emplace_back(makeShared<CWLRDataOffer>(makeShared<CZwlrDataControlOfferV1>(dev->resource->client(), dev->resource->version(), 0), sel)); const auto OFFER = m_offers.emplace_back(makeShared<CWLRDataOffer>(makeShared<CZwlrDataControlOfferV1>(dev->m_resource->client(), dev->m_resource->version(), 0), sel));
if (!OFFER->good()) { if (!OFFER->good()) {
dev->resource->noMemory(); dev->m_resource->noMemory();
m_vOffers.pop_back(); m_offers.pop_back();
return; return;
} }
OFFER->primary = primary; OFFER->m_primary = primary;
LOGM(LOG, "New {}offer {:x} for data source {:x}", primary ? "primary " : " ", (uintptr_t)OFFER.get(), (uintptr_t)sel.get()); LOGM(LOG, "New {}offer {:x} for data source {:x}", primary ? "primary " : " ", (uintptr_t)OFFER.get(), (uintptr_t)sel.get());
@ -289,18 +289,18 @@ void CDataDeviceWLRProtocol::sendSelectionToDevice(SP<CWLRDataDevice> dev, SP<ID
} }
void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary) { void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary) {
for (auto const& o : m_vOffers) { for (auto const& o : m_offers) {
if (o->source && o->source->hasDnd()) if (o->m_source && o->m_source->hasDnd())
continue; continue;
if (o->primary != primary) if (o->m_primary != primary)
continue; continue;
o->dead = true; o->m_dead = true;
} }
if (!source) { if (!source) {
LOGM(LOG, "resetting {}selection", primary ? "primary " : " "); LOGM(LOG, "resetting {}selection", primary ? "primary " : " ");
for (auto const& d : m_vDevices) { for (auto const& d : m_devices) {
sendSelectionToDevice(d, nullptr, primary); sendSelectionToDevice(d, nullptr, primary);
} }
@ -309,14 +309,14 @@ void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary)
LOGM(LOG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get()); LOGM(LOG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get());
for (auto const& d : m_vDevices) { for (auto const& d : m_devices) {
sendSelectionToDevice(d, source, primary); sendSelectionToDevice(d, source, primary);
} }
} }
SP<CWLRDataDevice> CDataDeviceWLRProtocol::dataDeviceForClient(wl_client* c) { SP<CWLRDataDevice> CDataDeviceWLRProtocol::dataDeviceForClient(wl_client* c) {
auto it = std::find_if(m_vDevices.begin(), m_vDevices.end(), [c](const auto& e) { return e->client() == c; }); auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; });
if (it == m_vDevices.end()) if (it == m_devices.end())
return nullptr; return nullptr;
return *it; return *it;
} }

View File

@ -19,13 +19,13 @@ class CWLRDataOffer {
bool good(); bool good();
void sendData(); void sendData();
bool dead = false; bool m_dead = false;
bool primary = false; bool m_primary = false;
WP<IDataSource> source; WP<IDataSource> m_source;
private: private:
SP<CZwlrDataControlOfferV1> resource; SP<CZwlrDataControlOfferV1> m_resource;
friend class CWLRDataDevice; friend class CWLRDataDevice;
}; };
@ -44,12 +44,12 @@ class CWLRDataSource : public IDataSource {
virtual void cancelled(); virtual void cancelled();
virtual void error(uint32_t code, const std::string& msg); virtual void error(uint32_t code, const std::string& msg);
std::vector<std::string> mimeTypes; std::vector<std::string> m_mimeTypes;
WP<CWLRDataSource> self; WP<CWLRDataSource> m_self;
WP<CWLRDataDevice> device; WP<CWLRDataDevice> m_device;
private: private:
SP<CZwlrDataControlSourceV1> resource; SP<CZwlrDataControlSourceV1> m_resource;
}; };
class CWLRDataDevice { class CWLRDataDevice {
@ -67,8 +67,8 @@ class CWLRDataDevice {
WP<CWLRDataDevice> self; WP<CWLRDataDevice> self;
private: private:
SP<CZwlrDataControlDeviceV1> resource; SP<CZwlrDataControlDeviceV1> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
friend class CDataDeviceWLRProtocol; friend class CDataDeviceWLRProtocol;
}; };
@ -79,11 +79,11 @@ class CWLRDataControlManagerResource {
bool good(); bool good();
WP<CWLRDataDevice> device; WP<CWLRDataDevice> m_device;
std::vector<WP<CWLRDataSource>> sources; std::vector<WP<CWLRDataSource>> m_sources;
private: private:
SP<CZwlrDataControlManagerV1> resource; SP<CZwlrDataControlManagerV1> m_resource;
}; };
class CDataDeviceWLRProtocol : public IWaylandProtocol { class CDataDeviceWLRProtocol : public IWaylandProtocol {
@ -99,10 +99,10 @@ class CDataDeviceWLRProtocol : public IWaylandProtocol {
void destroyResource(CWLRDataOffer* resource); void destroyResource(CWLRDataOffer* resource);
// //
std::vector<SP<CWLRDataControlManagerResource>> m_vManagers; std::vector<SP<CWLRDataControlManagerResource>> m_managers;
std::vector<SP<CWLRDataSource>> m_vSources; std::vector<SP<CWLRDataSource>> m_sources;
std::vector<SP<CWLRDataDevice>> m_vDevices; std::vector<SP<CWLRDataDevice>> m_devices;
std::vector<SP<CWLRDataOffer>> m_vOffers; std::vector<SP<CWLRDataOffer>> m_offers;
// //
void setSelection(SP<IDataSource> source, bool primary); void setSelection(SP<IDataSource> source, bool primary);

View File

@ -8,23 +8,23 @@
#include <wayland-server.h> #include <wayland-server.h>
CFocusGrabSurfaceState::CFocusGrabSurfaceState(CFocusGrab* grab, SP<CWLSurfaceResource> surface) { CFocusGrabSurfaceState::CFocusGrabSurfaceState(CFocusGrab* grab, SP<CWLSurfaceResource> surface) {
listeners.destroy = surface->m_events.destroy.registerListener([=](std::any d) { grab->eraseSurface(surface); }); m_listeners.destroy = surface->m_events.destroy.registerListener([=](std::any d) { grab->eraseSurface(surface); });
} }
CFocusGrab::CFocusGrab(SP<CHyprlandFocusGrabV1> resource_) : resource(resource_) { CFocusGrab::CFocusGrab(SP<CHyprlandFocusGrabV1> resource_) : m_resource(resource_) {
if UNLIKELY (!resource->resource()) if UNLIKELY (!m_resource->resource())
return; return;
grab = makeShared<CSeatGrab>(); m_grab = makeShared<CSeatGrab>();
grab->m_keyboard = true; m_grab->m_keyboard = true;
grab->m_pointer = true; m_grab->m_pointer = true;
grab->setCallback([this]() { finish(true); }); m_grab->setCallback([this]() { finish(true); });
resource->setDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); }); m_resource->setDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); });
resource->setOnDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); }); m_resource->setOnDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); });
resource->setAddSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { addSurface(CWLSurfaceResource::fromResource(surface)); }); m_resource->setAddSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { addSurface(CWLSurfaceResource::fromResource(surface)); });
resource->setRemoveSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { removeSurface(CWLSurfaceResource::fromResource(surface)); }); m_resource->setRemoveSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { removeSurface(CWLSurfaceResource::fromResource(surface)); });
resource->setCommit([this](CHyprlandFocusGrabV1* pMgr) { commit(); }); m_resource->setCommit([this](CHyprlandFocusGrabV1* pMgr) { commit(); });
} }
CFocusGrab::~CFocusGrab() { CFocusGrab::~CFocusGrab() {
@ -32,21 +32,21 @@ CFocusGrab::~CFocusGrab() {
} }
bool CFocusGrab::good() { bool CFocusGrab::good() {
return resource->resource(); return m_resource->resource();
} }
bool CFocusGrab::isSurfaceComitted(SP<CWLSurfaceResource> surface) { bool CFocusGrab::isSurfaceComitted(SP<CWLSurfaceResource> surface) {
auto iter = std::find_if(m_mSurfaces.begin(), m_mSurfaces.end(), [surface](const auto& o) { return o.first == surface; }); auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [surface](const auto& o) { return o.first == surface; });
if (iter == m_mSurfaces.end()) if (iter == m_surfaces.end())
return false; return false;
return iter->second->state == CFocusGrabSurfaceState::Comitted; return iter->second->m_state == CFocusGrabSurfaceState::Comitted;
} }
void CFocusGrab::start() { void CFocusGrab::start() {
if (!m_bGrabActive) { if (!m_grabActive) {
m_bGrabActive = true; m_grabActive = true;
g_pSeatManager->setGrab(grab); g_pSeatManager->setGrab(m_grab);
} }
// Ensure new surfaces are focused if under the mouse when comitted. // Ensure new surfaces are focused if under the mouse when comitted.
@ -55,33 +55,33 @@ void CFocusGrab::start() {
} }
void CFocusGrab::finish(bool sendCleared) { void CFocusGrab::finish(bool sendCleared) {
if (m_bGrabActive) { if (m_grabActive) {
m_bGrabActive = false; m_grabActive = false;
if (g_pSeatManager->m_seatGrab == grab) if (g_pSeatManager->m_seatGrab == m_grab)
g_pSeatManager->setGrab(nullptr); g_pSeatManager->setGrab(nullptr);
grab->clear(); m_grab->clear();
m_mSurfaces.clear(); m_surfaces.clear();
if (sendCleared) if (sendCleared)
resource->sendCleared(); m_resource->sendCleared();
} }
} }
void CFocusGrab::addSurface(SP<CWLSurfaceResource> surface) { void CFocusGrab::addSurface(SP<CWLSurfaceResource> surface) {
auto iter = std::find_if(m_mSurfaces.begin(), m_mSurfaces.end(), [surface](const auto& e) { return e.first == surface; }); auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [surface](const auto& e) { return e.first == surface; });
if (iter == m_mSurfaces.end()) if (iter == m_surfaces.end())
m_mSurfaces.emplace(surface, makeUnique<CFocusGrabSurfaceState>(this, surface)); m_surfaces.emplace(surface, makeUnique<CFocusGrabSurfaceState>(this, surface));
} }
void CFocusGrab::removeSurface(SP<CWLSurfaceResource> surface) { void CFocusGrab::removeSurface(SP<CWLSurfaceResource> surface) {
auto iter = m_mSurfaces.find(surface); auto iter = m_surfaces.find(surface);
if (iter != m_mSurfaces.end()) { if (iter != m_surfaces.end()) {
if (iter->second->state == CFocusGrabSurfaceState::PendingAddition) if (iter->second->m_state == CFocusGrabSurfaceState::PendingAddition)
m_mSurfaces.erase(iter); m_surfaces.erase(iter);
else else
iter->second->state = CFocusGrabSurfaceState::PendingRemoval; iter->second->m_state = CFocusGrabSurfaceState::PendingRemoval;
} }
} }
@ -96,8 +96,8 @@ void CFocusGrab::refocusKeyboard() {
return; return;
SP<CWLSurfaceResource> surface = nullptr; SP<CWLSurfaceResource> surface = nullptr;
for (auto const& [surf, state] : m_mSurfaces) { for (auto const& [surf, state] : m_surfaces) {
if (state->state == CFocusGrabSurfaceState::Comitted) { if (state->m_state == CFocusGrabSurfaceState::Comitted) {
surface = surf.lock(); surface = surf.lock();
break; break;
} }
@ -112,17 +112,17 @@ void CFocusGrab::refocusKeyboard() {
void CFocusGrab::commit(bool removeOnly) { void CFocusGrab::commit(bool removeOnly) {
auto surfacesChanged = false; auto surfacesChanged = false;
auto anyComitted = false; auto anyComitted = false;
for (auto iter = m_mSurfaces.begin(); iter != m_mSurfaces.end();) { for (auto iter = m_surfaces.begin(); iter != m_surfaces.end();) {
switch (iter->second->state) { switch (iter->second->m_state) {
case CFocusGrabSurfaceState::PendingRemoval: case CFocusGrabSurfaceState::PendingRemoval:
grab->remove(iter->first.lock()); m_grab->remove(iter->first.lock());
iter = m_mSurfaces.erase(iter); iter = m_surfaces.erase(iter);
surfacesChanged = true; surfacesChanged = true;
continue; continue;
case CFocusGrabSurfaceState::PendingAddition: case CFocusGrabSurfaceState::PendingAddition:
if (!removeOnly) { if (!removeOnly) {
iter->second->state = CFocusGrabSurfaceState::Comitted; iter->second->m_state = CFocusGrabSurfaceState::Comitted;
grab->add(iter->first.lock()); m_grab->add(iter->first.lock());
surfacesChanged = true; surfacesChanged = true;
anyComitted = true; anyComitted = true;
} }
@ -146,7 +146,7 @@ CFocusGrabProtocol::CFocusGrabProtocol(const wl_interface* iface, const int& ver
} }
void CFocusGrabProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CFocusGrabProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CHyprlandFocusGrabManagerV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CHyprlandFocusGrabManagerV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CHyprlandFocusGrabManagerV1* p) { onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CHyprlandFocusGrabManagerV1* p) { onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CHyprlandFocusGrabManagerV1* p) { onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CHyprlandFocusGrabManagerV1* p) { onManagerResourceDestroy(p->resource()); });
@ -154,19 +154,19 @@ void CFocusGrabProtocol::bindManager(wl_client* client, void* data, uint32_t ver
} }
void CFocusGrabProtocol::onManagerResourceDestroy(wl_resource* res) { void CFocusGrabProtocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
} }
void CFocusGrabProtocol::destroyGrab(CFocusGrab* grab) { void CFocusGrabProtocol::destroyGrab(CFocusGrab* grab) {
std::erase_if(m_vGrabs, [&](const auto& other) { return other.get() == grab; }); std::erase_if(m_grabs, [&](const auto& other) { return other.get() == grab; });
} }
void CFocusGrabProtocol::onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id) { void CFocusGrabProtocol::onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id) {
m_vGrabs.push_back(makeUnique<CFocusGrab>(makeShared<CHyprlandFocusGrabV1>(pMgr->client(), pMgr->version(), id))); m_grabs.push_back(makeUnique<CFocusGrab>(makeShared<CHyprlandFocusGrabV1>(pMgr->client(), pMgr->version(), id)));
const auto RESOURCE = m_vGrabs.back().get(); const auto RESOURCE = m_grabs.back().get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory(); pMgr->noMemory();
m_vGrabs.pop_back(); m_grabs.pop_back();
} }
} }

View File

@ -21,12 +21,12 @@ class CFocusGrabSurfaceState {
PendingAddition, PendingAddition,
PendingRemoval, PendingRemoval,
Comitted, Comitted,
} state = PendingAddition; } m_state = PendingAddition;
private: private:
struct { struct {
CHyprSignalListener destroy; CHyprSignalListener destroy;
} listeners; } m_listeners;
}; };
class CFocusGrab { class CFocusGrab {
@ -47,11 +47,11 @@ class CFocusGrab {
void refocusKeyboard(); void refocusKeyboard();
void commit(bool removeOnly = false); void commit(bool removeOnly = false);
SP<CHyprlandFocusGrabV1> resource; SP<CHyprlandFocusGrabV1> m_resource;
std::unordered_map<WP<CWLSurfaceResource>, UP<CFocusGrabSurfaceState>> m_mSurfaces; std::unordered_map<WP<CWLSurfaceResource>, UP<CFocusGrabSurfaceState>> m_surfaces;
SP<CSeatGrab> grab; SP<CSeatGrab> m_grab;
bool m_bGrabActive = false; bool m_grabActive = false;
friend class CFocusGrabSurfaceState; friend class CFocusGrabSurfaceState;
}; };
@ -67,8 +67,8 @@ class CFocusGrabProtocol : public IWaylandProtocol {
void destroyGrab(CFocusGrab* grab); void destroyGrab(CFocusGrab* grab);
void onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id); void onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id);
std::vector<UP<CHyprlandFocusGrabManagerV1>> m_vManagers; std::vector<UP<CHyprlandFocusGrabManagerV1>> m_managers;
std::vector<UP<CFocusGrab>> m_vGrabs; std::vector<UP<CFocusGrab>> m_grabs;
friend class CFocusGrab; friend class CFocusGrab;
}; };

View File

@ -2,34 +2,34 @@
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "../managers/HookSystemManager.hpp" #include "../managers/HookSystemManager.hpp"
CForeignToplevelHandle::CForeignToplevelHandle(SP<CExtForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : resource(resource_), pWindow(pWindow_) { CForeignToplevelHandle::CForeignToplevelHandle(SP<CExtForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) {
if UNLIKELY (!resource_->resource()) if UNLIKELY (!resource_->resource())
return; return;
resource->setData(this); m_resource->setData(this);
resource->setOnDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); }); m_resource->setOnDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); });
resource->setDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); }); m_resource->setDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); });
} }
bool CForeignToplevelHandle::good() { bool CForeignToplevelHandle::good() {
return resource->resource(); return m_resource->resource();
} }
PHLWINDOW CForeignToplevelHandle::window() { PHLWINDOW CForeignToplevelHandle::window() {
return pWindow.lock(); return m_window.lock();
} }
CForeignToplevelList::CForeignToplevelList(SP<CExtForeignToplevelListV1> resource_) : resource(resource_) { CForeignToplevelList::CForeignToplevelList(SP<CExtForeignToplevelListV1> resource_) : m_resource(resource_) {
if UNLIKELY (!resource_->resource()) if UNLIKELY (!resource_->resource())
return; return;
resource->setOnDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); }); m_resource->setOnDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); });
resource->setDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); }); m_resource->setDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); });
resource->setStop([this](CExtForeignToplevelListV1* h) { m_resource->setStop([this](CExtForeignToplevelListV1* h) {
resource->sendFinished(); m_resource->sendFinished();
finished = true; m_finished = true;
LOGM(LOG, "CForeignToplevelList: finished"); LOGM(LOG, "CForeignToplevelList: finished");
}); });
@ -42,75 +42,75 @@ CForeignToplevelList::CForeignToplevelList(SP<CExtForeignToplevelListV1> resourc
} }
void CForeignToplevelList::onMap(PHLWINDOW pWindow) { void CForeignToplevelList::onMap(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto NEWHANDLE = PROTO::foreignToplevel->m_vHandles.emplace_back( const auto NEWHANDLE = PROTO::foreignToplevel->m_handles.emplace_back(
makeShared<CForeignToplevelHandle>(makeShared<CExtForeignToplevelHandleV1>(resource->client(), resource->version(), 0), pWindow)); makeShared<CForeignToplevelHandle>(makeShared<CExtForeignToplevelHandleV1>(m_resource->client(), m_resource->version(), 0), pWindow));
if (!NEWHANDLE->good()) { if (!NEWHANDLE->good()) {
LOGM(ERR, "Couldn't create a foreign handle"); LOGM(ERR, "Couldn't create a foreign handle");
resource->noMemory(); m_resource->noMemory();
PROTO::foreignToplevel->m_vHandles.pop_back(); PROTO::foreignToplevel->m_handles.pop_back();
return; return;
} }
const auto IDENTIFIER = std::format("{:08x}->{:016x}", static_cast<uint32_t>((uintptr_t)this & 0xFFFFFFFF), (uintptr_t)pWindow.get()); const auto IDENTIFIER = std::format("{:08x}->{:016x}", static_cast<uint32_t>((uintptr_t)this & 0xFFFFFFFF), (uintptr_t)pWindow.get());
LOGM(LOG, "Newly mapped window gets an identifier of {}", IDENTIFIER); LOGM(LOG, "Newly mapped window gets an identifier of {}", IDENTIFIER);
resource->sendToplevel(NEWHANDLE->resource.get()); m_resource->sendToplevel(NEWHANDLE->m_resource.get());
NEWHANDLE->resource->sendIdentifier(IDENTIFIER.c_str()); NEWHANDLE->m_resource->sendIdentifier(IDENTIFIER.c_str());
NEWHANDLE->resource->sendAppId(pWindow->m_initialClass.c_str()); NEWHANDLE->m_resource->sendAppId(pWindow->m_initialClass.c_str());
NEWHANDLE->resource->sendTitle(pWindow->m_initialTitle.c_str()); NEWHANDLE->m_resource->sendTitle(pWindow->m_initialTitle.c_str());
NEWHANDLE->resource->sendDone(); NEWHANDLE->m_resource->sendDone();
handles.push_back(NEWHANDLE); m_handles.push_back(NEWHANDLE);
} }
SP<CForeignToplevelHandle> CForeignToplevelList::handleForWindow(PHLWINDOW pWindow) { SP<CForeignToplevelHandle> CForeignToplevelList::handleForWindow(PHLWINDOW pWindow) {
std::erase_if(handles, [](const auto& wp) { return wp.expired(); }); std::erase_if(m_handles, [](const auto& wp) { return wp.expired(); });
const auto IT = std::find_if(handles.begin(), handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; }); const auto IT = std::find_if(m_handles.begin(), m_handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; });
return IT == handles.end() ? SP<CForeignToplevelHandle>{} : IT->lock(); return IT == m_handles.end() ? SP<CForeignToplevelHandle>{} : IT->lock();
} }
void CForeignToplevelList::onTitle(PHLWINDOW pWindow) { void CForeignToplevelList::onTitle(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H || H->closed) if UNLIKELY (!H || H->m_closed)
return; return;
H->resource->sendTitle(pWindow->m_title.c_str()); H->m_resource->sendTitle(pWindow->m_title.c_str());
H->resource->sendDone(); H->m_resource->sendDone();
} }
void CForeignToplevelList::onClass(PHLWINDOW pWindow) { void CForeignToplevelList::onClass(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H || H->closed) if UNLIKELY (!H || H->m_closed)
return; return;
H->resource->sendAppId(pWindow->m_class.c_str()); H->m_resource->sendAppId(pWindow->m_class.c_str());
H->resource->sendDone(); H->m_resource->sendDone();
} }
void CForeignToplevelList::onUnmap(PHLWINDOW pWindow) { void CForeignToplevelList::onUnmap(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H) if UNLIKELY (!H)
return; return;
H->resource->sendClosed(); H->m_resource->sendClosed();
H->closed = true; H->m_closed = true;
} }
bool CForeignToplevelList::good() { bool CForeignToplevelList::good() {
return resource->resource(); return m_resource->resource();
} }
CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -120,7 +120,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co
if (!windowValidForForeign(window)) if (!windowValidForForeign(window))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onMap(window); m->onMap(window);
} }
}); });
@ -131,7 +131,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co
if (!windowValidForForeign(window)) if (!windowValidForForeign(window))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onUnmap(window); m->onUnmap(window);
} }
}); });
@ -142,29 +142,29 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co
if (!windowValidForForeign(window)) if (!windowValidForForeign(window))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onTitle(window); m->onTitle(window);
} }
}); });
} }
void CForeignToplevelProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CForeignToplevelProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CForeignToplevelList>(makeShared<CExtForeignToplevelListV1>(client, ver, id))).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CForeignToplevelList>(makeShared<CExtForeignToplevelListV1>(client, ver, id))).get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
LOGM(ERR, "Couldn't create a foreign list"); LOGM(ERR, "Couldn't create a foreign list");
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CForeignToplevelProtocol::onManagerResourceDestroy(CForeignToplevelList* mgr) { void CForeignToplevelProtocol::onManagerResourceDestroy(CForeignToplevelList* mgr) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == mgr; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == mgr; });
} }
void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) { void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) {
std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; }); std::erase_if(m_handles, [&](const auto& other) { return other.get() == handle; });
} }
bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) { bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) {

View File

@ -14,9 +14,9 @@ class CForeignToplevelHandle {
PHLWINDOW window(); PHLWINDOW window();
private: private:
SP<CExtForeignToplevelHandleV1> resource; SP<CExtForeignToplevelHandleV1> m_resource;
PHLWINDOWREF pWindow; PHLWINDOWREF m_window;
bool closed = false; bool m_closed = false;
friend class CForeignToplevelList; friend class CForeignToplevelList;
friend class CForeignToplevelProtocol; friend class CForeignToplevelProtocol;
@ -34,12 +34,12 @@ class CForeignToplevelList {
bool good(); bool good();
private: private:
SP<CExtForeignToplevelListV1> resource; SP<CExtForeignToplevelListV1> m_resource;
bool finished = false; bool m_finished = false;
SP<CForeignToplevelHandle> handleForWindow(PHLWINDOW pWindow); SP<CForeignToplevelHandle> handleForWindow(PHLWINDOW pWindow);
std::vector<WP<CForeignToplevelHandle>> handles; std::vector<WP<CForeignToplevelHandle>> m_handles;
}; };
class CForeignToplevelProtocol : public IWaylandProtocol { class CForeignToplevelProtocol : public IWaylandProtocol {
@ -55,8 +55,8 @@ class CForeignToplevelProtocol : public IWaylandProtocol {
bool windowValidForForeign(PHLWINDOW pWindow); bool windowValidForForeign(PHLWINDOW pWindow);
// //
std::vector<UP<CForeignToplevelList>> m_vManagers; std::vector<UP<CForeignToplevelList>> m_managers;
std::vector<SP<CForeignToplevelHandle>> m_vHandles; std::vector<SP<CForeignToplevelHandle>> m_handles;
friend class CForeignToplevelList; friend class CForeignToplevelList;
friend class CForeignToplevelHandle; friend class CForeignToplevelHandle;

View File

@ -6,17 +6,17 @@
#include "../managers/HookSystemManager.hpp" #include "../managers/HookSystemManager.hpp"
#include "../managers/EventManager.hpp" #include "../managers/EventManager.hpp"
CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : resource(resource_), pWindow(pWindow_) { CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) {
if UNLIKELY (!resource_->resource()) if UNLIKELY (!resource_->resource())
return; return;
resource->setData(this); m_resource->setData(this);
resource->setOnDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); }); m_resource->setOnDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); });
resource->setDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); }); m_resource->setDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); });
resource->setActivate([this](CZwlrForeignToplevelHandleV1* p, wl_resource* seat) { m_resource->setActivate([this](CZwlrForeignToplevelHandleV1* p, wl_resource* seat) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -26,8 +26,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
PWINDOW->activate(true); PWINDOW->activate(true);
}); });
resource->setSetFullscreen([this](CZwlrForeignToplevelHandleV1* p, wl_resource* output) { m_resource->setSetFullscreen([this](CZwlrForeignToplevelHandleV1* p, wl_resource* output) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -57,8 +57,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
}); });
resource->setUnsetFullscreen([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setUnsetFullscreen([this](CZwlrForeignToplevelHandleV1* p) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -69,8 +69,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
g_pCompositor->changeWindowFullscreenModeClient(PWINDOW, FSMODE_FULLSCREEN, false); g_pCompositor->changeWindowFullscreenModeClient(PWINDOW, FSMODE_FULLSCREEN, false);
}); });
resource->setSetMaximized([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setSetMaximized([this](CZwlrForeignToplevelHandleV1* p) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -86,8 +86,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
g_pCompositor->changeWindowFullscreenModeClient(PWINDOW, FSMODE_MAXIMIZED, true); g_pCompositor->changeWindowFullscreenModeClient(PWINDOW, FSMODE_MAXIMIZED, true);
}); });
resource->setUnsetMaximized([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setUnsetMaximized([this](CZwlrForeignToplevelHandleV1* p) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -98,8 +98,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
g_pCompositor->changeWindowFullscreenModeClient(PWINDOW, FSMODE_MAXIMIZED, false); g_pCompositor->changeWindowFullscreenModeClient(PWINDOW, FSMODE_MAXIMIZED, false);
}); });
resource->setSetMinimized([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setSetMinimized([this](CZwlrForeignToplevelHandleV1* p) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -110,8 +110,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},1", (uintptr_t)PWINDOW.get())}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},1", (uintptr_t)PWINDOW.get())});
}); });
resource->setUnsetMinimized([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setUnsetMinimized([this](CZwlrForeignToplevelHandleV1* p) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -122,8 +122,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},0", (uintptr_t)PWINDOW.get())}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},0", (uintptr_t)PWINDOW.get())});
}); });
resource->setClose([this](CZwlrForeignToplevelHandleV1* p) { m_resource->setClose([this](CZwlrForeignToplevelHandleV1* p) {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW) if UNLIKELY (!PWINDOW)
return; return;
@ -133,42 +133,42 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
} }
bool CForeignToplevelHandleWlr::good() { bool CForeignToplevelHandleWlr::good() {
return resource->resource(); return m_resource->resource();
} }
PHLWINDOW CForeignToplevelHandleWlr::window() { PHLWINDOW CForeignToplevelHandleWlr::window() {
return pWindow.lock(); return m_window.lock();
} }
wl_resource* CForeignToplevelHandleWlr::res() { wl_resource* CForeignToplevelHandleWlr::res() {
return resource->resource(); return m_resource->resource();
} }
void CForeignToplevelHandleWlr::sendMonitor(PHLMONITOR pMonitor) { void CForeignToplevelHandleWlr::sendMonitor(PHLMONITOR pMonitor) {
if (lastMonitorID == pMonitor->m_id) if (m_lastMonitorID == pMonitor->m_id)
return; return;
const auto CLIENT = resource->client(); const auto CLIENT = m_resource->client();
if (const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(lastMonitorID); PLASTMONITOR && PROTO::outputs.contains(PLASTMONITOR->m_name)) { if (const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(m_lastMonitorID); PLASTMONITOR && PROTO::outputs.contains(PLASTMONITOR->m_name)) {
const auto OLDRESOURCE = PROTO::outputs.at(PLASTMONITOR->m_name)->outputResourceFrom(CLIENT); const auto OLDRESOURCE = PROTO::outputs.at(PLASTMONITOR->m_name)->outputResourceFrom(CLIENT);
if LIKELY (OLDRESOURCE) if LIKELY (OLDRESOURCE)
resource->sendOutputLeave(OLDRESOURCE->getResource()->resource()); m_resource->sendOutputLeave(OLDRESOURCE->getResource()->resource());
} }
if (PROTO::outputs.contains(pMonitor->m_name)) { if (PROTO::outputs.contains(pMonitor->m_name)) {
const auto NEWRESOURCE = PROTO::outputs.at(pMonitor->m_name)->outputResourceFrom(CLIENT); const auto NEWRESOURCE = PROTO::outputs.at(pMonitor->m_name)->outputResourceFrom(CLIENT);
if LIKELY (NEWRESOURCE) if LIKELY (NEWRESOURCE)
resource->sendOutputEnter(NEWRESOURCE->getResource()->resource()); m_resource->sendOutputEnter(NEWRESOURCE->getResource()->resource());
} }
lastMonitorID = pMonitor->m_id; m_lastMonitorID = pMonitor->m_id;
} }
void CForeignToplevelHandleWlr::sendState() { void CForeignToplevelHandleWlr::sendState() {
const auto PWINDOW = pWindow.lock(); const auto PWINDOW = m_window.lock();
if UNLIKELY (!PWINDOW || !PWINDOW->m_workspace || !PWINDOW->m_isMapped) if UNLIKELY (!PWINDOW || !PWINDOW->m_workspace || !PWINDOW->m_isMapped)
return; return;
@ -189,20 +189,20 @@ void CForeignToplevelHandleWlr::sendState() {
*p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED; *p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED;
} }
resource->sendState(&state); m_resource->sendState(&state);
wl_array_release(&state); wl_array_release(&state);
} }
CForeignToplevelWlrManager::CForeignToplevelWlrManager(SP<CZwlrForeignToplevelManagerV1> resource_) : resource(resource_) { CForeignToplevelWlrManager::CForeignToplevelWlrManager(SP<CZwlrForeignToplevelManagerV1> resource_) : m_resource(resource_) {
if UNLIKELY (!resource_->resource()) if UNLIKELY (!resource_->resource())
return; return;
resource->setOnDestroy([this](CZwlrForeignToplevelManagerV1* h) { PROTO::foreignToplevelWlr->onManagerResourceDestroy(this); }); m_resource->setOnDestroy([this](CZwlrForeignToplevelManagerV1* h) { PROTO::foreignToplevelWlr->onManagerResourceDestroy(this); });
resource->setStop([this](CZwlrForeignToplevelManagerV1* h) { m_resource->setStop([this](CZwlrForeignToplevelManagerV1* h) {
resource->sendFinished(); m_resource->sendFinished();
finished = true; m_finished = true;
LOGM(LOG, "CForeignToplevelWlrManager: finished"); LOGM(LOG, "CForeignToplevelWlrManager: finished");
PROTO::foreignToplevelWlr->onManagerResourceDestroy(this); PROTO::foreignToplevelWlr->onManagerResourceDestroy(this);
}); });
@ -214,84 +214,84 @@ CForeignToplevelWlrManager::CForeignToplevelWlrManager(SP<CZwlrForeignToplevelMa
onMap(w); onMap(w);
} }
lastFocus = g_pCompositor->m_lastWindow; m_lastFocus = g_pCompositor->m_lastWindow;
} }
void CForeignToplevelWlrManager::onMap(PHLWINDOW pWindow) { void CForeignToplevelWlrManager::onMap(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto NEWHANDLE = PROTO::foreignToplevelWlr->m_vHandles.emplace_back( const auto NEWHANDLE = PROTO::foreignToplevelWlr->m_handles.emplace_back(
makeShared<CForeignToplevelHandleWlr>(makeShared<CZwlrForeignToplevelHandleV1>(resource->client(), resource->version(), 0), pWindow)); makeShared<CForeignToplevelHandleWlr>(makeShared<CZwlrForeignToplevelHandleV1>(m_resource->client(), m_resource->version(), 0), pWindow));
if UNLIKELY (!NEWHANDLE->good()) { if UNLIKELY (!NEWHANDLE->good()) {
LOGM(ERR, "Couldn't create a foreign handle"); LOGM(ERR, "Couldn't create a foreign handle");
resource->noMemory(); m_resource->noMemory();
PROTO::foreignToplevelWlr->m_vHandles.pop_back(); PROTO::foreignToplevelWlr->m_handles.pop_back();
return; return;
} }
LOGM(LOG, "Newly mapped window {:016x}", (uintptr_t)pWindow.get()); LOGM(LOG, "Newly mapped window {:016x}", (uintptr_t)pWindow.get());
resource->sendToplevel(NEWHANDLE->resource.get()); m_resource->sendToplevel(NEWHANDLE->m_resource.get());
NEWHANDLE->resource->sendAppId(pWindow->m_class.c_str()); NEWHANDLE->m_resource->sendAppId(pWindow->m_class.c_str());
NEWHANDLE->resource->sendTitle(pWindow->m_title.c_str()); NEWHANDLE->m_resource->sendTitle(pWindow->m_title.c_str());
if LIKELY (const auto PMONITOR = pWindow->m_monitor.lock(); PMONITOR) if LIKELY (const auto PMONITOR = pWindow->m_monitor.lock(); PMONITOR)
NEWHANDLE->sendMonitor(PMONITOR); NEWHANDLE->sendMonitor(PMONITOR);
NEWHANDLE->sendState(); NEWHANDLE->sendState();
NEWHANDLE->resource->sendDone(); NEWHANDLE->m_resource->sendDone();
handles.push_back(NEWHANDLE); m_handles.push_back(NEWHANDLE);
} }
SP<CForeignToplevelHandleWlr> CForeignToplevelWlrManager::handleForWindow(PHLWINDOW pWindow) { SP<CForeignToplevelHandleWlr> CForeignToplevelWlrManager::handleForWindow(PHLWINDOW pWindow) {
std::erase_if(handles, [](const auto& wp) { return wp.expired(); }); std::erase_if(m_handles, [](const auto& wp) { return wp.expired(); });
const auto IT = std::find_if(handles.begin(), handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; }); const auto IT = std::find_if(m_handles.begin(), m_handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; });
return IT == handles.end() ? SP<CForeignToplevelHandleWlr>{} : IT->lock(); return IT == m_handles.end() ? SP<CForeignToplevelHandleWlr>{} : IT->lock();
} }
void CForeignToplevelWlrManager::onTitle(PHLWINDOW pWindow) { void CForeignToplevelWlrManager::onTitle(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H || H->closed) if UNLIKELY (!H || H->m_closed)
return; return;
H->resource->sendTitle(pWindow->m_title.c_str()); H->m_resource->sendTitle(pWindow->m_title.c_str());
H->resource->sendDone(); H->m_resource->sendDone();
} }
void CForeignToplevelWlrManager::onClass(PHLWINDOW pWindow) { void CForeignToplevelWlrManager::onClass(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H || H->closed) if UNLIKELY (!H || H->m_closed)
return; return;
H->resource->sendAppId(pWindow->m_class.c_str()); H->m_resource->sendAppId(pWindow->m_class.c_str());
H->resource->sendDone(); H->m_resource->sendDone();
} }
void CForeignToplevelWlrManager::onUnmap(PHLWINDOW pWindow) { void CForeignToplevelWlrManager::onUnmap(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H) if UNLIKELY (!H)
return; return;
H->resource->sendClosed(); H->m_resource->sendClosed();
H->resource->sendDone(); H->m_resource->sendDone();
H->closed = true; H->m_closed = true;
} }
void CForeignToplevelWlrManager::onMoveMonitor(PHLWINDOW pWindow) { void CForeignToplevelWlrManager::onMoveMonitor(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H || H->closed) if UNLIKELY (!H || H->m_closed)
return; return;
const auto PMONITOR = pWindow->m_monitor.lock(); const auto PMONITOR = pWindow->m_monitor.lock();
@ -300,42 +300,42 @@ void CForeignToplevelWlrManager::onMoveMonitor(PHLWINDOW pWindow) {
return; return;
H->sendMonitor(PMONITOR); H->sendMonitor(PMONITOR);
H->resource->sendDone(); H->m_resource->sendDone();
} }
void CForeignToplevelWlrManager::onFullscreen(PHLWINDOW pWindow) { void CForeignToplevelWlrManager::onFullscreen(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H || H->closed) if UNLIKELY (!H || H->m_closed)
return; return;
H->sendState(); H->sendState();
H->resource->sendDone(); H->m_resource->sendDone();
} }
void CForeignToplevelWlrManager::onNewFocus(PHLWINDOW pWindow) { void CForeignToplevelWlrManager::onNewFocus(PHLWINDOW pWindow) {
if UNLIKELY (finished) if UNLIKELY (m_finished)
return; return;
if LIKELY (const auto HOLD = handleForWindow(lastFocus.lock()); HOLD) { if LIKELY (const auto HOLD = handleForWindow(m_lastFocus.lock()); HOLD) {
HOLD->sendState(); HOLD->sendState();
HOLD->resource->sendDone(); HOLD->m_resource->sendDone();
} }
lastFocus = pWindow; m_lastFocus = pWindow;
const auto H = handleForWindow(pWindow); const auto H = handleForWindow(pWindow);
if UNLIKELY (!H || H->closed) if UNLIKELY (!H || H->m_closed)
return; return;
H->sendState(); H->sendState();
H->resource->sendDone(); H->m_resource->sendDone();
} }
bool CForeignToplevelWlrManager::good() { bool CForeignToplevelWlrManager::good() {
return resource->resource(); return m_resource->resource();
} }
CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -345,7 +345,7 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
if (!windowValidForForeign(PWINDOW)) if (!windowValidForForeign(PWINDOW))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onMap(PWINDOW); m->onMap(PWINDOW);
} }
}); });
@ -356,7 +356,7 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
if (!windowValidForForeign(PWINDOW)) if (!windowValidForForeign(PWINDOW))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onUnmap(PWINDOW); m->onUnmap(PWINDOW);
} }
}); });
@ -367,7 +367,7 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
if (!windowValidForForeign(PWINDOW)) if (!windowValidForForeign(PWINDOW))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onTitle(PWINDOW); m->onTitle(PWINDOW);
} }
}); });
@ -378,14 +378,14 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
if (PWINDOW && !windowValidForForeign(PWINDOW)) if (PWINDOW && !windowValidForForeign(PWINDOW))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onNewFocus(PWINDOW); m->onNewFocus(PWINDOW);
} }
}); });
static auto P4 = g_pHookSystem->hookDynamic("moveWindow", [this](void* self, SCallbackInfo& info, std::any data) { static auto P4 = g_pHookSystem->hookDynamic("moveWindow", [this](void* self, SCallbackInfo& info, std::any data) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(std::any_cast<std::vector<std::any>>(data).at(0)); const auto PWINDOW = std::any_cast<PHLWINDOW>(std::any_cast<std::vector<std::any>>(data).at(0));
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onMoveMonitor(PWINDOW); m->onMoveMonitor(PWINDOW);
} }
}); });
@ -396,29 +396,29 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
if (!windowValidForForeign(PWINDOW)) if (!windowValidForForeign(PWINDOW))
return; return;
for (auto const& m : m_vManagers) { for (auto const& m : m_managers) {
m->onFullscreen(PWINDOW); m->onFullscreen(PWINDOW);
} }
}); });
} }
void CForeignToplevelWlrProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CForeignToplevelWlrProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CForeignToplevelWlrManager>(makeShared<CZwlrForeignToplevelManagerV1>(client, ver, id))).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CForeignToplevelWlrManager>(makeShared<CZwlrForeignToplevelManagerV1>(client, ver, id))).get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
LOGM(ERR, "Couldn't create a foreign list"); LOGM(ERR, "Couldn't create a foreign list");
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CForeignToplevelWlrProtocol::onManagerResourceDestroy(CForeignToplevelWlrManager* mgr) { void CForeignToplevelWlrProtocol::onManagerResourceDestroy(CForeignToplevelWlrManager* mgr) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == mgr; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == mgr; });
} }
void CForeignToplevelWlrProtocol::destroyHandle(CForeignToplevelHandleWlr* handle) { void CForeignToplevelWlrProtocol::destroyHandle(CForeignToplevelHandleWlr* handle) {
std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; }); std::erase_if(m_handles, [&](const auto& other) { return other.get() == handle; });
} }
PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res) { PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res) {

View File

@ -16,10 +16,10 @@ class CForeignToplevelHandleWlr {
wl_resource* res(); wl_resource* res();
private: private:
SP<CZwlrForeignToplevelHandleV1> resource; SP<CZwlrForeignToplevelHandleV1> m_resource;
PHLWINDOWREF pWindow; PHLWINDOWREF m_window;
bool closed = false; bool m_closed = false;
MONITORID lastMonitorID = MONITOR_INVALID; MONITORID m_lastMonitorID = MONITOR_INVALID;
void sendMonitor(PHLMONITOR pMonitor); void sendMonitor(PHLMONITOR pMonitor);
void sendState(); void sendState();
@ -42,13 +42,13 @@ class CForeignToplevelWlrManager {
bool good(); bool good();
private: private:
SP<CZwlrForeignToplevelManagerV1> resource; SP<CZwlrForeignToplevelManagerV1> m_resource;
bool finished = false; bool m_finished = false;
PHLWINDOWREF lastFocus; // READ-ONLY PHLWINDOWREF m_lastFocus; // READ-ONLY
SP<CForeignToplevelHandleWlr> handleForWindow(PHLWINDOW pWindow); SP<CForeignToplevelHandleWlr> handleForWindow(PHLWINDOW pWindow);
std::vector<WP<CForeignToplevelHandleWlr>> handles; std::vector<WP<CForeignToplevelHandleWlr>> m_handles;
}; };
class CForeignToplevelWlrProtocol : public IWaylandProtocol { class CForeignToplevelWlrProtocol : public IWaylandProtocol {
@ -65,8 +65,8 @@ class CForeignToplevelWlrProtocol : public IWaylandProtocol {
bool windowValidForForeign(PHLWINDOW pWindow); bool windowValidForForeign(PHLWINDOW pWindow);
// //
std::vector<UP<CForeignToplevelWlrManager>> m_vManagers; std::vector<UP<CForeignToplevelWlrManager>> m_managers;
std::vector<SP<CForeignToplevelHandleWlr>> m_vHandles; std::vector<SP<CForeignToplevelHandleWlr>> m_handles;
friend class CForeignToplevelWlrManager; friend class CForeignToplevelWlrManager;
friend class CForeignToplevelHandleWlr; friend class CForeignToplevelHandleWlr;

View File

@ -7,7 +7,7 @@ CFractionalScaleProtocol::CFractionalScaleProtocol(const wl_interface* iface, co
} }
void CFractionalScaleProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CFractionalScaleProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CWpFractionalScaleManagerV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CWpFractionalScaleManagerV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CWpFractionalScaleManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CWpFractionalScaleManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CWpFractionalScaleManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setDestroy([this](CWpFractionalScaleManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@ -16,15 +16,15 @@ void CFractionalScaleProtocol::bindManager(wl_client* client, void* data, uint32
} }
void CFractionalScaleProtocol::removeAddon(CFractionalScaleAddon* addon) { void CFractionalScaleProtocol::removeAddon(CFractionalScaleAddon* addon) {
m_mAddons.erase(addon->surf()); m_addons.erase(addon->surf());
} }
void CFractionalScaleProtocol::onManagerResourceDestroy(wl_resource* res) { void CFractionalScaleProtocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [res](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [res](const auto& other) { return other->resource() == res; });
} }
void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface) { void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface) {
for (auto const& [k, v] : m_mAddons) { for (auto const& [k, v] : m_addons) {
if (k == surface) { if (k == surface) {
LOGM(ERR, "Surface {:x} already has a fractionalScale addon", (uintptr_t)surface.get()); LOGM(ERR, "Surface {:x} already has a fractionalScale addon", (uintptr_t)surface.get());
pMgr->error(WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale already exists"); pMgr->error(WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale already exists");
@ -33,10 +33,10 @@ void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1*
} }
const auto PADDON = const auto PADDON =
m_mAddons.emplace(surface, makeUnique<CFractionalScaleAddon>(makeShared<CWpFractionalScaleV1>(pMgr->client(), pMgr->version(), id), surface)).first->second.get(); m_addons.emplace(surface, makeUnique<CFractionalScaleAddon>(makeShared<CWpFractionalScaleV1>(pMgr->client(), pMgr->version(), id), surface)).first->second.get();
if UNLIKELY (!PADDON->good()) { if UNLIKELY (!PADDON->good()) {
m_mAddons.erase(surface); m_addons.erase(surface);
pMgr->noMemory(); pMgr->noMemory();
return; return;
} }
@ -44,20 +44,20 @@ void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1*
PADDON->m_resource->setOnDestroy([this, PADDON](CWpFractionalScaleV1* self) { this->removeAddon(PADDON); }); PADDON->m_resource->setOnDestroy([this, PADDON](CWpFractionalScaleV1* self) { this->removeAddon(PADDON); });
PADDON->m_resource->setDestroy([this, PADDON](CWpFractionalScaleV1* self) { this->removeAddon(PADDON); }); PADDON->m_resource->setDestroy([this, PADDON](CWpFractionalScaleV1* self) { this->removeAddon(PADDON); });
if (std::ranges::find_if(m_mSurfaceScales, [surface](const auto& e) { return e.first == surface; }) == m_mSurfaceScales.end()) if (std::ranges::find_if(m_surfaceScales, [surface](const auto& e) { return e.first == surface; }) == m_surfaceScales.end())
m_mSurfaceScales.emplace(surface, 1.F); m_surfaceScales.emplace(surface, 1.F);
if (surface->m_mapped) if (surface->m_mapped)
PADDON->setScale(m_mSurfaceScales.at(surface)); PADDON->setScale(m_surfaceScales.at(surface));
// clean old // clean old
std::erase_if(m_mSurfaceScales, [](const auto& e) { return e.first.expired(); }); std::erase_if(m_surfaceScales, [](const auto& e) { return e.first.expired(); });
} }
void CFractionalScaleProtocol::sendScale(SP<CWLSurfaceResource> surf, const float& scale) { void CFractionalScaleProtocol::sendScale(SP<CWLSurfaceResource> surf, const float& scale) {
m_mSurfaceScales[surf] = scale; m_surfaceScales[surf] = scale;
if (m_mAddons.contains(surf)) if (m_addons.contains(surf))
m_mAddons[surf]->setScale(scale); m_addons[surf]->setScale(scale);
} }
CFractionalScaleAddon::CFractionalScaleAddon(SP<CWpFractionalScaleV1> resource_, SP<CWLSurfaceResource> surf_) : m_resource(resource_), m_surface(surf_) { CFractionalScaleAddon::CFractionalScaleAddon(SP<CWpFractionalScaleV1> resource_, SP<CWLSurfaceResource> surf_) : m_resource(resource_), m_surface(surf_) {

View File

@ -49,9 +49,9 @@ class CFractionalScaleProtocol : public IWaylandProtocol {
// //
std::unordered_map<WP<CWLSurfaceResource>, float> m_mSurfaceScales; std::unordered_map<WP<CWLSurfaceResource>, float> m_surfaceScales;
std::unordered_map<WP<CWLSurfaceResource>, UP<CFractionalScaleAddon>> m_mAddons; std::unordered_map<WP<CWLSurfaceResource>, UP<CFractionalScaleAddon>> m_addons;
std::vector<UP<CWpFractionalScaleManagerV1>> m_vManagers; std::vector<UP<CWpFractionalScaleManagerV1>> m_managers;
friend class CFractionalScaleAddon; friend class CFractionalScaleAddon;
}; };

View File

@ -22,14 +22,14 @@ static wpColorManagerV1Primaries getWPPrimaries(frogColorManagedSurfacePrimaries
return (wpColorManagerV1Primaries)(primaries + 1); return (wpColorManagerV1Primaries)(primaries + 1);
} }
CFrogColorManager::CFrogColorManager(SP<CFrogColorManagementFactoryV1> resource_) : resource(resource_) { CFrogColorManager::CFrogColorManager(SP<CFrogColorManagementFactoryV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); }); m_resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); });
resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); });
resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) { m_resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) {
LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface);
auto SURF = CWLSurfaceResource::fromResource(surface); auto SURF = CWLSurfaceResource::fromResource(surface);
@ -39,70 +39,70 @@ CFrogColorManager::CFrogColorManager(SP<CFrogColorManagementFactoryV1> resource_
return; return;
} }
const auto RESOURCE = PROTO::frogColorManagement->m_vSurfaces.emplace_back( const auto RESOURCE =
makeShared<CFrogColorManagementSurface>(makeShared<CFrogColorManagedSurface>(r->client(), r->version(), id), SURF)); PROTO::frogColorManagement->m_surfaces.emplace_back(makeShared<CFrogColorManagementSurface>(makeShared<CFrogColorManagedSurface>(r->client(), r->version(), id), SURF));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::frogColorManagement->m_vSurfaces.pop_back(); PROTO::frogColorManagement->m_surfaces.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
} }
bool CFrogColorManager::good() { bool CFrogColorManager::good() {
return resource->resource(); return m_resource->resource();
} }
CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSurface> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) { CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSurface> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = resource->client(); m_client = m_resource->client();
if (!surface->m_colorManagement.valid()) { if (!m_surface->m_colorManagement.valid()) {
const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared<CColorManagementSurface>(surface_)); const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared<CColorManagementSurface>(surface_));
if UNLIKELY (!RESOURCE) { if UNLIKELY (!RESOURCE) {
resource->noMemory(); m_resource->noMemory();
PROTO::colorManagement->m_vSurfaces.pop_back(); PROTO::colorManagement->m_surfaces.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
surface->m_colorManagement = RESOURCE; m_surface->m_colorManagement = RESOURCE;
resource->setOnDestroy([this](CFrogColorManagedSurface* r) { m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) {
LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)m_surface);
if (surface.valid()) if (m_surface.valid())
PROTO::colorManagement->destroyResource(surface->m_colorManagement.get()); PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get());
PROTO::frogColorManagement->destroyResource(this); PROTO::frogColorManagement->destroyResource(this);
}); });
} else } else
resource->setOnDestroy([this](CFrogColorManagedSurface* r) { m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) {
LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface);
PROTO::frogColorManagement->destroyResource(this); PROTO::frogColorManagement->destroyResource(this);
}); });
resource->setDestroy([this](CFrogColorManagedSurface* r) { m_resource->setDestroy([this](CFrogColorManagedSurface* r) {
LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface);
PROTO::frogColorManagement->destroyResource(this); PROTO::frogColorManagement->destroyResource(this);
}); });
resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) { m_resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) {
LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, surface->id()); LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, m_surface->id());
switch (tf) { switch (tf) {
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ:
surface->m_colorManagement->m_imageDescription.transferFunction = m_surface->m_colorManagement->m_imageDescription.transferFunction =
convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ));
break; break;
; ;
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22:
if (pqIntentSent) { if (m_pqIntentSent) {
LOGM(TRACE, LOGM(TRACE,
"FIXME: assuming broken enum value 2 (FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22) referring to eotf value 2 (TRANSFER_FUNCTION_ST2084_PQ)"); "FIXME: assuming broken enum value 2 (FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22) referring to eotf value 2 (TRANSFER_FUNCTION_ST2084_PQ)");
surface->m_colorManagement->m_imageDescription.transferFunction = m_surface->m_colorManagement->m_imageDescription.transferFunction =
convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ));
break; break;
}; };
@ -110,49 +110,49 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_UNDEFINED: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_UNDEFINED:
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SCRGB_LINEAR: LOGM(TRACE, "FIXME: add tf support for {}", (uint32_t)tf); [[fallthrough]]; case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SCRGB_LINEAR: LOGM(TRACE, "FIXME: add tf support for {}", (uint32_t)tf); [[fallthrough]];
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB:
surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf));
surface->m_colorManagement->setHasImageDescription(true); m_surface->m_colorManagement->setHasImageDescription(true);
} }
}); });
resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) { m_resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) {
LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName); LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName);
switch (primariesName) { switch (primariesName) {
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED: case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED:
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break; case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break;
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break; case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break;
} }
surface->m_colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName)); m_surface->m_colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName));
surface->m_colorManagement->setHasImageDescription(true); m_surface->m_colorManagement->setHasImageDescription(true);
}); });
resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) { m_resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) {
LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent); LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent);
pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; m_pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL;
surface->m_colorManagement->setHasImageDescription(true); m_surface->m_colorManagement->setHasImageDescription(true);
}); });
resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y, m_resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x,
uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) { uint32_t w_y, uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) {
LOGM(TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll, fall); LOGM(TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll, fall);
surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f}, m_surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f},
.green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f}, .green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f},
.blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f},
.white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}}; .white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}};
surface->m_colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f; m_surface->m_colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f;
surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum; m_surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum;
surface->m_colorManagement->m_imageDescription.maxCLL = cll; m_surface->m_colorManagement->m_imageDescription.maxCLL = cll;
surface->m_colorManagement->m_imageDescription.maxFALL = fall; m_surface->m_colorManagement->m_imageDescription.maxFALL = fall;
surface->m_colorManagement->setHasImageDescription(true); m_surface->m_colorManagement->setHasImageDescription(true);
}); });
} }
bool CFrogColorManagementSurface::good() { bool CFrogColorManagementSurface::good() {
return resource->resource(); return m_resource->resource();
} }
wl_client* CFrogColorManagementSurface::client() { wl_client* CFrogColorManagementSurface::client() {
return pClient; return m_client;
} }
CFrogColorManagementProtocol::CFrogColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CFrogColorManagementProtocol::CFrogColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -160,11 +160,11 @@ CFrogColorManagementProtocol::CFrogColorManagementProtocol(const wl_interface* i
} }
void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CFrogColorManager>(makeShared<CFrogColorManagementFactoryV1>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CFrogColorManager>(makeShared<CFrogColorManagementFactoryV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
@ -172,9 +172,9 @@ void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, ui
} }
void CFrogColorManagementProtocol::destroyResource(CFrogColorManager* resource) { void CFrogColorManagementProtocol::destroyResource(CFrogColorManager* resource) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
} }
void CFrogColorManagementProtocol::destroyResource(CFrogColorManagementSurface* resource) { void CFrogColorManagementProtocol::destroyResource(CFrogColorManagementSurface* resource) {
std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; });
} }

View File

@ -12,7 +12,7 @@ class CFrogColorManager {
bool good(); bool good();
private: private:
SP<CFrogColorManagementFactoryV1> resource; SP<CFrogColorManagementFactoryV1> m_resource;
}; };
class CFrogColorManagementSurface { class CFrogColorManagementSurface {
@ -22,14 +22,14 @@ class CFrogColorManagementSurface {
bool good(); bool good();
wl_client* client(); wl_client* client();
WP<CFrogColorManagementSurface> self; WP<CFrogColorManagementSurface> m_self;
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
bool pqIntentSent = false; bool m_pqIntentSent = false;
private: private:
SP<CFrogColorManagedSurface> resource; SP<CFrogColorManagedSurface> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
}; };
class CFrogColorManagementProtocol : public IWaylandProtocol { class CFrogColorManagementProtocol : public IWaylandProtocol {
@ -42,8 +42,8 @@ class CFrogColorManagementProtocol : public IWaylandProtocol {
void destroyResource(CFrogColorManager* resource); void destroyResource(CFrogColorManager* resource);
void destroyResource(CFrogColorManagementSurface* resource); void destroyResource(CFrogColorManagementSurface* resource);
std::vector<SP<CFrogColorManager>> m_vManagers; std::vector<SP<CFrogColorManager>> m_managers;
std::vector<SP<CFrogColorManagementSurface>> m_vSurfaces; std::vector<SP<CFrogColorManagementSurface>> m_surfaces;
friend class CFrogColorManager; friend class CFrogColorManager;
friend class CFrogColorManagementSurface; friend class CFrogColorManagementSurface;

View File

@ -6,7 +6,7 @@
#include "../render/Renderer.hpp" #include "../render/Renderer.hpp"
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* output) : resource(resource_) { CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* output) : m_resource(resource_) {
if UNLIKELY (!resource_->resource()) if UNLIKELY (!resource_->resource())
return; return;
@ -14,144 +14,144 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
if UNLIKELY (!OUTPUTRES) { if UNLIKELY (!OUTPUTRES) {
LOGM(ERR, "No output in CGammaControl"); LOGM(ERR, "No output in CGammaControl");
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
pMonitor = OUTPUTRES->m_monitor; m_monitor = OUTPUTRES->m_monitor;
if UNLIKELY (!pMonitor || !pMonitor->m_output) { if UNLIKELY (!m_monitor || !m_monitor->m_output) {
LOGM(ERR, "No CMonitor"); LOGM(ERR, "No CMonitor");
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
for (auto const& g : PROTO::gamma->m_vGammaControllers) { for (auto const& g : PROTO::gamma->m_gammaControllers) {
if UNLIKELY (g->pMonitor == pMonitor) { if UNLIKELY (g->m_monitor == m_monitor) {
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
} }
gammaSize = pMonitor->m_output->getGammaSize(); m_gammaSize = m_monitor->m_output->getGammaSize();
if UNLIKELY (gammaSize <= 0) { if UNLIKELY (m_gammaSize <= 0) {
LOGM(ERR, "Output {} doesn't support gamma", pMonitor->m_name); LOGM(ERR, "Output {} doesn't support gamma", m_monitor->m_name);
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
gammaTable.resize(gammaSize * 3); m_gammaTable.resize(m_gammaSize * 3);
resource->setDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); }); m_resource->setDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); });
resource->setOnDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); }); m_resource->setOnDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); });
resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) { m_resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) {
CFileDescriptor gammaFd{fd}; CFileDescriptor gammaFd{fd};
if UNLIKELY (!pMonitor) { if UNLIKELY (!m_monitor) {
LOGM(ERR, "setGamma for a dead monitor"); LOGM(ERR, "setGamma for a dead monitor");
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
LOGM(LOG, "setGamma for {}", pMonitor->m_name); LOGM(LOG, "setGamma for {}", m_monitor->m_name);
// TODO: make CFileDescriptor getflags use F_GETFL // TODO: make CFileDescriptor getflags use F_GETFL
int fdFlags = fcntl(gammaFd.get(), F_GETFL, 0); int fdFlags = fcntl(gammaFd.get(), F_GETFL, 0);
if UNLIKELY (fdFlags < 0) { if UNLIKELY (fdFlags < 0) {
LOGM(ERR, "Failed to get fd flags"); LOGM(ERR, "Failed to get fd flags");
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
// TODO: make CFileDescriptor setflags use F_SETFL // TODO: make CFileDescriptor setflags use F_SETFL
if UNLIKELY (fcntl(gammaFd.get(), F_SETFL, fdFlags | O_NONBLOCK) < 0) { if UNLIKELY (fcntl(gammaFd.get(), F_SETFL, fdFlags | O_NONBLOCK) < 0) {
LOGM(ERR, "Failed to set fd flags"); LOGM(ERR, "Failed to set fd flags");
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
ssize_t readBytes = pread(gammaFd.get(), gammaTable.data(), gammaTable.size() * sizeof(uint16_t), 0); ssize_t readBytes = pread(gammaFd.get(), m_gammaTable.data(), m_gammaTable.size() * sizeof(uint16_t), 0);
if (readBytes < 0 || (size_t)readBytes != gammaTable.size() * sizeof(uint16_t)) { if (readBytes < 0 || (size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) {
LOGM(ERR, "Failed to read bytes"); LOGM(ERR, "Failed to read bytes");
if ((size_t)readBytes != gammaTable.size() * sizeof(uint16_t)) { if ((size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) {
gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch"); gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch");
return; return;
} }
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
gammaTableSet = true; m_gammaTableSet = true;
// translate the table to AQ format // translate the table to AQ format
std::vector<uint16_t> red, green, blue; std::vector<uint16_t> red, green, blue;
red.resize(gammaTable.size() / 3); red.resize(m_gammaTable.size() / 3);
green.resize(gammaTable.size() / 3); green.resize(m_gammaTable.size() / 3);
blue.resize(gammaTable.size() / 3); blue.resize(m_gammaTable.size() / 3);
for (size_t i = 0; i < gammaTable.size() / 3; ++i) { for (size_t i = 0; i < m_gammaTable.size() / 3; ++i) {
red.at(i) = gammaTable.at(i); red.at(i) = m_gammaTable.at(i);
green.at(i) = gammaTable.at(gammaTable.size() / 3 + i); green.at(i) = m_gammaTable.at(m_gammaTable.size() / 3 + i);
blue.at(i) = gammaTable.at((gammaTable.size() / 3) * 2 + i); blue.at(i) = m_gammaTable.at((m_gammaTable.size() / 3) * 2 + i);
} }
for (size_t i = 0; i < gammaTable.size() / 3; ++i) { for (size_t i = 0; i < m_gammaTable.size() / 3; ++i) {
gammaTable.at(i * 3) = red.at(i); m_gammaTable.at(i * 3) = red.at(i);
gammaTable.at(i * 3 + 1) = green.at(i); m_gammaTable.at(i * 3 + 1) = green.at(i);
gammaTable.at(i * 3 + 2) = blue.at(i); m_gammaTable.at(i * 3 + 2) = blue.at(i);
} }
applyToMonitor(); applyToMonitor();
}); });
resource->sendGammaSize(gammaSize); m_resource->sendGammaSize(m_gammaSize);
listeners.monitorDestroy = pMonitor->m_events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); }); m_listeners.monitorDestroy = m_monitor->m_events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
listeners.monitorDisconnect = pMonitor->m_events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); }); m_listeners.monitorDisconnect = m_monitor->m_events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); });
} }
CGammaControl::~CGammaControl() { CGammaControl::~CGammaControl() {
if (!gammaTableSet || !pMonitor || !pMonitor->m_output) if (!m_gammaTableSet || !m_monitor || !m_monitor->m_output)
return; return;
// reset the LUT if the client dies for whatever reason and doesn't unset the gamma // reset the LUT if the client dies for whatever reason and doesn't unset the gamma
pMonitor->m_output->state->setGammaLut({}); m_monitor->m_output->state->setGammaLut({});
} }
bool CGammaControl::good() { bool CGammaControl::good() {
return resource->resource(); return m_resource->resource();
} }
void CGammaControl::applyToMonitor() { void CGammaControl::applyToMonitor() {
if UNLIKELY (!pMonitor || !pMonitor->m_output) if UNLIKELY (!m_monitor || !m_monitor->m_output)
return; // ?? return; // ??
LOGM(LOG, "setting to monitor {}", pMonitor->m_name); LOGM(LOG, "setting to monitor {}", m_monitor->m_name);
if (!gammaTableSet) { if (!m_gammaTableSet) {
pMonitor->m_output->state->setGammaLut({}); m_monitor->m_output->state->setGammaLut({});
return; return;
} }
pMonitor->m_output->state->setGammaLut(gammaTable); m_monitor->m_output->state->setGammaLut(m_gammaTable);
if (!pMonitor->m_state.test()) { if (!m_monitor->m_state.test()) {
LOGM(LOG, "setting to monitor {} failed", pMonitor->m_name); LOGM(LOG, "setting to monitor {} failed", m_monitor->m_name);
pMonitor->m_output->state->setGammaLut({}); m_monitor->m_output->state->setGammaLut({});
} }
g_pHyprRenderer->damageMonitor(pMonitor.lock()); g_pHyprRenderer->damageMonitor(m_monitor.lock());
} }
PHLMONITOR CGammaControl::getMonitor() { PHLMONITOR CGammaControl::getMonitor() {
return pMonitor ? pMonitor.lock() : nullptr; return m_monitor ? m_monitor.lock() : nullptr;
} }
void CGammaControl::onMonitorDestroy() { void CGammaControl::onMonitorDestroy() {
LOGM(LOG, "Destroying gamma control for {}", pMonitor->m_name); LOGM(LOG, "Destroying gamma control for {}", m_monitor->m_name);
resource->sendFailed(); m_resource->sendFailed();
} }
CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -159,7 +159,7 @@ CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const in
} }
void CGammaControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CGammaControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwlrGammaControlManagerV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwlrGammaControlManagerV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CZwlrGammaControlManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CZwlrGammaControlManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CZwlrGammaControlManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setDestroy([this](CZwlrGammaControlManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@ -167,26 +167,26 @@ void CGammaControlProtocol::bindManager(wl_client* client, void* data, uint32_t
} }
void CGammaControlProtocol::onManagerResourceDestroy(wl_resource* res) { void CGammaControlProtocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
} }
void CGammaControlProtocol::destroyGammaControl(CGammaControl* gamma) { void CGammaControlProtocol::destroyGammaControl(CGammaControl* gamma) {
std::erase_if(m_vGammaControllers, [&](const auto& other) { return other.get() == gamma; }); std::erase_if(m_gammaControllers, [&](const auto& other) { return other.get() == gamma; });
} }
void CGammaControlProtocol::onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output) { void CGammaControlProtocol::onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output) {
const auto CLIENT = pMgr->client(); const auto CLIENT = pMgr->client();
const auto RESOURCE = m_vGammaControllers.emplace_back(makeUnique<CGammaControl>(makeShared<CZwlrGammaControlV1>(CLIENT, pMgr->version(), id), output)).get(); const auto RESOURCE = m_gammaControllers.emplace_back(makeUnique<CGammaControl>(makeShared<CZwlrGammaControlV1>(CLIENT, pMgr->version(), id), output)).get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory(); pMgr->noMemory();
m_vGammaControllers.pop_back(); m_gammaControllers.pop_back();
return; return;
} }
} }
void CGammaControlProtocol::applyGammaToState(PHLMONITOR pMonitor) { void CGammaControlProtocol::applyGammaToState(PHLMONITOR pMonitor) {
for (auto const& g : m_vGammaControllers) { for (auto const& g : m_gammaControllers) {
if (g->getMonitor() != pMonitor) if (g->getMonitor() != pMonitor)
continue; continue;

View File

@ -18,18 +18,18 @@ class CGammaControl {
PHLMONITOR getMonitor(); PHLMONITOR getMonitor();
private: private:
SP<CZwlrGammaControlV1> resource; SP<CZwlrGammaControlV1> m_resource;
PHLMONITORREF pMonitor; PHLMONITORREF m_monitor;
size_t gammaSize = 0; size_t m_gammaSize = 0;
bool gammaTableSet = false; bool m_gammaTableSet = false;
std::vector<uint16_t> gammaTable; // [r,g,b]+ std::vector<uint16_t> m_gammaTable; // [r,g,b]+
void onMonitorDestroy(); void onMonitorDestroy();
struct { struct {
CHyprSignalListener monitorDisconnect; CHyprSignalListener monitorDisconnect;
CHyprSignalListener monitorDestroy; CHyprSignalListener monitorDestroy;
} listeners; } m_listeners;
}; };
class CGammaControlProtocol : public IWaylandProtocol { class CGammaControlProtocol : public IWaylandProtocol {
@ -46,8 +46,8 @@ class CGammaControlProtocol : public IWaylandProtocol {
void onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output); void onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output);
// //
std::vector<UP<CZwlrGammaControlManagerV1>> m_vManagers; std::vector<UP<CZwlrGammaControlManagerV1>> m_managers;
std::vector<UP<CGammaControl>> m_vGammaControllers; std::vector<UP<CGammaControl>> m_gammaControllers;
friend class CGammaControl; friend class CGammaControl;
}; };

View File

@ -1,21 +1,21 @@
#include "GlobalShortcuts.hpp" #include "GlobalShortcuts.hpp"
#include "../helpers/time/Time.hpp" #include "../helpers/time/Time.hpp"
CShortcutClient::CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource_) : resource(resource_) { CShortcutClient::CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); }); m_resource->setOnDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); });
resource->setDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); }); m_resource->setDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); });
resource->setRegisterShortcut([this](CHyprlandGlobalShortcutsManagerV1* pMgr, uint32_t shortcut, const char* id, const char* app_id, const char* description, m_resource->setRegisterShortcut([this](CHyprlandGlobalShortcutsManagerV1* pMgr, uint32_t shortcut, const char* id, const char* app_id, const char* description,
const char* trigger_description) { const char* trigger_description) {
if UNLIKELY (PROTO::globalShortcuts->isTaken(id, app_id)) { if UNLIKELY (PROTO::globalShortcuts->isTaken(id, app_id)) {
resource->error(HYPRLAND_GLOBAL_SHORTCUTS_MANAGER_V1_ERROR_ALREADY_TAKEN, "Combination is taken"); m_resource->error(HYPRLAND_GLOBAL_SHORTCUTS_MANAGER_V1_ERROR_ALREADY_TAKEN, "Combination is taken");
return; return;
} }
const auto PSHORTCUT = shortcuts.emplace_back(makeShared<SShortcut>(makeShared<CHyprlandGlobalShortcutV1>(resource->client(), resource->version(), shortcut))); const auto PSHORTCUT = m_shortcuts.emplace_back(makeShared<SShortcut>(makeShared<CHyprlandGlobalShortcutV1>(m_resource->client(), m_resource->version(), shortcut)));
PSHORTCUT->id = id; PSHORTCUT->id = id;
PSHORTCUT->description = description; PSHORTCUT->description = description;
PSHORTCUT->appid = app_id; PSHORTCUT->appid = app_id;
@ -23,16 +23,16 @@ CShortcutClient::CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource_
if UNLIKELY (!PSHORTCUT->resource->resource()) { if UNLIKELY (!PSHORTCUT->resource->resource()) {
PSHORTCUT->resource->noMemory(); PSHORTCUT->resource->noMemory();
shortcuts.pop_back(); m_shortcuts.pop_back();
return; return;
} }
PSHORTCUT->resource->setDestroy([this](CHyprlandGlobalShortcutV1* pMgr) { std::erase_if(shortcuts, [&](const auto& other) { return other->resource.get() == pMgr; }); }); PSHORTCUT->resource->setDestroy([this](CHyprlandGlobalShortcutV1* pMgr) { std::erase_if(m_shortcuts, [&](const auto& other) { return other->resource.get() == pMgr; }); });
}); });
} }
bool CShortcutClient::good() { bool CShortcutClient::good() {
return resource->resource(); return m_resource->resource();
} }
CGlobalShortcutsProtocol::CGlobalShortcutsProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CGlobalShortcutsProtocol::CGlobalShortcutsProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -40,22 +40,22 @@ CGlobalShortcutsProtocol::CGlobalShortcutsProtocol(const wl_interface* iface, co
} }
void CGlobalShortcutsProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CGlobalShortcutsProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESROUCE = m_vClients.emplace_back(makeShared<CShortcutClient>(makeShared<CHyprlandGlobalShortcutsManagerV1>(client, ver, id))); const auto RESROUCE = m_clients.emplace_back(makeShared<CShortcutClient>(makeShared<CHyprlandGlobalShortcutsManagerV1>(client, ver, id)));
if UNLIKELY (!RESROUCE->good()) { if UNLIKELY (!RESROUCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vClients.pop_back(); m_clients.pop_back();
return; return;
} }
} }
void CGlobalShortcutsProtocol::destroyResource(CShortcutClient* client) { void CGlobalShortcutsProtocol::destroyResource(CShortcutClient* client) {
std::erase_if(m_vClients, [&](const auto& other) { return other.get() == client; }); std::erase_if(m_clients, [&](const auto& other) { return other.get() == client; });
} }
bool CGlobalShortcutsProtocol::isTaken(std::string appid, std::string trigger) { bool CGlobalShortcutsProtocol::isTaken(std::string appid, std::string trigger) {
for (auto const& c : m_vClients) { for (auto const& c : m_clients) {
for (auto const& sh : c->shortcuts) { for (auto const& sh : c->m_shortcuts) {
if (sh->appid == appid && sh->id == trigger) { if (sh->appid == appid && sh->id == trigger) {
return true; return true;
} }
@ -66,8 +66,8 @@ bool CGlobalShortcutsProtocol::isTaken(std::string appid, std::string trigger) {
} }
void CGlobalShortcutsProtocol::sendGlobalShortcutEvent(std::string appid, std::string trigger, bool pressed) { void CGlobalShortcutsProtocol::sendGlobalShortcutEvent(std::string appid, std::string trigger, bool pressed) {
for (auto const& c : m_vClients) { for (auto const& c : m_clients) {
for (auto const& sh : c->shortcuts) { for (auto const& sh : c->m_shortcuts) {
if (sh->appid == appid && sh->id == trigger) { if (sh->appid == appid && sh->id == trigger) {
const auto [sec, nsec] = Time::secNsec(Time::steadyNow()); const auto [sec, nsec] = Time::secNsec(Time::steadyNow());
uint32_t tvSecHi = (sizeof(sec) > 4) ? sec >> 32 : 0; uint32_t tvSecHi = (sizeof(sec) > 4) ? sec >> 32 : 0;
@ -87,15 +87,15 @@ std::vector<SShortcut> CGlobalShortcutsProtocol::getAllShortcuts() {
// and potential reallocation is more costly then the added precompute overhead of looping // and potential reallocation is more costly then the added precompute overhead of looping
// and finding the total size. // and finding the total size.
size_t totalShortcuts = 0; size_t totalShortcuts = 0;
for (const auto& c : m_vClients) { for (const auto& c : m_clients) {
totalShortcuts += c->shortcuts.size(); totalShortcuts += c->m_shortcuts.size();
} }
// reserve number of elements to avoid reallocations // reserve number of elements to avoid reallocations
copy.reserve(totalShortcuts); copy.reserve(totalShortcuts);
for (const auto& c : m_vClients) { for (const auto& c : m_clients) {
for (const auto& sh : c->shortcuts) { for (const auto& sh : c->m_shortcuts) {
copy.push_back(*sh); copy.push_back(*sh);
} }
} }

View File

@ -17,8 +17,8 @@ class CShortcutClient {
bool good(); bool good();
private: private:
SP<CHyprlandGlobalShortcutsManagerV1> resource; SP<CHyprlandGlobalShortcutsManagerV1> m_resource;
std::vector<SP<SShortcut>> shortcuts; std::vector<SP<SShortcut>> m_shortcuts;
friend class CGlobalShortcutsProtocol; friend class CGlobalShortcutsProtocol;
}; };
@ -35,7 +35,7 @@ class CGlobalShortcutsProtocol : IWaylandProtocol {
std::vector<SShortcut> getAllShortcuts(); std::vector<SShortcut> getAllShortcuts();
private: private:
std::vector<SP<CShortcutClient>> m_vClients; std::vector<SP<CShortcutClient>> m_clients;
}; };
namespace PROTO { namespace PROTO {

View File

@ -6,83 +6,83 @@
#include <hyprutils/math/Region.hpp> #include <hyprutils/math/Region.hpp>
#include <wayland-server.h> #include <wayland-server.h>
CHyprlandSurface::CHyprlandSurface(SP<CHyprlandSurfaceV1> resource, SP<CWLSurfaceResource> surface) : m_pSurface(surface) { CHyprlandSurface::CHyprlandSurface(SP<CHyprlandSurfaceV1> resource, SP<CWLSurfaceResource> surface) : m_surface(surface) {
setResource(std::move(resource)); setResource(std::move(resource));
} }
bool CHyprlandSurface::good() const { bool CHyprlandSurface::good() const {
return m_pResource->resource(); return m_resource->resource();
} }
void CHyprlandSurface::setResource(SP<CHyprlandSurfaceV1> resource) { void CHyprlandSurface::setResource(SP<CHyprlandSurfaceV1> resource) {
m_pResource = std::move(resource); m_resource = std::move(resource);
if UNLIKELY (!m_pResource->resource()) if UNLIKELY (!m_resource->resource())
return; return;
m_pResource->setDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); }); m_resource->setDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); });
m_pResource->setOnDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); }); m_resource->setOnDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); });
m_pResource->setSetOpacity([this](CHyprlandSurfaceV1* resource, uint32_t opacity) { m_resource->setSetOpacity([this](CHyprlandSurfaceV1* resource, uint32_t opacity) {
if UNLIKELY (!m_pSurface) { if UNLIKELY (!m_surface) {
m_pResource->error(HYPRLAND_SURFACE_V1_ERROR_NO_SURFACE, "set_opacity called for destroyed wl_surface"); m_resource->error(HYPRLAND_SURFACE_V1_ERROR_NO_SURFACE, "set_opacity called for destroyed wl_surface");
return; return;
} }
auto fOpacity = wl_fixed_to_double(opacity); auto fOpacity = wl_fixed_to_double(opacity);
if UNLIKELY (fOpacity < 0.0 || fOpacity > 1.0) { if UNLIKELY (fOpacity < 0.0 || fOpacity > 1.0) {
m_pResource->error(HYPRLAND_SURFACE_V1_ERROR_OUT_OF_RANGE, "set_opacity called with an opacity value larger than 1.0 or smaller than 0.0."); m_resource->error(HYPRLAND_SURFACE_V1_ERROR_OUT_OF_RANGE, "set_opacity called with an opacity value larger than 1.0 or smaller than 0.0.");
return; return;
} }
m_fOpacity = fOpacity; m_opacity = fOpacity;
}); });
m_pResource->setSetVisibleRegion([this](CHyprlandSurfaceV1* resource, wl_resource* region) { m_resource->setSetVisibleRegion([this](CHyprlandSurfaceV1* resource, wl_resource* region) {
if (!region) { if (!region) {
if (!m_visibleRegion.empty()) if (!m_visibleRegion.empty())
m_bVisibleRegionChanged = true; m_visibleRegionChanged = true;
m_visibleRegion.clear(); m_visibleRegion.clear();
return; return;
} }
m_bVisibleRegionChanged = true; m_visibleRegionChanged = true;
m_visibleRegion = CWLRegionResource::fromResource(region)->m_region; m_visibleRegion = CWLRegionResource::fromResource(region)->m_region;
}); });
listeners.surfaceCommitted = m_pSurface->m_events.commit.registerListener([this](std::any data) { m_listeners.surfaceCommitted = m_surface->m_events.commit.registerListener([this](std::any data) {
auto surface = CWLSurface::fromResource(m_pSurface.lock()); auto surface = CWLSurface::fromResource(m_surface.lock());
if (surface && (surface->m_overallOpacity != m_fOpacity || m_bVisibleRegionChanged)) { if (surface && (surface->m_overallOpacity != m_opacity || m_visibleRegionChanged)) {
surface->m_overallOpacity = m_fOpacity; surface->m_overallOpacity = m_opacity;
surface->m_visibleRegion = m_visibleRegion; surface->m_visibleRegion = m_visibleRegion;
auto box = surface->getSurfaceBoxGlobal(); auto box = surface->getSurfaceBoxGlobal();
if (box.has_value()) if (box.has_value())
g_pHyprRenderer->damageBox(*box); g_pHyprRenderer->damageBox(*box);
if (!m_pResource) if (!m_resource)
PROTO::hyprlandSurface->destroySurface(this); PROTO::hyprlandSurface->destroySurface(this);
} }
}); });
listeners.surfaceDestroyed = m_pSurface->m_events.destroy.registerListener([this](std::any data) { m_listeners.surfaceDestroyed = m_surface->m_events.destroy.registerListener([this](std::any data) {
if (!m_pResource) if (!m_resource)
PROTO::hyprlandSurface->destroySurface(this); PROTO::hyprlandSurface->destroySurface(this);
}); });
} }
void CHyprlandSurface::destroy() { void CHyprlandSurface::destroy() {
m_pResource.reset(); m_resource.reset();
m_fOpacity = 1.F; m_opacity = 1.F;
if (!m_visibleRegion.empty()) if (!m_visibleRegion.empty())
m_bVisibleRegionChanged = true; m_visibleRegionChanged = true;
m_visibleRegion.clear(); m_visibleRegion.clear();
if (!m_pSurface) if (!m_surface)
PROTO::hyprlandSurface->destroySurface(this); PROTO::hyprlandSurface->destroySurface(this);
} }
@ -91,7 +91,7 @@ CHyprlandSurfaceProtocol::CHyprlandSurfaceProtocol(const wl_interface* iface, co
} }
void CHyprlandSurfaceProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CHyprlandSurfaceProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
auto manager = m_vManagers.emplace_back(makeUnique<CHyprlandSurfaceManagerV1>(client, ver, id)).get(); auto manager = m_managers.emplace_back(makeUnique<CHyprlandSurfaceManagerV1>(client, ver, id)).get();
manager->setOnDestroy([this](CHyprlandSurfaceManagerV1* manager) { destroyManager(manager); }); manager->setOnDestroy([this](CHyprlandSurfaceManagerV1* manager) { destroyManager(manager); });
manager->setDestroy([this](CHyprlandSurfaceManagerV1* manager) { destroyManager(manager); }); manager->setDestroy([this](CHyprlandSurfaceManagerV1* manager) { destroyManager(manager); });
@ -100,19 +100,19 @@ void CHyprlandSurfaceProtocol::bindManager(wl_client* client, void* data, uint32
} }
void CHyprlandSurfaceProtocol::destroyManager(CHyprlandSurfaceManagerV1* manager) { void CHyprlandSurfaceProtocol::destroyManager(CHyprlandSurfaceManagerV1* manager) {
std::erase_if(m_vManagers, [&](const auto& p) { return p.get() == manager; }); std::erase_if(m_managers, [&](const auto& p) { return p.get() == manager; });
} }
void CHyprlandSurfaceProtocol::destroySurface(CHyprlandSurface* surface) { void CHyprlandSurfaceProtocol::destroySurface(CHyprlandSurface* surface) {
std::erase_if(m_mSurfaces, [&](const auto& entry) { return entry.second.get() == surface; }); std::erase_if(m_surfaces, [&](const auto& entry) { return entry.second.get() == surface; });
} }
void CHyprlandSurfaceProtocol::getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP<CWLSurfaceResource> surface) { void CHyprlandSurfaceProtocol::getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP<CWLSurfaceResource> surface) {
CHyprlandSurface* hyprlandSurface = nullptr; CHyprlandSurface* hyprlandSurface = nullptr;
auto iter = std::find_if(m_mSurfaces.begin(), m_mSurfaces.end(), [&](const auto& entry) { return entry.second->m_pSurface == surface; }); auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [&](const auto& entry) { return entry.second->m_surface == surface; });
if (iter != m_mSurfaces.end()) { if (iter != m_surfaces.end()) {
if (iter->second->m_pResource) { if (iter->second->m_resource) {
LOGM(ERR, "HyprlandSurface already present for surface {:x}", (uintptr_t)surface.get()); LOGM(ERR, "HyprlandSurface already present for surface {:x}", (uintptr_t)surface.get());
manager->error(HYPRLAND_SURFACE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "HyprlandSurface already present"); manager->error(HYPRLAND_SURFACE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "HyprlandSurface already present");
return; return;
@ -122,11 +122,11 @@ void CHyprlandSurfaceProtocol::getSurface(CHyprlandSurfaceManagerV1* manager, ui
} }
} else { } else {
hyprlandSurface = hyprlandSurface =
m_mSurfaces.emplace(surface, makeUnique<CHyprlandSurface>(makeShared<CHyprlandSurfaceV1>(manager->client(), manager->version(), id), surface)).first->second.get(); m_surfaces.emplace(surface, makeUnique<CHyprlandSurface>(makeShared<CHyprlandSurfaceV1>(manager->client(), manager->version(), id), surface)).first->second.get();
} }
if UNLIKELY (!hyprlandSurface->good()) { if UNLIKELY (!hyprlandSurface->good()) {
manager->noMemory(); manager->noMemory();
m_mSurfaces.erase(surface); m_surfaces.erase(surface);
} }
} }

View File

@ -18,10 +18,10 @@ class CHyprlandSurface {
void setResource(SP<CHyprlandSurfaceV1> resource); void setResource(SP<CHyprlandSurfaceV1> resource);
private: private:
SP<CHyprlandSurfaceV1> m_pResource; SP<CHyprlandSurfaceV1> m_resource;
WP<CWLSurfaceResource> m_pSurface; WP<CWLSurfaceResource> m_surface;
float m_fOpacity = 1.0; float m_opacity = 1.0;
bool m_bVisibleRegionChanged = false; bool m_visibleRegionChanged = false;
CRegion m_visibleRegion; CRegion m_visibleRegion;
void destroy(); void destroy();
@ -29,7 +29,7 @@ class CHyprlandSurface {
struct { struct {
CHyprSignalListener surfaceCommitted; CHyprSignalListener surfaceCommitted;
CHyprSignalListener surfaceDestroyed; CHyprSignalListener surfaceDestroyed;
} listeners; } m_listeners;
friend class CHyprlandSurfaceProtocol; friend class CHyprlandSurfaceProtocol;
}; };
@ -45,8 +45,8 @@ class CHyprlandSurfaceProtocol : public IWaylandProtocol {
void destroySurface(CHyprlandSurface* surface); void destroySurface(CHyprlandSurface* surface);
void getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP<CWLSurfaceResource> surface); void getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP<CWLSurfaceResource> surface);
std::vector<UP<CHyprlandSurfaceManagerV1>> m_vManagers; std::vector<UP<CHyprlandSurfaceManagerV1>> m_managers;
std::unordered_map<WP<CWLSurfaceResource>, UP<CHyprlandSurface>> m_mSurfaces; std::unordered_map<WP<CWLSurfaceResource>, UP<CHyprlandSurface>> m_surfaces;
friend class CHyprlandSurface; friend class CHyprlandSurface;
}; };

View File

@ -1,25 +1,25 @@
#include "IdleInhibit.hpp" #include "IdleInhibit.hpp"
#include "core/Compositor.hpp" #include "core/Compositor.hpp"
CIdleInhibitor::CIdleInhibitor(SP<CIdleInhibitorResource> resource_, SP<CWLSurfaceResource> surf_) : resource(resource_), surface(surf_) { CIdleInhibitor::CIdleInhibitor(SP<CIdleInhibitorResource> resource_, SP<CWLSurfaceResource> surf_) : m_resource(resource_), m_surface(surf_) {
; ;
} }
CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, SP<CWLSurfaceResource> surface_) : resource(resource_), surface(surface_) { CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, SP<CWLSurfaceResource> surface_) : m_resource(resource_), m_surface(surface_) {
listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { m_listeners.destroySurface = m_surface->m_events.destroy.registerListener([this](std::any d) {
surface.reset(); m_surface.reset();
listeners.destroySurface.reset(); m_listeners.destroySurface.reset();
destroySent = true; m_destroySent = true;
events.destroy.emit(); m_events.destroy.emit();
}); });
resource->setOnDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); m_resource->setOnDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); });
resource->setDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); m_resource->setDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); });
} }
CIdleInhibitorResource::~CIdleInhibitorResource() { CIdleInhibitorResource::~CIdleInhibitorResource() {
if (!destroySent) if (!m_destroySent)
events.destroy.emit(); m_events.destroy.emit();
} }
CIdleInhibitProtocol::CIdleInhibitProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CIdleInhibitProtocol::CIdleInhibitProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -27,11 +27,11 @@ CIdleInhibitProtocol::CIdleInhibitProtocol(const wl_interface* iface, const int&
} }
void CIdleInhibitProtocol::onManagerResourceDestroy(wl_resource* res) { void CIdleInhibitProtocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [res](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [res](const auto& other) { return other->resource() == res; });
} }
void CIdleInhibitProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CIdleInhibitProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwpIdleInhibitManagerV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwpIdleInhibitManagerV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CZwpIdleInhibitManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CZwpIdleInhibitManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CZwpIdleInhibitManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setDestroy([this](CZwpIdleInhibitManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@ -40,13 +40,13 @@ void CIdleInhibitProtocol::bindManager(wl_client* client, void* data, uint32_t v
} }
void CIdleInhibitProtocol::removeInhibitor(CIdleInhibitorResource* resource) { void CIdleInhibitProtocol::removeInhibitor(CIdleInhibitorResource* resource) {
std::erase_if(m_vInhibitors, [resource](const auto& el) { return el.get() == resource; }); std::erase_if(m_inhibitors, [resource](const auto& el) { return el.get() == resource; });
} }
void CIdleInhibitProtocol::onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface) { void CIdleInhibitProtocol::onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface) {
const auto CLIENT = pMgr->client(); const auto CLIENT = pMgr->client();
const auto RESOURCE = m_vInhibitors.emplace_back(makeShared<CIdleInhibitorResource>(makeShared<CZwpIdleInhibitorV1>(CLIENT, pMgr->version(), id), surface)); const auto RESOURCE = m_inhibitors.emplace_back(makeShared<CIdleInhibitorResource>(makeShared<CZwpIdleInhibitorV1>(CLIENT, pMgr->version(), id), surface));
RESOURCE->inhibitor = makeShared<CIdleInhibitor>(RESOURCE, surface); RESOURCE->m_inhibitor = makeShared<CIdleInhibitor>(RESOURCE, surface);
events.newIdleInhibitor.emit(RESOURCE->inhibitor); m_events.newIdleInhibitor.emit(RESOURCE->m_inhibitor);
} }

View File

@ -14,10 +14,10 @@ class CIdleInhibitor {
struct { struct {
CHyprSignalListener destroy; CHyprSignalListener destroy;
} listeners; } m_listeners;
WP<CIdleInhibitorResource> resource; WP<CIdleInhibitorResource> m_resource;
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
}; };
class CIdleInhibitorResource { class CIdleInhibitorResource {
@ -25,20 +25,20 @@ class CIdleInhibitorResource {
CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, SP<CWLSurfaceResource> surface_); CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, SP<CWLSurfaceResource> surface_);
~CIdleInhibitorResource(); ~CIdleInhibitorResource();
SP<CIdleInhibitor> inhibitor; SP<CIdleInhibitor> m_inhibitor;
struct { struct {
CSignal destroy; CSignal destroy;
} events; } m_events;
private: private:
SP<CZwpIdleInhibitorV1> resource; SP<CZwpIdleInhibitorV1> m_resource;
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
bool destroySent = false; bool m_destroySent = false;
struct { struct {
CHyprSignalListener destroySurface; CHyprSignalListener destroySurface;
} listeners; } m_listeners;
}; };
class CIdleInhibitProtocol : public IWaylandProtocol { class CIdleInhibitProtocol : public IWaylandProtocol {
@ -49,7 +49,7 @@ class CIdleInhibitProtocol : public IWaylandProtocol {
struct { struct {
CSignal newIdleInhibitor; // data: SP<CIdleInhibitor> CSignal newIdleInhibitor; // data: SP<CIdleInhibitor>
} events; } m_events;
private: private:
void onManagerResourceDestroy(wl_resource* res); void onManagerResourceDestroy(wl_resource* res);
@ -58,8 +58,8 @@ class CIdleInhibitProtocol : public IWaylandProtocol {
void removeInhibitor(CIdleInhibitorResource*); void removeInhibitor(CIdleInhibitorResource*);
// //
std::vector<UP<CZwpIdleInhibitManagerV1>> m_vManagers; std::vector<UP<CZwpIdleInhibitManagerV1>> m_managers;
std::vector<SP<CIdleInhibitorResource>> m_vInhibitors; std::vector<SP<CIdleInhibitorResource>> m_inhibitors;
friend class CIdleInhibitorResource; friend class CIdleInhibitorResource;
}; };

View File

@ -11,15 +11,15 @@ static int onTimer(SP<CEventLoopTimer> self, void* data) {
} }
CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_, bool obeyInhibitors_) : CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_, bool obeyInhibitors_) :
resource(resource_), timeoutMs(timeoutMs_), obeyInhibitors(obeyInhibitors_) { m_resource(resource_), m_timeoutMs(timeoutMs_), m_obeyInhibitors(obeyInhibitors_) {
if UNLIKELY (!resource_->resource()) if UNLIKELY (!resource_->resource())
return; return;
resource->setDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); }); m_resource->setDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); });
resource->setOnDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); }); m_resource->setOnDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); });
timer = makeShared<CEventLoopTimer>(std::nullopt, onTimer, this); m_timer = makeShared<CEventLoopTimer>(std::nullopt, onTimer, this);
g_pEventLoopManager->addTimer(timer); g_pEventLoopManager->addTimer(m_timer);
updateTimer(); updateTimer();
@ -27,36 +27,36 @@ CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_,
} }
CExtIdleNotification::~CExtIdleNotification() { CExtIdleNotification::~CExtIdleNotification() {
g_pEventLoopManager->removeTimer(timer); g_pEventLoopManager->removeTimer(m_timer);
timer.reset(); m_timer.reset();
} }
bool CExtIdleNotification::good() { bool CExtIdleNotification::good() {
return resource->resource(); return m_resource->resource();
} }
void CExtIdleNotification::updateTimer() { void CExtIdleNotification::updateTimer() {
if (PROTO::idle->isInhibited && obeyInhibitors) if (PROTO::idle->isInhibited && m_obeyInhibitors)
timer->updateTimeout(std::nullopt); m_timer->updateTimeout(std::nullopt);
else else
timer->updateTimeout(std::chrono::milliseconds(timeoutMs)); m_timer->updateTimeout(std::chrono::milliseconds(m_timeoutMs));
} }
void CExtIdleNotification::onTimerFired() { void CExtIdleNotification::onTimerFired() {
resource->sendIdled(); m_resource->sendIdled();
idled = true; m_idled = true;
} }
void CExtIdleNotification::onActivity() { void CExtIdleNotification::onActivity() {
if (idled) if (m_idled)
resource->sendResumed(); m_resource->sendResumed();
idled = false; m_idled = false;
updateTimer(); updateTimer();
} }
bool CExtIdleNotification::inhibitorsAreObeyed() const { bool CExtIdleNotification::inhibitorsAreObeyed() const {
return obeyInhibitors; return m_obeyInhibitors;
} }
CIdleNotifyProtocol::CIdleNotifyProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CIdleNotifyProtocol::CIdleNotifyProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -64,7 +64,7 @@ CIdleNotifyProtocol::CIdleNotifyProtocol(const wl_interface* iface, const int& v
} }
void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CExtIdleNotifierV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CExtIdleNotifierV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CExtIdleNotifierV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CExtIdleNotifierV1* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CExtIdleNotifierV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setDestroy([this](CExtIdleNotifierV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@ -75,34 +75,34 @@ void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ve
} }
void CIdleNotifyProtocol::onManagerResourceDestroy(wl_resource* res) { void CIdleNotifyProtocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
} }
void CIdleNotifyProtocol::destroyNotification(CExtIdleNotification* notif) { void CIdleNotifyProtocol::destroyNotification(CExtIdleNotification* notif) {
std::erase_if(m_vNotifications, [&](const auto& other) { return other.get() == notif; }); std::erase_if(m_notifications, [&](const auto& other) { return other.get() == notif; });
} }
void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors) { void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors) {
const auto CLIENT = pMgr->client(); const auto CLIENT = pMgr->client();
const auto RESOURCE = const auto RESOURCE =
m_vNotifications.emplace_back(makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version(), id), timeout, obeyInhibitors)).get(); m_notifications.emplace_back(makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version(), id), timeout, obeyInhibitors)).get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory(); pMgr->noMemory();
m_vNotifications.pop_back(); m_notifications.pop_back();
return; return;
} }
} }
void CIdleNotifyProtocol::onActivity() { void CIdleNotifyProtocol::onActivity() {
for (auto const& n : m_vNotifications) { for (auto const& n : m_notifications) {
n->onActivity(); n->onActivity();
} }
} }
void CIdleNotifyProtocol::setInhibit(bool inhibited) { void CIdleNotifyProtocol::setInhibit(bool inhibited) {
isInhibited = inhibited; isInhibited = inhibited;
for (auto const& n : m_vNotifications) { for (auto const& n : m_notifications) {
if (n->inhibitorsAreObeyed()) if (n->inhibitorsAreObeyed())
n->onActivity(); n->onActivity();
} }

View File

@ -19,12 +19,12 @@ class CExtIdleNotification {
bool inhibitorsAreObeyed() const; bool inhibitorsAreObeyed() const;
private: private:
SP<CExtIdleNotificationV1> resource; SP<CExtIdleNotificationV1> m_resource;
uint32_t timeoutMs = 0; uint32_t m_timeoutMs = 0;
SP<CEventLoopTimer> timer; SP<CEventLoopTimer> m_timer;
bool idled = false; bool m_idled = false;
bool obeyInhibitors = false; bool m_obeyInhibitors = false;
void updateTimer(); void updateTimer();
}; };
@ -46,8 +46,8 @@ class CIdleNotifyProtocol : public IWaylandProtocol {
bool isInhibited = false; bool isInhibited = false;
// //
std::vector<UP<CExtIdleNotifierV1>> m_vManagers; std::vector<UP<CExtIdleNotifierV1>> m_managers;
std::vector<SP<CExtIdleNotification>> m_vNotifications; std::vector<SP<CExtIdleNotification>> m_notifications;
friend class CExtIdleNotification; friend class CExtIdleNotification;
}; };

View File

@ -6,12 +6,12 @@
#include "core/Compositor.hpp" #include "core/Compositor.hpp"
#include <cstring> #include <cstring>
CInputMethodKeyboardGrabV2::CInputMethodKeyboardGrabV2(SP<CZwpInputMethodKeyboardGrabV2> resource_, SP<CInputMethodV2> owner_) : resource(resource_), owner(owner_) { CInputMethodKeyboardGrabV2::CInputMethodKeyboardGrabV2(SP<CZwpInputMethodKeyboardGrabV2> resource_, SP<CInputMethodV2> owner_) : m_resource(resource_), m_owner(owner_) {
if UNLIKELY (!resource->resource()) if UNLIKELY (!m_resource->resource())
return; return;
resource->setRelease([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); }); m_resource->setRelease([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); });
resource->setOnDestroy([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); }); m_resource->setOnDestroy([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); });
if (!g_pSeatManager->m_keyboard) { if (!g_pSeatManager->m_keyboard) {
LOGM(ERR, "IME called but no active keyboard???"); LOGM(ERR, "IME called but no active keyboard???");
@ -22,16 +22,16 @@ CInputMethodKeyboardGrabV2::CInputMethodKeyboardGrabV2(SP<CZwpInputMethodKeyboar
} }
CInputMethodKeyboardGrabV2::~CInputMethodKeyboardGrabV2() { CInputMethodKeyboardGrabV2::~CInputMethodKeyboardGrabV2() {
if (!owner.expired()) if (!m_owner.expired())
std::erase_if(owner->grabs, [](const auto& g) { return g.expired(); }); std::erase_if(m_owner->m_grabs, [](const auto& g) { return g.expired(); });
} }
void CInputMethodKeyboardGrabV2::sendKeyboardData(SP<IKeyboard> keyboard) { void CInputMethodKeyboardGrabV2::sendKeyboardData(SP<IKeyboard> keyboard) {
if (keyboard == pLastKeyboard) if (keyboard == m_lastKeyboard)
return; return;
pLastKeyboard = keyboard; m_lastKeyboard = keyboard;
auto keymapFD = allocateSHMFile(keyboard->m_xkbKeymapString.length() + 1); auto keymapFD = allocateSHMFile(keyboard->m_xkbKeymapString.length() + 1);
if UNLIKELY (!keymapFD.isValid()) { if UNLIKELY (!keymapFD.isValid()) {
@ -48,95 +48,96 @@ void CInputMethodKeyboardGrabV2::sendKeyboardData(SP<IKeyboard> keyboard) {
memcpy(data, keyboard->m_xkbKeymapString.c_str(), keyboard->m_xkbKeymapString.length()); memcpy(data, keyboard->m_xkbKeymapString.c_str(), keyboard->m_xkbKeymapString.length());
munmap(data, keyboard->m_xkbKeymapString.length() + 1); munmap(data, keyboard->m_xkbKeymapString.length() + 1);
resource->sendKeymap(WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymapFD.get(), keyboard->m_xkbKeymapString.length() + 1); m_resource->sendKeymap(WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymapFD.get(), keyboard->m_xkbKeymapString.length() + 1);
sendMods(keyboard->m_modifiersState.depressed, keyboard->m_modifiersState.latched, keyboard->m_modifiersState.locked, keyboard->m_modifiersState.group); sendMods(keyboard->m_modifiersState.depressed, keyboard->m_modifiersState.latched, keyboard->m_modifiersState.locked, keyboard->m_modifiersState.group);
resource->sendRepeatInfo(keyboard->m_repeatRate, keyboard->m_repeatDelay); m_resource->sendRepeatInfo(keyboard->m_repeatRate, keyboard->m_repeatDelay);
} }
void CInputMethodKeyboardGrabV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) { void CInputMethodKeyboardGrabV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) {
const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(resource->client())); const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client()));
resource->sendKey(SERIAL, time, key, (uint32_t)state); m_resource->sendKey(SERIAL, time, key, (uint32_t)state);
} }
void CInputMethodKeyboardGrabV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { void CInputMethodKeyboardGrabV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(resource->client())); const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client()));
resource->sendModifiers(SERIAL, depressed, latched, locked, group); m_resource->sendModifiers(SERIAL, depressed, latched, locked, group);
} }
bool CInputMethodKeyboardGrabV2::good() { bool CInputMethodKeyboardGrabV2::good() {
return resource->resource(); return m_resource->resource();
} }
SP<CInputMethodV2> CInputMethodKeyboardGrabV2::getOwner() { SP<CInputMethodV2> CInputMethodKeyboardGrabV2::getOwner() {
return owner.lock(); return m_owner.lock();
} }
wl_client* CInputMethodKeyboardGrabV2::client() { wl_client* CInputMethodKeyboardGrabV2::client() {
return resource->resource() ? resource->client() : nullptr; return m_resource->resource() ? m_resource->client() : nullptr;
} }
CInputMethodPopupV2::CInputMethodPopupV2(SP<CZwpInputPopupSurfaceV2> resource_, SP<CInputMethodV2> owner_, SP<CWLSurfaceResource> surface) : resource(resource_), owner(owner_) { CInputMethodPopupV2::CInputMethodPopupV2(SP<CZwpInputPopupSurfaceV2> resource_, SP<CInputMethodV2> owner_, SP<CWLSurfaceResource> surface) :
if UNLIKELY (!resource->resource()) m_resource(resource_), m_owner(owner_) {
if UNLIKELY (!m_resource->resource())
return; return;
resource->setDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); }); m_resource->setDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); });
resource->setOnDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); }); m_resource->setOnDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); });
pSurface = surface; m_surface = surface;
listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { m_listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) {
if (mapped) if (m_mapped)
events.unmap.emit(); m_events.unmap.emit();
listeners.destroySurface.reset(); m_listeners.destroySurface.reset();
listeners.commitSurface.reset(); m_listeners.commitSurface.reset();
if (g_pCompositor->m_lastFocus == pSurface) if (g_pCompositor->m_lastFocus == m_surface)
g_pCompositor->m_lastFocus.reset(); g_pCompositor->m_lastFocus.reset();
pSurface.reset(); m_surface.reset();
}); });
listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) { m_listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) {
if (pSurface->m_current.texture && !mapped) { if (m_surface->m_current.texture && !m_mapped) {
mapped = true; m_mapped = true;
pSurface->map(); m_surface->map();
events.map.emit(); m_events.map.emit();
return; return;
} }
if (!pSurface->m_current.texture && mapped) { if (!m_surface->m_current.texture && m_mapped) {
mapped = false; m_mapped = false;
pSurface->unmap(); m_surface->unmap();
events.unmap.emit(); m_events.unmap.emit();
return; return;
} }
events.commit.emit(); m_events.commit.emit();
}); });
} }
CInputMethodPopupV2::~CInputMethodPopupV2() { CInputMethodPopupV2::~CInputMethodPopupV2() {
if (!owner.expired()) if (!m_owner.expired())
std::erase_if(owner->popups, [](const auto& p) { return p.expired(); }); std::erase_if(m_owner->m_popups, [](const auto& p) { return p.expired(); });
events.destroy.emit(); m_events.destroy.emit();
} }
bool CInputMethodPopupV2::good() { bool CInputMethodPopupV2::good() {
return resource->resource(); return m_resource->resource();
} }
void CInputMethodPopupV2::sendInputRectangle(const CBox& box) { void CInputMethodPopupV2::sendInputRectangle(const CBox& box) {
resource->sendTextInputRectangle(box.x, box.y, box.w, box.h); m_resource->sendTextInputRectangle(box.x, box.y, box.w, box.h);
} }
SP<CWLSurfaceResource> CInputMethodPopupV2::surface() { SP<CWLSurfaceResource> CInputMethodPopupV2::surface() {
return pSurface.lock(); return m_surface.lock();
} }
void CInputMethodV2::SState::reset() { void CInputMethodV2::SState::reset() {
@ -145,127 +146,127 @@ void CInputMethodV2::SState::reset() {
preeditString.committed = false; preeditString.committed = false;
} }
CInputMethodV2::CInputMethodV2(SP<CZwpInputMethodV2> resource_) : resource(resource_) { CInputMethodV2::CInputMethodV2(SP<CZwpInputMethodV2> resource_) : m_resource(resource_) {
if UNLIKELY (!resource->resource()) if UNLIKELY (!m_resource->resource())
return; return;
resource->setDestroy([this](CZwpInputMethodV2* r) { m_resource->setDestroy([this](CZwpInputMethodV2* r) {
events.destroy.emit(); m_events.destroy.emit();
PROTO::ime->destroyResource(this); PROTO::ime->destroyResource(this);
}); });
resource->setOnDestroy([this](CZwpInputMethodV2* r) { m_resource->setOnDestroy([this](CZwpInputMethodV2* r) {
events.destroy.emit(); m_events.destroy.emit();
PROTO::ime->destroyResource(this); PROTO::ime->destroyResource(this);
}); });
resource->setCommitString([this](CZwpInputMethodV2* r, const char* str) { m_resource->setCommitString([this](CZwpInputMethodV2* r, const char* str) {
pending.committedString.string = str; m_pending.committedString.string = str;
pending.committedString.committed = true; m_pending.committedString.committed = true;
}); });
resource->setDeleteSurroundingText([this](CZwpInputMethodV2* r, uint32_t before, uint32_t after) { m_resource->setDeleteSurroundingText([this](CZwpInputMethodV2* r, uint32_t before, uint32_t after) {
pending.deleteSurrounding.before = before; m_pending.deleteSurrounding.before = before;
pending.deleteSurrounding.after = after; m_pending.deleteSurrounding.after = after;
pending.deleteSurrounding.committed = true; m_pending.deleteSurrounding.committed = true;
}); });
resource->setSetPreeditString([this](CZwpInputMethodV2* r, const char* str, int32_t begin, int32_t end) { m_resource->setSetPreeditString([this](CZwpInputMethodV2* r, const char* str, int32_t begin, int32_t end) {
pending.preeditString.string = str; m_pending.preeditString.string = str;
pending.preeditString.begin = begin; m_pending.preeditString.begin = begin;
pending.preeditString.end = end; m_pending.preeditString.end = end;
pending.preeditString.committed = true; m_pending.preeditString.committed = true;
}); });
resource->setCommit([this](CZwpInputMethodV2* r, uint32_t serial) { m_resource->setCommit([this](CZwpInputMethodV2* r, uint32_t serial) {
current = pending; m_current = m_pending;
pending.reset(); m_pending.reset();
events.onCommit.emit(); m_events.onCommit.emit();
}); });
resource->setGetInputPopupSurface([this](CZwpInputMethodV2* r, uint32_t id, wl_resource* surface) { m_resource->setGetInputPopupSurface([this](CZwpInputMethodV2* r, uint32_t id, wl_resource* surface) {
const auto RESOURCE = PROTO::ime->m_vPopups.emplace_back( const auto RESOURCE = PROTO::ime->m_popups.emplace_back(
makeShared<CInputMethodPopupV2>(makeShared<CZwpInputPopupSurfaceV2>(r->client(), r->version(), id), self.lock(), CWLSurfaceResource::fromResource(surface))); makeShared<CInputMethodPopupV2>(makeShared<CZwpInputPopupSurfaceV2>(r->client(), r->version(), id), m_self.lock(), CWLSurfaceResource::fromResource(surface)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::ime->m_vPopups.pop_back(); PROTO::ime->m_popups.pop_back();
return; return;
} }
LOGM(LOG, "New IME Popup with resource id {}", id); LOGM(LOG, "New IME Popup with resource id {}", id);
popups.emplace_back(RESOURCE); m_popups.emplace_back(RESOURCE);
events.newPopup.emit(RESOURCE); m_events.newPopup.emit(RESOURCE);
}); });
resource->setGrabKeyboard([this](CZwpInputMethodV2* r, uint32_t id) { m_resource->setGrabKeyboard([this](CZwpInputMethodV2* r, uint32_t id) {
const auto RESOURCE = const auto RESOURCE =
PROTO::ime->m_vGrabs.emplace_back(makeShared<CInputMethodKeyboardGrabV2>(makeShared<CZwpInputMethodKeyboardGrabV2>(r->client(), r->version(), id), self.lock())); PROTO::ime->m_grabs.emplace_back(makeShared<CInputMethodKeyboardGrabV2>(makeShared<CZwpInputMethodKeyboardGrabV2>(r->client(), r->version(), id), m_self.lock()));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::ime->m_vGrabs.pop_back(); PROTO::ime->m_grabs.pop_back();
return; return;
} }
LOGM(LOG, "New IME Grab with resource id {}", id); LOGM(LOG, "New IME Grab with resource id {}", id);
grabs.emplace_back(RESOURCE); m_grabs.emplace_back(RESOURCE);
}); });
} }
CInputMethodV2::~CInputMethodV2() { CInputMethodV2::~CInputMethodV2() {
events.destroy.emit(); m_events.destroy.emit();
} }
bool CInputMethodV2::good() { bool CInputMethodV2::good() {
return resource->resource(); return m_resource->resource();
} }
void CInputMethodV2::activate() { void CInputMethodV2::activate() {
if (active) if (m_active)
return; return;
resource->sendActivate(); m_resource->sendActivate();
active = true; m_active = true;
} }
void CInputMethodV2::deactivate() { void CInputMethodV2::deactivate() {
if (!active) if (!m_active)
return; return;
resource->sendDeactivate(); m_resource->sendDeactivate();
active = false; m_active = false;
} }
void CInputMethodV2::surroundingText(const std::string& text, uint32_t cursor, uint32_t anchor) { void CInputMethodV2::surroundingText(const std::string& text, uint32_t cursor, uint32_t anchor) {
resource->sendSurroundingText(text.c_str(), cursor, anchor); m_resource->sendSurroundingText(text.c_str(), cursor, anchor);
} }
void CInputMethodV2::textChangeCause(zwpTextInputV3ChangeCause changeCause) { void CInputMethodV2::textChangeCause(zwpTextInputV3ChangeCause changeCause) {
resource->sendTextChangeCause((uint32_t)changeCause); m_resource->sendTextChangeCause((uint32_t)changeCause);
} }
void CInputMethodV2::textContentType(zwpTextInputV3ContentHint hint, zwpTextInputV3ContentPurpose purpose) { void CInputMethodV2::textContentType(zwpTextInputV3ContentHint hint, zwpTextInputV3ContentPurpose purpose) {
resource->sendContentType((uint32_t)hint, (uint32_t)purpose); m_resource->sendContentType((uint32_t)hint, (uint32_t)purpose);
} }
void CInputMethodV2::done() { void CInputMethodV2::done() {
resource->sendDone(); m_resource->sendDone();
} }
void CInputMethodV2::unavailable() { void CInputMethodV2::unavailable() {
resource->sendUnavailable(); m_resource->sendUnavailable();
} }
bool CInputMethodV2::hasGrab() { bool CInputMethodV2::hasGrab() {
return !grabs.empty(); return !m_grabs.empty();
} }
wl_client* CInputMethodV2::grabClient() { wl_client* CInputMethodV2::grabClient() {
if (grabs.empty()) if (m_grabs.empty())
return nullptr; return nullptr;
for (auto const& gw : grabs) { for (auto const& gw : m_grabs) {
auto g = gw.lock(); auto g = gw.lock();
if (!g) if (!g)
@ -278,19 +279,19 @@ wl_client* CInputMethodV2::grabClient() {
} }
void CInputMethodV2::sendInputRectangle(const CBox& box) { void CInputMethodV2::sendInputRectangle(const CBox& box) {
inputRectangle = box; m_inputRectangle = box;
for (auto const& wp : popups) { for (auto const& wp : m_popups) {
auto p = wp.lock(); auto p = wp.lock();
if (!p) if (!p)
continue; continue;
p->sendInputRectangle(inputRectangle); p->sendInputRectangle(m_inputRectangle);
} }
} }
void CInputMethodV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) { void CInputMethodV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) {
for (auto const& gw : grabs) { for (auto const& gw : m_grabs) {
auto g = gw.lock(); auto g = gw.lock();
if (!g) if (!g)
@ -301,7 +302,7 @@ void CInputMethodV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state
} }
void CInputMethodV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { void CInputMethodV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
for (auto const& gw : grabs) { for (auto const& gw : m_grabs) {
auto g = gw.lock(); auto g = gw.lock();
if (!g) if (!g)
@ -312,7 +313,7 @@ void CInputMethodV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t loc
} }
void CInputMethodV2::setKeyboard(SP<IKeyboard> keyboard) { void CInputMethodV2::setKeyboard(SP<IKeyboard> keyboard) {
for (auto const& gw : grabs) { for (auto const& gw : m_grabs) {
auto g = gw.lock(); auto g = gw.lock();
if (!g) if (!g)
@ -323,7 +324,7 @@ void CInputMethodV2::setKeyboard(SP<IKeyboard> keyboard) {
} }
wl_client* CInputMethodV2::client() { wl_client* CInputMethodV2::client() {
return resource->client(); return m_resource->client();
} }
CInputMethodV2Protocol::CInputMethodV2Protocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CInputMethodV2Protocol::CInputMethodV2Protocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -331,7 +332,7 @@ CInputMethodV2Protocol::CInputMethodV2Protocol(const wl_interface* iface, const
} }
void CInputMethodV2Protocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CInputMethodV2Protocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwpInputMethodManagerV2>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwpInputMethodManagerV2>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CZwpInputMethodManagerV2* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CZwpInputMethodManagerV2* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CZwpInputMethodManagerV2* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setDestroy([this](CZwpInputMethodManagerV2* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@ -339,33 +340,33 @@ void CInputMethodV2Protocol::bindManager(wl_client* client, void* data, uint32_t
} }
void CInputMethodV2Protocol::onManagerResourceDestroy(wl_resource* res) { void CInputMethodV2Protocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
} }
void CInputMethodV2Protocol::destroyResource(CInputMethodPopupV2* popup) { void CInputMethodV2Protocol::destroyResource(CInputMethodPopupV2* popup) {
std::erase_if(m_vPopups, [&](const auto& other) { return other.get() == popup; }); std::erase_if(m_popups, [&](const auto& other) { return other.get() == popup; });
} }
void CInputMethodV2Protocol::destroyResource(CInputMethodKeyboardGrabV2* grab) { void CInputMethodV2Protocol::destroyResource(CInputMethodKeyboardGrabV2* grab) {
std::erase_if(m_vGrabs, [&](const auto& other) { return other.get() == grab; }); std::erase_if(m_grabs, [&](const auto& other) { return other.get() == grab; });
} }
void CInputMethodV2Protocol::destroyResource(CInputMethodV2* ime) { void CInputMethodV2Protocol::destroyResource(CInputMethodV2* ime) {
std::erase_if(m_vIMEs, [&](const auto& other) { return other.get() == ime; }); std::erase_if(m_imes, [&](const auto& other) { return other.get() == ime; });
} }
void CInputMethodV2Protocol::onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource* seat, uint32_t id) { void CInputMethodV2Protocol::onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource* seat, uint32_t id) {
const auto RESOURCE = m_vIMEs.emplace_back(makeShared<CInputMethodV2>(makeShared<CZwpInputMethodV2>(mgr->client(), mgr->version(), id))); const auto RESOURCE = m_imes.emplace_back(makeShared<CInputMethodV2>(makeShared<CZwpInputMethodV2>(mgr->client(), mgr->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
mgr->noMemory(); mgr->noMemory();
m_vIMEs.pop_back(); m_imes.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
LOGM(LOG, "New IME with resource id {}", id); LOGM(LOG, "New IME with resource id {}", id);
events.newIME.emit(RESOURCE); m_events.newIME.emit(RESOURCE);
} }

View File

@ -21,7 +21,7 @@ class CInputMethodV2 {
CSignal onCommit; CSignal onCommit;
CSignal destroy; CSignal destroy;
CSignal newPopup; CSignal newPopup;
} events; } m_events;
struct SState { struct SState {
void reset(); void reset();
@ -43,7 +43,8 @@ class CInputMethodV2 {
} deleteSurrounding; } deleteSurrounding;
}; };
SState pending, current; SState m_pending;
SState m_current;
bool good(); bool good();
void activate(); void activate();
@ -64,15 +65,15 @@ class CInputMethodV2 {
wl_client* grabClient(); wl_client* grabClient();
private: private:
SP<CZwpInputMethodV2> resource; SP<CZwpInputMethodV2> m_resource;
std::vector<WP<CInputMethodKeyboardGrabV2>> grabs; std::vector<WP<CInputMethodKeyboardGrabV2>> m_grabs;
std::vector<WP<CInputMethodPopupV2>> popups; std::vector<WP<CInputMethodPopupV2>> m_popups;
WP<CInputMethodV2> self; WP<CInputMethodV2> m_self;
bool active = false; bool m_active = false;
CBox inputRectangle; CBox m_inputRectangle;
friend class CInputMethodPopupV2; friend class CInputMethodPopupV2;
friend class CInputMethodKeyboardGrabV2; friend class CInputMethodKeyboardGrabV2;
@ -93,10 +94,10 @@ class CInputMethodKeyboardGrabV2 {
void sendKeyboardData(SP<IKeyboard> keyboard); void sendKeyboardData(SP<IKeyboard> keyboard);
private: private:
SP<CZwpInputMethodKeyboardGrabV2> resource; SP<CZwpInputMethodKeyboardGrabV2> m_resource;
WP<CInputMethodV2> owner; WP<CInputMethodV2> m_owner;
WP<IKeyboard> pLastKeyboard; WP<IKeyboard> m_lastKeyboard;
}; };
class CInputMethodPopupV2 { class CInputMethodPopupV2 {
@ -113,19 +114,19 @@ class CInputMethodPopupV2 {
CSignal unmap; CSignal unmap;
CSignal commit; CSignal commit;
CSignal destroy; CSignal destroy;
} events; } m_events;
bool mapped = false; bool m_mapped = false;
private: private:
SP<CZwpInputPopupSurfaceV2> resource; SP<CZwpInputPopupSurfaceV2> m_resource;
WP<CInputMethodV2> owner; WP<CInputMethodV2> m_owner;
WP<CWLSurfaceResource> pSurface; WP<CWLSurfaceResource> m_surface;
struct { struct {
CHyprSignalListener destroySurface; CHyprSignalListener destroySurface;
CHyprSignalListener commitSurface; CHyprSignalListener commitSurface;
} listeners; } m_listeners;
}; };
class CInputMethodV2Protocol : public IWaylandProtocol { class CInputMethodV2Protocol : public IWaylandProtocol {
@ -136,7 +137,7 @@ class CInputMethodV2Protocol : public IWaylandProtocol {
struct { struct {
CSignal newIME; // SP<CInputMethodV2> CSignal newIME; // SP<CInputMethodV2>
} events; } m_events;
private: private:
void onManagerResourceDestroy(wl_resource* res); void onManagerResourceDestroy(wl_resource* res);
@ -147,10 +148,10 @@ class CInputMethodV2Protocol : public IWaylandProtocol {
void onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource* seat, uint32_t id); void onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource* seat, uint32_t id);
// //
std::vector<UP<CZwpInputMethodManagerV2>> m_vManagers; std::vector<UP<CZwpInputMethodManagerV2>> m_managers;
std::vector<SP<CInputMethodV2>> m_vIMEs; std::vector<SP<CInputMethodV2>> m_imes;
std::vector<SP<CInputMethodKeyboardGrabV2>> m_vGrabs; std::vector<SP<CInputMethodKeyboardGrabV2>> m_grabs;
std::vector<SP<CInputMethodPopupV2>> m_vPopups; std::vector<SP<CInputMethodPopupV2>> m_popups;
friend class CInputMethodPopupV2; friend class CInputMethodPopupV2;
friend class CInputMethodKeyboardGrabV2; friend class CInputMethodKeyboardGrabV2;

View File

@ -17,107 +17,107 @@ void CLayerShellResource::SState::reset() {
} }
CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, PHLMONITOR pMonitor, CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, PHLMONITOR pMonitor,
zwlrLayerShellV1Layer layer) : layerNamespace(namespace_), surface(surf_), resource(resource_) { zwlrLayerShellV1Layer layer) : m_layerNamespace(namespace_), m_surface(surf_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
current.layer = layer; m_current.layer = layer;
monitor = pMonitor ? pMonitor->m_name : ""; m_monitor = pMonitor ? pMonitor->m_name : "";
resource->setDestroy([this](CZwlrLayerSurfaceV1* r) { m_resource->setDestroy([this](CZwlrLayerSurfaceV1* r) {
events.destroy.emit(); m_events.destroy.emit();
PROTO::layerShell->destroyResource(this); PROTO::layerShell->destroyResource(this);
}); });
resource->setOnDestroy([this](CZwlrLayerSurfaceV1* r) { m_resource->setOnDestroy([this](CZwlrLayerSurfaceV1* r) {
events.destroy.emit(); m_events.destroy.emit();
PROTO::layerShell->destroyResource(this); PROTO::layerShell->destroyResource(this);
}); });
listeners.destroySurface = surf_->m_events.destroy.registerListener([this](std::any d) { m_listeners.destroySurface = surf_->m_events.destroy.registerListener([this](std::any d) {
events.destroy.emit(); m_events.destroy.emit();
PROTO::layerShell->destroyResource(this); PROTO::layerShell->destroyResource(this);
}); });
listeners.unmapSurface = surf_->m_events.unmap.registerListener([this](std::any d) { events.unmap.emit(); }); m_listeners.unmapSurface = surf_->m_events.unmap.registerListener([this](std::any d) { m_events.unmap.emit(); });
listeners.commitSurface = surf_->m_events.commit.registerListener([this](std::any d) { m_listeners.commitSurface = surf_->m_events.commit.registerListener([this](std::any d) {
current = pending; m_current = m_pending;
pending.committed = 0; m_pending.committed = 0;
bool attachedBuffer = surface->m_current.texture; bool attachedBuffer = m_surface->m_current.texture;
if (attachedBuffer && !configured) { if (attachedBuffer && !m_configured) {
surface->error(-1, "layerSurface was not configured, but a buffer was attached"); m_surface->error(-1, "layerSurface was not configured, but a buffer was attached");
return; return;
} }
constexpr uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; constexpr uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
constexpr uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; constexpr uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
if (current.desiredSize.x <= 0 && (current.anchor & horiz) != horiz) { if (m_current.desiredSize.x <= 0 && (m_current.anchor & horiz) != horiz) {
surface->error(-1, "x == 0 but anchor doesn't have left and right"); m_surface->error(-1, "x == 0 but anchor doesn't have left and right");
return; return;
} }
if (current.desiredSize.y <= 0 && (current.anchor & vert) != vert) { if (m_current.desiredSize.y <= 0 && (m_current.anchor & vert) != vert) {
surface->error(-1, "y == 0 but anchor doesn't have top and bottom"); m_surface->error(-1, "y == 0 but anchor doesn't have top and bottom");
return; return;
} }
if (attachedBuffer && !mapped) { if (attachedBuffer && !m_mapped) {
mapped = true; m_mapped = true;
surface->map(); m_surface->map();
events.map.emit(); m_events.map.emit();
return; return;
} }
if (!attachedBuffer && mapped) { if (!attachedBuffer && m_mapped) {
mapped = false; m_mapped = false;
events.unmap.emit(); m_events.unmap.emit();
surface->unmap(); m_surface->unmap();
configured = false; m_configured = false;
return; return;
} }
events.commit.emit(); m_events.commit.emit();
}); });
resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) { m_resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) {
pending.committed |= STATE_SIZE; m_pending.committed |= STATE_SIZE;
pending.desiredSize = {(int)x, (int)y}; m_pending.desiredSize = {(int)x, (int)y};
}); });
resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { m_resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {
if (anchor > (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { if (anchor > (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) {
r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR, "Invalid anchor"); r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR, "Invalid anchor");
return; return;
} }
pending.committed |= STATE_ANCHOR; m_pending.committed |= STATE_ANCHOR;
pending.anchor = anchor; m_pending.anchor = anchor;
}); });
resource->setSetExclusiveZone([this](CZwlrLayerSurfaceV1* r, int32_t zone) { m_resource->setSetExclusiveZone([this](CZwlrLayerSurfaceV1* r, int32_t zone) {
pending.committed |= STATE_EXCLUSIVE; m_pending.committed |= STATE_EXCLUSIVE;
pending.exclusive = zone; m_pending.exclusive = zone;
}); });
resource->setSetMargin([this](CZwlrLayerSurfaceV1* r, int32_t top, int32_t right, int32_t bottom, int32_t left) { m_resource->setSetMargin([this](CZwlrLayerSurfaceV1* r, int32_t top, int32_t right, int32_t bottom, int32_t left) {
pending.committed |= STATE_MARGIN; m_pending.committed |= STATE_MARGIN;
pending.margin = {left, right, top, bottom}; m_pending.margin = {left, right, top, bottom};
}); });
resource->setSetKeyboardInteractivity([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1KeyboardInteractivity kbi) { m_resource->setSetKeyboardInteractivity([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1KeyboardInteractivity kbi) {
if (kbi > ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) { if (kbi > ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) {
r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_KEYBOARD_INTERACTIVITY, "Invalid keyboard interactivity"); r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_KEYBOARD_INTERACTIVITY, "Invalid keyboard interactivity");
return; return;
} }
pending.committed |= STATE_INTERACTIVITY; m_pending.committed |= STATE_INTERACTIVITY;
pending.interactivity = kbi; m_pending.interactivity = kbi;
}); });
resource->setGetPopup([this](CZwlrLayerSurfaceV1* r, wl_resource* popup_) { m_resource->setGetPopup([this](CZwlrLayerSurfaceV1* r, wl_resource* popup_) {
auto popup = CXDGPopupResource::fromResource(popup_); auto popup = CXDGPopupResource::fromResource(popup_);
if (popup->taken) { if (popup->taken) {
@ -126,74 +126,74 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
} }
popup->taken = true; popup->taken = true;
events.newPopup.emit(popup); m_events.newPopup.emit(popup);
}); });
resource->setAckConfigure([this](CZwlrLayerSurfaceV1* r, uint32_t serial) { m_resource->setAckConfigure([this](CZwlrLayerSurfaceV1* r, uint32_t serial) {
auto serialFound = std::find_if(serials.begin(), serials.end(), [serial](const auto& e) { return e.first == serial; }); auto serialFound = std::find_if(m_serials.begin(), m_serials.end(), [serial](const auto& e) { return e.first == serial; });
if (serialFound == serials.end()) { if (serialFound == m_serials.end()) {
r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE, "Serial invalid in ack_configure"); r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE, "Serial invalid in ack_configure");
return; return;
} }
configured = true; m_configured = true;
size = serialFound->second; m_size = serialFound->second;
serials.erase(serialFound); m_serials.erase(serialFound);
}); });
resource->setSetLayer([this](CZwlrLayerSurfaceV1* r, uint32_t layer) { m_resource->setSetLayer([this](CZwlrLayerSurfaceV1* r, uint32_t layer) {
if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) { if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) {
r->error(ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER, "Invalid layer"); r->error(ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER, "Invalid layer");
return; return;
} }
pending.committed |= STATE_LAYER; m_pending.committed |= STATE_LAYER;
pending.layer = (zwlrLayerShellV1Layer)layer; m_pending.layer = (zwlrLayerShellV1Layer)layer;
}); });
resource->setSetExclusiveEdge([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { m_resource->setSetExclusiveEdge([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {
if (anchor > (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { if (anchor > (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) {
r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Invalid exclusive edge"); r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Invalid exclusive edge");
return; return;
} }
if (anchor && (!pending.anchor || !(pending.anchor & anchor))) { if (anchor && (!m_pending.anchor || !(m_pending.anchor & anchor))) {
r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Exclusive edge doesn't align with anchor"); r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Exclusive edge doesn't align with anchor");
return; return;
} }
pending.committed |= STATE_EDGE; m_pending.committed |= STATE_EDGE;
pending.exclusiveEdge = anchor; m_pending.exclusiveEdge = anchor;
}); });
} }
CLayerShellResource::~CLayerShellResource() { CLayerShellResource::~CLayerShellResource() {
events.destroy.emit(); m_events.destroy.emit();
if (surface) if (m_surface)
surface->resetRole(); m_surface->resetRole();
} }
bool CLayerShellResource::good() { bool CLayerShellResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CLayerShellResource::sendClosed() { void CLayerShellResource::sendClosed() {
if (closed) if (m_closed)
return; return;
closed = true; m_closed = true;
resource->sendClosed(); m_resource->sendClosed();
} }
void CLayerShellResource::configure(const Vector2D& size_) { void CLayerShellResource::configure(const Vector2D& size_) {
size = size_; m_size = size_;
auto serial = wl_display_next_serial(g_pCompositor->m_wlDisplay); auto serial = wl_display_next_serial(g_pCompositor->m_wlDisplay);
serials.push_back({serial, size_}); m_serials.push_back({serial, size_});
resource->sendConfigure(serial, size_.x, size_.y); m_resource->sendConfigure(serial, size_.x, size_.y);
} }
CLayerShellProtocol::CLayerShellProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CLayerShellProtocol::CLayerShellProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -201,7 +201,7 @@ CLayerShellProtocol::CLayerShellProtocol(const wl_interface* iface, const int& v
} }
void CLayerShellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CLayerShellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwlrLayerShellV1>(client, ver, id)).get(); const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwlrLayerShellV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CZwlrLayerShellV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setOnDestroy([this](CZwlrLayerShellV1* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CZwlrLayerShellV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); RESOURCE->setDestroy([this](CZwlrLayerShellV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@ -211,11 +211,11 @@ void CLayerShellProtocol::bindManager(wl_client* client, void* data, uint32_t ve
} }
void CLayerShellProtocol::onManagerResourceDestroy(wl_resource* res) { void CLayerShellProtocol::onManagerResourceDestroy(wl_resource* res) {
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
} }
void CLayerShellProtocol::destroyResource(CLayerShellResource* surf) { void CLayerShellProtocol::destroyResource(CLayerShellResource* surf) {
std::erase_if(m_vLayers, [&](const auto& other) { return other.get() == surf; }); std::erase_if(m_layers, [&](const auto& other) { return other.get() == surf; });
} }
void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_) { void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_) {
@ -238,11 +238,11 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id
return; return;
} }
const auto RESOURCE = m_vLayers.emplace_back(makeShared<CLayerShellResource>(makeShared<CZwlrLayerSurfaceV1>(CLIENT, pMgr->version(), id), SURF, namespace_, PMONITOR, layer)); const auto RESOURCE = m_layers.emplace_back(makeShared<CLayerShellResource>(makeShared<CZwlrLayerSurfaceV1>(CLIENT, pMgr->version(), id), SURF, namespace_, PMONITOR, layer));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory(); pMgr->noMemory();
m_vLayers.pop_back(); m_layers.pop_back();
return; return;
} }
@ -252,6 +252,6 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id
LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get()); LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get());
} }
CLayerShellRole::CLayerShellRole(SP<CLayerShellResource> ls) : layerSurface(ls) { CLayerShellRole::CLayerShellRole(SP<CLayerShellResource> ls) : m_layerSurface(ls) {
; ;
} }

View File

@ -21,8 +21,9 @@ class CLayerShellRole : public ISurfaceRole {
return SURFACE_ROLE_LAYER_SHELL; return SURFACE_ROLE_LAYER_SHELL;
} }
WP<CLayerShellResource> layerSurface; WP<CLayerShellResource> m_layerSurface;
}; };
class CLayerShellResource { class CLayerShellResource {
public: public:
CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, PHLMONITOR pMonitor, zwlrLayerShellV1Layer layer); CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, PHLMONITOR pMonitor, zwlrLayerShellV1Layer layer);
@ -48,7 +49,7 @@ class CLayerShellResource {
CSignal map; CSignal map;
CSignal unmap; CSignal unmap;
CSignal newPopup; // wlr_xdg_popup* CSignal newPopup; // wlr_xdg_popup*
} events; } m_events;
struct SState { struct SState {
uint32_t anchor = 0; uint32_t anchor = 0;
@ -64,27 +65,27 @@ class CLayerShellResource {
} margin; } margin;
void reset(); void reset();
} current, pending; } m_current, m_pending;
Vector2D size; Vector2D m_size;
std::string layerNamespace; std::string m_layerNamespace;
std::string monitor = ""; std::string m_monitor = "";
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
bool mapped = false; bool m_mapped = false;
bool configured = false; bool m_configured = false;
private: private:
SP<CZwlrLayerSurfaceV1> resource; SP<CZwlrLayerSurfaceV1> m_resource;
struct { struct {
CHyprSignalListener commitSurface; CHyprSignalListener commitSurface;
CHyprSignalListener destroySurface; CHyprSignalListener destroySurface;
CHyprSignalListener unmapSurface; CHyprSignalListener unmapSurface;
} listeners; } m_listeners;
bool closed = false; bool m_closed = false;
std::vector<std::pair<uint32_t, Vector2D>> serials; std::vector<std::pair<uint32_t, Vector2D>> m_serials;
}; };
class CLayerShellProtocol : public IWaylandProtocol { class CLayerShellProtocol : public IWaylandProtocol {
@ -99,8 +100,8 @@ class CLayerShellProtocol : public IWaylandProtocol {
void onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_); void onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_);
// //
std::vector<UP<CZwlrLayerShellV1>> m_vManagers; std::vector<UP<CZwlrLayerShellV1>> m_managers;
std::vector<SP<CLayerShellResource>> m_vLayers; std::vector<SP<CLayerShellResource>> m_layers;
friend class CLayerShellResource; friend class CLayerShellResource;
}; };

View File

@ -24,7 +24,7 @@ static std::optional<dev_t> devIDFromFD(int fd) {
} }
CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vector<std::pair<PHLMONITORREF, SDMABUFTranche>> tranches_) : CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vector<std::pair<PHLMONITORREF, SDMABUFTranche>> tranches_) :
rendererTranche(_rendererTranche), monitorTranches(tranches_) { m_rendererTranche(_rendererTranche), m_monitorTranches(tranches_) {
std::vector<SDMABUFFormatTableEntry> formatsVec; std::vector<SDMABUFFormatTableEntry> formatsVec;
std::set<std::pair<uint32_t, uint64_t>> formats; std::set<std::pair<uint32_t, uint64_t>> formats;
@ -32,14 +32,14 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
// insert formats into vec if they got inserted into set, meaning they're unique // insert formats into vec if they got inserted into set, meaning they're unique
size_t i = 0; size_t i = 0;
rendererTranche.indicies.clear(); m_rendererTranche.indicies.clear();
for (auto const& fmt : rendererTranche.formats) { for (auto const& fmt : m_rendererTranche.formats) {
for (auto const& mod : fmt.modifiers) { for (auto const& mod : fmt.modifiers) {
auto format = std::make_pair<>(fmt.drmFormat, mod); auto format = std::make_pair<>(fmt.drmFormat, mod);
auto [_, inserted] = formats.insert(format); auto [_, inserted] = formats.insert(format);
if (inserted) { if (inserted) {
// if it was inserted into set, then its unique and will have a new index in vec // if it was inserted into set, then its unique and will have a new index in vec
rendererTranche.indicies.push_back(i++); m_rendererTranche.indicies.push_back(i++);
formatsVec.push_back(SDMABUFFormatTableEntry{ formatsVec.push_back(SDMABUFFormatTableEntry{
.fmt = fmt.drmFormat, .fmt = fmt.drmFormat,
.modifier = mod, .modifier = mod,
@ -48,12 +48,12 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
// if it wasn't inserted then find its index in vec // if it wasn't inserted then find its index in vec
auto it = auto it =
std::find_if(formatsVec.begin(), formatsVec.end(), [fmt, mod](const SDMABUFFormatTableEntry& oth) { return oth.fmt == fmt.drmFormat && oth.modifier == mod; }); std::find_if(formatsVec.begin(), formatsVec.end(), [fmt, mod](const SDMABUFFormatTableEntry& oth) { return oth.fmt == fmt.drmFormat && oth.modifier == mod; });
rendererTranche.indicies.push_back(it - formatsVec.begin()); m_rendererTranche.indicies.push_back(it - formatsVec.begin());
} }
} }
} }
for (auto& [monitor, tranche] : monitorTranches) { for (auto& [monitor, tranche] : m_monitorTranches) {
tranche.indicies.clear(); tranche.indicies.clear();
for (auto const& fmt : tranche.formats) { for (auto const& fmt : tranche.formats) {
for (auto const& mod : fmt.modifiers) { for (auto const& mod : fmt.modifiers) {
@ -77,12 +77,12 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
} }
} }
tableSize = formatsVec.size() * sizeof(SDMABUFFormatTableEntry); m_tableSize = formatsVec.size() * sizeof(SDMABUFFormatTableEntry);
CFileDescriptor fds[2]; CFileDescriptor fds[2];
allocateSHMFilePair(tableSize, fds[0], fds[1]); allocateSHMFilePair(m_tableSize, fds[0], fds[1]);
auto arr = (SDMABUFFormatTableEntry*)mmap(nullptr, tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0); auto arr = (SDMABUFFormatTableEntry*)mmap(nullptr, m_tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0);
if (arr == MAP_FAILED) { if (arr == MAP_FAILED) {
LOGM(ERR, "mmap failed"); LOGM(ERR, "mmap failed");
@ -91,50 +91,50 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
std::copy(formatsVec.begin(), formatsVec.end(), arr); std::copy(formatsVec.begin(), formatsVec.end(), arr);
munmap(arr, tableSize); munmap(arr, m_tableSize);
tableFD = std::move(fds[1]); m_tableFD = std::move(fds[1]);
} }
CLinuxDMABuffer::CLinuxDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs) { CLinuxDMABuffer::CLinuxDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs) {
buffer = makeShared<CDMABuffer>(id, client, attrs); m_buffer = makeShared<CDMABuffer>(id, client, attrs);
buffer->m_resource->m_buffer = buffer; m_buffer->m_resource->m_buffer = m_buffer;
listeners.bufferResourceDestroy = buffer->events.destroy.registerListener([this](std::any d) { m_listeners.bufferResourceDestroy = m_buffer->events.destroy.registerListener([this](std::any d) {
listeners.bufferResourceDestroy.reset(); m_listeners.bufferResourceDestroy.reset();
PROTO::linuxDma->destroyResource(this); PROTO::linuxDma->destroyResource(this);
}); });
if (!buffer->m_success) if (!m_buffer->m_success)
LOGM(ERR, "Possibly compositor bug: buffer failed to create"); LOGM(ERR, "Possibly compositor bug: buffer failed to create");
} }
CLinuxDMABuffer::~CLinuxDMABuffer() { CLinuxDMABuffer::~CLinuxDMABuffer() {
if (buffer && buffer->m_resource) if (m_buffer && m_buffer->m_resource)
buffer->m_resource->sendRelease(); m_buffer->m_resource->sendRelease();
buffer.reset(); m_buffer.reset();
listeners.bufferResourceDestroy.reset(); m_listeners.bufferResourceDestroy.reset();
} }
bool CLinuxDMABuffer::good() { bool CLinuxDMABuffer::good() {
return buffer && buffer->good(); return m_buffer && m_buffer->good();
} }
CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP<CZwpLinuxBufferParamsV1> resource_) : resource(resource_) { CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP<CZwpLinuxBufferParamsV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); }); m_resource->setOnDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); });
resource->setDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); }); m_resource->setDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); });
attrs = makeShared<Aquamarine::SDMABUFAttrs>(); m_attrs = makeShared<Aquamarine::SDMABUFAttrs>();
attrs->success = true; m_attrs->success = true;
resource->setAdd([this](CZwpLinuxBufferParamsV1* r, int32_t fd, uint32_t plane, uint32_t offset, uint32_t stride, uint32_t modHi, uint32_t modLo) { m_resource->setAdd([this](CZwpLinuxBufferParamsV1* r, int32_t fd, uint32_t plane, uint32_t offset, uint32_t stride, uint32_t modHi, uint32_t modLo) {
if (used) { if (m_used) {
r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used"); r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used");
return; return;
} }
@ -144,19 +144,19 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP<CZwpLinuxBufferParamsV
return; return;
} }
if (attrs->fds.at(plane) != -1) { if (m_attrs->fds.at(plane) != -1) {
r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, "plane used"); r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, "plane used");
return; return;
} }
attrs->fds[plane] = fd; m_attrs->fds[plane] = fd;
attrs->strides[plane] = stride; m_attrs->strides[plane] = stride;
attrs->offsets[plane] = offset; m_attrs->offsets[plane] = offset;
attrs->modifier = ((uint64_t)modHi << 32) | modLo; m_attrs->modifier = ((uint64_t)modHi << 32) | modLo;
}); });
resource->setCreate([this](CZwpLinuxBufferParamsV1* r, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) { m_resource->setCreate([this](CZwpLinuxBufferParamsV1* r, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) {
if (used) { if (m_used) {
r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used"); r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used");
return; return;
} }
@ -167,15 +167,15 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP<CZwpLinuxBufferParamsV
return; return;
} }
attrs->size = {w, h}; m_attrs->size = {w, h};
attrs->format = fmt; m_attrs->format = fmt;
attrs->planes = 4 - std::count(attrs->fds.begin(), attrs->fds.end(), -1); m_attrs->planes = 4 - std::count(m_attrs->fds.begin(), m_attrs->fds.end(), -1);
create(0); create(0);
}); });
resource->setCreateImmed([this](CZwpLinuxBufferParamsV1* r, uint32_t id, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) { m_resource->setCreateImmed([this](CZwpLinuxBufferParamsV1* r, uint32_t id, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) {
if (used) { if (m_used) {
r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used"); r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used");
return; return;
} }
@ -186,20 +186,20 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP<CZwpLinuxBufferParamsV
return; return;
} }
attrs->size = {w, h}; m_attrs->size = {w, h};
attrs->format = fmt; m_attrs->format = fmt;
attrs->planes = 4 - std::count(attrs->fds.begin(), attrs->fds.end(), -1); m_attrs->planes = 4 - std::count(m_attrs->fds.begin(), m_attrs->fds.end(), -1);
create(id); create(id);
}); });
} }
bool CLinuxDMABUFParamsResource::good() { bool CLinuxDMABUFParamsResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CLinuxDMABUFParamsResource::create(uint32_t id) { void CLinuxDMABUFParamsResource::create(uint32_t id) {
used = true; m_used = true;
if UNLIKELY (!verify()) { if UNLIKELY (!verify()) {
LOGM(ERR, "Failed creating a dmabuf: verify() said no"); LOGM(ERR, "Failed creating a dmabuf: verify() said no");
@ -208,42 +208,42 @@ void CLinuxDMABUFParamsResource::create(uint32_t id) {
if UNLIKELY (!commence()) { if UNLIKELY (!commence()) {
LOGM(ERR, "Failed creating a dmabuf: commence() said no"); LOGM(ERR, "Failed creating a dmabuf: commence() said no");
resource->sendFailed(); m_resource->sendFailed();
return; return;
} }
LOGM(LOG, "Creating a dmabuf, with id {}: size {}, fmt {}, planes {}", id, attrs->size, NFormatUtils::drmFormatName(attrs->format), attrs->planes); LOGM(LOG, "Creating a dmabuf, with id {}: size {}, fmt {}, planes {}", id, m_attrs->size, NFormatUtils::drmFormatName(m_attrs->format), m_attrs->planes);
for (int i = 0; i < attrs->planes; ++i) { for (int i = 0; i < m_attrs->planes; ++i) {
LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs->modifier, attrs->fds[i], attrs->strides[i], attrs->offsets[i]); LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, m_attrs->modifier, m_attrs->fds[i], m_attrs->strides[i], m_attrs->offsets[i]);
} }
auto buf = PROTO::linuxDma->m_vBuffers.emplace_back(makeShared<CLinuxDMABuffer>(id, resource->client(), *attrs)); auto buf = PROTO::linuxDma->m_buffers.emplace_back(makeShared<CLinuxDMABuffer>(id, m_resource->client(), *m_attrs));
if UNLIKELY (!buf->good() || !buf->buffer->m_success) { if UNLIKELY (!buf->good() || !buf->m_buffer->m_success) {
resource->sendFailed(); m_resource->sendFailed();
PROTO::linuxDma->m_vBuffers.pop_back(); PROTO::linuxDma->m_buffers.pop_back();
return; return;
} }
if (!id) if (!id)
resource->sendCreated(PROTO::linuxDma->m_vBuffers.back()->buffer->m_resource->getResource()); m_resource->sendCreated(PROTO::linuxDma->m_buffers.back()->m_buffer->m_resource->getResource());
createdBuffer = buf; m_createdBuffer = buf;
} }
bool CLinuxDMABUFParamsResource::commence() { bool CLinuxDMABUFParamsResource::commence() {
if (!PROTO::linuxDma->mainDeviceFD.isValid()) if (!PROTO::linuxDma->m_mainDeviceFD.isValid())
return true; return true;
for (int i = 0; i < attrs->planes; i++) { for (int i = 0; i < m_attrs->planes; i++) {
uint32_t handle = 0; uint32_t handle = 0;
if (drmPrimeFDToHandle(PROTO::linuxDma->mainDeviceFD.get(), attrs->fds.at(i), &handle)) { if (drmPrimeFDToHandle(PROTO::linuxDma->m_mainDeviceFD.get(), m_attrs->fds.at(i), &handle)) {
LOGM(ERR, "Failed to import dmabuf fd"); LOGM(ERR, "Failed to import dmabuf fd");
return false; return false;
} }
if (drmCloseBufferHandle(PROTO::linuxDma->mainDeviceFD.get(), handle)) { if (drmCloseBufferHandle(PROTO::linuxDma->m_mainDeviceFD.get(), handle)) {
LOGM(ERR, "Failed to close dmabuf handle"); LOGM(ERR, "Failed to close dmabuf handle");
return false; return false;
} }
@ -253,20 +253,20 @@ bool CLinuxDMABUFParamsResource::commence() {
} }
bool CLinuxDMABUFParamsResource::verify() { bool CLinuxDMABUFParamsResource::verify() {
if UNLIKELY (attrs->planes <= 0) { if UNLIKELY (m_attrs->planes <= 0) {
resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No planes added"); m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No planes added");
return false; return false;
} }
if UNLIKELY (attrs->fds.at(0) < 0) { if UNLIKELY (m_attrs->fds.at(0) < 0) {
resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No plane 0"); m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No plane 0");
return false; return false;
} }
bool empty = false; bool empty = false;
for (auto const& plane : attrs->fds) { for (auto const& plane : m_attrs->fds) {
if (empty && plane != -1) { if (empty && plane != -1) {
resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT, "Gap in planes"); m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT, "Gap in planes");
return false; return false;
} }
@ -276,16 +276,16 @@ bool CLinuxDMABUFParamsResource::verify() {
} }
} }
if UNLIKELY (attrs->size.x < 1 || attrs->size.y < 1) { if UNLIKELY (m_attrs->size.x < 1 || m_attrs->size.y < 1) {
resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS, "x/y < 1"); m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS, "x/y < 1");
return false; return false;
} }
for (size_t i = 0; i < (size_t)attrs->planes; ++i) { for (size_t i = 0; i < (size_t)m_attrs->planes; ++i) {
if ((uint64_t)attrs->offsets.at(i) + (uint64_t)attrs->strides.at(i) * attrs->size.y > UINT32_MAX) { if ((uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i) * m_attrs->size.y > UINT32_MAX) {
resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS, m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, (uint64_t)attrs->offsets.at(i), std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, (uint64_t)m_attrs->offsets.at(i),
(uint64_t)attrs->strides.at(i), attrs->size.y, (uint64_t)attrs->offsets.at(i) + (uint64_t)attrs->strides.at(i))); (uint64_t)m_attrs->strides.at(i), m_attrs->size.y, (uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i)));
return false; return false;
} }
} }
@ -293,20 +293,20 @@ bool CLinuxDMABUFParamsResource::verify() {
return true; return true;
} }
CLinuxDMABUFFeedbackResource::CLinuxDMABUFFeedbackResource(SP<CZwpLinuxDmabufFeedbackV1> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) { CLinuxDMABUFFeedbackResource::CLinuxDMABUFFeedbackResource(SP<CZwpLinuxDmabufFeedbackV1> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); }); m_resource->setOnDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); });
resource->setDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); }); m_resource->setDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); });
auto& formatTable = PROTO::linuxDma->formatTable; auto& formatTable = PROTO::linuxDma->m_formatTable;
resource->sendFormatTable(formatTable->tableFD.get(), formatTable->tableSize); m_resource->sendFormatTable(formatTable->m_tableFD.get(), formatTable->m_tableSize);
sendDefaultFeedback(); sendDefaultFeedback();
} }
bool CLinuxDMABUFFeedbackResource::good() { bool CLinuxDMABUFFeedbackResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) { void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) {
@ -314,95 +314,95 @@ void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) {
.size = sizeof(tranche.device), .size = sizeof(tranche.device),
.data = (void*)&tranche.device, .data = (void*)&tranche.device,
}; };
resource->sendTrancheTargetDevice(&deviceArr); m_resource->sendTrancheTargetDevice(&deviceArr);
resource->sendTrancheFlags((zwpLinuxDmabufFeedbackV1TrancheFlags)tranche.flags); m_resource->sendTrancheFlags((zwpLinuxDmabufFeedbackV1TrancheFlags)tranche.flags);
wl_array indices = { wl_array indices = {
.size = tranche.indicies.size() * sizeof(tranche.indicies.at(0)), .size = tranche.indicies.size() * sizeof(tranche.indicies.at(0)),
.data = tranche.indicies.data(), .data = tranche.indicies.data(),
}; };
resource->sendTrancheFormats(&indices); m_resource->sendTrancheFormats(&indices);
resource->sendTrancheDone(); m_resource->sendTrancheDone();
} }
// default tranche is based on renderer (egl) // default tranche is based on renderer (egl)
void CLinuxDMABUFFeedbackResource::sendDefaultFeedback() { void CLinuxDMABUFFeedbackResource::sendDefaultFeedback() {
auto mainDevice = PROTO::linuxDma->mainDevice; auto mainDevice = PROTO::linuxDma->m_mainDevice;
auto& formatTable = PROTO::linuxDma->formatTable; auto& formatTable = PROTO::linuxDma->m_formatTable;
struct wl_array deviceArr = { struct wl_array deviceArr = {
.size = sizeof(mainDevice), .size = sizeof(mainDevice),
.data = (void*)&mainDevice, .data = (void*)&mainDevice,
}; };
resource->sendMainDevice(&deviceArr); m_resource->sendMainDevice(&deviceArr);
sendTranche(formatTable->rendererTranche); sendTranche(formatTable->m_rendererTranche);
resource->sendDone(); m_resource->sendDone();
lastFeedbackWasScanout = false; m_lastFeedbackWasScanout = false;
} }
CLinuxDMABUFResource::CLinuxDMABUFResource(SP<CZwpLinuxDmabufV1> resource_) : resource(resource_) { CLinuxDMABUFResource::CLinuxDMABUFResource(SP<CZwpLinuxDmabufV1> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); }); m_resource->setOnDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); });
resource->setDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); }); m_resource->setDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); });
resource->setGetDefaultFeedback([](CZwpLinuxDmabufV1* r, uint32_t id) { m_resource->setGetDefaultFeedback([](CZwpLinuxDmabufV1* r, uint32_t id) {
const auto RESOURCE = const auto RESOURCE =
PROTO::linuxDma->m_vFeedbacks.emplace_back(makeShared<CLinuxDMABUFFeedbackResource>(makeShared<CZwpLinuxDmabufFeedbackV1>(r->client(), r->version(), id), nullptr)); PROTO::linuxDma->m_feedbacks.emplace_back(makeShared<CLinuxDMABUFFeedbackResource>(makeShared<CZwpLinuxDmabufFeedbackV1>(r->client(), r->version(), id), nullptr));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::linuxDma->m_vFeedbacks.pop_back(); PROTO::linuxDma->m_feedbacks.pop_back();
return; return;
} }
}); });
resource->setGetSurfaceFeedback([](CZwpLinuxDmabufV1* r, uint32_t id, wl_resource* surf) { m_resource->setGetSurfaceFeedback([](CZwpLinuxDmabufV1* r, uint32_t id, wl_resource* surf) {
const auto RESOURCE = PROTO::linuxDma->m_vFeedbacks.emplace_back( const auto RESOURCE = PROTO::linuxDma->m_feedbacks.emplace_back(
makeShared<CLinuxDMABUFFeedbackResource>(makeShared<CZwpLinuxDmabufFeedbackV1>(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surf))); makeShared<CLinuxDMABUFFeedbackResource>(makeShared<CZwpLinuxDmabufFeedbackV1>(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surf)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::linuxDma->m_vFeedbacks.pop_back(); PROTO::linuxDma->m_feedbacks.pop_back();
return; return;
} }
}); });
resource->setCreateParams([](CZwpLinuxDmabufV1* r, uint32_t id) { m_resource->setCreateParams([](CZwpLinuxDmabufV1* r, uint32_t id) {
const auto RESOURCE = PROTO::linuxDma->m_vParams.emplace_back(makeShared<CLinuxDMABUFParamsResource>(makeShared<CZwpLinuxBufferParamsV1>(r->client(), r->version(), id))); const auto RESOURCE = PROTO::linuxDma->m_params.emplace_back(makeShared<CLinuxDMABUFParamsResource>(makeShared<CZwpLinuxBufferParamsV1>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::linuxDma->m_vParams.pop_back(); PROTO::linuxDma->m_params.pop_back();
return; return;
} }
}); });
if (resource->version() < 4) if (m_resource->version() < 4)
sendMods(); sendMods();
} }
bool CLinuxDMABUFResource::good() { bool CLinuxDMABUFResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CLinuxDMABUFResource::sendMods() { void CLinuxDMABUFResource::sendMods() {
for (auto const& fmt : PROTO::linuxDma->formatTable->rendererTranche.formats) { for (auto const& fmt : PROTO::linuxDma->m_formatTable->m_rendererTranche.formats) {
for (auto const& mod : fmt.modifiers) { for (auto const& mod : fmt.modifiers) {
if (resource->version() < 3) { if (m_resource->version() < 3) {
if (mod == DRM_FORMAT_MOD_INVALID || mod == DRM_FORMAT_MOD_LINEAR) if (mod == DRM_FORMAT_MOD_INVALID || mod == DRM_FORMAT_MOD_LINEAR)
resource->sendFormat(fmt.drmFormat); m_resource->sendFormat(fmt.drmFormat);
continue; continue;
} }
// TODO: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1166 // TODO: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1166
resource->sendModifier(fmt.drmFormat, mod >> 32, mod & 0xFFFFFFFF); m_resource->sendModifier(fmt.drmFormat, mod >> 32, mod & 0xFFFFFFFF);
} }
} }
} }
@ -418,10 +418,10 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
return; return;
} }
mainDevice = *dev; m_mainDevice = *dev;
SDMABUFTranche eglTranche = { SDMABUFTranche eglTranche = {
.device = mainDevice, .device = m_mainDevice,
.flags = 0, // renderer isnt for ds so dont set flag. .flags = 0, // renderer isnt for ds so dont set flag.
.formats = g_pHyprOpenGL->getDRMFormats(), .formats = g_pHyprOpenGL->getDRMFormats(),
}; };
@ -434,7 +434,7 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
for (auto const& mon : g_pCompositor->m_monitors) { for (auto const& mon : g_pCompositor->m_monitors) {
auto tranche = SDMABUFTranche{ auto tranche = SDMABUFTranche{
.device = mainDevice, .device = m_mainDevice,
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
.formats = mon->m_output->getRenderFormats(), .formats = mon->m_output->getRenderFormats(),
}; };
@ -444,25 +444,25 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
static auto monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) { static auto monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
auto pMonitor = std::any_cast<PHLMONITOR>(param); auto pMonitor = std::any_cast<PHLMONITOR>(param);
auto tranche = SDMABUFTranche{ auto tranche = SDMABUFTranche{
.device = mainDevice, .device = m_mainDevice,
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
.formats = pMonitor->m_output->getRenderFormats(), .formats = pMonitor->m_output->getRenderFormats(),
}; };
formatTable->monitorTranches.emplace_back(std::make_pair<>(pMonitor, tranche)); m_formatTable->m_monitorTranches.emplace_back(std::make_pair<>(pMonitor, tranche));
resetFormatTable(); resetFormatTable();
}); });
static auto monitorRemoved = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) { static auto monitorRemoved = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
auto pMonitor = std::any_cast<PHLMONITOR>(param); auto pMonitor = std::any_cast<PHLMONITOR>(param);
std::erase_if(formatTable->monitorTranches, [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; }); std::erase_if(m_formatTable->m_monitorTranches, [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; });
resetFormatTable(); resetFormatTable();
}); });
} }
formatTable = makeUnique<CDMABUFFormatTable>(eglTranche, tches); m_formatTable = makeUnique<CDMABUFFormatTable>(eglTranche, tches);
drmDevice* device = nullptr; drmDevice* device = nullptr;
if (drmGetDeviceFromDevId(mainDevice, 0, &device) != 0) { if (drmGetDeviceFromDevId(m_mainDevice, 0, &device) != 0) {
LOGM(ERR, "failed to get drm dev, disabling linux dmabuf"); LOGM(ERR, "failed to get drm dev, disabling linux dmabuf");
removeGlobal(); removeGlobal();
return; return;
@ -470,9 +470,9 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
if (device->available_nodes & (1 << DRM_NODE_RENDER)) { if (device->available_nodes & (1 << DRM_NODE_RENDER)) {
const char* name = device->nodes[DRM_NODE_RENDER]; const char* name = device->nodes[DRM_NODE_RENDER];
mainDeviceFD = CFileDescriptor{open(name, O_RDWR | O_CLOEXEC)}; m_mainDeviceFD = CFileDescriptor{open(name, O_RDWR | O_CLOEXEC)};
drmFreeDevice(&device); drmFreeDevice(&device);
if (!mainDeviceFD.isValid()) { if (!m_mainDeviceFD.isValid()) {
LOGM(ERR, "failed to open drm dev, disabling linux dmabuf"); LOGM(ERR, "failed to open drm dev, disabling linux dmabuf");
removeGlobal(); removeGlobal();
return; return;
@ -485,19 +485,19 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
} }
void CLinuxDMABufV1Protocol::resetFormatTable() { void CLinuxDMABufV1Protocol::resetFormatTable() {
if (!formatTable) if (!m_formatTable)
return; return;
LOGM(LOG, "Resetting format table"); LOGM(LOG, "Resetting format table");
// this might be a big copy // this might be a big copy
auto newFormatTable = makeUnique<CDMABUFFormatTable>(formatTable->rendererTranche, formatTable->monitorTranches); auto newFormatTable = makeUnique<CDMABUFFormatTable>(m_formatTable->m_rendererTranche, m_formatTable->m_monitorTranches);
for (auto const& feedback : m_vFeedbacks) { for (auto const& feedback : m_feedbacks) {
feedback->resource->sendFormatTable(newFormatTable->tableFD.get(), newFormatTable->tableSize); feedback->m_resource->sendFormatTable(newFormatTable->m_tableFD.get(), newFormatTable->m_tableSize);
if (feedback->lastFeedbackWasScanout) { if (feedback->m_lastFeedbackWasScanout) {
PHLMONITOR mon; PHLMONITOR mon;
auto HLSurface = CWLSurface::fromResource(feedback->surface); auto HLSurface = CWLSurface::fromResource(feedback->m_surface);
if (auto w = HLSurface->getWindow(); w) if (auto w = HLSurface->getWindow(); w)
if (auto m = w->m_monitor.lock(); m) if (auto m = w->m_monitor.lock(); m)
mon = m->m_self.lock(); mon = m->m_self.lock();
@ -507,46 +507,46 @@ void CLinuxDMABufV1Protocol::resetFormatTable() {
return; return;
} }
updateScanoutTranche(feedback->surface, mon); updateScanoutTranche(feedback->m_surface, mon);
} else { } else {
feedback->sendDefaultFeedback(); feedback->sendDefaultFeedback();
} }
} }
// delete old table after we sent new one // delete old table after we sent new one
formatTable = std::move(newFormatTable); m_formatTable = std::move(newFormatTable);
} }
void CLinuxDMABufV1Protocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CLinuxDMABufV1Protocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CLinuxDMABUFResource>(makeShared<CZwpLinuxDmabufV1>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CLinuxDMABUFResource>(makeShared<CZwpLinuxDmabufV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFResource* resource) { void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFResource* resource) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
} }
void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFFeedbackResource* resource) { void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFFeedbackResource* resource) {
std::erase_if(m_vFeedbacks, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_feedbacks, [&](const auto& other) { return other.get() == resource; });
} }
void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFParamsResource* resource) { void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFParamsResource* resource) {
std::erase_if(m_vParams, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_params, [&](const auto& other) { return other.get() == resource; });
} }
void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABuffer* resource) { void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABuffer* resource) {
std::erase_if(m_vBuffers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_buffers, [&](const auto& other) { return other.get() == resource; });
} }
void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface, PHLMONITOR pMonitor) { void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface, PHLMONITOR pMonitor) {
SP<CLinuxDMABUFFeedbackResource> feedbackResource; SP<CLinuxDMABUFFeedbackResource> feedbackResource;
for (auto const& f : m_vFeedbacks) { for (auto const& f : m_feedbacks) {
if (f->surface != surface) if (f->m_surface != surface)
continue; continue;
feedbackResource = f; feedbackResource = f;
@ -564,10 +564,10 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface
return; return;
} }
const auto& monitorTranchePair = std::find_if(formatTable->monitorTranches.begin(), formatTable->monitorTranches.end(), const auto& monitorTranchePair = std::find_if(m_formatTable->m_monitorTranches.begin(), m_formatTable->m_monitorTranches.end(),
[pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; }); [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; });
if (monitorTranchePair == formatTable->monitorTranches.end()) { if (monitorTranchePair == m_formatTable->m_monitorTranches.end()) {
LOGM(LOG, "updateScanoutTranche: monitor has no tranche"); LOGM(LOG, "updateScanoutTranche: monitor has no tranche");
return; return;
} }
@ -577,17 +577,17 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface
LOGM(LOG, "updateScanoutTranche: sending a scanout tranche"); LOGM(LOG, "updateScanoutTranche: sending a scanout tranche");
struct wl_array deviceArr = { struct wl_array deviceArr = {
.size = sizeof(mainDevice), .size = sizeof(m_mainDevice),
.data = (void*)&mainDevice, .data = (void*)&m_mainDevice,
}; };
feedbackResource->resource->sendMainDevice(&deviceArr); feedbackResource->m_resource->sendMainDevice(&deviceArr);
// prioritize scnaout tranche but have renderer fallback tranche // prioritize scnaout tranche but have renderer fallback tranche
// also yes formats can be duped here because different tranche flags (ds and no ds) // also yes formats can be duped here because different tranche flags (ds and no ds)
feedbackResource->sendTranche(monitorTranche); feedbackResource->sendTranche(monitorTranche);
feedbackResource->sendTranche(formatTable->rendererTranche); feedbackResource->sendTranche(m_formatTable->m_rendererTranche);
feedbackResource->resource->sendDone(); feedbackResource->m_resource->sendDone();
feedbackResource->lastFeedbackWasScanout = true; feedbackResource->m_lastFeedbackWasScanout = true;
} }

View File

@ -22,11 +22,11 @@ class CLinuxDMABuffer {
bool good(); bool good();
private: private:
SP<CDMABuffer> buffer; SP<CDMABuffer> m_buffer;
struct { struct {
CHyprSignalListener bufferResourceDestroy; CHyprSignalListener bufferResourceDestroy;
} listeners; } m_listeners;
friend class CLinuxDMABUFParamsResource; friend class CLinuxDMABUFParamsResource;
}; };
@ -51,10 +51,10 @@ class CDMABUFFormatTable {
CDMABUFFormatTable(SDMABUFTranche rendererTranche, std::vector<std::pair<PHLMONITORREF, SDMABUFTranche>> tranches); CDMABUFFormatTable(SDMABUFTranche rendererTranche, std::vector<std::pair<PHLMONITORREF, SDMABUFTranche>> tranches);
~CDMABUFFormatTable() = default; ~CDMABUFFormatTable() = default;
Hyprutils::OS::CFileDescriptor tableFD; Hyprutils::OS::CFileDescriptor m_tableFD;
size_t tableSize = 0; size_t m_tableSize = 0;
SDMABUFTranche rendererTranche; SDMABUFTranche m_rendererTranche;
std::vector<std::pair<PHLMONITORREF, SDMABUFTranche>> monitorTranches; std::vector<std::pair<PHLMONITORREF, SDMABUFTranche>> m_monitorTranches;
}; };
class CLinuxDMABUFParamsResource { class CLinuxDMABUFParamsResource {
@ -65,12 +65,12 @@ class CLinuxDMABUFParamsResource {
bool good(); bool good();
void create(uint32_t id); // 0 means not immed void create(uint32_t id); // 0 means not immed
SP<Aquamarine::SDMABUFAttrs> attrs; SP<Aquamarine::SDMABUFAttrs> m_attrs;
WP<CLinuxDMABuffer> createdBuffer; WP<CLinuxDMABuffer> m_createdBuffer;
bool used = false; bool m_used = false;
private: private:
SP<CZwpLinuxBufferParamsV1> resource; SP<CZwpLinuxBufferParamsV1> m_resource;
bool verify(); bool verify();
bool commence(); bool commence();
@ -85,11 +85,11 @@ class CLinuxDMABUFFeedbackResource {
void sendDefaultFeedback(); void sendDefaultFeedback();
void sendTranche(SDMABUFTranche& tranche); void sendTranche(SDMABUFTranche& tranche);
SP<CWLSurfaceResource> surface; // optional, for surface feedbacks SP<CWLSurfaceResource> m_surface; // optional, for surface feedbacks
private: private:
SP<CZwpLinuxDmabufFeedbackV1> resource; SP<CZwpLinuxDmabufFeedbackV1> m_resource;
bool lastFeedbackWasScanout = false; bool m_lastFeedbackWasScanout = false;
friend class CLinuxDMABufV1Protocol; friend class CLinuxDMABufV1Protocol;
}; };
@ -103,7 +103,7 @@ class CLinuxDMABUFResource {
void sendMods(); void sendMods();
private: private:
SP<CZwpLinuxDmabufV1> resource; SP<CZwpLinuxDmabufV1> m_resource;
}; };
class CLinuxDMABufV1Protocol : public IWaylandProtocol { class CLinuxDMABufV1Protocol : public IWaylandProtocol {
@ -123,14 +123,14 @@ class CLinuxDMABufV1Protocol : public IWaylandProtocol {
void resetFormatTable(); void resetFormatTable();
// //
std::vector<SP<CLinuxDMABUFResource>> m_vManagers; std::vector<SP<CLinuxDMABUFResource>> m_managers;
std::vector<SP<CLinuxDMABUFFeedbackResource>> m_vFeedbacks; std::vector<SP<CLinuxDMABUFFeedbackResource>> m_feedbacks;
std::vector<SP<CLinuxDMABUFParamsResource>> m_vParams; std::vector<SP<CLinuxDMABUFParamsResource>> m_params;
std::vector<SP<CLinuxDMABuffer>> m_vBuffers; std::vector<SP<CLinuxDMABuffer>> m_buffers;
UP<CDMABUFFormatTable> formatTable; UP<CDMABUFFormatTable> m_formatTable;
dev_t mainDevice; dev_t m_mainDevice;
Hyprutils::OS::CFileDescriptor mainDeviceFD; Hyprutils::OS::CFileDescriptor m_mainDeviceFD;
friend class CLinuxDMABUFResource; friend class CLinuxDMABUFResource;
friend class CLinuxDMABUFFeedbackResource; friend class CLinuxDMABUFFeedbackResource;

View File

@ -11,47 +11,48 @@ CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, A
LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs_.modifier, attrs_.fds[i], attrs_.strides[i], attrs_.offsets[i]); LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs_.modifier, attrs_.fds[i], attrs_.strides[i], attrs_.offsets[i]);
} }
buffer = makeShared<CDMABuffer>(id, client, attrs_); m_buffer = makeShared<CDMABuffer>(id, client, attrs_);
buffer->m_resource->m_buffer = buffer; m_buffer->m_resource->m_buffer = m_buffer;
listeners.bufferResourceDestroy = buffer->events.destroy.registerListener([this](std::any d) { m_listeners.bufferResourceDestroy = m_buffer->events.destroy.registerListener([this](std::any d) {
listeners.bufferResourceDestroy.reset(); m_listeners.bufferResourceDestroy.reset();
PROTO::mesaDRM->destroyResource(this); PROTO::mesaDRM->destroyResource(this);
}); });
if (!buffer->m_success) if (!m_buffer->m_success)
LOGM(ERR, "Possibly compositor bug: buffer failed to create"); LOGM(ERR, "Possibly compositor bug: buffer failed to create");
} }
CMesaDRMBufferResource::~CMesaDRMBufferResource() { CMesaDRMBufferResource::~CMesaDRMBufferResource() {
if (buffer && buffer->m_resource) if (m_buffer && m_buffer->m_resource)
buffer->m_resource->sendRelease(); m_buffer->m_resource->sendRelease();
buffer.reset(); m_buffer.reset();
listeners.bufferResourceDestroy.reset(); m_listeners.bufferResourceDestroy.reset();
} }
bool CMesaDRMBufferResource::good() { bool CMesaDRMBufferResource::good() {
return buffer && buffer->good(); return m_buffer && m_buffer->good();
} }
CMesaDRMResource::CMesaDRMResource(SP<CWlDrm> resource_) : resource(resource_) { CMesaDRMResource::CMesaDRMResource(SP<CWlDrm> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWlDrm* r) { PROTO::mesaDRM->destroyResource(this); }); m_resource->setOnDestroy([this](CWlDrm* r) { PROTO::mesaDRM->destroyResource(this); });
resource->setAuthenticate([this](CWlDrm* r, uint32_t token) { m_resource->setAuthenticate([this](CWlDrm* r, uint32_t token) {
// we don't need this // we don't need this
resource->sendAuthenticated(); m_resource->sendAuthenticated();
}); });
resource->setCreateBuffer([](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, uint32_t) { r->error(WL_DRM_ERROR_INVALID_NAME, "Not supported, use prime instead"); }); m_resource->setCreateBuffer(
[](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, uint32_t) { r->error(WL_DRM_ERROR_INVALID_NAME, "Not supported, use prime instead"); });
resource->setCreatePlanarBuffer([](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t) { m_resource->setCreatePlanarBuffer([](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t) {
r->error(WL_DRM_ERROR_INVALID_NAME, "Not supported, use prime instead"); r->error(WL_DRM_ERROR_INVALID_NAME, "Not supported, use prime instead");
}); });
resource->setCreatePrimeBuffer( m_resource->setCreatePrimeBuffer(
[this](CWlDrm* r, uint32_t id, int32_t nameFd, int32_t w, int32_t h, uint32_t fmt, int32_t off0, int32_t str0, int32_t off1, int32_t str1, int32_t off2, int32_t str2) { [this](CWlDrm* r, uint32_t id, int32_t nameFd, int32_t w, int32_t h, uint32_t fmt, int32_t off0, int32_t str0, int32_t off1, int32_t str1, int32_t off2, int32_t str2) {
if (off0 < 0 || w <= 0 || h <= 0) { if (off0 < 0 || w <= 0 || h <= 0) {
r->error(WL_DRM_ERROR_INVALID_FORMAT, "Invalid w, h, or offset"); r->error(WL_DRM_ERROR_INVALID_FORMAT, "Invalid w, h, or offset");
@ -85,29 +86,29 @@ CMesaDRMResource::CMesaDRMResource(SP<CWlDrm> resource_) : resource(resource_) {
attrs.fds[0] = nameFd; attrs.fds[0] = nameFd;
attrs.format = fmt; attrs.format = fmt;
const auto RESOURCE = PROTO::mesaDRM->m_vBuffers.emplace_back(makeShared<CMesaDRMBufferResource>(id, resource->client(), attrs)); const auto RESOURCE = PROTO::mesaDRM->m_buffers.emplace_back(makeShared<CMesaDRMBufferResource>(id, m_resource->client(), attrs));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::mesaDRM->m_vBuffers.pop_back(); PROTO::mesaDRM->m_buffers.pop_back();
return; return;
} }
// append instance so that buffer knows its owner // append instance so that buffer knows its owner
RESOURCE->buffer->m_resource->m_buffer = RESOURCE->buffer; RESOURCE->m_buffer->m_resource->m_buffer = RESOURCE->m_buffer;
}); });
resource->sendDevice(PROTO::mesaDRM->nodeName.c_str()); m_resource->sendDevice(PROTO::mesaDRM->m_nodeName.c_str());
resource->sendCapabilities(WL_DRM_CAPABILITY_PRIME); m_resource->sendCapabilities(WL_DRM_CAPABILITY_PRIME);
auto fmts = g_pHyprOpenGL->getDRMFormats(); auto fmts = g_pHyprOpenGL->getDRMFormats();
for (auto const& fmt : fmts) { for (auto const& fmt : fmts) {
resource->sendFormat(fmt.drmFormat); m_resource->sendFormat(fmt.drmFormat);
} }
} }
bool CMesaDRMResource::good() { bool CMesaDRMResource::good() {
return resource->resource(); return m_resource->resource();
} }
CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@ -120,7 +121,7 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co
} }
if (dev->available_nodes & (1 << DRM_NODE_RENDER)) { if (dev->available_nodes & (1 << DRM_NODE_RENDER)) {
nodeName = dev->nodes[DRM_NODE_RENDER]; m_nodeName = dev->nodes[DRM_NODE_RENDER];
} else { } else {
ASSERT(dev->available_nodes & (1 << DRM_NODE_PRIMARY)); ASSERT(dev->available_nodes & (1 << DRM_NODE_PRIMARY));
@ -132,25 +133,25 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co
} }
LOGM(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]); LOGM(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]);
nodeName = dev->nodes[DRM_NODE_PRIMARY]; m_nodeName = dev->nodes[DRM_NODE_PRIMARY];
} }
drmFreeDevice(&dev); drmFreeDevice(&dev);
} }
void CMesaDRMProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { void CMesaDRMProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CMesaDRMResource>(makeShared<CWlDrm>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CMesaDRMResource>(makeShared<CWlDrm>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CMesaDRMProtocol::destroyResource(CMesaDRMResource* resource) { void CMesaDRMProtocol::destroyResource(CMesaDRMResource* resource) {
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
} }
void CMesaDRMProtocol::destroyResource(CMesaDRMBufferResource* resource) { void CMesaDRMProtocol::destroyResource(CMesaDRMBufferResource* resource) {
std::erase_if(m_vBuffers, [&](const auto& other) { return other.get() == resource; }); std::erase_if(m_buffers, [&](const auto& other) { return other.get() == resource; });
} }

View File

@ -15,11 +15,11 @@ class CMesaDRMBufferResource {
bool good(); bool good();
private: private:
SP<CDMABuffer> buffer; SP<CDMABuffer> m_buffer;
struct { struct {
CHyprSignalListener bufferResourceDestroy; CHyprSignalListener bufferResourceDestroy;
} listeners; } m_listeners;
friend class CMesaDRMResource; friend class CMesaDRMResource;
}; };
@ -31,7 +31,7 @@ class CMesaDRMResource {
bool good(); bool good();
private: private:
SP<CWlDrm> resource; SP<CWlDrm> m_resource;
}; };
class CMesaDRMProtocol : public IWaylandProtocol { class CMesaDRMProtocol : public IWaylandProtocol {
@ -45,10 +45,10 @@ class CMesaDRMProtocol : public IWaylandProtocol {
void destroyResource(CMesaDRMBufferResource* resource); void destroyResource(CMesaDRMBufferResource* resource);
// //
std::vector<SP<CMesaDRMResource>> m_vManagers; std::vector<SP<CMesaDRMResource>> m_managers;
std::vector<SP<CMesaDRMBufferResource>> m_vBuffers; std::vector<SP<CMesaDRMBufferResource>> m_buffers;
std::string nodeName = ""; std::string m_nodeName = "";
friend class CMesaDRMResource; friend class CMesaDRMResource;
friend class CMesaDRMBufferResource; friend class CMesaDRMBufferResource;

View File

@ -196,14 +196,14 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
pClient = resource->client(); pClient = resource->client();
if (!surface->m_colorManagement.valid()) { if (!surface->m_colorManagement.valid()) {
const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared<CColorManagementSurface>(surface_)); const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared<CColorManagementSurface>(surface_));
if UNLIKELY (!RESOURCE) { if UNLIKELY (!RESOURCE) {
resource->noMemory(); resource->noMemory();
PROTO::colorManagement->m_vSurfaces.pop_back(); PROTO::colorManagement->m_surfaces.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
surface->m_colorManagement = RESOURCE; surface->m_colorManagement = RESOURCE;

View File

@ -1686,7 +1686,7 @@ void CHyprRenderer::arrangeLayerArray(PHLMONITOR pMonitor, const std::vector<PHL
continue; continue;
const auto PLAYER = ls->m_layerSurface; const auto PLAYER = ls->m_layerSurface;
const auto PSTATE = &PLAYER->current; const auto PSTATE = &PLAYER->m_current;
if (exclusiveZone != (PSTATE->exclusive > 0)) if (exclusiveZone != (PSTATE->exclusive > 0))
continue; continue;