From d9cad5e1b63f2e1e86eb54551c72d17ee4dd070d Mon Sep 17 00:00:00 2001 From: davc0n Date: Sat, 3 May 2025 16:02:49 +0200 Subject: [PATCH] protocols: refactor class member vars (core) (#10259) --- src/Compositor.cpp | 8 +- src/desktop/LayerSurface.cpp | 14 +- src/desktop/Popup.cpp | 14 +- src/desktop/Subsurface.cpp | 44 +-- src/desktop/WLSurface.cpp | 41 +-- src/desktop/Window.cpp | 30 +- src/devices/Tablet.cpp | 2 +- src/events/Windows.cpp | 5 +- src/helpers/Monitor.cpp | 14 +- src/layout/IHyprLayout.cpp | 2 +- src/managers/PointerManager.cpp | 30 +- src/managers/ProtocolManager.cpp | 2 +- src/managers/SeatManager.cpp | 44 +-- src/managers/input/InputManager.cpp | 6 +- src/managers/input/InputMethodPopup.cpp | 2 +- src/managers/input/TextInput.cpp | 6 +- src/protocols/AlphaModifier.cpp | 4 +- src/protocols/CTMControl.cpp | 2 +- src/protocols/ColorManagement.cpp | 6 +- src/protocols/ContentType.cpp | 10 +- src/protocols/DRMSyncobj.cpp | 24 +- src/protocols/FocusGrab.cpp | 2 +- src/protocols/ForeignToplevelWlr.cpp | 2 +- src/protocols/FractionalScale.cpp | 2 +- src/protocols/FrogColorManagement.cpp | 42 +-- src/protocols/GammaControl.cpp | 2 +- src/protocols/HyprlandSurface.cpp | 6 +- src/protocols/IdleInhibit.cpp | 2 +- src/protocols/InputMethodV2.cpp | 8 +- src/protocols/LayerShell.cpp | 14 +- src/protocols/OutputPower.cpp | 2 +- src/protocols/PointerConstraints.cpp | 6 +- src/protocols/Screencopy.cpp | 2 +- src/protocols/SessionLock.cpp | 10 +- src/protocols/Viewporter.cpp | 32 +- src/protocols/VirtualPointer.cpp | 2 +- src/protocols/XDGOutput.cpp | 4 +- src/protocols/XDGShell.cpp | 16 +- src/protocols/XXColorManagement.cpp | 16 +- src/protocols/core/Compositor.cpp | 374 ++++++++++----------- src/protocols/core/Compositor.hpp | 50 +-- src/protocols/core/DataDevice.cpp | 416 ++++++++++++------------ src/protocols/core/DataDevice.hpp | 56 ++-- src/protocols/core/Output.cpp | 86 ++--- src/protocols/core/Output.hpp | 22 +- src/protocols/core/Seat.cpp | 332 +++++++++---------- src/protocols/core/Seat.hpp | 62 ++-- src/protocols/core/Shm.cpp | 116 +++---- src/protocols/core/Shm.hpp | 31 +- src/protocols/core/Subcompositor.cpp | 156 ++++----- src/protocols/core/Subcompositor.hpp | 26 +- src/render/OpenGL.cpp | 18 +- src/render/Renderer.cpp | 53 +-- src/render/pass/Pass.cpp | 6 +- src/render/pass/SurfacePassElement.cpp | 22 +- src/xwayland/XSurface.cpp | 10 +- src/xwayland/XWM.cpp | 2 +- 57 files changed, 1160 insertions(+), 1158 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index a9106480..fcb67873 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1288,14 +1288,14 @@ SP CCompositor::vectorToLayerSurface(const Vector2D& pos, st bool aboveLockscreen) { 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->mapped) || ls->m_alpha->value() == 0.f || + 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 || (aboveLockscreen && (!ls->m_aboveLockscreen || !ls->m_aboveLockscreenInteractable))) continue; auto [surf, local] = ls->m_layerSurface->surface->at(pos - ls->m_geometry.pos(), true); if (surf) { - if (surf->current.input.empty()) + if (surf->m_current.input.empty()) continue; *ppLayerSurfaceFound = ls.lock(); @@ -1310,10 +1310,10 @@ SP CCompositor::vectorToLayerSurface(const Vector2D& pos, st } PHLWINDOW CCompositor::getWindowFromSurface(SP pSurface) { - if (!pSurface || !pSurface->hlSurface) + if (!pSurface || !pSurface->m_hlSurface) return nullptr; - return pSurface->hlSurface->getWindow(); + return pSurface->m_hlSurface->getWindow(); } PHLWINDOW CCompositor::getWindowFromHandle(uint32_t handle) { diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index c31f9bb7..9818c093 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -238,7 +238,7 @@ void CLayerSurface::onUnmap() { // refocus if needed // vvvvvvvvvvvvv if there is a last focus and the last focus is not keyboard focusable, fallback to window - if (WASLASTFOCUS || (g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->hlSurface && !g_pCompositor->m_lastFocus->hlSurface->keyboardFocusable())) { + if (WASLASTFOCUS || (g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->m_hlSurface && !g_pCompositor->m_lastFocus->m_hlSurface->keyboardFocusable())) { if (!g_pInputManager->refocusLastWindow(PMONITOR)) g_pInputManager->refocus(); } else if (g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus != m_surface->resource()) @@ -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}; 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->current.size.x, - (int)m_layerSurface->surface->current.size.y}; + 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, + (int)m_layerSurface->surface->m_current.size.y}; g_pHyprRenderer->damageBox(geomFixed); g_pInputManager->simulateMouseMovement(); @@ -262,7 +262,7 @@ void CLayerSurface::onCommit() { if (!m_mapped) { // we're re-mapping if this is the case - if (m_layerSurface->surface && !m_layerSurface->surface->current.texture) { + if (m_layerSurface->surface && !m_layerSurface->surface->m_current.texture) { m_fadingOut = false; m_geometry = {}; g_pHyprRenderer->arrangeLayersForMonitor(monitorID()); @@ -308,12 +308,12 @@ void CLayerSurface::onCommit() { m_position = Vector2D(m_geometry.x, m_geometry.y); // update geom if it changed - if (m_layerSurface->surface->current.scale == 1 && PMONITOR->m_scale != 1.f && m_layerSurface->surface->current.viewport.hasDestination) { + if (m_layerSurface->surface->m_current.scale == 1 && PMONITOR->m_scale != 1.f && m_layerSurface->surface->m_current.viewport.hasDestination) { // fractional scaling. Dirty hack. - m_geometry = {m_geometry.pos(), m_layerSurface->surface->current.viewport.destination}; + m_geometry = {m_geometry.pos(), m_layerSurface->surface->m_current.viewport.destination}; } else { // 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->current.size}; + m_geometry = {m_geometry.pos(), m_layerSurface->surface->m_current.size}; } } diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 30cf966d..86928faf 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -93,7 +93,7 @@ void CPopup::onMap() { return; m_mapped = true; - m_lastSize = m_resource->surface->surface->current.size; + m_lastSize = m_resource->surface->surface->m_current.size; const auto COORDS = coordsGlobal(); const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS); @@ -128,7 +128,7 @@ void CPopup::onUnmap() { m_mapped = false; - m_lastSize = m_resource->surface->surface->current.size; + m_lastSize = m_resource->surface->surface->m_current.size; const auto COORDS = coordsGlobal(); @@ -172,7 +172,7 @@ void CPopup::onCommit(bool ignoreSiblings) { } if (!m_windowOwner.expired() && (!m_windowOwner->m_isMapped || !m_windowOwner->m_workspace->m_visible)) { - m_lastSize = m_resource->surface->surface->current.size; + m_lastSize = m_resource->surface->surface->m_current.size; static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) @@ -186,10 +186,10 @@ void CPopup::onCommit(bool ignoreSiblings) { const auto COORDS = coordsGlobal(); const auto COORDSLOCAL = coordsRelativeToParent(); - if (m_lastSize != m_resource->surface->surface->current.size || m_requestedReposition || m_lastPos != COORDSLOCAL) { + if (m_lastSize != m_resource->surface->surface->m_current.size || m_requestedReposition || m_lastPos != COORDSLOCAL) { CBox box = {localToGlobal(m_lastPos), m_lastSize}; g_pHyprRenderer->damageBox(box); - m_lastSize = m_resource->surface->surface->current.size; + m_lastSize = m_resource->surface->surface->m_current.size; box = {COORDS, m_lastSize}; g_pHyprRenderer->damageBox(box); @@ -246,7 +246,7 @@ Vector2D CPopup::coordsRelativeToParent() { while (current->m_parent && current->m_resource) { - offset += current->m_wlSurface->resource()->current.offset; + offset += current->m_wlSurface->resource()->m_current.offset; offset += current->m_resource->geometry.pos(); current = current->m_parent; @@ -363,7 +363,7 @@ WP CPopup::at(const Vector2D& globalCoords, bool allowsInput) { if (BOX.containsPoint(globalCoords)) return p; } else { - const auto REGION = CRegion{p->m_wlSurface->resource()->current.input}.intersect(CBox{{}, p->m_wlSurface->resource()->current.size}).translate(p->coordsGlobal()); + const auto REGION = CRegion{p->m_wlSurface->resource()->m_current.input}.intersect(CBox{{}, p->m_wlSurface->resource()->m_current.size}).translate(p->coordsGlobal()); if (REGION.containsPoint(globalCoords)) return p; } diff --git a/src/desktop/Subsurface.cpp b/src/desktop/Subsurface.cpp index 419c7e31..1c5d5c70 100644 --- a/src/desktop/Subsurface.cpp +++ b/src/desktop/Subsurface.cpp @@ -32,9 +32,9 @@ UP CSubsurface::create(SP pSubsurface, PHLWI subsurface->m_subsurface = pSubsurface; subsurface->m_self = subsurface; subsurface->m_wlSurface = CWLSurface::create(); - subsurface->m_wlSurface->assign(pSubsurface->surface.lock(), subsurface.get()); + subsurface->m_wlSurface->assign(pSubsurface->m_surface.lock(), subsurface.get()); subsurface->initSignals(); - subsurface->initExistingSubsurfaces(pSubsurface->surface.lock()); + subsurface->initExistingSubsurfaces(pSubsurface->m_surface.lock()); return subsurface; } @@ -44,27 +44,27 @@ UP CSubsurface::create(SP pSubsurface, WPm_subsurface = pSubsurface; subsurface->m_self = subsurface; subsurface->m_wlSurface = CWLSurface::create(); - subsurface->m_wlSurface->assign(pSubsurface->surface.lock(), subsurface.get()); + subsurface->m_wlSurface->assign(pSubsurface->m_surface.lock(), subsurface.get()); subsurface->initSignals(); - subsurface->initExistingSubsurfaces(pSubsurface->surface.lock()); + subsurface->initExistingSubsurfaces(pSubsurface->m_surface.lock()); return subsurface; } void CSubsurface::initSignals() { if (m_subsurface) { - m_listeners.commitSubsurface = m_subsurface->surface->events.commit.registerListener([this](std::any d) { onCommit(); }); - m_listeners.destroySubsurface = m_subsurface->events.destroy.registerListener([this](std::any d) { onDestroy(); }); - m_listeners.mapSubsurface = m_subsurface->surface->events.map.registerListener([this](std::any d) { onMap(); }); - m_listeners.unmapSubsurface = m_subsurface->surface->events.unmap.registerListener([this](std::any d) { onUnmap(); }); + m_listeners.commitSubsurface = m_subsurface->m_surface->m_events.commit.registerListener([this](std::any d) { onCommit(); }); + m_listeners.destroySubsurface = m_subsurface->m_events.destroy.registerListener([this](std::any d) { onDestroy(); }); + m_listeners.mapSubsurface = m_subsurface->m_surface->m_events.map.registerListener([this](std::any d) { onMap(); }); + m_listeners.unmapSubsurface = m_subsurface->m_surface->m_events.unmap.registerListener([this](std::any d) { onUnmap(); }); m_listeners.newSubsurface = - m_subsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast>(d)); }); + m_subsurface->m_surface->m_events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast>(d)); }); } else { if (m_windowParent) - m_listeners.newSubsurface = m_windowParent->m_wlSurface->resource()->events.newSubsurface.registerListener( + m_listeners.newSubsurface = m_windowParent->m_wlSurface->resource()->m_events.newSubsurface.registerListener( [this](std::any d) { onNewSubsurface(std::any_cast>(d)); }); else if (m_popupParent) - m_listeners.newSubsurface = - m_popupParent->m_wlSurface->resource()->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast>(d)); }); + m_listeners.newSubsurface = m_popupParent->m_wlSurface->resource()->m_events.newSubsurface.registerListener( + [this](std::any d) { onNewSubsurface(std::any_cast>(d)); }); else ASSERT(false); } @@ -95,7 +95,7 @@ void CSubsurface::recheckDamageForSubsurfaces() { void CSubsurface::onCommit() { // no damaging if it's not visible if (!m_windowParent.expired() && (!m_windowParent->m_isMapped || !m_windowParent->m_workspace->m_visible)) { - m_lastSize = m_wlSurface->resource()->current.size; + m_lastSize = m_wlSurface->resource()->m_current.size; static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) @@ -115,10 +115,10 @@ void CSubsurface::onCommit() { // I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox) checkSiblingDamage(); - if (m_lastSize != m_wlSurface->resource()->current.size || m_lastPosition != m_subsurface->position) { + if (m_lastSize != m_wlSurface->resource()->m_current.size || m_lastPosition != m_subsurface->m_position) { damageLastArea(); - m_lastSize = m_wlSurface->resource()->current.size; - m_lastPosition = m_subsurface->position; + m_lastSize = m_wlSurface->resource()->m_current.size; + m_lastPosition = m_subsurface->m_position; } } @@ -151,8 +151,8 @@ void CSubsurface::onNewSubsurface(SP pSubsurface) { } void CSubsurface::onMap() { - m_lastSize = m_wlSurface->resource()->current.size; - m_lastPosition = m_subsurface->position; + m_lastSize = m_wlSurface->resource()->m_current.size; + m_lastPosition = m_subsurface->m_position; const auto COORDS = coordsGlobal(); CBox box{COORDS, m_lastSize}; @@ -175,7 +175,7 @@ void CSubsurface::onUnmap() { } void CSubsurface::damageLastArea() { - const auto COORDS = coordsGlobal() + m_lastPosition - m_subsurface->position; + const auto COORDS = coordsGlobal() + m_lastPosition - m_subsurface->m_position; CBox box{COORDS, m_lastSize}; box.expand(4); g_pHyprRenderer->damageBox(box); @@ -199,15 +199,15 @@ Vector2D CSubsurface::coordsGlobal() { } void CSubsurface::initExistingSubsurfaces(SP pSurface) { - for (auto const& s : pSurface->subsurfaces) { - if (!s || s->surface->hlSurface /* already assigned */) + for (auto const& s : pSurface->m_subsurfaces) { + if (!s || s->m_surface->m_hlSurface /* already assigned */) continue; onNewSubsurface(s.lock()); } } Vector2D CSubsurface::size() { - return m_wlSurface->resource()->current.size; + return m_wlSurface->resource()->m_current.size; } bool CSubsurface::visible() { diff --git a/src/desktop/WLSurface.cpp b/src/desktop/WLSurface.cpp index d5e35be1..6666ea52 100644 --- a/src/desktop/WLSurface.cpp +++ b/src/desktop/WLSurface.cpp @@ -59,12 +59,12 @@ bool CWLSurface::small() const { if (!validMapped(m_windowOwner) || !exists()) return false; - if (!m_resource->current.texture) + if (!m_resource->m_current.texture) return false; const auto O = m_windowOwner.lock(); - return O->m_reportedSize.x > m_resource->current.size.x + 1 || O->m_reportedSize.y > m_resource->current.size.y + 1; + return O->m_reportedSize.x > m_resource->m_current.size.x + 1 || O->m_reportedSize.y > m_resource->m_current.size.y + 1; } Vector2D CWLSurface::correctSmallVec() const { @@ -78,36 +78,37 @@ Vector2D CWLSurface::correctSmallVec() const { } Vector2D CWLSurface::correctSmallVecBuf() const { - if (!exists() || !small() || m_fillIgnoreSmall || !m_resource->current.texture) + if (!exists() || !small() || m_fillIgnoreSmall || !m_resource->m_current.texture) return {}; const auto SIZE = getViewporterCorrectedSize(); - const auto BS = m_resource->current.bufferSize; + const auto BS = m_resource->m_current.bufferSize; return Vector2D{(BS.x - SIZE.x) / 2, (BS.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}); } Vector2D CWLSurface::getViewporterCorrectedSize() const { - if (!exists() || !m_resource->current.texture) + if (!exists() || !m_resource->m_current.texture) return {}; - return m_resource->current.viewport.hasDestination ? m_resource->current.viewport.destination : m_resource->current.bufferSize; + return m_resource->m_current.viewport.hasDestination ? m_resource->m_current.viewport.destination : m_resource->m_current.bufferSize; } CRegion CWLSurface::computeDamage() const { - if (!m_resource->current.texture) + if (!m_resource->m_current.texture) return {}; - CRegion damage = m_resource->current.accumulateBufferDamage(); - damage.transform(wlTransformToHyprutils(m_resource->current.transform), m_resource->current.bufferSize.x, m_resource->current.bufferSize.y); + CRegion damage = m_resource->m_current.accumulateBufferDamage(); + damage.transform(wlTransformToHyprutils(m_resource->m_current.transform), m_resource->m_current.bufferSize.x, m_resource->m_current.bufferSize.y); - const auto BUFSIZE = m_resource->current.bufferSize; + const auto BUFSIZE = m_resource->m_current.bufferSize; const auto CORRECTVEC = correctSmallVecBuf(); - if (m_resource->current.viewport.hasSource) - damage.intersect(m_resource->current.viewport.source); + if (m_resource->m_current.viewport.hasSource) + damage.intersect(m_resource->m_current.viewport.source); - const auto SCALEDSRCSIZE = m_resource->current.viewport.hasSource ? m_resource->current.viewport.source.size() * m_resource->current.scale : m_resource->current.bufferSize; + const auto SCALEDSRCSIZE = + m_resource->m_current.viewport.hasSource ? m_resource->m_current.viewport.source.size() * m_resource->m_current.scale : m_resource->m_current.bufferSize; damage.scale({BUFSIZE.x / SCALEDSRCSIZE.x, BUFSIZE.y / SCALEDSRCSIZE.y}); damage.translate(CORRECTVEC); @@ -115,8 +116,8 @@ CRegion CWLSurface::computeDamage() const { // go from buffer coords in the damage to hl logical const auto BOX = getSurfaceBoxGlobal(); - const Vector2D SCALE = BOX.has_value() ? BOX->size() / m_resource->current.bufferSize : - Vector2D{1.0 / m_resource->current.scale, 1.0 / m_resource->current.scale /* Wrong... but we can't really do better */}; + const Vector2D SCALE = BOX.has_value() ? BOX->size() / m_resource->m_current.bufferSize : + Vector2D{1.0 / m_resource->m_current.scale, 1.0 / m_resource->m_current.scale /* Wrong... but we can't really do better */}; damage.scale(SCALE); @@ -135,7 +136,7 @@ void CWLSurface::destroy() { m_constraint.reset(); m_listeners.destroy.reset(); - m_resource->hlSurface.reset(); + m_resource->m_hlSurface.reset(); m_windowOwner.reset(); m_layerOwner.reset(); m_popupOwner = nullptr; @@ -154,11 +155,11 @@ void CWLSurface::init() { if (!m_resource) return; - RASSERT(!m_resource->hlSurface, "Attempted to duplicate CWLSurface ownership!"); + RASSERT(!m_resource->m_hlSurface, "Attempted to duplicate CWLSurface ownership!"); - m_resource->hlSurface = m_self.lock(); + m_resource->m_hlSurface = m_self.lock(); - m_listeners.destroy = m_resource->events.destroy.registerListener([this](std::any d) { destroy(); }); + m_listeners.destroy = m_resource->m_events.destroy.registerListener([this](std::any d) { destroy(); }); Debug::log(LOG, "CWLSurface {:x} called init()", (uintptr_t)this); } @@ -222,7 +223,7 @@ bool CWLSurface::visible() { SP CWLSurface::fromResource(SP pSurface) { if (!pSurface) return nullptr; - return pSurface->hlSurface.lock(); + return pSurface->m_hlSurface.lock(); } bool CWLSurface::keyboardFocusable() const { diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 64771895..4686ecb1 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -184,11 +184,11 @@ SBoxExtents CWindow::getFullWindowExtents() { if (-surfaceExtents.y > maxExtents.topLeft.y) maxExtents.topLeft.y = -surfaceExtents.y; - if (surfaceExtents.x + surfaceExtents.width > m_wlSurface->resource()->current.size.x + maxExtents.bottomRight.x) - maxExtents.bottomRight.x = surfaceExtents.x + surfaceExtents.width - m_wlSurface->resource()->current.size.x; + if (surfaceExtents.x + surfaceExtents.width > m_wlSurface->resource()->m_current.size.x + maxExtents.bottomRight.x) + maxExtents.bottomRight.x = surfaceExtents.x + surfaceExtents.width - m_wlSurface->resource()->m_current.size.x; - if (surfaceExtents.y + surfaceExtents.height > m_wlSurface->resource()->current.size.y + maxExtents.bottomRight.y) - maxExtents.bottomRight.y = surfaceExtents.y + surfaceExtents.height - m_wlSurface->resource()->current.size.y; + if (surfaceExtents.y + surfaceExtents.height > m_wlSurface->resource()->m_current.size.y + maxExtents.bottomRight.y) + maxExtents.bottomRight.y = surfaceExtents.y + surfaceExtents.height - m_wlSurface->resource()->m_current.size.y; } return maxExtents; @@ -1159,18 +1159,18 @@ bool CWindow::opaque() { if (PWORKSPACE->m_alpha->value() != 1.f) return false; - if (m_isX11 && m_xwaylandSurface && m_xwaylandSurface->surface && m_xwaylandSurface->surface->current.texture) - return m_xwaylandSurface->surface->current.texture->m_bOpaque; + if (m_isX11 && m_xwaylandSurface && m_xwaylandSurface->surface && m_xwaylandSurface->surface->m_current.texture) + return m_xwaylandSurface->surface->m_current.texture->m_bOpaque; - if (!m_wlSurface->resource() || !m_wlSurface->resource()->current.texture) + if (!m_wlSurface->resource() || !m_wlSurface->resource()->m_current.texture) return false; // TODO: this is wrong - const auto EXTENTS = m_xdgSurface->surface->current.opaque.getExtents(); - if (EXTENTS.w >= m_xdgSurface->surface->current.bufferSize.x && EXTENTS.h >= m_xdgSurface->surface->current.bufferSize.y) + const auto EXTENTS = m_xdgSurface->surface->m_current.opaque.getExtents(); + if (EXTENTS.w >= m_xdgSurface->surface->m_current.bufferSize.x && EXTENTS.h >= m_xdgSurface->surface->m_current.bufferSize.y) return true; - return m_wlSurface->resource()->current.texture->m_bOpaque; + return m_wlSurface->resource()->m_current.texture->m_bOpaque; } float CWindow::rounding() { @@ -1772,19 +1772,19 @@ void CWindow::sendWindowSize(bool force) { } NContentType::eContentType CWindow::getContentType() { - if (!m_wlSurface || !m_wlSurface->resource() || !m_wlSurface->resource()->contentType.valid()) + if (!m_wlSurface || !m_wlSurface->resource() || !m_wlSurface->resource()->m_contentType.valid()) return CONTENT_TYPE_NONE; - return m_wlSurface->resource()->contentType->value; + return m_wlSurface->resource()->m_contentType->value; } void CWindow::setContentType(NContentType::eContentType contentType) { - if (!m_wlSurface->resource()->contentType.valid()) - m_wlSurface->resource()->contentType = PROTO::contentType->getContentType(m_wlSurface->resource()); + if (!m_wlSurface->resource()->m_contentType.valid()) + m_wlSurface->resource()->m_contentType = PROTO::contentType->getContentType(m_wlSurface->resource()); // else disallow content type change if proto is used? Debug::log(INFO, "ContentType for window {}", (int)contentType); - m_wlSurface->resource()->contentType->value = contentType; + m_wlSurface->resource()->m_contentType->value = contentType; } void CWindow::deactivateGroupMembers() { diff --git a/src/devices/Tablet.cpp b/src/devices/Tablet.cpp index e4c399c9..faeb3d73 100644 --- a/src/devices/Tablet.cpp +++ b/src/devices/Tablet.cpp @@ -265,7 +265,7 @@ void CTabletTool::setSurface(SP surf) { m_surface = surf; if (surf) { - m_listeners.destroySurface = surf->events.destroy.registerListener([this](std::any d) { + m_listeners.destroySurface = surf->m_events.destroy.registerListener([this](std::any d) { PROTO::tablet->proximityOut(m_self.lock()); m_surface.reset(); m_listeners.destroySurface.reset(); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index eec01a7d..87429874 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -892,8 +892,9 @@ void Events::listener_commitWindow(void* owner, void* data) { } // tearing: if solitary, redraw it. This still might be a single surface window - if (PMONITOR && PMONITOR->m_solitaryClient.lock() == PWINDOW && PWINDOW->canBeTorn() && PMONITOR->m_tearingState.canTear && PWINDOW->m_wlSurface->resource()->current.texture) { - CRegion damageBox{PWINDOW->m_wlSurface->resource()->current.accumulateBufferDamage()}; + if (PMONITOR && PMONITOR->m_solitaryClient.lock() == PWINDOW && PWINDOW->canBeTorn() && PMONITOR->m_tearingState.canTear && + PWINDOW->m_wlSurface->resource()->m_current.texture) { + CRegion damageBox{PWINDOW->m_wlSurface->resource()->m_current.accumulateBufferDamage()}; if (!damageBox.empty()) { if (PMONITOR->m_tearingState.busy) { diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 2edba78a..043cd5cc 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -1368,20 +1368,20 @@ bool CMonitor::attemptDirectScanout() { const auto PSURFACE = g_pXWaylandManager->getWindowSurface(PCANDIDATE); - if (!PSURFACE || !PSURFACE->current.texture || !PSURFACE->current.buffer) + if (!PSURFACE || !PSURFACE->m_current.texture || !PSURFACE->m_current.buffer) return false; - if (PSURFACE->current.bufferSize != m_pixelSize || PSURFACE->current.transform != m_transform) + if (PSURFACE->m_current.bufferSize != m_pixelSize || PSURFACE->m_current.transform != m_transform) return false; // we can't scanout shm buffers. - const auto params = PSURFACE->current.buffer->dmabuf(); - if (!params.success || !PSURFACE->current.texture->m_pEglImage /* dmabuf */) + const auto params = PSURFACE->m_current.buffer->dmabuf(); + if (!params.success || !PSURFACE->m_current.texture->m_pEglImage /* dmabuf */) return false; - Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", (uintptr_t)PSURFACE.get(), (uintptr_t)PSURFACE->current.buffer.buffer.get()); + Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", (uintptr_t)PSURFACE.get(), (uintptr_t)PSURFACE->m_current.buffer.buffer.get()); - auto PBUFFER = PSURFACE->current.buffer.buffer; + auto PBUFFER = PSURFACE->m_current.buffer.buffer; if (PBUFFER == m_output->state->state().buffer) { PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock()); @@ -1427,7 +1427,7 @@ bool CMonitor::attemptDirectScanout() { PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock()); - m_output->state->addDamage(PSURFACE->current.accumulateBufferDamage()); + m_output->state->addDamage(PSURFACE->m_current.accumulateBufferDamage()); m_output->state->resetExplicitFences(); // no need to do explicit sync here as surface current can only ever be ready to read diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 3b0821d7..e107a9e1 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -118,7 +118,7 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) { if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) { const auto PWINDOWSURFACE = pWindow->m_wlSurface->resource(); - *pWindow->m_realSize = PWINDOWSURFACE->current.size; + *pWindow->m_realSize = PWINDOWSURFACE->m_current.size; if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_isX11 && pWindow->isX11OverrideRedirect()) { // XDG windows should be fine. TODO: check for weird atoms? diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 48044a69..d9dd602e 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -131,9 +131,9 @@ void CPointerManager::setCursorSurface(SP surf, const Vector2D& hots damageIfSoftware(); if (surf == m_currentCursorImage.surface) { - if (hotspot != m_currentCursorImage.hotspot || (surf && surf->resource() ? surf->resource()->current.scale : 1.F) != m_currentCursorImage.scale) { + if (hotspot != m_currentCursorImage.hotspot || (surf && surf->resource() ? surf->resource()->m_current.scale : 1.F) != m_currentCursorImage.scale) { m_currentCursorImage.hotspot = hotspot; - m_currentCursorImage.scale = surf && surf->resource() ? surf->resource()->current.scale : 1.F; + m_currentCursorImage.scale = surf && surf->resource() ? surf->resource()->m_current.scale : 1.F; updateCursorBackend(); damageIfSoftware(); } @@ -145,22 +145,22 @@ void CPointerManager::setCursorSurface(SP surf, const Vector2D& hots if (surf) { m_currentCursorImage.surface = surf; - m_currentCursorImage.scale = surf->resource()->current.scale; + m_currentCursorImage.scale = surf->resource()->m_current.scale; surf->resource()->map(); m_currentCursorImage.destroySurface = surf->m_events.destroy.registerListener([this](std::any data) { resetCursorImage(); }); - m_currentCursorImage.commitSurface = surf->resource()->events.commit.registerListener([this](std::any data) { + m_currentCursorImage.commitSurface = surf->resource()->m_events.commit.registerListener([this](std::any data) { damageIfSoftware(); - m_currentCursorImage.size = m_currentCursorImage.surface->resource()->current.texture ? m_currentCursorImage.surface->resource()->current.bufferSize : Vector2D{}; - m_currentCursorImage.scale = m_currentCursorImage.surface ? m_currentCursorImage.surface->resource()->current.scale : 1.F; + m_currentCursorImage.size = m_currentCursorImage.surface->resource()->m_current.texture ? m_currentCursorImage.surface->resource()->m_current.bufferSize : Vector2D{}; + m_currentCursorImage.scale = m_currentCursorImage.surface ? m_currentCursorImage.surface->resource()->m_current.scale : 1.F; recheckEnteredOutputs(); updateCursorBackend(); damageIfSoftware(); }); - if (surf->resource()->current.texture) { - m_currentCursorImage.size = surf->resource()->current.bufferSize; + if (surf->resource()->m_current.texture) { + m_currentCursorImage.size = surf->resource()->m_current.bufferSize; surf->resource()->frame(Time::steadyNow()); } } @@ -464,18 +464,18 @@ SP CPointerManager::renderHWCursorBuffer(SPdataCopy(); if (texData.empty()) { - if (m_currentCursorImage.surface && m_currentCursorImage.surface->resource()->role->role() == SURFACE_ROLE_CURSOR) { + if (m_currentCursorImage.surface && m_currentCursorImage.surface->resource()->m_role->role() == SURFACE_ROLE_CURSOR) { const auto SURFACE = m_currentCursorImage.surface->resource(); auto& shmBuffer = CCursorSurfaceRole::cursorPixelData(SURFACE); bool flipRB = false; - if (SURFACE->current.texture) { - Debug::log(TRACE, "Cursor CPU surface: format {}, expecting AR24", NFormatUtils::drmFormatName(SURFACE->current.texture->m_iDrmFormat)); - if (SURFACE->current.texture->m_iDrmFormat == DRM_FORMAT_ABGR8888) { + if (SURFACE->m_current.texture) { + Debug::log(TRACE, "Cursor CPU surface: format {}, expecting AR24", NFormatUtils::drmFormatName(SURFACE->m_current.texture->m_iDrmFormat)); + if (SURFACE->m_current.texture->m_iDrmFormat == DRM_FORMAT_ABGR8888) { Debug::log(TRACE, "Cursor CPU surface format AB24, will flip. WARNING: this will break on big endian!"); flipRB = true; - } else if (SURFACE->current.texture->m_iDrmFormat != DRM_FORMAT_ARGB8888) { + } else if (SURFACE->m_current.texture->m_iDrmFormat != DRM_FORMAT_ARGB8888) { Debug::log(TRACE, "Cursor CPU surface format rejected, falling back to sw"); return nullptr; } @@ -869,7 +869,7 @@ void CPointerManager::onMonitorLayoutChange() { } SP CPointerManager::getCurrentCursorTexture() { - if (!m_currentCursorImage.pBuffer && (!m_currentCursorImage.surface || !m_currentCursorImage.surface->resource()->current.texture)) + if (!m_currentCursorImage.pBuffer && (!m_currentCursorImage.surface || !m_currentCursorImage.surface->resource()->m_current.texture)) return nullptr; if (m_currentCursorImage.pBuffer) { @@ -878,7 +878,7 @@ SP CPointerManager::getCurrentCursorTexture() { return m_currentCursorImage.bufferTex; } - return m_currentCursorImage.surface->resource()->current.texture; + return m_currentCursorImage.surface->resource()->m_current.texture; } void CPointerManager::attachPointer(SP pointer) { diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index f2a9b0ea..ab542fc2 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -120,7 +120,7 @@ CProtocolManager::CProtocolManager() { auto ref = makeShared(&wl_output_interface, 4, std::format("WLOutput ({})", M->m_name), M->m_self.lock()); PROTO::outputs.emplace(M->m_name, ref); - ref->self = ref; + ref->m_self = ref; m_modeChangeListeners[M->m_name] = M->m_events.modeChanged.registerListener([M, this](std::any d) { onMonitorModeChange(M); }); }); diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index 809c0ad5..f910598d 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -14,11 +14,11 @@ #include CSeatManager::CSeatManager() { - m_listeners.newSeatResource = PROTO::seat->events.newSeatResource.registerListener([this](std::any res) { onNewSeatResource(std::any_cast>(res)); }); + m_listeners.newSeatResource = PROTO::seat->m_events.newSeatResource.registerListener([this](std::any res) { onNewSeatResource(std::any_cast>(res)); }); } CSeatManager::SSeatResourceContainer::SSeatResourceContainer(SP res) : resource(res) { - listeners.destroy = res->events.destroy.registerListener( + listeners.destroy = res->m_events.destroy.registerListener( [this](std::any data) { std::erase_if(g_pSeatManager->m_seatResources, [this](const auto& e) { return e->resource.expired() || e->resource == resource; }); }); } @@ -119,7 +119,7 @@ void CSeatManager::setKeyboardFocus(SP surf) { if (s->resource->client() != client) continue; - for (auto const& k : s->resource->keyboards) { + for (auto const& k : s->resource->m_keyboards) { if (!k) continue; @@ -142,7 +142,7 @@ void CSeatManager::setKeyboardFocus(SP surf) { continue; m_state.keyboardFocusResource = r->resource; - for (auto const& k : r->resource->keyboards) { + for (auto const& k : r->resource->m_keyboards) { if (!k) continue; @@ -151,7 +151,7 @@ void CSeatManager::setKeyboardFocus(SP surf) { } } - m_listeners.keyboardSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setKeyboardFocus(nullptr); }); + m_listeners.keyboardSurfaceDestroy = surf->m_events.destroy.registerListener([this](std::any d) { setKeyboardFocus(nullptr); }); m_events.keyboardFocusChange.emit(); } @@ -164,7 +164,7 @@ void CSeatManager::sendKeyboardKey(uint32_t timeMs, uint32_t key, wl_keyboard_ke if (s->resource->client() != m_state.keyboardFocusResource->client()) continue; - for (auto const& k : s->resource->keyboards) { + for (auto const& k : s->resource->m_keyboards) { if (!k) continue; @@ -181,7 +181,7 @@ void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32 if (s->resource->client() != m_state.keyboardFocusResource->client()) continue; - for (auto const& k : s->resource->keyboards) { + for (auto const& k : s->resource->m_keyboards) { if (!k) continue; @@ -216,7 +216,7 @@ void CSeatManager::setPointerFocus(SP surf, const Vector2D& if (s->resource->client() != client) continue; - for (auto const& p : s->resource->pointers) { + for (auto const& p : s->resource->m_pointers) { if (!p) continue; @@ -245,7 +245,7 @@ void CSeatManager::setPointerFocus(SP surf, const Vector2D& continue; m_state.pointerFocusResource = r->resource; - for (auto const& p : r->resource->pointers) { + for (auto const& p : r->resource->m_pointers) { if (!p) continue; @@ -258,7 +258,7 @@ void CSeatManager::setPointerFocus(SP surf, const Vector2D& sendPointerFrame(); - m_listeners.pointerSurfaceDestroy = surf->events.destroy.registerListener([this](std::any d) { setPointerFocus(nullptr, {}); }); + m_listeners.pointerSurfaceDestroy = surf->m_events.destroy.registerListener([this](std::any d) { setPointerFocus(nullptr, {}); }); m_events.pointerFocusChange.emit(); m_events.dndPointerFocusChange.emit(); @@ -272,7 +272,7 @@ void CSeatManager::sendPointerMotion(uint32_t timeMs, const Vector2D& local) { if (s->resource->client() != m_state.pointerFocusResource->client()) continue; - for (auto const& p : s->resource->pointers) { + for (auto const& p : s->resource->m_pointers) { if (!p) continue; @@ -291,7 +291,7 @@ void CSeatManager::sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_b if (s->resource->client() != m_state.pointerFocusResource->client()) continue; - for (auto const& p : s->resource->pointers) { + for (auto const& p : s->resource->m_pointers) { if (!p) continue; @@ -315,7 +315,7 @@ void CSeatManager::sendPointerFrame(WP pResource) { if (s->resource->client() != pResource->client()) continue; - for (auto const& p : s->resource->pointers) { + for (auto const& p : s->resource->m_pointers) { if (!p) continue; @@ -333,7 +333,7 @@ void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double if (s->resource->client() != m_state.pointerFocusResource->client()) continue; - for (auto const& p : s->resource->pointers) { + for (auto const& p : s->resource->m_pointers) { if (!p) continue; @@ -364,7 +364,7 @@ void CSeatManager::sendTouchDown(SP surf, uint32_t timeMs, i continue; m_state.touchFocusResource = r->resource; - for (auto const& t : r->resource->touches) { + for (auto const& t : r->resource->m_touches) { if (!t) continue; @@ -372,7 +372,7 @@ void CSeatManager::sendTouchDown(SP surf, uint32_t timeMs, i } } - m_listeners.touchSurfaceDestroy = surf->events.destroy.registerListener([this, timeMs, id](std::any d) { sendTouchUp(timeMs + 10, id); }); + m_listeners.touchSurfaceDestroy = surf->m_events.destroy.registerListener([this, timeMs, id](std::any d) { sendTouchUp(timeMs + 10, id); }); m_touchLocks++; @@ -390,7 +390,7 @@ void CSeatManager::sendTouchUp(uint32_t timeMs, int32_t id) { continue; m_state.touchFocusResource = r->resource; - for (auto const& t : r->resource->touches) { + for (auto const& t : r->resource->m_touches) { if (!t) continue; @@ -412,7 +412,7 @@ void CSeatManager::sendTouchMotion(uint32_t timeMs, int32_t id, const Vector2D& if (s->resource->client() != m_state.touchFocusResource->client()) continue; - for (auto const& t : s->resource->touches) { + for (auto const& t : s->resource->m_touches) { if (!t) continue; @@ -429,7 +429,7 @@ void CSeatManager::sendTouchFrame() { if (s->resource->client() != m_state.touchFocusResource->client()) continue; - for (auto const& t : s->resource->touches) { + for (auto const& t : s->resource->m_touches) { if (!t) continue; @@ -446,7 +446,7 @@ void CSeatManager::sendTouchCancel() { if (s->resource->client() != m_state.touchFocusResource->client()) continue; - for (auto const& t : s->resource->touches) { + for (auto const& t : s->resource->m_touches) { if (!t) continue; @@ -463,7 +463,7 @@ void CSeatManager::sendTouchShape(int32_t id, const Vector2D& shape) { if (s->resource->client() != m_state.touchFocusResource->client()) continue; - for (auto const& t : s->resource->touches) { + for (auto const& t : s->resource->m_touches) { if (!t) continue; @@ -480,7 +480,7 @@ void CSeatManager::sendTouchOrientation(int32_t id, double angle) { if (s->resource->client() != m_state.touchFocusResource->client()) continue; - for (auto const& t : s->resource->touches) { + for (auto const& t : s->resource->m_touches) { if (!t) continue; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 1e62af64..c48ca908 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -289,8 +289,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { // if we are holding a pointer button, // and we're not dnd-ing, don't refocus. Keep focus on last surface. - if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->mapped && g_pSeatManager->m_state.pointerFocus && - !m_hardInput) { + if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->m_mapped && + g_pSeatManager->m_state.pointerFocus && !m_hardInput) { foundSurface = g_pSeatManager->m_state.pointerFocus.lock(); // IME popups aren't desktop-like elements @@ -1490,7 +1490,7 @@ bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) { } else { // otherwise fall back to a normal refocus. - if (foundSurface && !foundSurface->hlSurface->keyboardFocusable()) { + if (foundSurface && !foundSurface->m_hlSurface->keyboardFocusable()) { const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock(); g_pCompositor->focusWindow(PLASTWINDOW); } diff --git a/src/managers/input/InputMethodPopup.cpp b/src/managers/input/InputMethodPopup.cpp index c374f63c..ac526c7b 100644 --- a/src/managers/input/InputMethodPopup.cpp +++ b/src/managers/input/InputMethodPopup.cpp @@ -102,7 +102,7 @@ void CInputPopup::updateBox() { cursorBoxParent = {0, 0, (int)parentBox.w, (int)parentBox.h}; } - Vector2D currentPopupSize = m_surface->getViewporterCorrectedSize() / m_surface->resource()->current.scale; + Vector2D currentPopupSize = m_surface->getViewporterCorrectedSize() / m_surface->resource()->m_current.scale; PHLMONITOR pMonitor = g_pCompositor->getMonitorFromVector(parentBox.middle()); diff --git a/src/managers/input/TextInput.cpp b/src/managers/input/TextInput.cpp index 160d1c90..a629cd18 100644 --- a/src/managers/input/TextInput.cpp +++ b/src/managers/input/TextInput.cpp @@ -135,7 +135,7 @@ void CTextInput::setFocusedSurface(SP pSurface) { m_listeners.surfaceUnmap.reset(); m_listeners.surfaceDestroy.reset(); - m_listeners.surfaceUnmap = pSurface->events.unmap.registerListener([this](std::any d) { + m_listeners.surfaceUnmap = pSurface->m_events.unmap.registerListener([this](std::any d) { Debug::log(LOG, "Unmap TI owner1"); if (m_enterLocks) @@ -155,7 +155,7 @@ void CTextInput::setFocusedSurface(SP pSurface) { g_pInputManager->m_relay.deactivateIME(this); }); - m_listeners.surfaceDestroy = pSurface->events.destroy.registerListener([this](std::any d) { + m_listeners.surfaceDestroy = pSurface->m_events.destroy.registerListener([this](std::any d) { Debug::log(LOG, "Destroy TI owner1"); if (m_enterLocks) @@ -181,7 +181,7 @@ bool CTextInput::isV3() { } void CTextInput::enter(SP pSurface) { - if (!pSurface || !pSurface->mapped) + if (!pSurface || !pSurface->m_mapped) return; if (pSurface == focusedSurface()) diff --git a/src/protocols/AlphaModifier.cpp b/src/protocols/AlphaModifier.cpp index 3fea51fe..87c46765 100644 --- a/src/protocols/AlphaModifier.cpp +++ b/src/protocols/AlphaModifier.cpp @@ -30,7 +30,7 @@ void CAlphaModifier::setResource(SP resource) { m_fAlpha = alpha / (float)UINT32_MAX; }); - listeners.surfaceCommitted = m_pSurface->events.commit.registerListener([this](std::any data) { + listeners.surfaceCommitted = m_pSurface->m_events.commit.registerListener([this](std::any data) { auto surface = CWLSurface::fromResource(m_pSurface.lock()); if (surface && surface->m_alphaModifier != m_fAlpha) { @@ -45,7 +45,7 @@ void CAlphaModifier::setResource(SP resource) { } }); - listeners.surfaceDestroyed = m_pSurface->events.destroy.registerListener([this](std::any data) { + listeners.surfaceDestroyed = m_pSurface->m_events.destroy.registerListener([this](std::any data) { if (!m_pResource) PROTO::alphaModifier->destroyAlphaModifier(this); }); diff --git a/src/protocols/CTMControl.cpp b/src/protocols/CTMControl.cpp index a6fad119..c848fab8 100644 --- a/src/protocols/CTMControl.cpp +++ b/src/protocols/CTMControl.cpp @@ -25,7 +25,7 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SPmonitor.lock(); + const auto PMONITOR = OUTPUTRESOURCE->m_monitor.lock(); if UNLIKELY (!PMONITOR) return; // ?!?! diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp index 812ac4c6..5810b414 100644 --- a/src/protocols/ColorManagement.cpp +++ b/src/protocols/ColorManagement.cpp @@ -74,7 +74,7 @@ CColorManager::CColorManager(SP resource) : m_resource(resour return; } - const auto PMONITOR = OUTPUTRESOURCE->monitor.lock(); + const auto PMONITOR = OUTPUTRESOURCE->m_monitor.lock(); if UNLIKELY (!PMONITOR) { r->error(-1, "Invalid output (2)"); @@ -102,7 +102,7 @@ CColorManager::CColorManager(SP resource) : m_resource(resour return; } - if (SURF->colorManagement) { + if (SURF->m_colorManagement) { r->error(WP_COLOR_MANAGER_V1_ERROR_SURFACE_EXISTS, "CM Surface already exists"); return; } @@ -117,7 +117,7 @@ CColorManager::CColorManager(SP resource) : m_resource(resour RESOURCE->self = RESOURCE; - SURF->colorManagement = RESOURCE; + SURF->m_colorManagement = RESOURCE; }); m_resource->setGetSurfaceFeedback([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) { LOGM(TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface); diff --git a/src/protocols/ContentType.cpp b/src/protocols/ContentType.cpp index 0dd5481a..8ea212f1 100644 --- a/src/protocols/ContentType.cpp +++ b/src/protocols/ContentType.cpp @@ -19,7 +19,7 @@ CContentTypeManager::CContentTypeManager(SP resource) : return; } - if (SURF->colorManagement) { + if (SURF->m_colorManagement) { r->error(WP_CONTENT_TYPE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "CT manager already exists"); return; } @@ -33,7 +33,7 @@ CContentTypeManager::CContentTypeManager(SP resource) : RESOURCE->self = RESOURCE; - SURF->contentType = RESOURCE; + SURF->m_contentType = RESOURCE; }); } @@ -42,7 +42,7 @@ bool CContentTypeManager::good() { } CContentType::CContentType(WP surface) { - destroy = surface->events.destroy.registerListener([this](std::any d) { PROTO::contentType->destroyResource(this); }); + destroy = surface->m_events.destroy.registerListener([this](std::any d) { PROTO::contentType->destroyResource(this); }); } CContentType::CContentType(SP resource) : m_resource(resource) { @@ -80,8 +80,8 @@ void CContentTypeProtocol::bindManager(wl_client* client, void* data, uint32_t v } SP CContentTypeProtocol::getContentType(WP surface) { - if (surface->contentType.valid()) - return surface->contentType.lock(); + if (surface->m_contentType.valid()) + return surface->m_contentType.lock(); return m_vContentTypes.emplace_back(makeShared(surface)); } diff --git a/src/protocols/DRMSyncobj.cpp b/src/protocols/DRMSyncobj.cpp index 48a80dcc..2da2340a 100644 --- a/src/protocols/DRMSyncobj.cpp +++ b/src/protocols/DRMSyncobj.cpp @@ -74,38 +74,38 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UPtimeline, ((uint64_t)hi << 32) | (uint64_t)lo}; }); - listeners.surfacePrecommit = surface->events.precommit.registerListener([this](std::any d) { - if (!surface->pending.updated.buffer || !surface->pending.buffer) { + listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) { + if (!surface->m_pending.updated.buffer || !surface->m_pending.buffer) { if (pendingAcquire.timeline() || pendingRelease.timeline()) { resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER, "Missing buffer"); - surface->pending.rejected = true; + surface->m_pending.rejected = true; } return; } if (!pendingAcquire.timeline()) { resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_ACQUIRE_POINT, "Missing acquire timeline"); - surface->pending.rejected = true; + surface->m_pending.rejected = true; return; } if (!pendingRelease.timeline()) { resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_RELEASE_POINT, "Missing release timeline"); - surface->pending.rejected = true; + surface->m_pending.rejected = true; return; } if (pendingAcquire.timeline() == pendingRelease.timeline() && pendingAcquire.point() >= 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"); - surface->pending.rejected = true; + surface->m_pending.rejected = true; return; } - surface->pending.updated.acquire = true; - surface->pending.acquire = pendingAcquire; - pendingAcquire = {}; + surface->m_pending.updated.acquire = true; + surface->m_pending.acquire = pendingAcquire; + pendingAcquire = {}; - surface->pending.buffer->addReleasePoint(pendingRelease); + surface->m_pending.buffer->addReleasePoint(pendingRelease); pendingRelease = {}; }); } @@ -163,7 +163,7 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UPsyncobj) { + if UNLIKELY (SURF->m_syncobj) { resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS, "Surface already has a syncobj attached"); return; } @@ -176,7 +176,7 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UPsyncobj = RESOURCE; + SURF->m_syncobj = RESOURCE; LOGM(LOG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get()); }); diff --git a/src/protocols/FocusGrab.cpp b/src/protocols/FocusGrab.cpp index 9a3e1c51..9751666d 100644 --- a/src/protocols/FocusGrab.cpp +++ b/src/protocols/FocusGrab.cpp @@ -8,7 +8,7 @@ #include CFocusGrabSurfaceState::CFocusGrabSurfaceState(CFocusGrab* grab, SP surface) { - listeners.destroy = surface->events.destroy.registerListener([=](std::any d) { grab->eraseSurface(surface); }); + listeners.destroy = surface->m_events.destroy.registerListener([=](std::any d) { grab->eraseSurface(surface); }); } CFocusGrab::CFocusGrab(SP resource_) : resource(resource_) { diff --git a/src/protocols/ForeignToplevelWlr.cpp b/src/protocols/ForeignToplevelWlr.cpp index 2a2929e5..38ce60d2 100644 --- a/src/protocols/ForeignToplevelWlr.cpp +++ b/src/protocols/ForeignToplevelWlr.cpp @@ -41,7 +41,7 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPmonitor; + const auto wpMonitor = CWLOutputResource::fromResource(output)->m_monitor; if (!wpMonitor.expired()) { const auto monitor = wpMonitor.lock(); diff --git a/src/protocols/FractionalScale.cpp b/src/protocols/FractionalScale.cpp index 494de9c5..a9fbcb16 100644 --- a/src/protocols/FractionalScale.cpp +++ b/src/protocols/FractionalScale.cpp @@ -47,7 +47,7 @@ void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* if (std::ranges::find_if(m_mSurfaceScales, [surface](const auto& e) { return e.first == surface; }) == m_mSurfaceScales.end()) m_mSurfaceScales.emplace(surface, 1.F); - if (surface->mapped) + if (surface->m_mapped) PADDON->setScale(m_mSurfaceScales.at(surface)); // clean old diff --git a/src/protocols/FrogColorManagement.cpp b/src/protocols/FrogColorManagement.cpp index 99bdb2bb..870b573f 100644 --- a/src/protocols/FrogColorManagement.cpp +++ b/src/protocols/FrogColorManagement.cpp @@ -61,7 +61,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SPclient(); - if (!surface->colorManagement.valid()) { + if (!surface->m_colorManagement.valid()) { const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared(surface_)); if UNLIKELY (!RESOURCE) { resource->noMemory(); @@ -71,12 +71,12 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SPself = RESOURCE; - surface->colorManagement = RESOURCE; + surface->m_colorManagement = RESOURCE; resource->setOnDestroy([this](CFrogColorManagedSurface* r) { LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)surface); if (surface.valid()) - PROTO::colorManagement->destroyResource(surface->colorManagement.get()); + PROTO::colorManagement->destroyResource(surface->m_colorManagement.get()); PROTO::frogColorManagement->destroyResource(this); }); } else @@ -94,7 +94,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SPid()); switch (tf) { case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ: - surface->colorManagement->m_imageDescription.transferFunction = + surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); break; ; @@ -102,7 +102,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SPcolorManagement->m_imageDescription.transferFunction = + surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); break; }; @@ -110,40 +110,40 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SPcolorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); + surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); - surface->colorManagement->setHasImageDescription(true); + surface->m_colorManagement->setHasImageDescription(true); } }); resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) { LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName); switch (primariesName) { case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED: - case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: surface->colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break; - case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: surface->colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break; + case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: 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; } - surface->colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName)); + surface->m_colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName)); - surface->colorManagement->setHasImageDescription(true); + surface->m_colorManagement->setHasImageDescription(true); }); resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) { LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent); pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; - surface->colorManagement->setHasImageDescription(true); + 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, 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); - surface->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}, - .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, - .white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}}; - surface->colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f; - surface->colorManagement->m_imageDescription.masteringLuminances.max = max_lum; - surface->colorManagement->m_imageDescription.maxCLL = cll; - surface->colorManagement->m_imageDescription.maxFALL = fall; + 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}, + .blue = {.x = b_x / 50000.0f, .y = b_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; + surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum; + surface->m_colorManagement->m_imageDescription.maxCLL = cll; + surface->m_colorManagement->m_imageDescription.maxFALL = fall; - surface->colorManagement->setHasImageDescription(true); + surface->m_colorManagement->setHasImageDescription(true); }); } diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp index 322f0e56..1309ffc5 100644 --- a/src/protocols/GammaControl.cpp +++ b/src/protocols/GammaControl.cpp @@ -18,7 +18,7 @@ CGammaControl::CGammaControl(SP resource_, wl_resource* out return; } - pMonitor = OUTPUTRES->monitor; + pMonitor = OUTPUTRES->m_monitor; if UNLIKELY (!pMonitor || !pMonitor->m_output) { LOGM(ERR, "No CMonitor"); diff --git a/src/protocols/HyprlandSurface.cpp b/src/protocols/HyprlandSurface.cpp index cdf6d722..13d5a49a 100644 --- a/src/protocols/HyprlandSurface.cpp +++ b/src/protocols/HyprlandSurface.cpp @@ -48,10 +48,10 @@ void CHyprlandSurface::setResource(SP resource) { } m_bVisibleRegionChanged = true; - m_visibleRegion = CWLRegionResource::fromResource(region)->region; + m_visibleRegion = CWLRegionResource::fromResource(region)->m_region; }); - listeners.surfaceCommitted = m_pSurface->events.commit.registerListener([this](std::any data) { + listeners.surfaceCommitted = m_pSurface->m_events.commit.registerListener([this](std::any data) { auto surface = CWLSurface::fromResource(m_pSurface.lock()); if (surface && (surface->m_overallOpacity != m_fOpacity || m_bVisibleRegionChanged)) { @@ -67,7 +67,7 @@ void CHyprlandSurface::setResource(SP resource) { } }); - listeners.surfaceDestroyed = m_pSurface->events.destroy.registerListener([this](std::any data) { + listeners.surfaceDestroyed = m_pSurface->m_events.destroy.registerListener([this](std::any data) { if (!m_pResource) PROTO::hyprlandSurface->destroySurface(this); }); diff --git a/src/protocols/IdleInhibit.cpp b/src/protocols/IdleInhibit.cpp index a015cdd0..b8ba01e2 100644 --- a/src/protocols/IdleInhibit.cpp +++ b/src/protocols/IdleInhibit.cpp @@ -6,7 +6,7 @@ CIdleInhibitor::CIdleInhibitor(SP resource_, SP resource_, SP surface_) : resource(resource_), surface(surface_) { - listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { + listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { surface.reset(); listeners.destroySurface.reset(); destroySent = true; diff --git a/src/protocols/InputMethodV2.cpp b/src/protocols/InputMethodV2.cpp index 05cf90e1..ae575250 100644 --- a/src/protocols/InputMethodV2.cpp +++ b/src/protocols/InputMethodV2.cpp @@ -88,7 +88,7 @@ CInputMethodPopupV2::CInputMethodPopupV2(SP resource_, pSurface = surface; - listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { + listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { if (mapped) events.unmap.emit(); @@ -101,15 +101,15 @@ CInputMethodPopupV2::CInputMethodPopupV2(SP resource_, pSurface.reset(); }); - listeners.commitSurface = surface->events.commit.registerListener([this](std::any d) { - if (pSurface->current.texture && !mapped) { + listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) { + if (pSurface->m_current.texture && !mapped) { mapped = true; pSurface->map(); events.map.emit(); return; } - if (!pSurface->current.texture && mapped) { + if (!pSurface->m_current.texture && mapped) { mapped = false; pSurface->unmap(); events.unmap.emit(); diff --git a/src/protocols/LayerShell.cpp b/src/protocols/LayerShell.cpp index 7f5d366a..bc4112fa 100644 --- a/src/protocols/LayerShell.cpp +++ b/src/protocols/LayerShell.cpp @@ -33,18 +33,18 @@ CLayerShellResource::CLayerShellResource(SP resource_, SPdestroyResource(this); }); - listeners.destroySurface = surf_->events.destroy.registerListener([this](std::any d) { + listeners.destroySurface = surf_->m_events.destroy.registerListener([this](std::any d) { events.destroy.emit(); PROTO::layerShell->destroyResource(this); }); - listeners.unmapSurface = surf_->events.unmap.registerListener([this](std::any d) { events.unmap.emit(); }); + listeners.unmapSurface = surf_->m_events.unmap.registerListener([this](std::any d) { events.unmap.emit(); }); - listeners.commitSurface = surf_->events.commit.registerListener([this](std::any d) { + listeners.commitSurface = surf_->m_events.commit.registerListener([this](std::any d) { current = pending; pending.committed = 0; - bool attachedBuffer = surface->current.texture; + bool attachedBuffer = surface->m_current.texture; if (attachedBuffer && !configured) { surface->error(-1, "layerSurface was not configured, but a buffer was attached"); @@ -220,7 +220,7 @@ void CLayerShellProtocol::destroyResource(CLayerShellResource* surf) { void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_) { const auto CLIENT = pMgr->client(); - const auto PMONITOR = output ? CWLOutputResource::fromResource(output)->monitor.lock() : nullptr; + const auto PMONITOR = output ? CWLOutputResource::fromResource(output)->m_monitor.lock() : nullptr; auto SURF = CWLSurfaceResource::fromResource(surface); if UNLIKELY (!SURF) { @@ -228,7 +228,7 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id return; } - if UNLIKELY (SURF->role->role() != SURFACE_ROLE_UNASSIGNED) { + if UNLIKELY (SURF->m_role->role() != SURFACE_ROLE_UNASSIGNED) { pMgr->error(-1, "Surface already has a different role"); return; } @@ -246,7 +246,7 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id return; } - SURF->role = makeShared(RESOURCE); + SURF->m_role = makeShared(RESOURCE); g_pCompositor->m_layers.emplace_back(CLayerSurface::create(RESOURCE)); LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get()); diff --git a/src/protocols/OutputPower.cpp b/src/protocols/OutputPower.cpp index 55ea0376..37f932bb 100644 --- a/src/protocols/OutputPower.cpp +++ b/src/protocols/OutputPower.cpp @@ -68,7 +68,7 @@ void COutputPowerProtocol::onGetOutputPower(CZwlrOutputPowerManagerV1* pMgr, uin } const auto CLIENT = pMgr->client(); - const auto RESOURCE = m_vOutputPowers.emplace_back(makeUnique(makeShared(CLIENT, pMgr->version(), id), OUTPUT->monitor.lock())).get(); + const auto RESOURCE = m_vOutputPowers.emplace_back(makeUnique(makeShared(CLIENT, pMgr->version(), id), OUTPUT->m_monitor.lock())).get(); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); diff --git a/src/protocols/PointerConstraints.cpp b/src/protocols/PointerConstraints.cpp index c97759d8..38df694c 100644 --- a/src/protocols/PointerConstraints.cpp +++ b/src/protocols/PointerConstraints.cpp @@ -22,7 +22,7 @@ CPointerConstraint::CPointerConstraint(SP resource_, SPregion); + region.set(CWLRegionResource::fromResource(region_)->m_region); resource_->setSetRegion([this](CZwpLockedPointerV1* p, wl_resource* region) { onSetRegion(region); }); resource_->setSetCursorPositionHint([this](CZwpLockedPointerV1* p, wl_fixed_t x, wl_fixed_t y) { @@ -61,7 +61,7 @@ CPointerConstraint::CPointerConstraint(SP resource_, SPregion); + region.set(CWLRegionResource::fromResource(region_)->m_region); resource_->setSetRegion([this](CZwpConfinedPointerV1* p, wl_resource* region) { onSetRegion(region); }); @@ -151,7 +151,7 @@ void CPointerConstraint::onSetRegion(wl_resource* wlRegion) { return; } - const auto REGION = region.set(CWLRegionResource::fromResource(wlRegion)->region); + const auto REGION = region.set(CWLRegionResource::fromResource(wlRegion)->m_region); region.set(REGION); positionHint = region.closestPoint(positionHint); diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 28523fde..4539a463 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -22,7 +22,7 @@ CScreencopyFrame::CScreencopyFrame(SP resource_, int32_t return; overlayCursor = !!overlay_cursor; - pMonitor = CWLOutputResource::fromResource(output)->monitor; + pMonitor = CWLOutputResource::fromResource(output)->m_monitor; if (!pMonitor) { LOGM(ERR, "Client requested sharing of a monitor that doesnt exist"); diff --git a/src/protocols/SessionLock.cpp b/src/protocols/SessionLock.cpp index 40c73a7b..0eccb543 100644 --- a/src/protocols/SessionLock.cpp +++ b/src/protocols/SessionLock.cpp @@ -23,8 +23,8 @@ CSessionLockSurface::CSessionLockSurface(SP resource_, resource->setAckConfigure([this](CExtSessionLockSurfaceV1* r, uint32_t serial) { ackdConfigure = true; }); - listeners.surfaceCommit = pSurface->events.commit.registerListener([this](std::any d) { - if (!pSurface->current.texture) { + listeners.surfaceCommit = pSurface->m_events.commit.registerListener([this](std::any d) { + if (!pSurface->m_current.texture) { LOGM(ERR, "SessionLock attached a null buffer"); resource->error(EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER, "Null buffer attached"); return; @@ -45,7 +45,7 @@ CSessionLockSurface::CSessionLockSurface(SP resource_, committed = true; }); - listeners.surfaceDestroy = pSurface->events.destroy.registerListener([this](std::any d) { + listeners.surfaceDestroy = pSurface->m_events.destroy.registerListener([this](std::any d) { LOGM(WARN, "SessionLockSurface object remains but surface is being destroyed???"); pSurface->unmap(); listeners.surfaceCommit.reset(); @@ -64,7 +64,7 @@ CSessionLockSurface::CSessionLockSurface(SP resource_, } CSessionLockSurface::~CSessionLockSurface() { - if (pSurface && pSurface->mapped) + if (pSurface && pSurface->m_mapped) pSurface->unmap(); listeners.surfaceCommit.reset(); listeners.surfaceDestroy.reset(); @@ -189,7 +189,7 @@ void CSessionLockProtocol::onGetLockSurface(CExtSessionLockV1* lock, uint32_t id LOGM(LOG, "New sessionLockSurface with id {}", id); auto PSURFACE = CWLSurfaceResource::fromResource(surface); - auto PMONITOR = CWLOutputResource::fromResource(output)->monitor.lock(); + auto PMONITOR = CWLOutputResource::fromResource(output)->m_monitor.lock(); SP sessionLock; for (auto const& l : m_vLocks) { diff --git a/src/protocols/Viewporter.cpp b/src/protocols/Viewporter.cpp index 674b8373..0b82603f 100644 --- a/src/protocols/Viewporter.cpp +++ b/src/protocols/Viewporter.cpp @@ -15,10 +15,10 @@ CViewportResource::CViewportResource(SP resource_, SPpending.updated.viewport = true; + surface->m_pending.updated.viewport = true; if (x == -1 && y == -1) { - surface->pending.viewport.hasDestination = false; + surface->m_pending.viewport.hasDestination = false; return; } @@ -27,8 +27,8 @@ CViewportResource::CViewportResource(SP resource_, SPpending.viewport.hasDestination = true; - surface->pending.viewport.destination = {x, y}; + surface->m_pending.viewport.hasDestination = true; + surface->m_pending.viewport.destination = {x, y}; }); resource->setSetSource([this](CWpViewport* r, wl_fixed_t fx, wl_fixed_t fy, wl_fixed_t fw, wl_fixed_t fh) { @@ -37,12 +37,12 @@ CViewportResource::CViewportResource(SP resource_, SPpending.updated.viewport = true; + surface->m_pending.updated.viewport = true; double x = wl_fixed_to_double(fx), y = wl_fixed_to_double(fy), w = wl_fixed_to_double(fw), h = wl_fixed_to_double(fh); if (x == -1 && y == -1 && w == -1 && h == -1) { - surface->pending.viewport.hasSource = false; + surface->m_pending.viewport.hasSource = false; return; } @@ -51,20 +51,20 @@ CViewportResource::CViewportResource(SP resource_, SPpending.viewport.hasSource = true; - surface->pending.viewport.source = {x, y, w, h}; + surface->m_pending.viewport.hasSource = true; + surface->m_pending.viewport.source = {x, y, w, h}; }); - listeners.surfacePrecommit = surface->events.precommit.registerListener([this](std::any d) { - if (!surface || !surface->pending.buffer) + listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) { + if (!surface || !surface->m_pending.buffer) return; - if (surface->pending.viewport.hasSource) { - auto& src = surface->pending.viewport.source; + if (surface->m_pending.viewport.hasSource) { + auto& src = surface->m_pending.viewport.source; - if (src.w + src.x > surface->pending.bufferSize.x || src.h + src.y > surface->pending.bufferSize.y) { + if (src.w + src.x > surface->m_pending.bufferSize.x || src.h + src.y > surface->m_pending.bufferSize.y) { resource->error(WP_VIEWPORT_ERROR_BAD_VALUE, "Box doesn't fit"); - surface->pending.rejected = true; + surface->m_pending.rejected = true; return; } } @@ -75,8 +75,8 @@ CViewportResource::~CViewportResource() { if (!surface) return; - surface->pending.viewport.hasDestination = false; - surface->pending.viewport.hasSource = false; + surface->m_pending.viewport.hasDestination = false; + surface->m_pending.viewport.hasSource = false; } bool CViewportResource::good() { diff --git a/src/protocols/VirtualPointer.cpp b/src/protocols/VirtualPointer.cpp index 8dc4bab6..ce64e1e5 100644 --- a/src/protocols/VirtualPointer.cpp +++ b/src/protocols/VirtualPointer.cpp @@ -121,7 +121,7 @@ void CVirtualPointerProtocol::bindManager(wl_client* client, void* data, uint32_ return; } - this->onCreatePointer(pMgr, seat, id, RES->monitor); + this->onCreatePointer(pMgr, seat, id, RES->m_monitor); } else this->onCreatePointer(pMgr, seat, id, {}); }); diff --git a/src/protocols/XDGOutput.cpp b/src/protocols/XDGOutput.cpp index 81c71447..92aaefc9 100644 --- a/src/protocols/XDGOutput.cpp +++ b/src/protocols/XDGOutput.cpp @@ -42,7 +42,7 @@ CXDGOutputProtocol::CXDGOutputProtocol(const wl_interface* iface, const int& ver void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource) { const auto OUTPUT = CWLOutputResource::fromResource(outputResource); - const auto PMONITOR = OUTPUT->monitor.lock(); + const auto PMONITOR = OUTPUT->m_monitor.lock(); const auto CLIENT = mgr->client(); CXDGOutput* pXDGOutput = m_vXDGOutputs.emplace_back(makeUnique(makeShared(CLIENT, mgr->version(), id), PMONITOR)).get(); @@ -52,7 +52,7 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32 #endif pXDGOutput->client = CLIENT; - pXDGOutput->outputProto = OUTPUT->owner; + pXDGOutput->outputProto = OUTPUT->m_owner; if UNLIKELY (!pXDGOutput->resource->resource()) { m_vXDGOutputs.pop_back(); diff --git a/src/protocols/XDGShell.cpp b/src/protocols/XDGShell.cpp index a82ba17e..6f58ef64 100644 --- a/src/protocols/XDGShell.cpp +++ b/src/protocols/XDGShell.cpp @@ -195,7 +195,7 @@ CXDGToplevelResource::CXDGToplevelResource(SP resource_, SPsetSetFullscreen([this](CXdgToplevel* r, wl_resource* output) { if (output) - if (const auto PM = CWLOutputResource::fromResource(output)->monitor; PM) + if (const auto PM = CWLOutputResource::fromResource(output)->m_monitor; PM) state.requestsFullscreenMonitor = PM->m_id; state.requestsFullscreen = true; @@ -372,7 +372,7 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP resource_, SPdestroyResource(this); }); - listeners.surfaceDestroy = surface->events.destroy.registerListener([this](std::any d) { + listeners.surfaceDestroy = surface->m_events.destroy.registerListener([this](std::any d) { LOGM(WARN, "wl_surface destroyed before its xdg_surface role object"); listeners.surfaceDestroy.reset(); listeners.surfaceCommit.reset(); @@ -385,17 +385,17 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP resource_, SPevents.commit.registerListener([this](std::any d) { + listeners.surfaceCommit = surface->m_events.commit.registerListener([this](std::any d) { current = pending; if (toplevel) toplevel->current = toplevel->pending; - if UNLIKELY (initialCommit && surface->pending.buffer) { + if UNLIKELY (initialCommit && surface->m_pending.buffer) { resource->error(-1, "Buffer attached before initial commit"); return; } - if (surface->current.texture && !mapped) { + if (surface->m_current.texture && !mapped) { // this forces apps to not draw CSD. if (toplevel) toplevel->setMaximized(true); @@ -406,7 +406,7 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP resource_, SPcurrent.texture && mapped) { + if (!surface->m_current.texture && mapped) { mapped = false; events.unmap.emit(); surface->unmap(); @@ -723,7 +723,7 @@ CXDGWMBase::CXDGWMBase(SP resource_) : resource(resource_) { return; } - if UNLIKELY (SURF->role->role() != SURFACE_ROLE_UNASSIGNED) { + if UNLIKELY (SURF->m_role->role() != SURFACE_ROLE_UNASSIGNED) { r->error(-1, "Surface already has a different role"); return; } @@ -738,7 +738,7 @@ CXDGWMBase::CXDGWMBase(SP resource_) : resource(resource_) { RESOURCE->self = RESOURCE; RESOURCE->surface = SURF; - SURF->role = makeShared(RESOURCE); + SURF->m_role = makeShared(RESOURCE); surfaces.emplace_back(RESOURCE); diff --git a/src/protocols/XXColorManagement.cpp b/src/protocols/XXColorManagement.cpp index 8231ec22..182c2a6d 100644 --- a/src/protocols/XXColorManagement.cpp +++ b/src/protocols/XXColorManagement.cpp @@ -88,7 +88,7 @@ CXXColorManager::CXXColorManager(SP resource_) : resource(res return; } - if (SURF->colorManagement) { + if (SURF->m_colorManagement) { r->error(XX_COLOR_MANAGER_V4_ERROR_SURFACE_EXISTS, "CM Surface already exists"); return; } @@ -195,7 +195,7 @@ CXXColorManagementSurface::CXXColorManagementSurface(SPclient(); - if (!surface->colorManagement.valid()) { + if (!surface->m_colorManagement.valid()) { const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared(surface_)); if UNLIKELY (!RESOURCE) { resource->noMemory(); @@ -205,12 +205,12 @@ CXXColorManagementSurface::CXXColorManagementSurface(SPself = RESOURCE; - surface->colorManagement = RESOURCE; + surface->m_colorManagement = RESOURCE; resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)surface); if (surface.valid()) - PROTO::colorManagement->destroyResource(surface->colorManagement.get()); + PROTO::colorManagement->destroyResource(surface->m_colorManagement.get()); PROTO::xxColorManagement->destroyResource(this); }); } else @@ -245,16 +245,16 @@ CXXColorManagementSurface::CXXColorManagementSurface(SPcolorManagement->m_imageDescription = imageDescription->get()->settings; - surface->colorManagement->setHasImageDescription(true); + surface->m_colorManagement->m_imageDescription = imageDescription->get()->settings; + surface->m_colorManagement->setHasImageDescription(true); } else LOGM(ERR, "Set image description for invalid surface"); }); resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) { LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r); if (surface.valid()) { - surface->colorManagement->m_imageDescription = SImageDescription{}; - surface->colorManagement->setHasImageDescription(false); + surface->m_colorManagement->m_imageDescription = SImageDescription{}; + surface->m_colorManagement->setHasImageDescription(false); } else LOGM(ERR, "Unset image description for invalid surface"); }); diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index b58ece97..df1916ef 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -24,129 +24,129 @@ class CDefaultSurfaceRole : public ISurfaceRole { } }; -CWLCallbackResource::CWLCallbackResource(SP resource_) : resource(resource_) { +CWLCallbackResource::CWLCallbackResource(SP resource_) : m_resource(resource_) { ; } bool CWLCallbackResource::good() { - return resource->resource(); + return m_resource->resource(); } void CWLCallbackResource::send(const Time::steady_tp& now) { - resource->sendDone(Time::millis(now)); + m_resource->sendDone(Time::millis(now)); } -CWLRegionResource::CWLRegionResource(SP resource_) : resource(resource_) { +CWLRegionResource::CWLRegionResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setDestroy([this](CWlRegion* r) { PROTO::compositor->destroyResource(this); }); - resource->setOnDestroy([this](CWlRegion* r) { PROTO::compositor->destroyResource(this); }); + m_resource->setDestroy([this](CWlRegion* r) { PROTO::compositor->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlRegion* r) { PROTO::compositor->destroyResource(this); }); - resource->setAdd([this](CWlRegion* r, int32_t x, int32_t y, int32_t w, int32_t h) { region.add(CBox{x, y, w, h}); }); - resource->setSubtract([this](CWlRegion* r, int32_t x, int32_t y, int32_t w, int32_t h) { region.subtract(CBox{x, y, w, h}); }); + m_resource->setAdd([this](CWlRegion* r, int32_t x, int32_t y, int32_t w, int32_t h) { m_region.add(CBox{x, y, w, h}); }); + m_resource->setSubtract([this](CWlRegion* r, int32_t x, int32_t y, int32_t w, int32_t h) { m_region.subtract(CBox{x, y, w, h}); }); } bool CWLRegionResource::good() { - return resource->resource(); + return m_resource->resource(); } SP CWLRegionResource::fromResource(wl_resource* res) { auto data = (CWLRegionResource*)(((CWlRegion*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } -CWLSurfaceResource::CWLSurfaceResource(SP resource_) : resource(resource_) { +CWLSurfaceResource::CWLSurfaceResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - resource->setData(this); + m_resource->setData(this); - role = makeShared(); + m_role = makeShared(); - resource->setDestroy([this](CWlSurface* r) { destroy(); }); - resource->setOnDestroy([this](CWlSurface* r) { destroy(); }); + m_resource->setDestroy([this](CWlSurface* r) { destroy(); }); + m_resource->setOnDestroy([this](CWlSurface* r) { destroy(); }); - resource->setAttach([this](CWlSurface* r, wl_resource* buffer, int32_t x, int32_t y) { - pending.updated.buffer = true; - pending.updated.offset = true; + m_resource->setAttach([this](CWlSurface* r, wl_resource* buffer, int32_t x, int32_t y) { + m_pending.updated.buffer = true; + m_pending.updated.offset = true; - pending.offset = {x, y}; + m_pending.offset = {x, y}; - if (pending.buffer) - pending.buffer.drop(); + if (m_pending.buffer) + m_pending.buffer.drop(); auto buf = buffer ? CWLBufferResource::fromResource(buffer) : nullptr; if (buf && buf->buffer) { - pending.buffer = CHLBufferReference(buf->buffer.lock()); - pending.texture = buf->buffer->texture; - pending.size = buf->buffer->size; - pending.bufferSize = buf->buffer->size; + m_pending.buffer = CHLBufferReference(buf->buffer.lock()); + m_pending.texture = buf->buffer->texture; + m_pending.size = buf->buffer->size; + m_pending.bufferSize = buf->buffer->size; } else { - pending.buffer = {}; - pending.texture.reset(); - pending.size = Vector2D{}; - pending.bufferSize = Vector2D{}; + m_pending.buffer = {}; + m_pending.texture.reset(); + m_pending.size = Vector2D{}; + m_pending.bufferSize = Vector2D{}; } - if (pending.bufferSize != current.bufferSize) { - pending.updated.damage = true; - pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; + if (m_pending.bufferSize != m_current.bufferSize) { + m_pending.updated.damage = true; + m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; } }); - resource->setCommit([this](CWlSurface* r) { - if (pending.buffer) - pending.bufferDamage.intersect(CBox{{}, pending.bufferSize}); + m_resource->setCommit([this](CWlSurface* r) { + if (m_pending.buffer) + m_pending.bufferDamage.intersect(CBox{{}, m_pending.bufferSize}); - if (!pending.buffer) - pending.size = {}; - else if (pending.viewport.hasDestination) - pending.size = pending.viewport.destination; - else if (pending.viewport.hasSource) - pending.size = pending.viewport.source.size(); + if (!m_pending.buffer) + m_pending.size = {}; + else if (m_pending.viewport.hasDestination) + m_pending.size = m_pending.viewport.destination; + else if (m_pending.viewport.hasSource) + m_pending.size = m_pending.viewport.source.size(); else { - Vector2D tfs = pending.transform % 2 == 1 ? Vector2D{pending.bufferSize.y, pending.bufferSize.x} : pending.bufferSize; - pending.size = tfs / pending.scale; + Vector2D tfs = m_pending.transform % 2 == 1 ? Vector2D{m_pending.bufferSize.y, m_pending.bufferSize.x} : m_pending.bufferSize; + m_pending.size = tfs / m_pending.scale; } - pending.damage.intersect(CBox{{}, pending.size}); + m_pending.damage.intersect(CBox{{}, m_pending.size}); - events.precommit.emit(); - if (pending.rejected) { - pending.rejected = false; + m_events.precommit.emit(); + if (m_pending.rejected) { + m_pending.rejected = false; dropPendingBuffer(); return; } - if ((!pending.updated.buffer) || // no new buffer attached - (!pending.buffer && !pending.texture) // null buffer attached + if ((!m_pending.updated.buffer) || // no new buffer attached + (!m_pending.buffer && !m_pending.texture) // null buffer attached ) { - commitState(pending); - pending.reset(); + commitState(m_pending); + m_pending.reset(); return; } // save state while we wait for buffer to become ready to read - const auto& state = pendingStates.emplace(makeUnique(pending)); - pending.reset(); + const auto& state = m_pendingStates.emplace(makeUnique(m_pending)); + m_pending.reset(); - auto whenReadable = [this, surf = self, state = WP(pendingStates.back())] { + auto whenReadable = [this, surf = m_self, state = WP(m_pendingStates.back())] { if (!surf || state.expired()) return; - while (!pendingStates.empty() && pendingStates.front() != state) { - commitState(*pendingStates.front()); - pendingStates.pop(); + while (!m_pendingStates.empty() && m_pendingStates.front() != state) { + commitState(*m_pendingStates.front()); + m_pendingStates.pop(); } - commitState(*pendingStates.front()); - pendingStates.pop(); + commitState(*m_pendingStates.front()); + m_pendingStates.pop(); }; if (state->updated.acquire) { @@ -169,106 +169,106 @@ CWLSurfaceResource::CWLSurfaceResource(SP resource_) : resource(reso } }); - resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { - pending.updated.damage = true; - pending.damage.add(CBox{x, y, w, h}); + m_resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { + m_pending.updated.damage = true; + m_pending.damage.add(CBox{x, y, w, h}); }); - resource->setDamageBuffer([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { - pending.updated.damage = true; - pending.bufferDamage.add(CBox{x, y, w, h}); + m_resource->setDamageBuffer([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { + m_pending.updated.damage = true; + m_pending.bufferDamage.add(CBox{x, y, w, h}); }); - resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) { - if (scale == pending.scale) + m_resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) { + if (scale == m_pending.scale) return; - pending.updated.scale = true; - pending.updated.damage = true; + m_pending.updated.scale = true; + m_pending.updated.damage = true; - pending.scale = scale; - pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; + m_pending.scale = scale; + m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; }); - resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) { - if (tr == pending.transform) + m_resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) { + if (tr == m_pending.transform) return; - pending.updated.transform = true; - pending.updated.damage = true; + m_pending.updated.transform = true; + m_pending.updated.damage = true; - pending.transform = (wl_output_transform)tr; - pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; + m_pending.transform = (wl_output_transform)tr; + m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; }); - resource->setSetInputRegion([this](CWlSurface* r, wl_resource* region) { - pending.updated.input = true; + m_resource->setSetInputRegion([this](CWlSurface* r, wl_resource* region) { + m_pending.updated.input = true; if (!region) { - pending.input = CBox{{}, {INT32_MAX, INT32_MAX}}; + m_pending.input = CBox{{}, {INT32_MAX, INT32_MAX}}; return; } - auto RG = CWLRegionResource::fromResource(region); - pending.input = RG->region; + auto RG = CWLRegionResource::fromResource(region); + m_pending.input = RG->m_region; }); - resource->setSetOpaqueRegion([this](CWlSurface* r, wl_resource* region) { - pending.updated.opaque = true; + m_resource->setSetOpaqueRegion([this](CWlSurface* r, wl_resource* region) { + m_pending.updated.opaque = true; if (!region) { - pending.opaque = CBox{{}, {}}; + m_pending.opaque = CBox{{}, {}}; return; } - auto RG = CWLRegionResource::fromResource(region); - pending.opaque = RG->region; + auto RG = CWLRegionResource::fromResource(region); + m_pending.opaque = RG->m_region; }); - resource->setFrame([this](CWlSurface* r, uint32_t id) { callbacks.emplace_back(makeShared(makeShared(pClient, 1, id))); }); + m_resource->setFrame([this](CWlSurface* r, uint32_t id) { m_callbacks.emplace_back(makeShared(makeShared(m_client, 1, id))); }); - resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) { - pending.updated.offset = true; - pending.offset = {x, y}; + m_resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) { + m_pending.updated.offset = true; + m_pending.offset = {x, y}; }); } CWLSurfaceResource::~CWLSurfaceResource() { - events.destroy.emit(); + m_events.destroy.emit(); } void CWLSurfaceResource::destroy() { - if (mapped) { - events.unmap.emit(); + if (m_mapped) { + m_events.unmap.emit(); unmap(); } - events.destroy.emit(); + m_events.destroy.emit(); releaseBuffers(false); PROTO::compositor->destroyResource(this); } void CWLSurfaceResource::dropPendingBuffer() { - pending.buffer = {}; + m_pending.buffer = {}; } void CWLSurfaceResource::dropCurrentBuffer() { - current.buffer = {}; + m_current.buffer = {}; } SP CWLSurfaceResource::fromResource(wl_resource* res) { auto data = (CWLSurfaceResource*)(((CWlSurface*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } bool CWLSurfaceResource::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CWLSurfaceResource::client() { - return pClient; + return m_client; } void CWLSurfaceResource::enter(PHLMONITOR monitor) { - if (std::find(enteredOutputs.begin(), enteredOutputs.end(), monitor) != enteredOutputs.end()) + if (std::find(m_enteredOutputs.begin(), m_enteredOutputs.end(), monitor) != m_enteredOutputs.end()) return; if UNLIKELY (!PROTO::outputs.contains(monitor->m_name)) { @@ -282,59 +282,59 @@ void CWLSurfaceResource::enter(PHLMONITOR monitor) { return; } - auto output = PROTO::outputs.at(monitor->m_name)->outputResourceFrom(pClient); + auto output = PROTO::outputs.at(monitor->m_name)->outputResourceFrom(m_client); if UNLIKELY (!output || !output->getResource() || !output->getResource()->resource()) { LOGM(ERR, "Cannot enter surface {:x} to {}, client hasn't bound the output", (uintptr_t)this, monitor->m_name); return; } - enteredOutputs.emplace_back(monitor); + m_enteredOutputs.emplace_back(monitor); - resource->sendEnter(output->getResource().get()); + m_resource->sendEnter(output->getResource().get()); } void CWLSurfaceResource::leave(PHLMONITOR monitor) { - if UNLIKELY (std::find(enteredOutputs.begin(), enteredOutputs.end(), monitor) == enteredOutputs.end()) + if UNLIKELY (std::find(m_enteredOutputs.begin(), m_enteredOutputs.end(), monitor) == m_enteredOutputs.end()) return; - auto output = PROTO::outputs.at(monitor->m_name)->outputResourceFrom(pClient); + auto output = PROTO::outputs.at(monitor->m_name)->outputResourceFrom(m_client); if UNLIKELY (!output) { LOGM(ERR, "Cannot leave surface {:x} from {}, client hasn't bound the output", (uintptr_t)this, monitor->m_name); return; } - std::erase(enteredOutputs, monitor); + std::erase(m_enteredOutputs, monitor); - resource->sendLeave(output->getResource().get()); + m_resource->sendLeave(output->getResource().get()); } void CWLSurfaceResource::sendPreferredTransform(wl_output_transform t) { - if (resource->version() < 6) + if (m_resource->version() < 6) return; - resource->sendPreferredBufferTransform(t); + m_resource->sendPreferredBufferTransform(t); } void CWLSurfaceResource::sendPreferredScale(int32_t scale) { - if (resource->version() < 6) + if (m_resource->version() < 6) return; - resource->sendPreferredBufferScale(scale); + m_resource->sendPreferredBufferScale(scale); } void CWLSurfaceResource::frame(const Time::steady_tp& now) { - if (callbacks.empty()) + if (m_callbacks.empty()) return; - for (auto const& c : callbacks) { + for (auto const& c : m_callbacks) { c->send(now); } - callbacks.clear(); + m_callbacks.clear(); } void CWLSurfaceResource::resetRole() { - role = makeShared(); + m_role = makeShared(); } void CWLSurfaceResource::bfHelper(std::vector> const& nodes, std::function, const Vector2D&, void*)> fn, void* data) { @@ -343,14 +343,14 @@ void CWLSurfaceResource::bfHelper(std::vector> const& nod // first, gather all nodes below for (auto const& n : nodes) { - std::erase_if(n->subsurfaces, [](const auto& e) { return e.expired(); }); + std::erase_if(n->m_subsurfaces, [](const auto& e) { return e.expired(); }); // subsurfaces is sorted lowest -> highest - for (auto const& c : n->subsurfaces) { - if (c->zIndex >= 0) + for (auto const& c : n->m_subsurfaces) { + if (c->m_zIndex >= 0) break; - if (c->surface.expired()) + if (c->m_surface.expired()) continue; - nodes2.push_back(c->surface.lock()); + nodes2.push_back(c->m_surface.lock()); } } @@ -361,8 +361,8 @@ void CWLSurfaceResource::bfHelper(std::vector> const& nod for (auto const& n : nodes) { Vector2D offset = {}; - if (n->role->role() == SURFACE_ROLE_SUBSURFACE) { - auto subsurface = ((CSubsurfaceRole*)n->role.get())->subsurface.lock(); + if (n->m_role->role() == SURFACE_ROLE_SUBSURFACE) { + auto subsurface = ((CSubsurfaceRole*)n->m_role.get())->m_subsurface.lock(); offset = subsurface->posRelativeToParent(); } @@ -370,12 +370,12 @@ void CWLSurfaceResource::bfHelper(std::vector> const& nod } for (auto const& n : nodes) { - for (auto const& c : n->subsurfaces) { - if (c->zIndex < 0) + for (auto const& c : n->m_subsurfaces) { + if (c->m_zIndex < 0) continue; - if (c->surface.expired()) + if (c->m_surface.expired()) continue; - nodes2.push_back(c->surface.lock()); + nodes2.push_back(c->m_surface.lock()); } } @@ -385,17 +385,17 @@ void CWLSurfaceResource::bfHelper(std::vector> const& nod void CWLSurfaceResource::breadthfirst(std::function, const Vector2D&, void*)> fn, void* data) { std::vector> surfs; - surfs.push_back(self.lock()); + surfs.push_back(m_self.lock()); bfHelper(surfs, fn, data); } SP CWLSurfaceResource::findFirstPreorderHelper(SP root, std::function)> fn) { if (fn(root)) return root; - for (auto const& sub : root->subsurfaces) { - if (sub.expired() || sub->surface.expired()) + for (auto const& sub : root->m_subsurfaces) { + if (sub.expired() || sub->m_surface.expired()) continue; - const auto found = findFirstPreorderHelper(sub->surface.lock(), fn); + const auto found = findFirstPreorderHelper(sub->m_surface.lock(), fn); if (found) return found; } @@ -403,7 +403,7 @@ SP CWLSurfaceResource::findFirstPreorderHelper(SP CWLSurfaceResource::findFirstPreorder(std::function)> fn) { - return findFirstPreorderHelper(self.lock(), fn); + return findFirstPreorderHelper(m_self.lock(), fn); } std::pair, Vector2D> CWLSurfaceResource::at(const Vector2D& localCoords, bool allowsInput) { @@ -412,11 +412,11 @@ std::pair, Vector2D> CWLSurfaceResource::at(const Vector2 for (auto const& [surf, pos] : surfs | std::views::reverse) { if (!allowsInput) { - const auto BOX = CBox{pos, surf->current.size}; + const auto BOX = CBox{pos, surf->m_current.size}; if (BOX.containsPoint(localCoords)) return {surf, localCoords - pos}; } else { - const auto REGION = surf->current.input.copy().intersect(CBox{{}, surf->current.size}).translate(pos); + const auto REGION = surf->m_current.input.copy().intersect(CBox{{}, surf->m_current.size}).translate(pos); if (REGION.containsPoint(localCoords)) return {surf, localCoords - pos}; } @@ -426,26 +426,26 @@ std::pair, Vector2D> CWLSurfaceResource::at(const Vector2 } uint32_t CWLSurfaceResource::id() { - return wl_resource_get_id(resource->resource()); + return wl_resource_get_id(m_resource->resource()); } void CWLSurfaceResource::map() { - if UNLIKELY (mapped) + if UNLIKELY (m_mapped) return; - mapped = true; + m_mapped = true; frame(Time::steadyNow()); - current.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; - pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; + m_current.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; + m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; } void CWLSurfaceResource::unmap() { - if UNLIKELY (!mapped) + if UNLIKELY (!m_mapped) return; - mapped = false; + m_mapped = false; // release the buffers. // this is necessary for XWayland to function correctly, @@ -460,66 +460,66 @@ void CWLSurfaceResource::releaseBuffers(bool onlyCurrent) { } void CWLSurfaceResource::error(int code, const std::string& str) { - resource->error(code, str); + m_resource->error(code, str); } SP CWLSurfaceResource::getResource() { - return resource; + return m_resource; } CBox CWLSurfaceResource::extends() { - CRegion full = CBox{{}, current.size}; + CRegion full = CBox{{}, m_current.size}; breadthfirst( [](SP surf, const Vector2D& offset, void* d) { - if (surf->role->role() != SURFACE_ROLE_SUBSURFACE) + if (surf->m_role->role() != SURFACE_ROLE_SUBSURFACE) return; - ((CRegion*)d)->add(CBox{offset, surf->current.size}); + ((CRegion*)d)->add(CBox{offset, surf->m_current.size}); }, &full); return full.getExtents(); } void CWLSurfaceResource::commitState(SSurfaceState& state) { - auto lastTexture = current.texture; - current.updateFrom(state); + auto lastTexture = m_current.texture; + m_current.updateFrom(state); - if (current.buffer) { - if (current.buffer->isSynchronous()) - current.updateSynchronousTexture(lastTexture); + if (m_current.buffer) { + if (m_current.buffer->isSynchronous()) + m_current.updateSynchronousTexture(lastTexture); // if the surface is a cursor, update the shm buffer // TODO: don't update the entire texture - if (role->role() == SURFACE_ROLE_CURSOR) - updateCursorShm(current.accumulateBufferDamage()); + if (m_role->role() == SURFACE_ROLE_CURSOR) + updateCursorShm(m_current.accumulateBufferDamage()); } - if (current.texture) - current.texture->m_eTransform = wlTransformToHyprutils(current.transform); + if (m_current.texture) + m_current.texture->m_eTransform = wlTransformToHyprutils(m_current.transform); - if (role->role() == SURFACE_ROLE_SUBSURFACE) { - auto subsurface = ((CSubsurfaceRole*)role.get())->subsurface.lock(); - if (subsurface->sync) + if (m_role->role() == SURFACE_ROLE_SUBSURFACE) { + auto subsurface = ((CSubsurfaceRole*)m_role.get())->m_subsurface.lock(); + if (subsurface->m_sync) return; - events.commit.emit(); + m_events.commit.emit(); } else { // send commit to all synced surfaces in this tree. breadthfirst( [](SP surf, const Vector2D& offset, void* data) { - if (surf->role->role() == SURFACE_ROLE_SUBSURFACE) { - auto subsurface = ((CSubsurfaceRole*)surf->role.get())->subsurface.lock(); - if (!subsurface->sync) + if (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE) { + auto subsurface = ((CSubsurfaceRole*)surf->m_role.get())->m_subsurface.lock(); + if (!subsurface->m_sync) return; } - surf->events.commit.emit(); + surf->m_events.commit.emit(); }, nullptr); } // release the buffer if it's synchronous (SHM) as updateSynchronousTexture() has copied the buffer data to a GPU tex // if it doesn't have a role, we can't release it yet, in case it gets turned into a cursor. - if (current.buffer && current.buffer->isSynchronous() && role->role() != SURFACE_ROLE_UNASSIGNED) + if (m_current.buffer && m_current.buffer->isSynchronous() && m_role->role() != SURFACE_ROLE_UNASSIGNED) dropCurrentBuffer(); } @@ -527,12 +527,12 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) { if (damage.empty()) return; - auto buf = current.buffer ? current.buffer : SP{}; + auto buf = m_current.buffer ? m_current.buffer : SP{}; if UNLIKELY (!buf) return; - auto& shmData = CCursorSurfaceRole::cursorPixelData(self.lock()); + auto& shmData = CCursorSurfaceRole::cursorPixelData(m_self.lock()); auto shmAttrs = buf->shm(); if (!shmAttrs.success) { @@ -563,7 +563,7 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) { void CWLSurfaceResource::presentFeedback(const Time::steady_tp& when, PHLMONITOR pMonitor, bool discarded) { frame(when); - auto FEEDBACK = makeShared(self.lock()); + auto FEEDBACK = makeShared(m_self.lock()); FEEDBACK->attachMonitor(pMonitor); if (discarded) FEEDBACK->discarded(); @@ -572,45 +572,45 @@ void CWLSurfaceResource::presentFeedback(const Time::steady_tp& when, PHLMONITOR PROTO::presentation->queueData(FEEDBACK); } -CWLCompositorResource::CWLCompositorResource(SP resource_) : resource(resource_) { +CWLCompositorResource::CWLCompositorResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlCompositor* r) { PROTO::compositor->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlCompositor* r) { PROTO::compositor->destroyResource(this); }); - resource->setCreateSurface([](CWlCompositor* r, uint32_t id) { - const auto RESOURCE = PROTO::compositor->m_vSurfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); + m_resource->setCreateSurface([](CWlCompositor* r, uint32_t id) { + const auto RESOURCE = PROTO::compositor->m_surfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::compositor->m_vSurfaces.pop_back(); + PROTO::compositor->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; LOGM(LOG, "New wl_surface with id {} at {:x}", id, (uintptr_t)RESOURCE.get()); - PROTO::compositor->events.newSurface.emit(RESOURCE); + PROTO::compositor->m_events.newSurface.emit(RESOURCE); }); - resource->setCreateRegion([](CWlCompositor* r, uint32_t id) { - const auto RESOURCE = PROTO::compositor->m_vRegions.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); + m_resource->setCreateRegion([](CWlCompositor* r, uint32_t id) { + const auto RESOURCE = PROTO::compositor->m_regions.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::compositor->m_vRegions.pop_back(); + PROTO::compositor->m_regions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; LOGM(LOG, "New wl_region with id {} at {:x}", id, (uintptr_t)RESOURCE.get()); }); } bool CWLCompositorResource::good() { - return resource->resource(); + return m_resource->resource(); } CWLCompositorProtocol::CWLCompositorProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -618,29 +618,29 @@ CWLCompositorProtocol::CWLCompositorProtocol(const wl_interface* iface, const in } void CWLCompositorProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CWLCompositorProtocol::destroyResource(CWLCompositorResource* 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 CWLCompositorProtocol::destroyResource(CWLSurfaceResource* 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 CWLCompositorProtocol::destroyResource(CWLRegionResource* resource) { - std::erase_if(m_vRegions, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_regions, [&](const auto& other) { return other.get() == resource; }); } void CWLCompositorProtocol::forEachSurface(std::function)> fn) { - for (auto& surf : m_vSurfaces) { + for (auto& surf : m_surfaces) { fn(surf); } } diff --git a/src/protocols/core/Compositor.hpp b/src/protocols/core/Compositor.hpp index 7415b4f5..90fac35d 100644 --- a/src/protocols/core/Compositor.hpp +++ b/src/protocols/core/Compositor.hpp @@ -40,7 +40,7 @@ class CWLCallbackResource { void send(const Time::steady_tp& now); private: - SP resource; + SP m_resource; }; class CWLRegionResource { @@ -50,11 +50,11 @@ class CWLRegionResource { bool good(); - CRegion region; - WP self; + CRegion m_region; + WP m_self; private: - SP resource; + SP m_resource; }; class CWLSurfaceResource { @@ -86,22 +86,22 @@ class CWLSurfaceResource { CSignal unmap; CSignal newSubsurface; CSignal destroy; - } events; + } m_events; - SSurfaceState current, pending; - std::queue> pendingStates; + SSurfaceState m_current; + SSurfaceState m_pending; + std::queue> m_pendingStates; - std::vector> callbacks; - WP self; - WP hlSurface; - std::vector enteredOutputs; - bool mapped = false; - std::vector> subsurfaces; - SP role; - WP viewportResource; - WP syncobj; // may not be present - WP colorManagement; - WP contentType; + std::vector> m_callbacks; + WP m_self; + WP m_hlSurface; + std::vector m_enteredOutputs; + bool m_mapped = false; + std::vector> m_subsurfaces; + SP m_role; + WP m_syncobj; // may not be present + WP m_colorManagement; + WP m_contentType; void breadthfirst(std::function, const Vector2D&, void*)> fn, void* data); SP findFirstPreorder(std::function)> fn); @@ -113,8 +113,8 @@ class CWLSurfaceResource { std::pair, Vector2D> at(const Vector2D& localCoords, bool allowsInput = false); private: - SP resource; - wl_client* pClient = nullptr; + SP m_resource; + wl_client* m_client = nullptr; void destroy(); void releaseBuffers(bool onlyCurrent = true); @@ -134,7 +134,7 @@ class CWLCompositorResource { bool good(); private: - SP resource; + SP m_resource; }; class CWLCompositorProtocol : public IWaylandProtocol { @@ -147,7 +147,7 @@ class CWLCompositorProtocol : public IWaylandProtocol { struct { CSignal newSurface; // SP - } events; + } m_events; private: void destroyResource(CWLCompositorResource* resource); @@ -155,9 +155,9 @@ class CWLCompositorProtocol : public IWaylandProtocol { void destroyResource(CWLRegionResource* resource); // - std::vector> m_vManagers; - std::vector> m_vSurfaces; - std::vector> m_vRegions; + std::vector> m_managers; + std::vector> m_surfaces; + std::vector> m_regions; friend class CWLSurfaceResource; friend class CWLCompositorResource; diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp index fda46980..a54ae7e1 100644 --- a/src/protocols/core/DataDevice.cpp +++ b/src/protocols/core/DataDevice.cpp @@ -16,60 +16,60 @@ #include "../../xwayland/Dnd.hpp" using namespace Hyprutils::OS; -CWLDataOfferResource::CWLDataOfferResource(SP resource_, SP source_) : source(source_), resource(resource_) { +CWLDataOfferResource::CWLDataOfferResource(SP resource_, SP source_) : m_source(source_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); }); - resource->setOnDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); }); + m_resource->setDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); }); - resource->setAccept([this](CWlDataOffer* r, uint32_t serial, const char* mime) { - if (!source) { + m_resource->setAccept([this](CWlDataOffer* r, uint32_t serial, const char* mime) { + if (!m_source) { LOGM(WARN, "Possible bug: Accept on an offer w/o a source"); return; } - if (dead) { + if (m_dead) { LOGM(WARN, "Possible bug: Accept on an offer that's dead"); return; } - LOGM(LOG, "Offer {:x} accepts data from source {:x} with mime {}", (uintptr_t)this, (uintptr_t)source.get(), mime ? mime : "null"); + LOGM(LOG, "Offer {:x} accepts data from source {:x} with mime {}", (uintptr_t)this, (uintptr_t)m_source.get(), mime ? mime : "null"); - source->accepted(mime ? mime : ""); - accepted = mime; + m_source->accepted(mime ? mime : ""); + m_accepted = mime; }); - resource->setReceive([this](CWlDataOffer* r, const char* mime, int fd) { + m_resource->setReceive([this](CWlDataOffer* r, const char* mime, int fd) { CFileDescriptor sendFd{fd}; - if (!source) { + if (!m_source) { LOGM(WARN, "Possible bug: Receive on an offer w/o a source"); return; } - if (dead) { + if (m_dead) { LOGM(WARN, "Possible bug: Receive on an offer that's dead"); 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()); - if (!accepted) { + if (!m_accepted) { LOGM(WARN, "Offer was never accepted, sending accept first"); - source->accepted(mime ? mime : ""); + m_source->accepted(mime ? mime : ""); } - source->send(mime ? mime : "", std::move(sendFd)); + m_source->send(mime ? mime : "", std::move(sendFd)); - recvd = true; + m_recvd = true; // if (source->hasDnd()) // PROTO::data->completeDrag(); }); - resource->setFinish([this](CWlDataOffer* r) { - dead = true; - if (!source || !recvd || !accepted) + m_resource->setFinish([this](CWlDataOffer* r) { + m_dead = true; + if (!m_source || !m_recvd || !m_accepted) PROTO::data->abortDrag(); else PROTO::data->completeDrag(); @@ -77,37 +77,37 @@ CWLDataOfferResource::CWLDataOfferResource(SP resource_, SPhasDnd() || dead) + if (!m_source || !m_source->hasDnd() || m_dead) return; - source->sendDndFinished(); + m_source->sendDndFinished(); } bool CWLDataOfferResource::good() { - return resource->resource(); + return m_resource->resource(); } void CWLDataOfferResource::sendData() { - if (!source) + if (!m_source) return; - const auto SOURCEACTIONS = source->actions(); + const auto SOURCEACTIONS = m_source->actions(); - if (resource->version() >= 3 && SOURCEACTIONS > 0) { - resource->sendSourceActions(SOURCEACTIONS); + if (m_resource->version() >= 3 && SOURCEACTIONS > 0) { + m_resource->sendSourceActions(SOURCEACTIONS); if (SOURCEACTIONS & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE) - resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); + m_resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); else if (SOURCEACTIONS & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY) - resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY); + m_resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY); else { LOGM(ERR, "Client bug? dnd source has no action move or copy. Sending move, f this."); - resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); + m_resource->sendAction(WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); } } - for (auto const& m : source->mimes()) { + for (auto const& m : m_source->mimes()) { LOGM(LOG, " | offer {:x} supports mime {}", (uintptr_t)this, m); - resource->sendOffer(m.c_str()); + m_resource->sendOffer(m.c_str()); } } @@ -116,7 +116,7 @@ eDataSourceType CWLDataOfferResource::type() { } SP CWLDataOfferResource::getWayland() { - return self.lock(); + return m_self.lock(); } SP CWLDataOfferResource::getX11() { @@ -124,127 +124,127 @@ SP CWLDataOfferResource::getX11() { } SP CWLDataOfferResource::getSource() { - return source.lock(); + return m_source.lock(); } -CWLDataSourceResource::CWLDataSourceResource(SP resource_, SP device_) : device(device_), resource(resource_) { +CWLDataSourceResource::CWLDataSourceResource(SP resource_, SP device_) : m_device(device_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setDestroy([this](CWlDataSource* r) { + m_resource->setDestroy([this](CWlDataSource* r) { events.destroy.emit(); - PROTO::data->onDestroyDataSource(self); + PROTO::data->onDestroyDataSource(m_self); PROTO::data->destroyResource(this); }); - resource->setOnDestroy([this](CWlDataSource* r) { + m_resource->setOnDestroy([this](CWlDataSource* r) { events.destroy.emit(); - PROTO::data->onDestroyDataSource(self); + PROTO::data->onDestroyDataSource(m_self); PROTO::data->destroyResource(this); }); - resource->setOffer([this](CWlDataSource* r, const char* mime) { mimeTypes.emplace_back(mime); }); - resource->setSetActions([this](CWlDataSource* r, uint32_t a) { + m_resource->setOffer([this](CWlDataSource* r, const char* mime) { m_mimeTypes.emplace_back(mime); }); + m_resource->setSetActions([this](CWlDataSource* r, uint32_t a) { LOGM(LOG, "DataSource {:x} actions {}", (uintptr_t)this, a); - supportedActions = a; + m_supportedActions = a; }); } CWLDataSourceResource::~CWLDataSourceResource() { events.destroy.emit(); - PROTO::data->onDestroyDataSource(self); + PROTO::data->onDestroyDataSource(m_self); } SP CWLDataSourceResource::fromResource(wl_resource* res) { auto data = (CWLDataSourceResource*)(((CWlDataSource*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } bool CWLDataSourceResource::good() { - return resource->resource(); + return m_resource->resource(); } void CWLDataSourceResource::accepted(const std::string& mime) { if (mime.empty()) { - resource->sendTarget(nullptr); + m_resource->sendTarget(nullptr); return; } - 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: CWLDataSourceResource::sendAccepted with non-existent mime"); return; } - resource->sendTarget(mime.c_str()); + m_resource->sendTarget(mime.c_str()); } std::vector CWLDataSourceResource::mimes() { - return mimeTypes; + return m_mimeTypes; } void CWLDataSourceResource::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: CWLDataSourceResource::sendAskSend with non-existent mime"); return; } - resource->sendSend(mime.c_str(), fd.get()); + m_resource->sendSend(mime.c_str(), fd.get()); } void CWLDataSourceResource::cancelled() { - resource->sendCancelled(); + m_resource->sendCancelled(); } bool CWLDataSourceResource::hasDnd() { - return dnd; + return m_dnd; } bool CWLDataSourceResource::dndDone() { - return dndSuccess; + return m_dndSuccess; } void CWLDataSourceResource::error(uint32_t code, const std::string& msg) { - resource->error(code, msg); + m_resource->error(code, msg); } void CWLDataSourceResource::sendDndDropPerformed() { - if (resource->version() < 3) + if (m_resource->version() < 3) return; - resource->sendDndDropPerformed(); - dropped = true; + m_resource->sendDndDropPerformed(); + m_dropped = true; } void CWLDataSourceResource::sendDndFinished() { - if (resource->version() < 3) + if (m_resource->version() < 3) return; - resource->sendDndFinished(); + m_resource->sendDndFinished(); } void CWLDataSourceResource::sendDndAction(wl_data_device_manager_dnd_action a) { - if (resource->version() < 3) + if (m_resource->version() < 3) return; - resource->sendAction(a); + m_resource->sendAction(a); } uint32_t CWLDataSourceResource::actions() { - return supportedActions; + return m_supportedActions; } eDataSourceType CWLDataSourceResource::type() { return DATA_SOURCE_TYPE_WAYLAND; } -CWLDataDeviceResource::CWLDataDeviceResource(SP resource_) : resource(resource_) { +CWLDataDeviceResource::CWLDataDeviceResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setRelease([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); }); - resource->setOnDestroy([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); }); + m_resource->setRelease([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); }); - pClient = resource->client(); + m_client = m_resource->client(); - resource->setSetSelection([](CWlDataDevice* r, wl_resource* sourceR, uint32_t serial) { + m_resource->setSetSelection([](CWlDataDevice* r, wl_resource* sourceR, uint32_t serial) { auto source = sourceR ? CWLDataSourceResource::fromResource(sourceR) : CSharedPointer{}; if (!source) { LOGM(LOG, "Reset selection received"); @@ -252,7 +252,7 @@ CWLDataDeviceResource::CWLDataDeviceResource(SP resource_) : reso return; } - if (source && source->used) + if (source && source->m_used) LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this."); source->markUsed(); @@ -260,63 +260,63 @@ CWLDataDeviceResource::CWLDataDeviceResource(SP resource_) : reso g_pSeatManager->setCurrentSelection(source); }); - resource->setStartDrag([](CWlDataDevice* r, wl_resource* sourceR, wl_resource* origin, wl_resource* icon, uint32_t serial) { + m_resource->setStartDrag([](CWlDataDevice* r, wl_resource* sourceR, wl_resource* origin, wl_resource* icon, uint32_t serial) { auto source = CWLDataSourceResource::fromResource(sourceR); if (!source) { LOGM(ERR, "No source in drag"); return; } - if (source && source->used) + if (source && source->m_used) LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this."); source->markUsed(); - source->dnd = true; + source->m_dnd = true; PROTO::data->initiateDrag(source, icon ? CWLSurfaceResource::fromResource(icon) : nullptr, CWLSurfaceResource::fromResource(origin)); }); } bool CWLDataDeviceResource::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CWLDataDeviceResource::client() { - return pClient; + return m_client; } void CWLDataDeviceResource::sendDataOffer(SP offer) { if (!offer) - resource->sendDataOfferRaw(nullptr); + m_resource->sendDataOfferRaw(nullptr); else if (const auto WL = offer->getWayland(); WL) - resource->sendDataOffer(WL->resource.get()); + m_resource->sendDataOffer(WL->m_resource.get()); //FIXME: X11 } void CWLDataDeviceResource::sendEnter(uint32_t serial, SP surf, const Vector2D& local, SP offer) { if (const auto WL = offer->getWayland(); WL) - resource->sendEnterRaw(serial, surf->getResource()->resource(), wl_fixed_from_double(local.x), wl_fixed_from_double(local.y), WL->resource->resource()); + m_resource->sendEnterRaw(serial, surf->getResource()->resource(), wl_fixed_from_double(local.x), wl_fixed_from_double(local.y), WL->m_resource->resource()); // FIXME: X11 } void CWLDataDeviceResource::sendLeave() { - resource->sendLeave(); + m_resource->sendLeave(); } void CWLDataDeviceResource::sendMotion(uint32_t timeMs, const Vector2D& local) { - resource->sendMotion(timeMs, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); + m_resource->sendMotion(timeMs, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } void CWLDataDeviceResource::sendDrop() { - resource->sendDrop(); + m_resource->sendDrop(); } void CWLDataDeviceResource::sendSelection(SP offer) { if (!offer) - resource->sendSelectionRaw(nullptr); + m_resource->sendSelectionRaw(nullptr); else if (const auto WL = offer->getWayland(); WL) - resource->sendSelection(WL->resource.get()); + m_resource->sendSelection(WL->m_resource.get()); } eDataSourceType CWLDataDeviceResource::type() { @@ -324,55 +324,55 @@ eDataSourceType CWLDataDeviceResource::type() { } SP CWLDataDeviceResource::getWayland() { - return self.lock(); + return m_self.lock(); } SP CWLDataDeviceResource::getX11() { return nullptr; } -CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP resource_) : resource(resource_) { +CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlDataDeviceManager* r) { PROTO::data->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlDataDeviceManager* r) { PROTO::data->destroyResource(this); }); - resource->setCreateDataSource([this](CWlDataDeviceManager* r, uint32_t id) { - std::erase_if(sources, [](const auto& e) { return e.expired(); }); + m_resource->setCreateDataSource([this](CWlDataDeviceManager* r, uint32_t id) { + std::erase_if(m_sources, [](const auto& e) { return e.expired(); }); - const auto RESOURCE = PROTO::data->m_vSources.emplace_back(makeShared(makeShared(r->client(), r->version(), id), device.lock())); + const auto RESOURCE = PROTO::data->m_sources.emplace_back(makeShared(makeShared(r->client(), r->version(), id), m_device.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::data->m_vSources.pop_back(); + PROTO::data->m_sources.pop_back(); return; } - if (!device) + if (!m_device) 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 data source bound at {:x}", (uintptr_t)RESOURCE.get()); }); - resource->setGetDataDevice([this](CWlDataDeviceManager* r, uint32_t id, wl_resource* seat) { - const auto RESOURCE = PROTO::data->m_vDevices.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); + m_resource->setGetDataDevice([this](CWlDataDeviceManager* r, uint32_t id, wl_resource* seat) { + const auto RESOURCE = PROTO::data->m_devices.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::data->m_vDevices.pop_back(); + PROTO::data->m_devices.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; - for (auto const& s : sources) { + for (auto const& s : m_sources) { if (!s) continue; - s->device = RESOURCE; + s->m_device = RESOURCE; } LOGM(LOG, "New data device bound at {:x}", (uintptr_t)RESOURCE.get()); @@ -380,22 +380,22 @@ CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SPresource(); + return m_resource->resource(); } CWLDataDeviceProtocol::CWLDataDeviceProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { g_pEventLoopManager->doLater([this]() { - listeners.onKeyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { onKeyboardFocus(); }); - listeners.onDndPointerFocusChange = g_pSeatManager->m_events.dndPointerFocusChange.registerListener([this](std::any d) { onDndPointerFocus(); }); + m_listeners.onKeyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { onKeyboardFocus(); }); + m_listeners.onDndPointerFocusChange = g_pSeatManager->m_events.dndPointerFocusChange.registerListener([this](std::any d) { onDndPointerFocus(); }); }); } void CWLDataDeviceProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } @@ -403,19 +403,19 @@ void CWLDataDeviceProtocol::bindManager(wl_client* client, void* data, uint32_t } void CWLDataDeviceProtocol::destroyResource(CWLDataDeviceManagerResource* seat) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == seat; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == seat; }); } void CWLDataDeviceProtocol::destroyResource(CWLDataDeviceResource* 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 CWLDataDeviceProtocol::destroyResource(CWLDataSourceResource* 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 CWLDataDeviceProtocol::destroyResource(CWLDataOfferResource* 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; }); } SP CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) { @@ -424,8 +424,8 @@ SP CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) { return g_pXWayland->pWM->getDataDevice(); #endif - auto it = std::find_if(m_vDevices.begin(), m_vDevices.end(), [c](const auto& e) { return e->client() == c; }); - if (it == m_vDevices.end()) + auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; }); + if (it == m_devices.end()) return nullptr; return *it; } @@ -439,15 +439,15 @@ void CWLDataDeviceProtocol::sendSelectionToDevice(SP dev, SP offer; if (const auto WL = dev->getWayland(); WL) { - const auto OFFER = m_vOffers.emplace_back(makeShared(makeShared(WL->resource->client(), WL->resource->version(), 0), sel)); + const auto OFFER = m_offers.emplace_back(makeShared(makeShared(WL->m_resource->client(), WL->m_resource->version(), 0), sel)); if UNLIKELY (!OFFER->good()) { - WL->resource->noMemory(); - m_vOffers.pop_back(); + WL->m_resource->noMemory(); + m_offers.pop_back(); return; } - OFFER->source = sel; - OFFER->self = OFFER; - offer = OFFER; + OFFER->m_source = sel; + OFFER->m_self = OFFER; + offer = OFFER; } #ifndef NO_XWAYLAND else if (const auto X11 = dev->getX11(); X11) @@ -468,15 +468,15 @@ void CWLDataDeviceProtocol::sendSelectionToDevice(SP dev, SP source) { - if (dnd.currentSource == source) + if (m_dnd.currentSource == source) abortDrag(); } void CWLDataDeviceProtocol::setSelection(SP source) { - for (auto const& o : m_vOffers) { - if (o->source && o->source->hasDnd()) + for (auto const& o : m_offers) { + if (o->m_source && o->m_source->hasDnd()) continue; - o->dead = true; + o->m_dead = true; } if (!source) { @@ -527,20 +527,20 @@ void CWLDataDeviceProtocol::updateSelection() { } void CWLDataDeviceProtocol::onKeyboardFocus() { - for (auto const& o : m_vOffers) { - if (o->source && o->source->hasDnd()) + for (auto const& o : m_offers) { + if (o->m_source && o->m_source->hasDnd()) continue; - o->dead = true; + o->m_dead = true; } updateSelection(); } void CWLDataDeviceProtocol::onDndPointerFocus() { - for (auto const& o : m_vOffers) { - if (o->source && !o->source->hasDnd()) + for (auto const& o : m_offers) { + if (o->m_source && !o->m_source->hasDnd()) continue; - o->dead = true; + o->m_dead = true; } updateDrag(); @@ -548,37 +548,37 @@ void CWLDataDeviceProtocol::onDndPointerFocus() { void CWLDataDeviceProtocol::initiateDrag(WP currentSource, SP dragSurface, SP origin) { - if (dnd.currentSource) { + if (m_dnd.currentSource) { LOGM(WARN, "New drag started while old drag still active??"); abortDrag(); } g_pInputManager->setCursorImageUntilUnset("grabbing"); - dnd.overriddenCursor = true; + m_dnd.overriddenCursor = true; LOGM(LOG, "initiateDrag: source {:x}, surface: {:x}, origin: {:x}", (uintptr_t)currentSource.get(), (uintptr_t)dragSurface, (uintptr_t)origin); - currentSource->used = true; + currentSource->m_used = true; - dnd.currentSource = currentSource; - dnd.originSurface = origin; - dnd.dndSurface = dragSurface; + m_dnd.currentSource = currentSource; + m_dnd.originSurface = origin; + m_dnd.dndSurface = dragSurface; if (dragSurface) { - dnd.dndSurfaceDestroy = dragSurface->events.destroy.registerListener([this](std::any d) { abortDrag(); }); - dnd.dndSurfaceCommit = dragSurface->events.commit.registerListener([this](std::any d) { - if (dnd.dndSurface->current.texture && !dnd.dndSurface->mapped) { - dnd.dndSurface->map(); + m_dnd.dndSurfaceDestroy = dragSurface->m_events.destroy.registerListener([this](std::any d) { abortDrag(); }); + m_dnd.dndSurfaceCommit = dragSurface->m_events.commit.registerListener([this](std::any d) { + if (m_dnd.dndSurface->m_current.texture && !m_dnd.dndSurface->m_mapped) { + m_dnd.dndSurface->map(); return; } - if (dnd.dndSurface->current.texture <= 0 && dnd.dndSurface->mapped) { - dnd.dndSurface->unmap(); + if (m_dnd.dndSurface->m_current.texture <= 0 && m_dnd.dndSurface->m_mapped) { + m_dnd.dndSurface->unmap(); return; } }); } - dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) { + m_dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) { auto E = std::any_cast(e); if (E.state == WL_POINTER_BUTTON_STATE_RELEASED) { LOGM(LOG, "Dropping drag on mouseUp"); @@ -586,14 +586,14 @@ void CWLDataDeviceProtocol::initiateDrag(WP currentSource } }); - dnd.touchUp = g_pHookSystem->hookDynamic("touchUp", [this](void* self, SCallbackInfo& info, std::any e) { + m_dnd.touchUp = g_pHookSystem->hookDynamic("touchUp", [this](void* self, SCallbackInfo& info, std::any e) { LOGM(LOG, "Dropping drag on touchUp"); dropDrag(); }); - dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) { + m_dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) { auto V = std::any_cast(e); - if (dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) { + if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) { auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock()); if (!surf) @@ -604,14 +604,14 @@ void CWLDataDeviceProtocol::initiateDrag(WP currentSource if (!box.has_value()) return; - dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), V - box->pos()); + m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), V - box->pos()); LOGM(LOG, "Drag motion {}", V - box->pos()); } }); - dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) { + m_dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) { auto E = std::any_cast(e); - if (dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) { + if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) { auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock()); if (!surf) @@ -622,7 +622,7 @@ void CWLDataDeviceProtocol::initiateDrag(WP currentSource if (!box.has_value()) return; - dnd.focusedDevice->sendMotion(E.timeMs, E.pos); + m_dnd.focusedDevice->sendMotion(E.timeMs, E.pos); LOGM(LOG, "Drag motion {}", E.pos); } }); @@ -642,34 +642,34 @@ void CWLDataDeviceProtocol::updateDrag() { if (!dndActive()) return; - if (dnd.focusedDevice) - dnd.focusedDevice->sendLeave(); + if (m_dnd.focusedDevice) + m_dnd.focusedDevice->sendLeave(); if (!g_pSeatManager->m_state.dndPointerFocus) return; - dnd.focusedDevice = dataDeviceForClient(g_pSeatManager->m_state.dndPointerFocus->client()); + m_dnd.focusedDevice = dataDeviceForClient(g_pSeatManager->m_state.dndPointerFocus->client()); - if (!dnd.focusedDevice) + if (!m_dnd.focusedDevice) return; SP offer; - if (const auto WL = dnd.focusedDevice->getWayland(); WL) { + if (const auto WL = m_dnd.focusedDevice->getWayland(); WL) { const auto OFFER = - m_vOffers.emplace_back(makeShared(makeShared(WL->resource->client(), WL->resource->version(), 0), dnd.currentSource.lock())); + m_offers.emplace_back(makeShared(makeShared(WL->m_resource->client(), WL->m_resource->version(), 0), m_dnd.currentSource.lock())); if (!OFFER->good()) { - WL->resource->noMemory(); - m_vOffers.pop_back(); + WL->m_resource->noMemory(); + m_offers.pop_back(); return; } - OFFER->source = dnd.currentSource; - OFFER->self = OFFER; - offer = OFFER; + OFFER->m_source = m_dnd.currentSource; + OFFER->m_self = OFFER; + offer = OFFER; } #ifndef NO_XWAYLAND - else if (const auto X11 = dnd.focusedDevice->getX11(); X11) - offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), dnd.currentSource.lock()); + else if (const auto X11 = m_dnd.focusedDevice->getX11(); X11) + offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), m_dnd.currentSource.lock()); #endif if (!offer) { @@ -678,28 +678,28 @@ void CWLDataDeviceProtocol::updateDrag() { } LOGM(LOG, "New {} dnd offer {:x} for data source {:x}", offer->type() == DATA_SOURCE_TYPE_WAYLAND ? "wayland" : "X11", (uintptr_t)offer.get(), - (uintptr_t)dnd.currentSource.get()); + (uintptr_t)m_dnd.currentSource.get()); - dnd.focusedDevice->sendDataOffer(offer); + m_dnd.focusedDevice->sendDataOffer(offer); if (const auto WL = offer->getWayland(); WL) WL->sendData(); - dnd.focusedDevice->sendEnter(wl_display_next_serial(g_pCompositor->m_wlDisplay), g_pSeatManager->m_state.dndPointerFocus.lock(), - g_pSeatManager->m_state.dndPointerFocus->current.size / 2.F, offer); + m_dnd.focusedDevice->sendEnter(wl_display_next_serial(g_pCompositor->m_wlDisplay), g_pSeatManager->m_state.dndPointerFocus.lock(), + g_pSeatManager->m_state.dndPointerFocus->m_current.size / 2.F, offer); } void CWLDataDeviceProtocol::cleanupDndState(bool resetDevice, bool resetSource, bool simulateInput) { - dnd.dndSurface.reset(); - dnd.dndSurfaceCommit.reset(); - dnd.dndSurfaceDestroy.reset(); - dnd.mouseButton.reset(); - dnd.mouseMove.reset(); - dnd.touchUp.reset(); - dnd.touchMove.reset(); + m_dnd.dndSurface.reset(); + m_dnd.dndSurfaceCommit.reset(); + m_dnd.dndSurfaceDestroy.reset(); + m_dnd.mouseButton.reset(); + m_dnd.mouseMove.reset(); + m_dnd.touchUp.reset(); + m_dnd.touchMove.reset(); if (resetDevice) - dnd.focusedDevice.reset(); + m_dnd.focusedDevice.reset(); if (resetSource) - dnd.currentSource.reset(); + m_dnd.currentSource.reset(); if (simulateInput) { g_pInputManager->simulateMouseMovement(); @@ -708,8 +708,8 @@ void CWLDataDeviceProtocol::cleanupDndState(bool resetDevice, bool resetSource, } void CWLDataDeviceProtocol::dropDrag() { - if (!dnd.focusedDevice || !dnd.currentSource) { - if (dnd.currentSource) + if (!m_dnd.focusedDevice || !m_dnd.currentSource) { + if (m_dnd.currentSource) abortDrag(); return; } @@ -719,40 +719,40 @@ void CWLDataDeviceProtocol::dropDrag() { return; } - dnd.focusedDevice->sendDrop(); + m_dnd.focusedDevice->sendDrop(); #ifndef NO_XWAYLAND - if (dnd.focusedDevice->getX11()) { - dnd.focusedDevice->sendLeave(); - if (dnd.overriddenCursor) + if (m_dnd.focusedDevice->getX11()) { + m_dnd.focusedDevice->sendLeave(); + if (m_dnd.overriddenCursor) g_pInputManager->unsetCursorImage(); - dnd.overriddenCursor = false; + m_dnd.overriddenCursor = false; cleanupDndState(true, true, true); return; } #endif - dnd.focusedDevice->sendLeave(); - if (dnd.overriddenCursor) + m_dnd.focusedDevice->sendLeave(); + if (m_dnd.overriddenCursor) g_pInputManager->unsetCursorImage(); - dnd.overriddenCursor = false; + m_dnd.overriddenCursor = false; cleanupDndState(false, false, false); } bool CWLDataDeviceProtocol::wasDragSuccessful() { - if (!dnd.currentSource) + if (!m_dnd.currentSource) return false; - for (auto const& o : m_vOffers) { - if (o->dead || o->source != dnd.currentSource) + for (auto const& o : m_offers) { + if (o->m_dead || o->m_source != m_dnd.currentSource) continue; - if (o->recvd || o->accepted) + if (o->m_recvd || o->m_accepted) return true; } #ifndef NO_XWAYLAND - if (dnd.focusedDevice->getX11()) + if (m_dnd.focusedDevice->getX11()) return true; #endif @@ -760,12 +760,12 @@ bool CWLDataDeviceProtocol::wasDragSuccessful() { } void CWLDataDeviceProtocol::completeDrag() { - if (!dnd.focusedDevice && !dnd.currentSource) + if (!m_dnd.focusedDevice && !m_dnd.currentSource) return; - if (dnd.currentSource) { - dnd.currentSource->sendDndDropPerformed(); - dnd.currentSource->sendDndFinished(); + if (m_dnd.currentSource) { + m_dnd.currentSource->sendDndDropPerformed(); + m_dnd.currentSource->sendDndFinished(); } cleanupDndState(true, true, true); @@ -774,56 +774,56 @@ void CWLDataDeviceProtocol::completeDrag() { void CWLDataDeviceProtocol::abortDrag() { cleanupDndState(false, false, false); - if (dnd.overriddenCursor) + if (m_dnd.overriddenCursor) g_pInputManager->unsetCursorImage(); - dnd.overriddenCursor = false; + m_dnd.overriddenCursor = false; - if (!dnd.focusedDevice && !dnd.currentSource) + if (!m_dnd.focusedDevice && !m_dnd.currentSource) return; - if (dnd.focusedDevice) { + if (m_dnd.focusedDevice) { #ifndef NO_XWAYLAND - if (auto x11Device = dnd.focusedDevice->getX11(); x11Device) + if (auto x11Device = m_dnd.focusedDevice->getX11(); x11Device) x11Device->forceCleanupDnd(); #endif - dnd.focusedDevice->sendLeave(); + m_dnd.focusedDevice->sendLeave(); } - if (dnd.currentSource) - dnd.currentSource->cancelled(); + if (m_dnd.currentSource) + m_dnd.currentSource->cancelled(); - dnd.focusedDevice.reset(); - dnd.currentSource.reset(); + m_dnd.focusedDevice.reset(); + m_dnd.currentSource.reset(); g_pInputManager->simulateMouseMovement(); g_pSeatManager->resendEnterEvents(); } void CWLDataDeviceProtocol::renderDND(PHLMONITOR pMonitor, const Time::steady_tp& when) { - if (!dnd.dndSurface || !dnd.dndSurface->current.texture) + if (!m_dnd.dndSurface || !m_dnd.dndSurface->m_current.texture) return; const auto POS = g_pInputManager->getMouseCoordsInternal(); Vector2D surfacePos = POS; - surfacePos += dnd.dndSurface->current.offset; + surfacePos += m_dnd.dndSurface->m_current.offset; - CBox box = CBox{surfacePos, dnd.dndSurface->current.size}.translate(-pMonitor->m_position).scale(pMonitor->m_scale); + CBox box = CBox{surfacePos, m_dnd.dndSurface->m_current.size}.translate(-pMonitor->m_position).scale(pMonitor->m_scale); CTexPassElement::SRenderData data; - data.tex = dnd.dndSurface->current.texture; + data.tex = m_dnd.dndSurface->m_current.texture; data.box = box; g_pHyprRenderer->m_sRenderPass.add(makeShared(data)); - CBox damageBox = CBox{surfacePos, dnd.dndSurface->current.size}.expand(5); + CBox damageBox = CBox{surfacePos, m_dnd.dndSurface->m_current.size}.expand(5); g_pHyprRenderer->damageBox(damageBox); - dnd.dndSurface->frame(when); + m_dnd.dndSurface->frame(when); } bool CWLDataDeviceProtocol::dndActive() { - return dnd.currentSource; + return m_dnd.currentSource; } void CWLDataDeviceProtocol::abortDndIfPresent() { diff --git a/src/protocols/core/DataDevice.hpp b/src/protocols/core/DataDevice.hpp index 0c53111b..d54927d2 100644 --- a/src/protocols/core/DataDevice.hpp +++ b/src/protocols/core/DataDevice.hpp @@ -40,17 +40,15 @@ class CWLDataOfferResource : public IDataOffer { virtual SP getX11(); virtual SP getSource(); - WP source; - WP self; + WP m_source; + WP m_self; - bool dead = false; - bool accepted = false; - bool recvd = false; - - uint32_t actions = 0; + bool m_dead = false; + bool m_accepted = false; + bool m_recvd = false; private: - SP resource; + SP m_resource; friend class CWLDataDeviceResource; }; @@ -76,19 +74,19 @@ class CWLDataSourceResource : public IDataSource { virtual void sendDndDropPerformed(); virtual void sendDndAction(wl_data_device_manager_dnd_action a); - bool used = false; - bool dnd = false; - bool dndSuccess = false; - bool dropped = false; + bool m_used = false; + bool m_dnd = false; + bool m_dndSuccess = false; + bool m_dropped = false; - WP device; - WP self; + WP m_device; + WP m_self; - std::vector mimeTypes; - uint32_t supportedActions = 0; + std::vector m_mimeTypes; + uint32_t m_supportedActions = 0; private: - SP resource; + SP m_resource; friend class CWLDataDeviceProtocol; }; @@ -110,11 +108,11 @@ class CWLDataDeviceResource : public IDataDevice { virtual void sendSelection(SP offer); virtual eDataSourceType type(); - WP self; + WP m_self; private: - SP resource; - wl_client* pClient = nullptr; + SP m_resource; + wl_client* m_client = nullptr; friend class CWLDataDeviceProtocol; }; @@ -125,11 +123,11 @@ class CWLDataDeviceManagerResource { bool good(); - WP device; - std::vector> sources; + WP m_device; + std::vector> m_sources; private: - SP resource; + SP m_resource; }; class CWLDataDeviceProtocol : public IWaylandProtocol { @@ -154,10 +152,10 @@ class CWLDataDeviceProtocol : public IWaylandProtocol { void destroyResource(CWLDataOfferResource* resource); // - std::vector> m_vManagers; - std::vector> m_vDevices; - std::vector> m_vSources; - std::vector> m_vOffers; + std::vector> m_managers; + std::vector> m_devices; + std::vector> m_sources; + std::vector> m_offers; // @@ -182,7 +180,7 @@ class CWLDataDeviceProtocol : public IWaylandProtocol { SP mouseButton; SP touchUp; SP touchMove; - } dnd; + } m_dnd; void abortDrag(); void initiateDrag(WP currentSource, SP dragSurface, SP origin); @@ -204,7 +202,7 @@ class CWLDataDeviceProtocol : public IWaylandProtocol { struct { CHyprSignalListener onKeyboardFocusChange; CHyprSignalListener onDndPointerFocusChange; - } listeners; + } m_listeners; }; namespace PROTO { diff --git a/src/protocols/core/Output.cpp b/src/protocols/core/Output.cpp index dfb89ba7..5db2f678 100644 --- a/src/protocols/core/Output.cpp +++ b/src/protocols/core/Output.cpp @@ -3,29 +3,29 @@ #include "../../Compositor.hpp" #include "../../helpers/Monitor.hpp" -CWLOutputResource::CWLOutputResource(SP resource_, PHLMONITOR pMonitor) : monitor(pMonitor), resource(resource_) { +CWLOutputResource::CWLOutputResource(SP resource_, PHLMONITOR pMonitor) : m_monitor(pMonitor), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - pClient = resource->client(); + m_client = m_resource->client(); - if (!monitor) + if (!m_monitor) return; - resource->setOnDestroy([this](CWlOutput* r) { - if (monitor && PROTO::outputs.contains(monitor->m_name)) - PROTO::outputs.at(monitor->m_name)->destroyResource(this); + m_resource->setOnDestroy([this](CWlOutput* r) { + if (m_monitor && PROTO::outputs.contains(m_monitor->m_name)) + PROTO::outputs.at(m_monitor->m_name)->destroyResource(this); }); - resource->setRelease([this](CWlOutput* r) { - if (monitor && PROTO::outputs.contains(monitor->m_name)) - PROTO::outputs.at(monitor->m_name)->destroyResource(this); + m_resource->setRelease([this](CWlOutput* r) { + if (m_monitor && PROTO::outputs.contains(m_monitor->m_name)) + PROTO::outputs.at(m_monitor->m_name)->destroyResource(this); }); - if (resource->version() >= 4) { - resource->sendName(monitor->m_name.c_str()); - resource->sendDescription(monitor->m_description.c_str()); + if (m_resource->version() >= 4) { + m_resource->sendName(m_monitor->m_name.c_str()); + m_resource->sendDescription(m_monitor->m_description.c_str()); } updateState(); @@ -52,72 +52,72 @@ CWLOutputResource::CWLOutputResource(SP resource_, PHLMONITOR pMonito SP CWLOutputResource::fromResource(wl_resource* res) { auto data = (CWLOutputResource*)(((CWlOutput*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } bool CWLOutputResource::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CWLOutputResource::client() { - return pClient; + return m_client; } SP CWLOutputResource::getResource() { - return resource; + return m_resource; } void CWLOutputResource::updateState() { - if (!monitor || (owner && owner->defunct)) + if (!m_monitor || (m_owner && m_owner->m_defunct)) return; - if (resource->version() >= 2) - resource->sendScale(std::ceil(monitor->m_scale)); + if (m_resource->version() >= 2) + m_resource->sendScale(std::ceil(m_monitor->m_scale)); - resource->sendMode((wl_output_mode)(WL_OUTPUT_MODE_CURRENT), monitor->m_pixelSize.x, monitor->m_pixelSize.y, monitor->m_refreshRate * 1000.0); + m_resource->sendMode((wl_output_mode)(WL_OUTPUT_MODE_CURRENT), m_monitor->m_pixelSize.x, m_monitor->m_pixelSize.y, m_monitor->m_refreshRate * 1000.0); - resource->sendGeometry(0, 0, monitor->m_output->physicalSize.x, monitor->m_output->physicalSize.y, (wl_output_subpixel)monitor->m_output->subpixel, - monitor->m_output->make.c_str(), monitor->m_output->model.c_str(), monitor->m_transform); + m_resource->sendGeometry(0, 0, m_monitor->m_output->physicalSize.x, m_monitor->m_output->physicalSize.y, (wl_output_subpixel)m_monitor->m_output->subpixel, + m_monitor->m_output->make.c_str(), m_monitor->m_output->model.c_str(), m_monitor->m_transform); - if (resource->version() >= 2) - resource->sendDone(); + if (m_resource->version() >= 2) + m_resource->sendDone(); } CWLOutputProtocol::CWLOutputProtocol(const wl_interface* iface, const int& ver, const std::string& name, PHLMONITOR pMonitor) : - IWaylandProtocol(iface, ver, name), monitor(pMonitor), szName(pMonitor->m_name) { + IWaylandProtocol(iface, ver, name), m_monitor(pMonitor), m_name(pMonitor->m_name) { - listeners.modeChanged = monitor->m_events.modeChanged.registerListener([this](std::any d) { - for (auto const& o : m_vOutputs) { + m_listeners.modeChanged = m_monitor->m_events.modeChanged.registerListener([this](std::any d) { + for (auto const& o : m_outputs) { o->updateState(); } }); } void CWLOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - if UNLIKELY (defunct) + if UNLIKELY (m_defunct) Debug::log(WARN, "[wl_output] Binding a wl_output that's inert?? Possible client bug."); - const auto RESOURCE = m_vOutputs.emplace_back(makeShared(makeShared(client, ver, id), monitor.lock())); + const auto RESOURCE = m_outputs.emplace_back(makeShared(makeShared(client, ver, id), m_monitor.lock())); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vOutputs.pop_back(); + m_outputs.pop_back(); return; } - RESOURCE->self = RESOURCE; - RESOURCE->owner = self; + RESOURCE->m_self = RESOURCE; + RESOURCE->m_owner = m_self; } void CWLOutputProtocol::destroyResource(CWLOutputResource* 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; }); - if (m_vOutputs.empty() && defunct) - PROTO::outputs.erase(szName); + if (m_outputs.empty() && m_defunct) + PROTO::outputs.erase(m_name); } SP CWLOutputProtocol::outputResourceFrom(wl_client* client) { - for (auto const& r : m_vOutputs) { + for (auto const& r : m_outputs) { if (r->client() != client) continue; @@ -128,22 +128,22 @@ SP CWLOutputProtocol::outputResourceFrom(wl_client* client) { } void CWLOutputProtocol::remove() { - if UNLIKELY (defunct) + if UNLIKELY (m_defunct) return; - defunct = true; + m_defunct = true; removeGlobal(); } bool CWLOutputProtocol::isDefunct() { - return defunct; + return m_defunct; } void CWLOutputProtocol::sendDone() { - if UNLIKELY (defunct) + if UNLIKELY (m_defunct) return; - for (auto const& r : m_vOutputs) { - r->resource->sendDone(); + for (auto const& r : m_outputs) { + r->m_resource->sendDone(); } } diff --git a/src/protocols/core/Output.hpp b/src/protocols/core/Output.hpp index 8ade5178..9f14289e 100644 --- a/src/protocols/core/Output.hpp +++ b/src/protocols/core/Output.hpp @@ -19,13 +19,13 @@ class CWLOutputResource { SP getResource(); void updateState(); - PHLMONITORREF monitor; - WP owner; - WP self; + PHLMONITORREF m_monitor; + WP m_owner; + WP m_self; private: - SP resource; - wl_client* pClient = nullptr; + SP m_resource; + wl_client* m_client = nullptr; friend class CWLOutputProtocol; }; @@ -39,8 +39,8 @@ class CWLOutputProtocol : public IWaylandProtocol { SP outputResourceFrom(wl_client* client); void sendDone(); - PHLMONITORREF monitor; - WP self; + PHLMONITORREF m_monitor; + WP m_self; // will mark the protocol for removal, will be removed when no. of bound outputs is 0 (or when overwritten by a new global) void remove(); @@ -50,13 +50,13 @@ class CWLOutputProtocol : public IWaylandProtocol { void destroyResource(CWLOutputResource* resource); // - std::vector> m_vOutputs; - bool defunct = false; - std::string szName = ""; + std::vector> m_outputs; + bool m_defunct = false; + std::string m_name = ""; struct { CHyprSignalListener modeChanged; - } listeners; + } m_listeners; friend class CWLOutputResource; }; diff --git a/src/protocols/core/Seat.cpp b/src/protocols/core/Seat.cpp index 6dbed8fd..bc224043 100644 --- a/src/protocols/core/Seat.cpp +++ b/src/protocols/core/Seat.cpp @@ -10,292 +10,292 @@ #include -CWLTouchResource::CWLTouchResource(SP resource_, SP owner_) : owner(owner_), resource(resource_) { +CWLTouchResource::CWLTouchResource(SP resource_, SP owner_) : m_owner(owner_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setRelease([this](CWlTouch* r) { PROTO::seat->destroyResource(this); }); - resource->setOnDestroy([this](CWlTouch* r) { PROTO::seat->destroyResource(this); }); + m_resource->setRelease([this](CWlTouch* r) { PROTO::seat->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlTouch* r) { PROTO::seat->destroyResource(this); }); } bool CWLTouchResource::good() { - return resource->resource(); + return m_resource->resource(); } void CWLTouchResource::sendDown(SP surface, uint32_t timeMs, int32_t id, const Vector2D& local) { - if (!owner || !surface || !surface->getResource()->resource()) + if (!m_owner || !surface || !surface->getResource()->resource()) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) return; - ASSERT(surface->client() == owner->client()); + ASSERT(surface->client() == m_owner->client()); - currentSurface = surface; - listeners.destroySurface = surface->events.destroy.registerListener([this, timeMs, id](std::any d) { sendUp(timeMs + 10 /* hack */, id); }); + m_currentSurface = surface; + m_listeners.destroySurface = surface->m_events.destroy.registerListener([this, timeMs, id](std::any d) { sendUp(timeMs + 10 /* hack */, id); }); - resource->sendDown(g_pSeatManager->nextSerial(owner.lock()), timeMs, surface->getResource().get(), id, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); + m_resource->sendDown(g_pSeatManager->nextSerial(m_owner.lock()), timeMs, surface->getResource().get(), id, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); - fingers++; + m_fingers++; } void CWLTouchResource::sendUp(uint32_t timeMs, int32_t id) { - if (!owner) + if (!m_owner) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) return; - resource->sendUp(g_pSeatManager->nextSerial(owner.lock()), timeMs, id); - fingers--; - if (fingers <= 0) { - currentSurface.reset(); - listeners.destroySurface.reset(); - fingers = 0; + m_resource->sendUp(g_pSeatManager->nextSerial(m_owner.lock()), timeMs, id); + m_fingers--; + if (m_fingers <= 0) { + m_currentSurface.reset(); + m_listeners.destroySurface.reset(); + m_fingers = 0; } } void CWLTouchResource::sendMotion(uint32_t timeMs, int32_t id, const Vector2D& local) { - if (!owner) + if (!m_owner) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) return; - resource->sendMotion(timeMs, id, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); + m_resource->sendMotion(timeMs, id, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } void CWLTouchResource::sendFrame() { - if (!owner) + if (!m_owner) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) return; - resource->sendFrame(); + m_resource->sendFrame(); } void CWLTouchResource::sendCancel() { - if (!owner || !currentSurface) + if (!m_owner || !m_currentSurface) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) return; - resource->sendCancel(); + m_resource->sendCancel(); } void CWLTouchResource::sendShape(int32_t id, const Vector2D& shape) { - if (!owner || !currentSurface || resource->version() < 6) + if (!m_owner || !m_currentSurface || m_resource->version() < 6) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) return; - resource->sendShape(id, wl_fixed_from_double(shape.x), wl_fixed_from_double(shape.y)); + m_resource->sendShape(id, wl_fixed_from_double(shape.x), wl_fixed_from_double(shape.y)); } void CWLTouchResource::sendOrientation(int32_t id, double angle) { - if (!owner || !currentSurface || resource->version() < 6) + if (!m_owner || !m_currentSurface || m_resource->version() < 6) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) return; - resource->sendOrientation(id, wl_fixed_from_double(angle)); + m_resource->sendOrientation(id, wl_fixed_from_double(angle)); } -CWLPointerResource::CWLPointerResource(SP resource_, SP owner_) : owner(owner_), resource(resource_) { +CWLPointerResource::CWLPointerResource(SP resource_, SP owner_) : m_owner(owner_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setRelease([this](CWlPointer* r) { PROTO::seat->destroyResource(this); }); - resource->setOnDestroy([this](CWlPointer* r) { PROTO::seat->destroyResource(this); }); + m_resource->setRelease([this](CWlPointer* r) { PROTO::seat->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlPointer* r) { PROTO::seat->destroyResource(this); }); - resource->setSetCursor([this](CWlPointer* r, uint32_t serial, wl_resource* surf, int32_t hotX, int32_t hotY) { - if (!owner) { + m_resource->setSetCursor([this](CWlPointer* r, uint32_t serial, wl_resource* surf, int32_t hotX, int32_t hotY) { + if (!m_owner) { LOGM(ERR, "Client bug: setCursor when seatClient is already dead"); return; } auto surfResource = surf ? CWLSurfaceResource::fromResource(surf) : nullptr; - if (surfResource && surfResource->role->role() != SURFACE_ROLE_CURSOR && surfResource->role->role() != SURFACE_ROLE_UNASSIGNED) { + if (surfResource && surfResource->m_role->role() != SURFACE_ROLE_CURSOR && surfResource->m_role->role() != SURFACE_ROLE_UNASSIGNED) { r->error(-1, "Cursor surface already has a different role"); return; } - if (surfResource && surfResource->role->role() != SURFACE_ROLE_CURSOR) { - surfResource->role = makeShared(); + if (surfResource && surfResource->m_role->role() != SURFACE_ROLE_CURSOR) { + surfResource->m_role = makeShared(); surfResource->updateCursorShm(); } - g_pSeatManager->onSetCursor(owner.lock(), serial, surfResource, {hotX, hotY}); + g_pSeatManager->onSetCursor(m_owner.lock(), serial, surfResource, {hotX, hotY}); }); - if (g_pSeatManager->m_state.pointerFocus && g_pSeatManager->m_state.pointerFocus->client() == resource->client()) + if (g_pSeatManager->m_state.pointerFocus && g_pSeatManager->m_state.pointerFocus->client() == m_resource->client()) sendEnter(g_pSeatManager->m_state.pointerFocus.lock(), {-1, -1} /* Coords don't really matter that much, they will be updated next move */); } int CWLPointerResource::version() { - return resource->version(); + return m_resource->version(); } bool CWLPointerResource::good() { - return resource->resource(); + return m_resource->resource(); } void CWLPointerResource::sendEnter(SP surface, const Vector2D& local) { - if (!owner || currentSurface == surface || !surface->getResource()->resource()) + if (!m_owner || m_currentSurface == surface || !surface->getResource()->resource()) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - if (currentSurface) { + if (m_currentSurface) { LOGM(WARN, "requested CWLPointerResource::sendEnter without sendLeave first."); sendLeave(); } - ASSERT(surface->client() == owner->client()); + ASSERT(surface->client() == m_owner->client()); - currentSurface = surface; - listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { sendLeave(); }); + m_currentSurface = surface; + m_listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { sendLeave(); }); - resource->sendEnter(g_pSeatManager->nextSerial(owner.lock()), surface->getResource().get(), wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); + m_resource->sendEnter(g_pSeatManager->nextSerial(m_owner.lock()), surface->getResource().get(), wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } void CWLPointerResource::sendLeave() { - if (!owner || !currentSurface || !currentSurface->getResource()->resource()) + if (!m_owner || !m_currentSurface || !m_currentSurface->getResource()->resource()) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; // release all buttons unless we have a dnd going on in which case // the events shall be lost. if (!PROTO::data->dndActive()) { - for (auto const& b : pressedButtons) { + for (auto const& b : m_pressedButtons) { sendButton(Time::millis(Time::steadyNow()), b, WL_POINTER_BUTTON_STATE_RELEASED); } } - pressedButtons.clear(); + m_pressedButtons.clear(); - resource->sendLeave(g_pSeatManager->nextSerial(owner.lock()), currentSurface->getResource().get()); - currentSurface.reset(); - listeners.destroySurface.reset(); + m_resource->sendLeave(g_pSeatManager->nextSerial(m_owner.lock()), m_currentSurface->getResource().get()); + m_currentSurface.reset(); + m_listeners.destroySurface.reset(); } void CWLPointerResource::sendMotion(uint32_t timeMs, const Vector2D& local) { - if (!owner || !currentSurface) + if (!m_owner || !m_currentSurface) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendMotion(timeMs, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); + m_resource->sendMotion(timeMs, wl_fixed_from_double(local.x), wl_fixed_from_double(local.y)); } void CWLPointerResource::sendButton(uint32_t timeMs, uint32_t button, wl_pointer_button_state state) { - if (!owner || !currentSurface) + if (!m_owner || !m_currentSurface) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - if (state == WL_POINTER_BUTTON_STATE_RELEASED && std::find(pressedButtons.begin(), pressedButtons.end(), button) == pressedButtons.end()) { + if (state == WL_POINTER_BUTTON_STATE_RELEASED && std::find(m_pressedButtons.begin(), m_pressedButtons.end(), button) == m_pressedButtons.end()) { LOGM(ERR, "sendButton release on a non-pressed button"); return; - } else if (state == WL_POINTER_BUTTON_STATE_PRESSED && std::find(pressedButtons.begin(), pressedButtons.end(), button) != pressedButtons.end()) { + } else if (state == WL_POINTER_BUTTON_STATE_PRESSED && std::find(m_pressedButtons.begin(), m_pressedButtons.end(), button) != m_pressedButtons.end()) { LOGM(ERR, "sendButton press on a non-pressed button"); return; } if (state == WL_POINTER_BUTTON_STATE_RELEASED) - std::erase(pressedButtons, button); + std::erase(m_pressedButtons, button); else if (state == WL_POINTER_BUTTON_STATE_PRESSED) - pressedButtons.emplace_back(button); + m_pressedButtons.emplace_back(button); - resource->sendButton(g_pSeatManager->nextSerial(owner.lock()), timeMs, button, state); + m_resource->sendButton(g_pSeatManager->nextSerial(m_owner.lock()), timeMs, button, state); } void CWLPointerResource::sendAxis(uint32_t timeMs, wl_pointer_axis axis, double value) { - if (!owner || !currentSurface) + if (!m_owner || !m_currentSurface) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendAxis(timeMs, axis, wl_fixed_from_double(value)); + m_resource->sendAxis(timeMs, axis, wl_fixed_from_double(value)); } void CWLPointerResource::sendFrame() { - if (!owner || resource->version() < 5) + if (!m_owner || m_resource->version() < 5) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendFrame(); + m_resource->sendFrame(); } void CWLPointerResource::sendAxisSource(wl_pointer_axis_source source) { - if (!owner || !currentSurface || resource->version() < 5) + if (!m_owner || !m_currentSurface || m_resource->version() < 5) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendAxisSource(source); + m_resource->sendAxisSource(source); } void CWLPointerResource::sendAxisStop(uint32_t timeMs, wl_pointer_axis axis) { - if (!owner || !currentSurface || resource->version() < 5) + if (!m_owner || !m_currentSurface || m_resource->version() < 5) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendAxisStop(timeMs, axis); + m_resource->sendAxisStop(timeMs, axis); } void CWLPointerResource::sendAxisDiscrete(wl_pointer_axis axis, int32_t discrete) { - if (!owner || !currentSurface || resource->version() < 5) + if (!m_owner || !m_currentSurface || m_resource->version() < 5) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendAxisDiscrete(axis, discrete); + m_resource->sendAxisDiscrete(axis, discrete); } void CWLPointerResource::sendAxisValue120(wl_pointer_axis axis, int32_t value120) { - if (!owner || !currentSurface || resource->version() < 8) + if (!m_owner || !m_currentSurface || m_resource->version() < 8) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendAxisValue120(axis, value120); + m_resource->sendAxisValue120(axis, value120); } void CWLPointerResource::sendAxisRelativeDirection(wl_pointer_axis axis, wl_pointer_axis_relative_direction direction) { - if (!owner || !currentSurface || resource->version() < 9) + if (!m_owner || !m_currentSurface || m_resource->version() < 9) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) return; - resource->sendAxisRelativeDirection(axis, direction); + m_resource->sendAxisRelativeDirection(axis, direction); } -CWLKeyboardResource::CWLKeyboardResource(SP resource_, SP owner_) : owner(owner_), resource(resource_) { +CWLKeyboardResource::CWLKeyboardResource(SP resource_, SP owner_) : m_owner(owner_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setRelease([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); }); - resource->setOnDestroy([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); }); + m_resource->setRelease([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); }); if (!g_pSeatManager->m_keyboard) { LOGM(ERR, "No keyboard on bound wl_keyboard??"); @@ -305,160 +305,160 @@ CWLKeyboardResource::CWLKeyboardResource(SP resource_, SPm_keyboard.lock()); repeatInfo(g_pSeatManager->m_keyboard->m_repeatRate, g_pSeatManager->m_keyboard->m_repeatDelay); - if (g_pSeatManager->m_state.keyboardFocus && g_pSeatManager->m_state.keyboardFocus->client() == resource->client()) + if (g_pSeatManager->m_state.keyboardFocus && g_pSeatManager->m_state.keyboardFocus->client() == m_resource->client()) sendEnter(g_pSeatManager->m_state.keyboardFocus.lock()); } bool CWLKeyboardResource::good() { - return resource->resource(); + return m_resource->resource(); } void CWLKeyboardResource::sendKeymap(SP keyboard) { if (!keyboard) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) return; std::string_view keymap = keyboard->m_xkbKeymapString; Hyprutils::OS::CFileDescriptor& fd = keyboard->m_xkbKeymapFD; uint32_t size = keyboard->m_xkbKeymapString.length() + 1; - if (keymap == lastKeymap) + if (keymap == m_lastKeymap) return; - lastKeymap = keymap; + m_lastKeymap = keymap; const wl_keyboard_keymap_format format = keyboard ? WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1 : WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP; - resource->sendKeymap(format, fd.get(), size); + m_resource->sendKeymap(format, fd.get(), size); } void CWLKeyboardResource::sendEnter(SP surface) { - if (!owner || currentSurface == surface || !surface->getResource()->resource()) + if (!m_owner || m_currentSurface == surface || !surface->getResource()->resource()) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) return; - if (currentSurface) { + if (m_currentSurface) { LOGM(WARN, "requested CWLKeyboardResource::sendEnter without sendLeave first."); sendLeave(); } - ASSERT(surface->client() == owner->client()); + ASSERT(surface->client() == m_owner->client()); - currentSurface = surface; - listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { sendLeave(); }); + m_currentSurface = surface; + m_listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { sendLeave(); }); wl_array arr; wl_array_init(&arr); - resource->sendEnter(g_pSeatManager->nextSerial(owner.lock()), surface->getResource().get(), &arr); + m_resource->sendEnter(g_pSeatManager->nextSerial(m_owner.lock()), surface->getResource().get(), &arr); wl_array_release(&arr); } void CWLKeyboardResource::sendLeave() { - if (!owner || !currentSurface || !currentSurface->getResource()->resource()) + if (!m_owner || !m_currentSurface || !m_currentSurface->getResource()->resource()) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) return; - resource->sendLeave(g_pSeatManager->nextSerial(owner.lock()), currentSurface->getResource().get()); - currentSurface.reset(); - listeners.destroySurface.reset(); + m_resource->sendLeave(g_pSeatManager->nextSerial(m_owner.lock()), m_currentSurface->getResource().get()); + m_currentSurface.reset(); + m_listeners.destroySurface.reset(); } void CWLKeyboardResource::sendKey(uint32_t timeMs, uint32_t key, wl_keyboard_key_state state) { - if (!owner || !currentSurface) + if (!m_owner || !m_currentSurface) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) return; - resource->sendKey(g_pSeatManager->nextSerial(owner.lock()), timeMs, key, state); + m_resource->sendKey(g_pSeatManager->nextSerial(m_owner.lock()), timeMs, key, state); } void CWLKeyboardResource::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { - if (!owner || !currentSurface) + if (!m_owner || !m_currentSurface) return; - if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) return; - resource->sendModifiers(g_pSeatManager->nextSerial(owner.lock()), depressed, latched, locked, group); + m_resource->sendModifiers(g_pSeatManager->nextSerial(m_owner.lock()), depressed, latched, locked, group); } void CWLKeyboardResource::repeatInfo(uint32_t rate, uint32_t delayMs) { - if (!owner || resource->version() < 4 || (rate == lastRate && delayMs == lastDelayMs)) + if (!m_owner || m_resource->version() < 4 || (rate == m_lastRate && delayMs == m_lastDelayMs)) return; - lastRate = rate; - lastDelayMs = delayMs; + m_lastRate = rate; + m_lastDelayMs = delayMs; - resource->sendRepeatInfo(rate, delayMs); + m_resource->sendRepeatInfo(rate, delayMs); } -CWLSeatResource::CWLSeatResource(SP resource_) : resource(resource_) { +CWLSeatResource::CWLSeatResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlSeat* r) { - events.destroy.emit(); + m_resource->setOnDestroy([this](CWlSeat* r) { + m_events.destroy.emit(); PROTO::seat->destroyResource(this); }); - resource->setRelease([this](CWlSeat* r) { - events.destroy.emit(); + m_resource->setRelease([this](CWlSeat* r) { + m_events.destroy.emit(); PROTO::seat->destroyResource(this); }); - pClient = resource->client(); + m_client = m_resource->client(); - resource->setGetKeyboard([this](CWlSeat* r, uint32_t id) { - const auto RESOURCE = PROTO::seat->m_vKeyboards.emplace_back(makeShared(makeShared(r->client(), r->version(), id), self.lock())); + m_resource->setGetKeyboard([this](CWlSeat* r, uint32_t id) { + const auto RESOURCE = PROTO::seat->m_keyboards.emplace_back(makeShared(makeShared(r->client(), r->version(), id), m_self.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::seat->m_vKeyboards.pop_back(); + PROTO::seat->m_keyboards.pop_back(); return; } - keyboards.emplace_back(RESOURCE); + m_keyboards.emplace_back(RESOURCE); }); - resource->setGetPointer([this](CWlSeat* r, uint32_t id) { - const auto RESOURCE = PROTO::seat->m_vPointers.emplace_back(makeShared(makeShared(r->client(), r->version(), id), self.lock())); + m_resource->setGetPointer([this](CWlSeat* r, uint32_t id) { + const auto RESOURCE = PROTO::seat->m_pointers.emplace_back(makeShared(makeShared(r->client(), r->version(), id), m_self.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::seat->m_vPointers.pop_back(); + PROTO::seat->m_pointers.pop_back(); return; } - pointers.emplace_back(RESOURCE); + m_pointers.emplace_back(RESOURCE); }); - resource->setGetTouch([this](CWlSeat* r, uint32_t id) { - const auto RESOURCE = PROTO::seat->m_vTouches.emplace_back(makeShared(makeShared(r->client(), r->version(), id), self.lock())); + m_resource->setGetTouch([this](CWlSeat* r, uint32_t id) { + const auto RESOURCE = PROTO::seat->m_touches.emplace_back(makeShared(makeShared(r->client(), r->version(), id), m_self.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::seat->m_vTouches.pop_back(); + PROTO::seat->m_touches.pop_back(); return; } - touches.emplace_back(RESOURCE); + m_touches.emplace_back(RESOURCE); }); - if (resource->version() >= 2) - resource->sendName(HL_SEAT_NAME); + if (m_resource->version() >= 2) + m_resource->sendName(HL_SEAT_NAME); - sendCapabilities(PROTO::seat->currentCaps); + sendCapabilities(PROTO::seat->m_currentCaps); } CWLSeatResource::~CWLSeatResource() { - events.destroy.emit(); + m_events.destroy.emit(); } void CWLSeatResource::sendCapabilities(uint32_t caps) { @@ -470,15 +470,15 @@ void CWLSeatResource::sendCapabilities(uint32_t caps) { if (caps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH) wlCaps |= WL_SEAT_CAPABILITY_TOUCH; - resource->sendCapabilities((wl_seat_capability)wlCaps); + m_resource->sendCapabilities((wl_seat_capability)wlCaps); } bool CWLSeatResource::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CWLSeatResource::client() { - return pClient; + return m_client; } CWLSeatProtocol::CWLSeatProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -486,68 +486,68 @@ CWLSeatProtocol::CWLSeatProtocol(const wl_interface* iface, const int& ver, cons } void CWLSeatProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vSeatResources.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_seatResources.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vSeatResources.pop_back(); + m_seatResources.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; LOGM(LOG, "New seat resource bound at {:x}", (uintptr_t)RESOURCE.get()); - events.newSeatResource.emit(RESOURCE); + m_events.newSeatResource.emit(RESOURCE); } void CWLSeatProtocol::destroyResource(CWLSeatResource* seat) { - std::erase_if(m_vSeatResources, [&](const auto& other) { return other.get() == seat; }); + std::erase_if(m_seatResources, [&](const auto& other) { return other.get() == seat; }); } void CWLSeatProtocol::destroyResource(CWLKeyboardResource* resource) { - std::erase_if(m_vKeyboards, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_keyboards, [&](const auto& other) { return other.get() == resource; }); } void CWLSeatProtocol::destroyResource(CWLPointerResource* resource) { - std::erase_if(m_vPointers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_pointers, [&](const auto& other) { return other.get() == resource; }); } void CWLSeatProtocol::destroyResource(CWLTouchResource* resource) { - std::erase_if(m_vTouches, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_touches, [&](const auto& other) { return other.get() == resource; }); } void CWLSeatProtocol::updateCapabilities(uint32_t caps) { - if (caps == currentCaps) + if (caps == m_currentCaps) return; - currentCaps = caps; + m_currentCaps = caps; - for (auto const& s : m_vSeatResources) { + for (auto const& s : m_seatResources) { s->sendCapabilities(caps); } } void CWLSeatProtocol::updateKeymap() { - if (!(currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + if (!(m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) return; - for (auto const& k : m_vKeyboards) { + for (auto const& k : m_keyboards) { k->sendKeymap(g_pSeatManager->m_keyboard.lock()); } } void CWLSeatProtocol::updateRepeatInfo(uint32_t rate, uint32_t delayMs) { - if (!(currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) + if (!(m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) return; - for (auto const& k : m_vKeyboards) { + for (auto const& k : m_keyboards) { k->repeatInfo(rate, delayMs); } } SP CWLSeatProtocol::seatResourceForClient(wl_client* client) { - for (auto const& r : m_vSeatResources) { + for (auto const& r : m_seatResources) { if (r->client() == client) return r; } @@ -556,8 +556,8 @@ SP CWLSeatProtocol::seatResourceForClient(wl_client* client) { } std::vector& CCursorSurfaceRole::cursorPixelData(SP surface) { - RASSERT(surface->role->role() == SURFACE_ROLE_CURSOR, "cursorPixelData called on a non-cursor surface"); + RASSERT(surface->m_role->role() == SURFACE_ROLE_CURSOR, "cursorPixelData called on a non-cursor surface"); - auto role = (CCursorSurfaceRole*)surface->role.get(); - return role->cursorShmPixelData; + auto role = (CCursorSurfaceRole*)surface->m_role.get(); + return role->m_cursorShmPixelData; } diff --git a/src/protocols/core/Seat.hpp b/src/protocols/core/Seat.hpp index a4889379..35839385 100644 --- a/src/protocols/core/Seat.hpp +++ b/src/protocols/core/Seat.hpp @@ -38,7 +38,7 @@ class CCursorSurfaceRole : public ISurfaceRole { static std::vector& cursorPixelData(SP surface); private: - std::vector cursorShmPixelData; + std::vector m_cursorShmPixelData; }; class CWLTouchResource { @@ -54,17 +54,17 @@ class CWLTouchResource { void sendShape(int32_t id, const Vector2D& shape); void sendOrientation(int32_t id, double angle); - WP owner; + WP m_owner; private: - SP resource; - WP currentSurface; + SP m_resource; + WP m_currentSurface; - int fingers = 0; + int m_fingers = 0; struct { CHyprSignalListener destroySurface; - } listeners; + } m_listeners; }; class CWLPointerResource { @@ -85,17 +85,17 @@ class CWLPointerResource { void sendAxisValue120(wl_pointer_axis axis, int32_t value120); void sendAxisRelativeDirection(wl_pointer_axis axis, wl_pointer_axis_relative_direction direction); - WP owner; + WP m_owner; private: - SP resource; - WP currentSurface; + SP m_resource; + WP m_currentSurface; - std::vector pressedButtons; + std::vector m_pressedButtons; struct { CHyprSignalListener destroySurface; - } listeners; + } m_listeners; }; class CWLKeyboardResource { @@ -110,19 +110,19 @@ class CWLKeyboardResource { void sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group); void repeatInfo(uint32_t rate, uint32_t delayMs); - WP owner; + WP m_owner; private: - SP resource; - WP currentSurface; + SP m_resource; + WP m_currentSurface; struct { CHyprSignalListener destroySurface; - } listeners; + } m_listeners; - std::string lastKeymap = ""; - uint32_t lastRate = 0; - uint32_t lastDelayMs = 0; + std::string m_lastKeymap = ""; + uint32_t m_lastRate = 0; + uint32_t m_lastDelayMs = 0; }; class CWLSeatResource { @@ -135,19 +135,19 @@ class CWLSeatResource { bool good(); wl_client* client(); - std::vector> pointers; - std::vector> keyboards; - std::vector> touches; + std::vector> m_pointers; + std::vector> m_keyboards; + std::vector> m_touches; - WP self; + WP m_self; struct { CSignal destroy; - } events; + } m_events; private: - SP resource; - wl_client* pClient = nullptr; + SP m_resource; + wl_client* m_client = nullptr; }; class CWLSeatProtocol : public IWaylandProtocol { @@ -158,7 +158,7 @@ class CWLSeatProtocol : public IWaylandProtocol { struct { CSignal newSeatResource; // SP - } events; + } m_events; private: void updateCapabilities(uint32_t caps); // in IHID caps @@ -171,15 +171,15 @@ class CWLSeatProtocol : public IWaylandProtocol { void destroyResource(CWLPointerResource* resource); // - std::vector> m_vSeatResources; - std::vector> m_vKeyboards; - std::vector> m_vTouches; - std::vector> m_vPointers; + std::vector> m_seatResources; + std::vector> m_keyboards; + std::vector> m_touches; + std::vector> m_pointers; SP seatResourceForClient(wl_client* client); // - uint32_t currentCaps = 0; + uint32_t m_currentCaps = 0; friend class CWLSeatResource; friend class CWLKeyboardResource; diff --git a/src/protocols/core/Shm.cpp b/src/protocols/core/Shm.cpp index 420b4a3f..6ebfa64f 100644 --- a/src/protocols/core/Shm.cpp +++ b/src/protocols/core/Shm.cpp @@ -10,22 +10,22 @@ using namespace Hyprutils::OS; CWLSHMBuffer::CWLSHMBuffer(SP pool_, uint32_t id, int32_t offset_, const Vector2D& size_, int32_t stride_, uint32_t fmt_) { - if UNLIKELY (!pool_->pool->data) + if UNLIKELY (!pool_->m_pool->m_data) return; g_pHyprRenderer->makeEGLCurrent(); - size = size_; - pool = pool_->pool; - stride = stride_; - fmt = fmt_; - offset = offset_; - opaque = NFormatUtils::isFormatOpaque(NFormatUtils::shmToDRM(fmt_)); + size = size_; + m_pool = pool_->m_pool; + m_stride = stride_; + m_fmt = fmt_; + m_offset = offset_; + opaque = NFormatUtils::isFormatOpaque(NFormatUtils::shmToDRM(fmt_)); - resource = CWLBufferResource::create(makeShared(pool_->resource->client(), 1, id)); + resource = CWLBufferResource::create(makeShared(pool_->m_resource->client(), 1, id)); - listeners.bufferResourceDestroy = events.destroy.registerListener([this](std::any d) { - listeners.bufferResourceDestroy.reset(); + m_listeners.bufferResourceDestroy = events.destroy.registerListener([this](std::any d) { + m_listeners.bufferResourceDestroy.reset(); PROTO::shm->destroyResource(this); }); } @@ -50,16 +50,16 @@ bool CWLSHMBuffer::isSynchronous() { Aquamarine::SSHMAttrs CWLSHMBuffer::shm() { Aquamarine::SSHMAttrs attrs; attrs.success = true; - attrs.fd = pool->fd.get(); - attrs.format = NFormatUtils::shmToDRM(fmt); + attrs.fd = m_pool->m_fd.get(); + attrs.format = NFormatUtils::shmToDRM(m_fmt); attrs.size = size; - attrs.stride = stride; - attrs.offset = offset; + attrs.stride = m_stride; + attrs.offset = m_offset; return attrs; } std::tuple CWLSHMBuffer::beginDataPtr(uint32_t flags) { - return {(uint8_t*)pool->data + offset, fmt, stride * size.y}; + return {(uint8_t*)m_pool->m_data + m_offset, m_fmt, m_stride * size.y}; } void CWLSHMBuffer::endDataPtr() { @@ -74,24 +74,24 @@ void CWLSHMBuffer::update(const CRegion& damage) { ; } -CSHMPool::CSHMPool(CFileDescriptor fd_, size_t size_) : fd(std::move(fd_)), size(size_), data(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd.get(), 0)) { +CSHMPool::CSHMPool(CFileDescriptor fd_, size_t size_) : m_fd(std::move(fd_)), m_size(size_), m_data(mmap(nullptr, m_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd.get(), 0)) { ; } CSHMPool::~CSHMPool() { - munmap(data, size); + munmap(m_data, m_size); } void CSHMPool::resize(size_t size_) { - LOGM(LOG, "Resizing a SHM pool from {} to {}", size, size_); + LOGM(LOG, "Resizing a SHM pool from {} to {}", m_size, size_); - if (data) - munmap(data, size); - size = size_; - data = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd.get(), 0); + if (m_data) + munmap(m_data, m_size); + m_size = size_; + m_data = mmap(nullptr, m_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd.get(), 0); - if UNLIKELY (data == MAP_FAILED) - LOGM(ERR, "Couldn't mmap {} bytes from fd {} of shm client", size, fd.get()); + if UNLIKELY (m_data == MAP_FAILED) + LOGM(ERR, "Couldn't mmap {} bytes from fd {} of shm client", m_size, m_fd.get()); } static int shmIsSizeValid(CFileDescriptor& fd, size_t size) { @@ -104,7 +104,7 @@ static int shmIsSizeValid(CFileDescriptor& fd, size_t size) { return (size_t)st.st_size >= size; } -CWLSHMPoolResource::CWLSHMPoolResource(SP resource_, CFileDescriptor fd_, size_t size_) : resource(resource_) { +CWLSHMPoolResource::CWLSHMPoolResource(SP resource_, CFileDescriptor fd_, size_t size_) : m_resource(resource_) { if UNLIKELY (!good()) return; @@ -113,31 +113,31 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP resource_, CFileDescriptor return; } - pool = makeShared(std::move(fd_), size_); + m_pool = makeShared(std::move(fd_), size_); - resource->setDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); }); - resource->setOnDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); }); + m_resource->setDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); }); - resource->setResize([this](CWlShmPool* r, int32_t size_) { - if UNLIKELY (size_ < (int32_t)pool->size) { + m_resource->setResize([this](CWlShmPool* r, int32_t size_) { + if UNLIKELY (size_ < (int32_t)m_pool->m_size) { r->error(-1, "Shrinking a shm pool is illegal"); return; } - if UNLIKELY (!shmIsSizeValid(pool->fd, size_)) { + if UNLIKELY (!shmIsSizeValid(m_pool->m_fd, size_)) { r->error(-1, "The size of the file is not big enough for the shm pool"); return; } - pool->resize(size_); + m_pool->resize(size_); }); - resource->setCreateBuffer([this](CWlShmPool* r, uint32_t id, int32_t offset, int32_t w, int32_t h, int32_t stride, uint32_t fmt) { - if UNLIKELY (!pool || !pool->data) { + m_resource->setCreateBuffer([this](CWlShmPool* r, uint32_t id, int32_t offset, int32_t w, int32_t h, int32_t stride, uint32_t fmt) { + if UNLIKELY (!m_pool || !m_pool->m_data) { r->error(-1, "The provided shm pool failed to allocate properly"); return; } - if UNLIKELY (std::find(PROTO::shm->shmFormats.begin(), PROTO::shm->shmFormats.end(), fmt) == PROTO::shm->shmFormats.end()) { + if UNLIKELY (std::find(PROTO::shm->m_shmFormats.begin(), PROTO::shm->m_shmFormats.end(), fmt) == PROTO::shm->m_shmFormats.end()) { r->error(WL_SHM_ERROR_INVALID_FORMAT, "Format invalid"); return; } @@ -147,11 +147,11 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP resource_, CFileDescriptor return; } - const auto RESOURCE = PROTO::shm->m_vBuffers.emplace_back(makeShared(self.lock(), id, offset, Vector2D{w, h}, stride, fmt)); + const auto RESOURCE = PROTO::shm->m_buffers.emplace_back(makeShared(m_self.lock(), id, offset, Vector2D{w, h}, stride, fmt)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::shm->m_vBuffers.pop_back(); + PROTO::shm->m_buffers.pop_back(); return; } @@ -159,41 +159,41 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP resource_, CFileDescriptor RESOURCE->resource->buffer = RESOURCE; }); - if UNLIKELY (pool->data == MAP_FAILED) - resource->error(WL_SHM_ERROR_INVALID_FD, "Couldn't mmap from fd"); + if UNLIKELY (m_pool->m_data == MAP_FAILED) + m_resource->error(WL_SHM_ERROR_INVALID_FD, "Couldn't mmap from fd"); } bool CWLSHMPoolResource::good() { - return resource->resource(); + return m_resource->resource(); } -CWLSHMResource::CWLSHMResource(SP resource_) : resource(resource_) { +CWLSHMResource::CWLSHMResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlShm* r) { PROTO::shm->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlShm* r) { PROTO::shm->destroyResource(this); }); - resource->setCreatePool([](CWlShm* r, uint32_t id, int32_t fd, int32_t size) { + m_resource->setCreatePool([](CWlShm* r, uint32_t id, int32_t fd, int32_t size) { CFileDescriptor poolFd{fd}; - const auto RESOURCE = PROTO::shm->m_vPools.emplace_back(makeShared(makeShared(r->client(), r->version(), id), std::move(poolFd), size)); + const auto RESOURCE = PROTO::shm->m_pools.emplace_back(makeShared(makeShared(r->client(), r->version(), id), std::move(poolFd), size)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::shm->m_vPools.pop_back(); + PROTO::shm->m_pools.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); // send a few supported formats. No need for any other I think? - for (auto const& s : PROTO::shm->shmFormats) { - resource->sendFormat((wl_shm_format)s); + for (auto const& s : PROTO::shm->m_shmFormats) { + m_resource->sendFormat((wl_shm_format)s); } } bool CWLSHMResource::good() { - return resource->resource(); + return m_resource->resource(); } CWLSHMProtocol::CWLSHMProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -201,36 +201,36 @@ CWLSHMProtocol::CWLSHMProtocol(const wl_interface* iface, const int& ver, const } void CWLSHMProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - if (shmFormats.empty()) { - shmFormats.push_back(WL_SHM_FORMAT_ARGB8888); - shmFormats.push_back(WL_SHM_FORMAT_XRGB8888); + if (m_shmFormats.empty()) { + m_shmFormats.push_back(WL_SHM_FORMAT_ARGB8888); + m_shmFormats.push_back(WL_SHM_FORMAT_XRGB8888); static const std::array supportedShmFourccFormats = { DRM_FORMAT_XBGR8888, DRM_FORMAT_ABGR8888, DRM_FORMAT_XRGB2101010, DRM_FORMAT_ARGB2101010, DRM_FORMAT_XBGR2101010, DRM_FORMAT_ABGR2101010, }; for (auto const& fmt : supportedShmFourccFormats) { - shmFormats.push_back(fmt); + m_shmFormats.push_back(fmt); } } - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CWLSHMProtocol::destroyResource(CWLSHMResource* 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 CWLSHMProtocol::destroyResource(CWLSHMPoolResource* resource) { - std::erase_if(m_vPools, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_pools, [&](const auto& other) { return other.get() == resource; }); } void CWLSHMProtocol::destroyResource(CWLSHMBuffer* 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; }); } diff --git a/src/protocols/core/Shm.hpp b/src/protocols/core/Shm.hpp index 61b26f12..e504146d 100644 --- a/src/protocols/core/Shm.hpp +++ b/src/protocols/core/Shm.hpp @@ -23,9 +23,9 @@ class CSHMPool { CSHMPool(Hyprutils::OS::CFileDescriptor fd, size_t size); ~CSHMPool(); - Hyprutils::OS::CFileDescriptor fd; - size_t size = 0; - void* data = nullptr; + Hyprutils::OS::CFileDescriptor m_fd; + size_t m_size = 0; + void* m_data = nullptr; void resize(size_t size); }; @@ -45,14 +45,15 @@ class CWLSHMBuffer : public IHLBuffer { bool good(); - int32_t offset = 0, stride = 0; - uint32_t fmt = 0; - SP pool; + int32_t m_offset = 0; + int32_t m_stride = 0; + uint32_t m_fmt = 0; + SP m_pool; private: struct { CHyprSignalListener bufferResourceDestroy; - } listeners; + } m_listeners; }; class CWLSHMPoolResource { @@ -61,12 +62,12 @@ class CWLSHMPoolResource { bool good(); - SP pool; + SP m_pool; - WP self; + WP m_self; private: - SP resource; + SP m_resource; friend class CWLSHMBuffer; }; @@ -78,7 +79,7 @@ class CWLSHMResource { bool good(); private: - SP resource; + SP m_resource; }; class CWLSHMProtocol : public IWaylandProtocol { @@ -93,12 +94,12 @@ class CWLSHMProtocol : public IWaylandProtocol { void destroyResource(CWLSHMBuffer* resource); // - std::vector> m_vManagers; - std::vector> m_vPools; - std::vector> m_vBuffers; + std::vector> m_managers; + std::vector> m_pools; + std::vector> m_buffers; // - std::vector shmFormats; + std::vector m_shmFormats; friend class CWLSHMResource; friend class CWLSHMPoolResource; diff --git a/src/protocols/core/Subcompositor.cpp b/src/protocols/core/Subcompositor.cpp index 82f4aedb..4111b5dc 100644 --- a/src/protocols/core/Subcompositor.cpp +++ b/src/protocols/core/Subcompositor.cpp @@ -3,154 +3,154 @@ #include CWLSubsurfaceResource::CWLSubsurfaceResource(SP resource_, SP surface_, SP parent_) : - surface(surface_), parent(parent_), resource(resource_) { + m_surface(surface_), m_parent(parent_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlSubsurface* r) { destroy(); }); - resource->setDestroy([this](CWlSubsurface* r) { destroy(); }); + m_resource->setOnDestroy([this](CWlSubsurface* r) { destroy(); }); + m_resource->setDestroy([this](CWlSubsurface* r) { destroy(); }); - resource->setSetPosition([this](CWlSubsurface* r, int32_t x, int32_t y) { position = {x, y}; }); + m_resource->setSetPosition([this](CWlSubsurface* r, int32_t x, int32_t y) { m_position = {x, y}; }); - resource->setSetDesync([this](CWlSubsurface* r) { sync = false; }); - resource->setSetSync([this](CWlSubsurface* r) { sync = true; }); + m_resource->setSetDesync([this](CWlSubsurface* r) { m_sync = false; }); + m_resource->setSetSync([this](CWlSubsurface* r) { m_sync = true; }); - resource->setPlaceAbove([this](CWlSubsurface* r, wl_resource* surf) { + m_resource->setPlaceAbove([this](CWlSubsurface* r, wl_resource* surf) { auto SURF = CWLSurfaceResource::fromResource(surf); - if (!parent) + if (!m_parent) return; auto pushAboveIndex = [this](int idx) -> void { - for (auto const& c : parent->subsurfaces) { - if (c->zIndex >= idx) - c->zIndex++; + for (auto const& c : m_parent->m_subsurfaces) { + if (c->m_zIndex >= idx) + c->m_zIndex++; } }; - std::erase_if(parent->subsurfaces, [this](const auto& e) { return e == self || !e; }); + std::erase_if(m_parent->m_subsurfaces, [this](const auto& e) { return e == m_self || !e; }); - auto it = std::find(parent->subsurfaces.begin(), parent->subsurfaces.end(), SURF); + auto it = std::find(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), SURF); - if (it == parent->subsurfaces.end()) { + if (it == m_parent->m_subsurfaces.end()) { LOGM(ERR, "Invalid surface reference in placeAbove, likely parent"); pushAboveIndex(1); - parent->subsurfaces.emplace_back(self); - zIndex = 1; + m_parent->m_subsurfaces.emplace_back(m_self); + m_zIndex = 1; } else { - pushAboveIndex((*it)->zIndex); - zIndex = (*it)->zIndex; - parent->subsurfaces.emplace_back(self); + pushAboveIndex((*it)->m_zIndex); + m_zIndex = (*it)->m_zIndex; + m_parent->m_subsurfaces.emplace_back(m_self); } - std::sort(parent->subsurfaces.begin(), parent->subsurfaces.end(), [](const auto& a, const auto& b) { return a->zIndex < b->zIndex; }); + std::sort(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), [](const auto& a, const auto& b) { return a->m_zIndex < b->m_zIndex; }); }); - resource->setPlaceBelow([this](CWlSubsurface* r, wl_resource* surf) { + m_resource->setPlaceBelow([this](CWlSubsurface* r, wl_resource* surf) { auto SURF = CWLSurfaceResource::fromResource(surf); - if (!parent) + if (!m_parent) return; auto pushBelowIndex = [this](int idx) -> void { - for (auto const& c : parent->subsurfaces) { - if (c->zIndex <= idx) - c->zIndex--; + for (auto const& c : m_parent->m_subsurfaces) { + if (c->m_zIndex <= idx) + c->m_zIndex--; } }; - std::erase_if(parent->subsurfaces, [this](const auto& e) { return e == self || !e; }); + std::erase_if(m_parent->m_subsurfaces, [this](const auto& e) { return e == m_self || !e; }); - auto it = std::find(parent->subsurfaces.begin(), parent->subsurfaces.end(), SURF); + auto it = std::find(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), SURF); - if (it == parent->subsurfaces.end()) { + if (it == m_parent->m_subsurfaces.end()) { LOGM(ERR, "Invalid surface reference in placeBelow, likely parent"); pushBelowIndex(-1); - parent->subsurfaces.emplace_back(self); - zIndex = -1; + m_parent->m_subsurfaces.emplace_back(m_self); + m_zIndex = -1; } else { - pushBelowIndex((*it)->zIndex); - zIndex = (*it)->zIndex; - parent->subsurfaces.emplace_back(self); + pushBelowIndex((*it)->m_zIndex); + m_zIndex = (*it)->m_zIndex; + m_parent->m_subsurfaces.emplace_back(m_self); } - std::sort(parent->subsurfaces.begin(), parent->subsurfaces.end(), [](const auto& a, const auto& b) { return a->zIndex < b->zIndex; }); + std::sort(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), [](const auto& a, const auto& b) { return a->m_zIndex < b->m_zIndex; }); }); - listeners.commitSurface = surface->events.commit.registerListener([this](std::any d) { - if (surface->current.texture && !surface->mapped) { - surface->map(); - surface->events.map.emit(); + m_listeners.commitSurface = m_surface->m_events.commit.registerListener([this](std::any d) { + if (m_surface->m_current.texture && !m_surface->m_mapped) { + m_surface->map(); + m_surface->m_events.map.emit(); return; } - if (!surface->current.texture && surface->mapped) { - surface->events.unmap.emit(); - surface->unmap(); + if (!m_surface->m_current.texture && m_surface->m_mapped) { + m_surface->m_events.unmap.emit(); + m_surface->unmap(); return; } }); } CWLSubsurfaceResource::~CWLSubsurfaceResource() { - events.destroy.emit(); - if (surface) - surface->resetRole(); + m_events.destroy.emit(); + if (m_surface) + m_surface->resetRole(); } void CWLSubsurfaceResource::destroy() { - if (surface && surface->mapped) { - surface->events.unmap.emit(); - surface->unmap(); + if (m_surface && m_surface->m_mapped) { + m_surface->m_events.unmap.emit(); + m_surface->unmap(); } - events.destroy.emit(); + m_events.destroy.emit(); PROTO::subcompositor->destroyResource(this); } Vector2D CWLSubsurfaceResource::posRelativeToParent() { - Vector2D pos = position; - SP surf = parent.lock(); + Vector2D pos = m_position; + SP surf = m_parent.lock(); // some apps might create cycles, which I believe _technically_ are not a protocol error // in some cases, notably firefox likes to do that, so we keep track of what // surfaces we've visited and if we hit a surface we've visited we bail out. std::vector> surfacesVisited; - while (surf->role->role() == SURFACE_ROLE_SUBSURFACE && + while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) { surfacesVisited.emplace_back(surf); - auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock(); - pos += subsurface->position; - surf = subsurface->parent.lock(); + auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock(); + pos += subsurface->m_position; + surf = subsurface->m_parent.lock(); } return pos; } bool CWLSubsurfaceResource::good() { - return resource->resource(); + return m_resource->resource(); } SP CWLSubsurfaceResource::t1Parent() { - SP surf = parent.lock(); + SP surf = m_parent.lock(); std::vector> surfacesVisited; - while (surf->role->role() == SURFACE_ROLE_SUBSURFACE && + while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) { surfacesVisited.emplace_back(surf); - auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock(); - surf = subsurface->parent.lock(); + auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock(); + surf = subsurface->m_parent.lock(); } return surf; } -CWLSubcompositorResource::CWLSubcompositorResource(SP resource_) : resource(resource_) { +CWLSubcompositorResource::CWLSubcompositorResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlSubcompositor* r) { PROTO::subcompositor->destroyResource(this); }); - resource->setDestroy([this](CWlSubcompositor* r) { PROTO::subcompositor->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlSubcompositor* r) { PROTO::subcompositor->destroyResource(this); }); + m_resource->setDestroy([this](CWlSubcompositor* r) { PROTO::subcompositor->destroyResource(this); }); - resource->setGetSubsurface([](CWlSubcompositor* r, uint32_t id, wl_resource* surface, wl_resource* parent) { + m_resource->setGetSubsurface([](CWlSubcompositor* r, uint32_t id, wl_resource* surface, wl_resource* parent) { auto SURF = CWLSurfaceResource::fromResource(surface); auto PARENT = CWLSurfaceResource::fromResource(parent); @@ -159,15 +159,15 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP resource return; } - if UNLIKELY (SURF->role->role() != SURFACE_ROLE_UNASSIGNED) { + if UNLIKELY (SURF->m_role->role() != SURFACE_ROLE_UNASSIGNED) { r->error(-1, "Surface already has a different role"); return; } SP t1Parent = nullptr; - if (PARENT->role->role() == SURFACE_ROLE_SUBSURFACE) { - auto subsurface = ((CSubsurfaceRole*)PARENT->role.get())->subsurface.lock(); + if (PARENT->m_role->role() == SURFACE_ROLE_SUBSURFACE) { + auto subsurface = ((CSubsurfaceRole*)PARENT->m_role.get())->m_subsurface.lock(); t1Parent = subsurface->t1Parent(); } else t1Parent = PARENT; @@ -178,26 +178,26 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP resource } const auto RESOURCE = - PROTO::subcompositor->m_vSurfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id), SURF, PARENT)); + PROTO::subcompositor->m_surfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id), SURF, PARENT)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::subcompositor->m_vSurfaces.pop_back(); + PROTO::subcompositor->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; - SURF->role = makeShared(RESOURCE); - PARENT->subsurfaces.emplace_back(RESOURCE); + RESOURCE->m_self = RESOURCE; + SURF->m_role = makeShared(RESOURCE); + PARENT->m_subsurfaces.emplace_back(RESOURCE); LOGM(LOG, "New wl_subsurface with id {} at {:x}", id, (uintptr_t)RESOURCE.get()); - PARENT->events.newSubsurface.emit(RESOURCE); + PARENT->m_events.newSubsurface.emit(RESOURCE); }); } bool CWLSubcompositorResource::good() { - return resource->resource(); + return m_resource->resource(); } CWLSubcompositorProtocol::CWLSubcompositorProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -205,23 +205,23 @@ CWLSubcompositorProtocol::CWLSubcompositorProtocol(const wl_interface* iface, co } void CWLSubcompositorProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CWLSubcompositorProtocol::destroyResource(CWLSubcompositorResource* 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 CWLSubcompositorProtocol::destroyResource(CWLSubsurfaceResource* 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; }); } -CSubsurfaceRole::CSubsurfaceRole(SP sub) : subsurface(sub) { +CSubsurfaceRole::CSubsurfaceRole(SP sub) : m_subsurface(sub) { ; } diff --git a/src/protocols/core/Subcompositor.hpp b/src/protocols/core/Subcompositor.hpp index dc713044..cf7913ec 100644 --- a/src/protocols/core/Subcompositor.hpp +++ b/src/protocols/core/Subcompositor.hpp @@ -25,7 +25,7 @@ class CSubsurfaceRole : public ISurfaceRole { return SURFACE_ROLE_SUBSURFACE; } - WP subsurface; + WP m_subsurface; }; class CWLSubsurfaceResource { @@ -37,28 +37,28 @@ class CWLSubsurfaceResource { bool good(); SP t1Parent(); - bool sync = false; - Vector2D position; + bool m_sync = false; + Vector2D m_position; - WP surface; - WP parent; + WP m_surface; + WP m_parent; - WP self; + WP m_self; - int zIndex = 1; // by default, it's above + int m_zIndex = 1; // by default, it's above struct { CSignal destroy; - } events; + } m_events; private: - SP resource; + SP m_resource; void destroy(); struct { CHyprSignalListener commitSurface; - } listeners; + } m_listeners; }; class CWLSubcompositorResource { @@ -68,7 +68,7 @@ class CWLSubcompositorResource { bool good(); private: - SP resource; + SP m_resource; }; class CWLSubcompositorProtocol : public IWaylandProtocol { @@ -82,8 +82,8 @@ class CWLSubcompositorProtocol : public IWaylandProtocol { void destroyResource(CWLSubsurfaceResource* resource); // - std::vector> m_vManagers; - std::vector> m_vSurfaces; + std::vector> m_managers; + std::vector> m_surfaces; friend class CWLSubcompositorResource; friend class CWLSubsurfaceResource; diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 31fd7b0a..c213f860 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1568,7 +1568,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP tex, const CB } const auto imageDescription = - m_RenderData.surface.valid() && m_RenderData.surface->colorManagement.valid() ? m_RenderData.surface->colorManagement->imageDescription() : SImageDescription{}; + m_RenderData.surface.valid() && m_RenderData.surface->m_colorManagement.valid() ? m_RenderData.surface->m_colorManagement->imageDescription() : SImageDescription{}; const bool skipCM = !*PENABLECM || !m_bCMSupported /* CM unsupported or disabled */ || (imageDescription == m_RenderData.pMonitor->m_imageDescription) /* Source and target have the same image description */ @@ -2088,9 +2088,9 @@ void CHyprOpenGLImpl::preRender(PHLMONITOR pMonitor) { CRegion inverseOpaque; - pixman_box32_t surfbox = {0, 0, PSURFACE->current.size.x, PSURFACE->current.size.y}; - CRegion opaqueRegion{PSURFACE->current.opaque}; - inverseOpaque.set(opaqueRegion).invert(&surfbox).intersect(0, 0, PSURFACE->current.size.x, PSURFACE->current.size.y); + pixman_box32_t surfbox = {0, 0, PSURFACE->m_current.size.x, PSURFACE->m_current.size.y}; + CRegion opaqueRegion{PSURFACE->m_current.opaque}; + inverseOpaque.set(opaqueRegion).invert(&surfbox).intersect(0, 0, PSURFACE->m_current.size.x, PSURFACE->m_current.size.y); if (inverseOpaque.empty()) return false; @@ -2224,11 +2224,11 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP tex, const CBox& box, f // amazing hack: the surface has an opaque region! CRegion inverseOpaque; - if (a >= 1.f && std::round(pSurface->current.size.x * m_RenderData.pMonitor->m_scale) == box.w && - std::round(pSurface->current.size.y * m_RenderData.pMonitor->m_scale) == box.h) { - pixman_box32_t surfbox = {0, 0, pSurface->current.size.x * pSurface->current.scale, pSurface->current.size.y * pSurface->current.scale}; - inverseOpaque = pSurface->current.opaque; - inverseOpaque.invert(&surfbox).intersect(0, 0, pSurface->current.size.x * pSurface->current.scale, pSurface->current.size.y * pSurface->current.scale); + if (a >= 1.f && std::round(pSurface->m_current.size.x * m_RenderData.pMonitor->m_scale) == box.w && + std::round(pSurface->m_current.size.y * m_RenderData.pMonitor->m_scale) == box.h) { + pixman_box32_t surfbox = {0, 0, pSurface->m_current.size.x * pSurface->m_current.scale, pSurface->m_current.size.y * pSurface->m_current.scale}; + inverseOpaque = pSurface->m_current.opaque; + inverseOpaque.invert(&surfbox).intersect(0, 0, pSurface->m_current.size.x * pSurface->m_current.scale, pSurface->m_current.size.y * pSurface->m_current.scale); if (inverseOpaque.empty()) { renderTexture(tex, box, a, round, roundingPower, false, true); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 15c52ba9..1b861f7a 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -589,7 +589,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T pWindow->m_wlSurface->resource()->breadthfirst( [this, &renderdata, &pWindow](SP s, const Vector2D& offset, void* data) { renderdata.localPos = offset; - renderdata.texture = s->current.texture; + renderdata.texture = s->m_current.texture; renderdata.surface = s; renderdata.mainSurface = s == pWindow->m_wlSurface->resource(); m_sRenderPass.add(makeShared(renderdata)); @@ -657,7 +657,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T popup->m_wlSurface->resource()->breadthfirst( [this, &renderdata](SP s, const Vector2D& offset, void* data) { renderdata.localPos = offset; - renderdata.texture = s->current.texture; + renderdata.texture = s->m_current.texture; renderdata.surface = s; renderdata.mainSurface = false; m_sRenderPass.add(makeShared(renderdata)); @@ -739,7 +739,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s pLayer->m_surface->resource()->breadthfirst( [this, &renderdata, &pLayer](SP s, const Vector2D& offset, void* data) { renderdata.localPos = offset; - renderdata.texture = s->current.texture; + renderdata.texture = s->m_current.texture; renderdata.surface = s; renderdata.mainSurface = s == pLayer->m_surface->resource(); m_sRenderPass.add(makeShared(renderdata)); @@ -760,7 +760,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s Vector2D pos = popup->coordsRelativeToParent(); renderdata.localPos = pos; - renderdata.texture = popup->m_wlSurface->resource()->current.texture; + renderdata.texture = popup->m_wlSurface->resource()->m_current.texture; renderdata.surface = popup->m_wlSurface->resource(); renderdata.mainSurface = false; m_sRenderPass.add(makeShared(renderdata)); @@ -779,8 +779,8 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, con renderdata.surface = SURF; renderdata.decorate = false; - renderdata.w = SURF->current.size.x; - renderdata.h = SURF->current.size.y; + renderdata.w = SURF->m_current.size.x; + renderdata.h = SURF->m_current.size.y; static auto PBLUR = CConfigValue("decoration:blur:enabled"); static auto PBLURIMES = CConfigValue("decoration:blur:input_methods"); @@ -795,7 +795,7 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, con SURF->breadthfirst( [this, &renderdata, &SURF](SP s, const Vector2D& offset, void* data) { renderdata.localPos = offset; - renderdata.texture = s->current.texture; + renderdata.texture = s->m_current.texture; renderdata.surface = s; renderdata.mainSurface = s == SURF; m_sRenderPass.add(makeShared(renderdata)); @@ -816,7 +816,7 @@ void CHyprRenderer::renderSessionLockSurface(WP pSurface, P renderdata.surface->breadthfirst( [this, &renderdata, &pSurface](SP s, const Vector2D& offset, void* data) { renderdata.localPos = offset; - renderdata.texture = s->current.texture; + renderdata.texture = s->m_current.texture; renderdata.surface = s; renderdata.mainSurface = s == pSurface->surface->surface(); m_sRenderPass.add(makeShared(renderdata)); @@ -1053,10 +1053,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPcurrent.viewport.hasSource) { + if (pSurface->m_current.viewport.hasSource) { // we stretch it to dest. if no dest, to 1,1 - Vector2D const& bufferSize = pSurface->current.bufferSize; - auto const& bufferSource = pSurface->current.viewport.source; + Vector2D const& bufferSize = pSurface->m_current.bufferSize; + auto const& bufferSource = pSurface->m_current.viewport.source; // calculate UV for the basic src_box. Assume dest == size. Scale to dest later uvTL = Vector2D(bufferSource.x / bufferSize.x, bufferSource.y / bufferSize.y); @@ -1071,8 +1071,8 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPcurrent.bufferSize; - const Vector2D MISALIGNMENT = pSurface->current.bufferSize - projSize; + const Vector2D PIXELASUV = Vector2D{1, 1} / pSurface->m_current.bufferSize; + const Vector2D MISALIGNMENT = pSurface->m_current.bufferSize - projSize; if (MISALIGNMENT != Vector2D{}) uvBR -= MISALIGNMENT * PIXELASUV; } @@ -1083,9 +1083,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SPm_scale); - const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->current.scale && !pSurface->current.viewport.hasDestination; + const bool SCALE_UNAWARE = MONITOR_WL_SCALE != pSurface->m_current.scale && !pSurface->m_current.viewport.hasDestination; const auto EXPECTED_SIZE = - ((pSurface->current.viewport.hasDestination ? pSurface->current.viewport.destination : pSurface->current.bufferSize / pSurface->current.scale) * pMonitor->m_scale) + ((pSurface->m_current.viewport.hasDestination ? pSurface->m_current.viewport.destination : pSurface->m_current.bufferSize / pSurface->m_current.scale) * + pMonitor->m_scale) .round(); if (!SCALE_UNAWARE && (EXPECTED_SIZE.x < projSize.x || EXPECTED_SIZE.y < projSize.y)) { // this will not work with shm AFAIK, idk why. @@ -1111,10 +1112,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP projSizeUnscaled.x || geom.height > projSizeUnscaled.y) { - const auto XPERC = (double)geom.x / (double)pSurface->current.size.x; - const auto YPERC = (double)geom.y / (double)pSurface->current.size.y; - const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->current.size.x; - const auto HPERC = (double)(geom.y + geom.height) / (double)pSurface->current.size.y; + const auto XPERC = (double)geom.x / (double)pSurface->m_current.size.x; + const auto YPERC = (double)geom.y / (double)pSurface->m_current.size.y; + const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->m_current.size.x; + const auto HPERC = (double)(geom.y + geom.height) / (double)pSurface->m_current.size.y; const auto TOADDTL = Vector2D(XPERC * (uvBR.x - uvTL.x), YPERC * (uvBR.y - uvTL.y)); uvBR = uvBR - Vector2D((1.0 - WPERC) * (uvBR.x - uvTL.x), (1.0 - HPERC) * (uvBR.y - uvTL.y)); @@ -1501,18 +1502,18 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) { const auto WINDOW = pMonitor->m_activeWorkspace->getFullscreenWindow(); const auto ROOT_SURF = WINDOW->m_wlSurface->resource(); const auto SURF = - ROOT_SURF->findFirstPreorder([ROOT_SURF](SP surf) { return surf->colorManagement.valid() && surf->extends() == ROOT_SURF->extends(); }); + ROOT_SURF->findFirstPreorder([ROOT_SURF](SP surf) { return surf->m_colorManagement.valid() && surf->extends() == ROOT_SURF->extends(); }); wantHDR = PHDR && *PPASS == 2; // we have a surface with image description and it's allowed by wantHDR - if (SURF && SURF->colorManagement.valid() && SURF->colorManagement->hasImageDescription() && - (!wantHDR || SURF->colorManagement->imageDescription().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ)) { - bool needsHdrMetadataUpdate = SURF->colorManagement->needsHdrMetadataUpdate() || pMonitor->m_previousFSWindow != WINDOW; - if (SURF->colorManagement->needsHdrMetadataUpdate()) - SURF->colorManagement->setHDRMetadata(createHDRMetadata(SURF->colorManagement->imageDescription(), pMonitor->m_output->parsedEDID)); + if (SURF && SURF->m_colorManagement.valid() && SURF->m_colorManagement->hasImageDescription() && + (!wantHDR || SURF->m_colorManagement->imageDescription().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ)) { + bool needsHdrMetadataUpdate = SURF->m_colorManagement->needsHdrMetadataUpdate() || pMonitor->m_previousFSWindow != WINDOW; + if (SURF->m_colorManagement->needsHdrMetadataUpdate()) + SURF->m_colorManagement->setHDRMetadata(createHDRMetadata(SURF->m_colorManagement->imageDescription(), pMonitor->m_output->parsedEDID)); if (needsHdrMetadataUpdate) - pMonitor->m_output->state->setHDRMetadata(SURF->colorManagement->hdrMetadata()); + pMonitor->m_output->state->setHDRMetadata(SURF->m_colorManagement->hdrMetadata()); hdrIsHandled = true; } diff --git a/src/render/pass/Pass.cpp b/src/render/pass/Pass.cpp index 8897be33..925a30b4 100644 --- a/src/render/pass/Pass.cpp +++ b/src/render/pass/Pass.cpp @@ -244,13 +244,13 @@ void CRenderPass::renderDebugData() { renderHLSurface(debugData.lastWindowText, g_pCompositor->m_lastWindow->m_wlSurface->resource(), Colors::LIGHT_BLUE.modifyA(0.1F)); if (g_pSeatManager->m_state.pointerFocus) { - if (g_pSeatManager->m_state.pointerFocus->current.input.intersect(CBox{{}, g_pSeatManager->m_state.pointerFocus->current.size}).getExtents().size() != - g_pSeatManager->m_state.pointerFocus->current.size) { + if (g_pSeatManager->m_state.pointerFocus->m_current.input.intersect(CBox{{}, g_pSeatManager->m_state.pointerFocus->m_current.size}).getExtents().size() != + g_pSeatManager->m_state.pointerFocus->m_current.size) { auto hlSurface = CWLSurface::fromResource(g_pSeatManager->m_state.pointerFocus.lock()); if (hlSurface) { auto BOX = hlSurface->getSurfaceBoxGlobal(); if (BOX) { - auto region = g_pSeatManager->m_state.pointerFocus->current.input.copy() + auto region = g_pSeatManager->m_state.pointerFocus->m_current.input.copy() .scale(g_pHyprOpenGL->m_RenderData.pMonitor->m_scale) .translate(BOX->pos() - g_pHyprOpenGL->m_RenderData.pMonitor->m_position); g_pHyprOpenGL->renderRectWithDamage(box, CHyprColor{0.8F, 0.8F, 0.2F, 0.4F}, region); diff --git a/src/render/pass/SurfacePassElement.cpp b/src/render/pass/SurfacePassElement.cpp index 3813e714..ade9277c 100644 --- a/src/render/pass/SurfacePassElement.cpp +++ b/src/render/pass/SurfacePassElement.cpp @@ -72,12 +72,12 @@ void CSurfacePassElement::draw(const CRegion& damage) { return; } - const bool MISALIGNEDFSV1 = std::floor(data.pMonitor->m_scale) != data.pMonitor->m_scale /* Fractional */ && data.surface->current.scale == 1 /* fs protocol */ && - windowBox.size() != data.surface->current.bufferSize /* misaligned */ && DELTALESSTHAN(windowBox.width, data.surface->current.bufferSize.x, 3) && - DELTALESSTHAN(windowBox.height, data.surface->current.bufferSize.y, 3) /* off by one-or-two */ && + const bool MISALIGNEDFSV1 = std::floor(data.pMonitor->m_scale) != data.pMonitor->m_scale /* Fractional */ && data.surface->m_current.scale == 1 /* fs protocol */ && + windowBox.size() != data.surface->m_current.bufferSize /* misaligned */ && DELTALESSTHAN(windowBox.width, data.surface->m_current.bufferSize.x, 3) && + DELTALESSTHAN(windowBox.height, data.surface->m_current.bufferSize.y, 3) /* off by one-or-two */ && (!data.pWindow || (!data.pWindow->m_realSize->isBeingAnimated() && !INTERACTIVERESIZEINPROGRESS)) /* not window or not animated/resizing */; - if (data.surface->colorManagement.valid()) + if (data.surface->m_colorManagement.valid()) Debug::log(TRACE, "FIXME: rendering surface with color management enabled, should apply necessary transformations"); g_pHyprRenderer->calculateUVForSurface(data.pWindow, data.surface, data.pMonitor->m_self.lock(), data.mainSurface, windowBox.size(), PROJSIZEUNSCALED, MISALIGNEDFSV1); @@ -131,8 +131,8 @@ void CSurfacePassElement::draw(const CRegion& damage) { // add async (dmabuf) buffers to usedBuffers so we can handle release later // sync (shm) buffers will be released in commitState, so no need to track them here - if (data.surface->current.buffer && !data.surface->current.buffer->isSynchronous()) - g_pHyprRenderer->usedAsyncBuffers.emplace_back(data.surface->current.buffer); + if (data.surface->m_current.buffer && !data.surface->m_current.buffer->isSynchronous()) + g_pHyprRenderer->usedAsyncBuffers.emplace_back(data.surface->m_current.buffer); g_pHyprOpenGL->blend(true); } @@ -167,8 +167,8 @@ CBox CSurfacePassElement::getTexBox() { } } else { // here we clamp to 2, these might be some tiny specks - windowBox = {(int)outputX + data.pos.x + data.localPos.x, (int)outputY + data.pos.y + data.localPos.y, std::max((float)data.surface->current.size.x, 2.F), - std::max((float)data.surface->current.size.y, 2.F)}; + windowBox = {(int)outputX + data.pos.x + data.localPos.x, (int)outputY + data.pos.y + data.localPos.y, std::max((float)data.surface->m_current.size.x, 2.F), + std::max((float)data.surface->m_current.size.y, 2.F)}; if (data.pWindow && data.pWindow->m_realSize->isBeingAnimated() && data.surface && !data.mainSurface && data.squishOversized /* subsurface */) { // adjust subsurfaces to the window windowBox.width = (windowBox.width / data.pWindow->m_reportedSize.x) * data.pWindow->m_realSize->value().x; @@ -226,8 +226,8 @@ CRegion CSurfacePassElement::opaqueRegion() { if (ALPHA < 1.F) return {}; - if (data.surface && data.surface->current.size == Vector2D{data.w, data.h}) { - CRegion opaqueSurf = data.surface->current.opaque.copy().intersect(CBox{{}, {data.w, data.h}}); + if (data.surface && data.surface->m_current.size == Vector2D{data.w, data.h}) { + CRegion opaqueSurf = data.surface->m_current.opaque.copy().intersect(CBox{{}, {data.w, data.h}}); const auto texBox = getTexBox(); opaqueSurf.scale(texBox.size() / Vector2D{data.w, data.h}); return opaqueSurf.translate(data.pos + data.localPos - data.pMonitor->m_position).expand(-data.rounding); @@ -241,7 +241,7 @@ CRegion CSurfacePassElement::visibleRegion(bool& cancel) { if (!PSURFACE) return {}; - const auto& bufferSize = data.surface->current.bufferSize; + const auto& bufferSize = data.surface->m_current.bufferSize; auto visibleRegion = PSURFACE->m_visibleRegion.copy(); if (visibleRegion.empty()) diff --git a/src/xwayland/XSurface.cpp b/src/xwayland/XSurface.cpp index 1ef1c673..89c65473 100644 --- a/src/xwayland/XSurface.cpp +++ b/src/xwayland/XSurface.cpp @@ -52,7 +52,7 @@ void CXWaylandSurface::ensureListeners() { listeners.destroySurface.reset(); listeners.commitSurface.reset(); } else if (!connected && surface) { - listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { + listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { if (mapped) unmap(); @@ -62,13 +62,13 @@ void CXWaylandSurface::ensureListeners() { events.resourceChange.emit(); }); - listeners.commitSurface = surface->events.commit.registerListener([this](std::any d) { - if (surface->current.texture && !mapped) { + listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) { + if (surface->m_current.texture && !mapped) { map(); return; } - if (!surface->current.texture && mapped) { + if (!surface->m_current.texture && mapped) { unmap(); return; } @@ -132,7 +132,7 @@ void CXWaylandSurface::considerMap() { return; } - if (surface->current.texture) { + if (surface->m_current.texture) { Debug::log(LOG, "XWayland surface: considerMap, sure, we have a buffer"); map(); return; diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp index 1c0e8ff4..6a0b1c84 100644 --- a/src/xwayland/XWM.cpp +++ b/src/xwayland/XWM.cpp @@ -957,7 +957,7 @@ CXWM::CXWM() : connection(g_pXWayland->pServer->xwmFDs[0].get()) { setActiveWindow(XCB_WINDOW_NONE); initSelection(); - listeners.newWLSurface = PROTO::compositor->events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast>(d)); }); + listeners.newWLSurface = PROTO::compositor->m_events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast>(d)); }); listeners.newXShellSurface = PROTO::xwaylandShell->events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast>(d)); }); createWMWindow();