protocols: refactor class member vars (core) (#10259)

This commit is contained in:
davc0n 2025-05-03 16:02:49 +02:00 committed by GitHub
parent 0c736217a7
commit d9cad5e1b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
57 changed files with 1160 additions and 1158 deletions

View File

@ -1288,14 +1288,14 @@ SP<CWLSurfaceResource> CCompositor::vectorToLayerSurface(const Vector2D& pos, st
bool aboveLockscreen) { bool aboveLockscreen) {
for (auto const& ls : *layerSurfaces | std::views::reverse) { for (auto const& ls : *layerSurfaces | std::views::reverse) {
if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->surface->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))) (aboveLockscreen && (!ls->m_aboveLockscreen || !ls->m_aboveLockscreenInteractable)))
continue; continue;
auto [surf, local] = ls->m_layerSurface->surface->at(pos - ls->m_geometry.pos(), true); auto [surf, local] = ls->m_layerSurface->surface->at(pos - ls->m_geometry.pos(), true);
if (surf) { if (surf) {
if (surf->current.input.empty()) if (surf->m_current.input.empty())
continue; continue;
*ppLayerSurfaceFound = ls.lock(); *ppLayerSurfaceFound = ls.lock();
@ -1310,10 +1310,10 @@ SP<CWLSurfaceResource> CCompositor::vectorToLayerSurface(const Vector2D& pos, st
} }
PHLWINDOW CCompositor::getWindowFromSurface(SP<CWLSurfaceResource> pSurface) { PHLWINDOW CCompositor::getWindowFromSurface(SP<CWLSurfaceResource> pSurface) {
if (!pSurface || !pSurface->hlSurface) if (!pSurface || !pSurface->m_hlSurface)
return nullptr; return nullptr;
return pSurface->hlSurface->getWindow(); return pSurface->m_hlSurface->getWindow();
} }
PHLWINDOW CCompositor::getWindowFromHandle(uint32_t handle) { PHLWINDOW CCompositor::getWindowFromHandle(uint32_t handle) {

View File

@ -238,7 +238,7 @@ void CLayerSurface::onUnmap() {
// refocus if needed // refocus if needed
// vvvvvvvvvvvvv if there is a last focus and the last focus is not keyboard focusable, fallback to window // 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)) if (!g_pInputManager->refocusLastWindow(PMONITOR))
g_pInputManager->refocus(); g_pInputManager->refocus();
} else if (g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus != m_surface->resource()) } 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}; CBox geomFixed = {m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y, m_geometry.width, m_geometry.height};
g_pHyprRenderer->damageBox(geomFixed); g_pHyprRenderer->damageBox(geomFixed);
geomFixed = {m_geometry.x + (int)PMONITOR->m_position.x, m_geometry.y + (int)PMONITOR->m_position.y, (int)m_layerSurface->surface->current.size.x, 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->current.size.y}; (int)m_layerSurface->surface->m_current.size.y};
g_pHyprRenderer->damageBox(geomFixed); g_pHyprRenderer->damageBox(geomFixed);
g_pInputManager->simulateMouseMovement(); g_pInputManager->simulateMouseMovement();
@ -262,7 +262,7 @@ void CLayerSurface::onCommit() {
if (!m_mapped) { if (!m_mapped) {
// we're re-mapping if this is the case // we're re-mapping if this is the case
if (m_layerSurface->surface && !m_layerSurface->surface->current.texture) { if (m_layerSurface->surface && !m_layerSurface->surface->m_current.texture) {
m_fadingOut = false; m_fadingOut = false;
m_geometry = {}; m_geometry = {};
g_pHyprRenderer->arrangeLayersForMonitor(monitorID()); g_pHyprRenderer->arrangeLayersForMonitor(monitorID());
@ -308,12 +308,12 @@ void CLayerSurface::onCommit() {
m_position = Vector2D(m_geometry.x, m_geometry.y); m_position = Vector2D(m_geometry.x, m_geometry.y);
// update geom if it changed // update geom if it changed
if (m_layerSurface->surface->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. // 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 { } else {
// this is because some apps like e.g. rofi-lbonn can't fucking use the protocol correctly. // this is because some apps like e.g. rofi-lbonn can't fucking use the protocol correctly.
m_geometry = {m_geometry.pos(), m_layerSurface->surface->current.size}; m_geometry = {m_geometry.pos(), m_layerSurface->surface->m_current.size};
} }
} }

View File

@ -93,7 +93,7 @@ void CPopup::onMap() {
return; return;
m_mapped = true; 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 COORDS = coordsGlobal();
const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS); const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS);
@ -128,7 +128,7 @@ void CPopup::onUnmap() {
m_mapped = false; m_mapped = false;
m_lastSize = m_resource->surface->surface->current.size; m_lastSize = m_resource->surface->surface->m_current.size;
const auto COORDS = coordsGlobal(); 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)) { 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<Hyprlang::INT>("debug:log_damage"); static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
if (*PLOGDAMAGE) if (*PLOGDAMAGE)
@ -186,10 +186,10 @@ void CPopup::onCommit(bool ignoreSiblings) {
const auto COORDS = coordsGlobal(); const auto COORDS = coordsGlobal();
const auto COORDSLOCAL = coordsRelativeToParent(); 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}; CBox box = {localToGlobal(m_lastPos), m_lastSize};
g_pHyprRenderer->damageBox(box); 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}; box = {COORDS, m_lastSize};
g_pHyprRenderer->damageBox(box); g_pHyprRenderer->damageBox(box);
@ -246,7 +246,7 @@ Vector2D CPopup::coordsRelativeToParent() {
while (current->m_parent && current->m_resource) { 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(); offset += current->m_resource->geometry.pos();
current = current->m_parent; current = current->m_parent;
@ -363,7 +363,7 @@ WP<CPopup> CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
if (BOX.containsPoint(globalCoords)) if (BOX.containsPoint(globalCoords))
return p; return p;
} else { } 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)) if (REGION.containsPoint(globalCoords))
return p; return p;
} }

View File

@ -32,9 +32,9 @@ UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, PHLWI
subsurface->m_subsurface = pSubsurface; subsurface->m_subsurface = pSubsurface;
subsurface->m_self = subsurface; subsurface->m_self = subsurface;
subsurface->m_wlSurface = CWLSurface::create(); 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->initSignals();
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock()); subsurface->initExistingSubsurfaces(pSubsurface->m_surface.lock());
return subsurface; return subsurface;
} }
@ -44,27 +44,27 @@ UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, WP<CP
subsurface->m_subsurface = pSubsurface; subsurface->m_subsurface = pSubsurface;
subsurface->m_self = subsurface; subsurface->m_self = subsurface;
subsurface->m_wlSurface = CWLSurface::create(); 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->initSignals();
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock()); subsurface->initExistingSubsurfaces(pSubsurface->m_surface.lock());
return subsurface; return subsurface;
} }
void CSubsurface::initSignals() { void CSubsurface::initSignals() {
if (m_subsurface) { if (m_subsurface) {
m_listeners.commitSubsurface = m_subsurface->surface->events.commit.registerListener([this](std::any d) { onCommit(); }); m_listeners.commitSubsurface = m_subsurface->m_surface->m_events.commit.registerListener([this](std::any d) { onCommit(); });
m_listeners.destroySubsurface = m_subsurface->events.destroy.registerListener([this](std::any d) { onDestroy(); }); m_listeners.destroySubsurface = m_subsurface->m_events.destroy.registerListener([this](std::any d) { onDestroy(); });
m_listeners.mapSubsurface = m_subsurface->surface->events.map.registerListener([this](std::any d) { onMap(); }); m_listeners.mapSubsurface = m_subsurface->m_surface->m_events.map.registerListener([this](std::any d) { onMap(); });
m_listeners.unmapSubsurface = m_subsurface->surface->events.unmap.registerListener([this](std::any d) { onUnmap(); }); m_listeners.unmapSubsurface = m_subsurface->m_surface->m_events.unmap.registerListener([this](std::any d) { onUnmap(); });
m_listeners.newSubsurface = m_listeners.newSubsurface =
m_subsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); }); m_subsurface->m_surface->m_events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
} else { } else {
if (m_windowParent) 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<SP<CWLSubsurfaceResource>>(d)); }); [this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
else if (m_popupParent) else if (m_popupParent)
m_listeners.newSubsurface = m_listeners.newSubsurface = m_popupParent->m_wlSurface->resource()->m_events.newSubsurface.registerListener(
m_popupParent->m_wlSurface->resource()->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); }); [this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
else else
ASSERT(false); ASSERT(false);
} }
@ -95,7 +95,7 @@ void CSubsurface::recheckDamageForSubsurfaces() {
void CSubsurface::onCommit() { void CSubsurface::onCommit() {
// no damaging if it's not visible // no damaging if it's not visible
if (!m_windowParent.expired() && (!m_windowParent->m_isMapped || !m_windowParent->m_workspace->m_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<Hyprlang::INT>("debug:log_damage"); static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
if (*PLOGDAMAGE) 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) // I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
checkSiblingDamage(); 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(); damageLastArea();
m_lastSize = m_wlSurface->resource()->current.size; m_lastSize = m_wlSurface->resource()->m_current.size;
m_lastPosition = m_subsurface->position; m_lastPosition = m_subsurface->m_position;
} }
} }
@ -151,8 +151,8 @@ void CSubsurface::onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface) {
} }
void CSubsurface::onMap() { void CSubsurface::onMap() {
m_lastSize = m_wlSurface->resource()->current.size; m_lastSize = m_wlSurface->resource()->m_current.size;
m_lastPosition = m_subsurface->position; m_lastPosition = m_subsurface->m_position;
const auto COORDS = coordsGlobal(); const auto COORDS = coordsGlobal();
CBox box{COORDS, m_lastSize}; CBox box{COORDS, m_lastSize};
@ -175,7 +175,7 @@ void CSubsurface::onUnmap() {
} }
void CSubsurface::damageLastArea() { 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}; CBox box{COORDS, m_lastSize};
box.expand(4); box.expand(4);
g_pHyprRenderer->damageBox(box); g_pHyprRenderer->damageBox(box);
@ -199,15 +199,15 @@ Vector2D CSubsurface::coordsGlobal() {
} }
void CSubsurface::initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface) { void CSubsurface::initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface) {
for (auto const& s : pSurface->subsurfaces) { for (auto const& s : pSurface->m_subsurfaces) {
if (!s || s->surface->hlSurface /* already assigned */) if (!s || s->m_surface->m_hlSurface /* already assigned */)
continue; continue;
onNewSubsurface(s.lock()); onNewSubsurface(s.lock());
} }
} }
Vector2D CSubsurface::size() { Vector2D CSubsurface::size() {
return m_wlSurface->resource()->current.size; return m_wlSurface->resource()->m_current.size;
} }
bool CSubsurface::visible() { bool CSubsurface::visible() {

View File

@ -59,12 +59,12 @@ bool CWLSurface::small() const {
if (!validMapped(m_windowOwner) || !exists()) if (!validMapped(m_windowOwner) || !exists())
return false; return false;
if (!m_resource->current.texture) if (!m_resource->m_current.texture)
return false; return false;
const auto O = m_windowOwner.lock(); 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 { Vector2D CWLSurface::correctSmallVec() const {
@ -78,36 +78,37 @@ Vector2D CWLSurface::correctSmallVec() const {
} }
Vector2D CWLSurface::correctSmallVecBuf() 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 {}; return {};
const auto SIZE = getViewporterCorrectedSize(); 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}); return Vector2D{(BS.x - SIZE.x) / 2, (BS.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY});
} }
Vector2D CWLSurface::getViewporterCorrectedSize() const { Vector2D CWLSurface::getViewporterCorrectedSize() const {
if (!exists() || !m_resource->current.texture) if (!exists() || !m_resource->m_current.texture)
return {}; 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 { CRegion CWLSurface::computeDamage() const {
if (!m_resource->current.texture) if (!m_resource->m_current.texture)
return {}; return {};
CRegion damage = m_resource->current.accumulateBufferDamage(); CRegion damage = m_resource->m_current.accumulateBufferDamage();
damage.transform(wlTransformToHyprutils(m_resource->current.transform), m_resource->current.bufferSize.x, m_resource->current.bufferSize.y); 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(); const auto CORRECTVEC = correctSmallVecBuf();
if (m_resource->current.viewport.hasSource) if (m_resource->m_current.viewport.hasSource)
damage.intersect(m_resource->current.viewport.source); 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.scale({BUFSIZE.x / SCALEDSRCSIZE.x, BUFSIZE.y / SCALEDSRCSIZE.y});
damage.translate(CORRECTVEC); damage.translate(CORRECTVEC);
@ -115,8 +116,8 @@ CRegion CWLSurface::computeDamage() const {
// go from buffer coords in the damage to hl logical // go from buffer coords in the damage to hl logical
const auto BOX = getSurfaceBoxGlobal(); const auto BOX = getSurfaceBoxGlobal();
const Vector2D SCALE = BOX.has_value() ? BOX->size() / m_resource->current.bufferSize : const Vector2D SCALE = BOX.has_value() ? BOX->size() / m_resource->m_current.bufferSize :
Vector2D{1.0 / m_resource->current.scale, 1.0 / m_resource->current.scale /* Wrong... but we can't really do better */}; 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); damage.scale(SCALE);
@ -135,7 +136,7 @@ void CWLSurface::destroy() {
m_constraint.reset(); m_constraint.reset();
m_listeners.destroy.reset(); m_listeners.destroy.reset();
m_resource->hlSurface.reset(); m_resource->m_hlSurface.reset();
m_windowOwner.reset(); m_windowOwner.reset();
m_layerOwner.reset(); m_layerOwner.reset();
m_popupOwner = nullptr; m_popupOwner = nullptr;
@ -154,11 +155,11 @@ void CWLSurface::init() {
if (!m_resource) if (!m_resource)
return; 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); Debug::log(LOG, "CWLSurface {:x} called init()", (uintptr_t)this);
} }
@ -222,7 +223,7 @@ bool CWLSurface::visible() {
SP<CWLSurface> CWLSurface::fromResource(SP<CWLSurfaceResource> pSurface) { SP<CWLSurface> CWLSurface::fromResource(SP<CWLSurfaceResource> pSurface) {
if (!pSurface) if (!pSurface)
return nullptr; return nullptr;
return pSurface->hlSurface.lock(); return pSurface->m_hlSurface.lock();
} }
bool CWLSurface::keyboardFocusable() const { bool CWLSurface::keyboardFocusable() const {

View File

@ -184,11 +184,11 @@ SBoxExtents CWindow::getFullWindowExtents() {
if (-surfaceExtents.y > maxExtents.topLeft.y) if (-surfaceExtents.y > maxExtents.topLeft.y)
maxExtents.topLeft.y = -surfaceExtents.y; maxExtents.topLeft.y = -surfaceExtents.y;
if (surfaceExtents.x + surfaceExtents.width > m_wlSurface->resource()->current.size.x + maxExtents.bottomRight.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()->current.size.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) 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()->current.size.y; maxExtents.bottomRight.y = surfaceExtents.y + surfaceExtents.height - m_wlSurface->resource()->m_current.size.y;
} }
return maxExtents; return maxExtents;
@ -1159,18 +1159,18 @@ bool CWindow::opaque() {
if (PWORKSPACE->m_alpha->value() != 1.f) if (PWORKSPACE->m_alpha->value() != 1.f)
return false; return false;
if (m_isX11 && m_xwaylandSurface && m_xwaylandSurface->surface && m_xwaylandSurface->surface->current.texture) if (m_isX11 && m_xwaylandSurface && m_xwaylandSurface->surface && m_xwaylandSurface->surface->m_current.texture)
return m_xwaylandSurface->surface->current.texture->m_bOpaque; 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; return false;
// TODO: this is wrong // TODO: this is wrong
const auto EXTENTS = m_xdgSurface->surface->current.opaque.getExtents(); const auto EXTENTS = m_xdgSurface->surface->m_current.opaque.getExtents();
if (EXTENTS.w >= m_xdgSurface->surface->current.bufferSize.x && EXTENTS.h >= m_xdgSurface->surface->current.bufferSize.y) if (EXTENTS.w >= m_xdgSurface->surface->m_current.bufferSize.x && EXTENTS.h >= m_xdgSurface->surface->m_current.bufferSize.y)
return true; return true;
return m_wlSurface->resource()->current.texture->m_bOpaque; return m_wlSurface->resource()->m_current.texture->m_bOpaque;
} }
float CWindow::rounding() { float CWindow::rounding() {
@ -1772,19 +1772,19 @@ void CWindow::sendWindowSize(bool force) {
} }
NContentType::eContentType CWindow::getContentType() { 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 CONTENT_TYPE_NONE;
return m_wlSurface->resource()->contentType->value; return m_wlSurface->resource()->m_contentType->value;
} }
void CWindow::setContentType(NContentType::eContentType contentType) { void CWindow::setContentType(NContentType::eContentType contentType) {
if (!m_wlSurface->resource()->contentType.valid()) if (!m_wlSurface->resource()->m_contentType.valid())
m_wlSurface->resource()->contentType = PROTO::contentType->getContentType(m_wlSurface->resource()); m_wlSurface->resource()->m_contentType = PROTO::contentType->getContentType(m_wlSurface->resource());
// else disallow content type change if proto is used? // else disallow content type change if proto is used?
Debug::log(INFO, "ContentType for window {}", (int)contentType); Debug::log(INFO, "ContentType for window {}", (int)contentType);
m_wlSurface->resource()->contentType->value = contentType; m_wlSurface->resource()->m_contentType->value = contentType;
} }
void CWindow::deactivateGroupMembers() { void CWindow::deactivateGroupMembers() {

View File

@ -265,7 +265,7 @@ void CTabletTool::setSurface(SP<CWLSurfaceResource> surf) {
m_surface = surf; m_surface = surf;
if (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()); PROTO::tablet->proximityOut(m_self.lock());
m_surface.reset(); m_surface.reset();
m_listeners.destroySurface.reset(); m_listeners.destroySurface.reset();

View File

@ -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 // 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) { if (PMONITOR && PMONITOR->m_solitaryClient.lock() == PWINDOW && PWINDOW->canBeTorn() && PMONITOR->m_tearingState.canTear &&
CRegion damageBox{PWINDOW->m_wlSurface->resource()->current.accumulateBufferDamage()}; PWINDOW->m_wlSurface->resource()->m_current.texture) {
CRegion damageBox{PWINDOW->m_wlSurface->resource()->m_current.accumulateBufferDamage()};
if (!damageBox.empty()) { if (!damageBox.empty()) {
if (PMONITOR->m_tearingState.busy) { if (PMONITOR->m_tearingState.busy) {

View File

@ -1368,20 +1368,20 @@ bool CMonitor::attemptDirectScanout() {
const auto PSURFACE = g_pXWaylandManager->getWindowSurface(PCANDIDATE); 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; 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; return false;
// we can't scanout shm buffers. // we can't scanout shm buffers.
const auto params = PSURFACE->current.buffer->dmabuf(); const auto params = PSURFACE->m_current.buffer->dmabuf();
if (!params.success || !PSURFACE->current.texture->m_pEglImage /* dmabuf */) if (!params.success || !PSURFACE->m_current.texture->m_pEglImage /* dmabuf */)
return false; 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) { if (PBUFFER == m_output->state->state().buffer) {
PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock()); PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock());
@ -1427,7 +1427,7 @@ bool CMonitor::attemptDirectScanout() {
PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock()); 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(); m_output->state->resetExplicitFences();
// no need to do explicit sync here as surface current can only ever be ready to read // no need to do explicit sync here as surface current can only ever be ready to read

View File

@ -118,7 +118,7 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) { if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
const auto PWINDOWSURFACE = pWindow->m_wlSurface->resource(); 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 && if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_isX11 &&
pWindow->isX11OverrideRedirect()) { // XDG windows should be fine. TODO: check for weird atoms? pWindow->isX11OverrideRedirect()) { // XDG windows should be fine. TODO: check for weird atoms?

View File

@ -131,9 +131,9 @@ void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hots
damageIfSoftware(); damageIfSoftware();
if (surf == m_currentCursorImage.surface) { 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.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(); updateCursorBackend();
damageIfSoftware(); damageIfSoftware();
} }
@ -145,22 +145,22 @@ void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hots
if (surf) { if (surf) {
m_currentCursorImage.surface = surf; m_currentCursorImage.surface = surf;
m_currentCursorImage.scale = surf->resource()->current.scale; m_currentCursorImage.scale = surf->resource()->m_current.scale;
surf->resource()->map(); surf->resource()->map();
m_currentCursorImage.destroySurface = surf->m_events.destroy.registerListener([this](std::any data) { resetCursorImage(); }); 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(); damageIfSoftware();
m_currentCursorImage.size = m_currentCursorImage.surface->resource()->current.texture ? m_currentCursorImage.surface->resource()->current.bufferSize : Vector2D{}; 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()->current.scale : 1.F; m_currentCursorImage.scale = m_currentCursorImage.surface ? m_currentCursorImage.surface->resource()->m_current.scale : 1.F;
recheckEnteredOutputs(); recheckEnteredOutputs();
updateCursorBackend(); updateCursorBackend();
damageIfSoftware(); damageIfSoftware();
}); });
if (surf->resource()->current.texture) { if (surf->resource()->m_current.texture) {
m_currentCursorImage.size = surf->resource()->current.bufferSize; m_currentCursorImage.size = surf->resource()->m_current.bufferSize;
surf->resource()->frame(Time::steadyNow()); surf->resource()->frame(Time::steadyNow());
} }
} }
@ -464,18 +464,18 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
// get the texture data if available. // get the texture data if available.
auto texData = texture->dataCopy(); auto texData = texture->dataCopy();
if (texData.empty()) { 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(); const auto SURFACE = m_currentCursorImage.surface->resource();
auto& shmBuffer = CCursorSurfaceRole::cursorPixelData(SURFACE); auto& shmBuffer = CCursorSurfaceRole::cursorPixelData(SURFACE);
bool flipRB = false; bool flipRB = false;
if (SURFACE->current.texture) { if (SURFACE->m_current.texture) {
Debug::log(TRACE, "Cursor CPU surface: format {}, expecting AR24", NFormatUtils::drmFormatName(SURFACE->current.texture->m_iDrmFormat)); Debug::log(TRACE, "Cursor CPU surface: format {}, expecting AR24", NFormatUtils::drmFormatName(SURFACE->m_current.texture->m_iDrmFormat));
if (SURFACE->current.texture->m_iDrmFormat == DRM_FORMAT_ABGR8888) { 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!"); Debug::log(TRACE, "Cursor CPU surface format AB24, will flip. WARNING: this will break on big endian!");
flipRB = true; 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"); Debug::log(TRACE, "Cursor CPU surface format rejected, falling back to sw");
return nullptr; return nullptr;
} }
@ -869,7 +869,7 @@ void CPointerManager::onMonitorLayoutChange() {
} }
SP<CTexture> CPointerManager::getCurrentCursorTexture() { SP<CTexture> 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; return nullptr;
if (m_currentCursorImage.pBuffer) { if (m_currentCursorImage.pBuffer) {
@ -878,7 +878,7 @@ SP<CTexture> CPointerManager::getCurrentCursorTexture() {
return m_currentCursorImage.bufferTex; return m_currentCursorImage.bufferTex;
} }
return m_currentCursorImage.surface->resource()->current.texture; return m_currentCursorImage.surface->resource()->m_current.texture;
} }
void CPointerManager::attachPointer(SP<IPointer> pointer) { void CPointerManager::attachPointer(SP<IPointer> pointer) {

View File

@ -120,7 +120,7 @@ CProtocolManager::CProtocolManager() {
auto ref = makeShared<CWLOutputProtocol>(&wl_output_interface, 4, std::format("WLOutput ({})", M->m_name), M->m_self.lock()); auto ref = makeShared<CWLOutputProtocol>(&wl_output_interface, 4, std::format("WLOutput ({})", M->m_name), M->m_self.lock());
PROTO::outputs.emplace(M->m_name, ref); 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); }); m_modeChangeListeners[M->m_name] = M->m_events.modeChanged.registerListener([M, this](std::any d) { onMonitorModeChange(M); });
}); });

View File

@ -14,11 +14,11 @@
#include <ranges> #include <ranges>
CSeatManager::CSeatManager() { CSeatManager::CSeatManager() {
m_listeners.newSeatResource = PROTO::seat->events.newSeatResource.registerListener([this](std::any res) { onNewSeatResource(std::any_cast<SP<CWLSeatResource>>(res)); }); m_listeners.newSeatResource = PROTO::seat->m_events.newSeatResource.registerListener([this](std::any res) { onNewSeatResource(std::any_cast<SP<CWLSeatResource>>(res)); });
} }
CSeatManager::SSeatResourceContainer::SSeatResourceContainer(SP<CWLSeatResource> res) : resource(res) { CSeatManager::SSeatResourceContainer::SSeatResourceContainer(SP<CWLSeatResource> 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; }); }); [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<CWLSurfaceResource> surf) {
if (s->resource->client() != client) if (s->resource->client() != client)
continue; continue;
for (auto const& k : s->resource->keyboards) { for (auto const& k : s->resource->m_keyboards) {
if (!k) if (!k)
continue; continue;
@ -142,7 +142,7 @@ void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> surf) {
continue; continue;
m_state.keyboardFocusResource = r->resource; m_state.keyboardFocusResource = r->resource;
for (auto const& k : r->resource->keyboards) { for (auto const& k : r->resource->m_keyboards) {
if (!k) if (!k)
continue; continue;
@ -151,7 +151,7 @@ void CSeatManager::setKeyboardFocus(SP<CWLSurfaceResource> 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(); 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()) if (s->resource->client() != m_state.keyboardFocusResource->client())
continue; continue;
for (auto const& k : s->resource->keyboards) { for (auto const& k : s->resource->m_keyboards) {
if (!k) if (!k)
continue; continue;
@ -181,7 +181,7 @@ void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32
if (s->resource->client() != m_state.keyboardFocusResource->client()) if (s->resource->client() != m_state.keyboardFocusResource->client())
continue; continue;
for (auto const& k : s->resource->keyboards) { for (auto const& k : s->resource->m_keyboards) {
if (!k) if (!k)
continue; continue;
@ -216,7 +216,7 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
if (s->resource->client() != client) if (s->resource->client() != client)
continue; continue;
for (auto const& p : s->resource->pointers) { for (auto const& p : s->resource->m_pointers) {
if (!p) if (!p)
continue; continue;
@ -245,7 +245,7 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
continue; continue;
m_state.pointerFocusResource = r->resource; m_state.pointerFocusResource = r->resource;
for (auto const& p : r->resource->pointers) { for (auto const& p : r->resource->m_pointers) {
if (!p) if (!p)
continue; continue;
@ -258,7 +258,7 @@ void CSeatManager::setPointerFocus(SP<CWLSurfaceResource> surf, const Vector2D&
sendPointerFrame(); 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.pointerFocusChange.emit();
m_events.dndPointerFocusChange.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()) if (s->resource->client() != m_state.pointerFocusResource->client())
continue; continue;
for (auto const& p : s->resource->pointers) { for (auto const& p : s->resource->m_pointers) {
if (!p) if (!p)
continue; 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()) if (s->resource->client() != m_state.pointerFocusResource->client())
continue; continue;
for (auto const& p : s->resource->pointers) { for (auto const& p : s->resource->m_pointers) {
if (!p) if (!p)
continue; continue;
@ -315,7 +315,7 @@ void CSeatManager::sendPointerFrame(WP<CWLSeatResource> pResource) {
if (s->resource->client() != pResource->client()) if (s->resource->client() != pResource->client())
continue; continue;
for (auto const& p : s->resource->pointers) { for (auto const& p : s->resource->m_pointers) {
if (!p) if (!p)
continue; continue;
@ -333,7 +333,7 @@ void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double
if (s->resource->client() != m_state.pointerFocusResource->client()) if (s->resource->client() != m_state.pointerFocusResource->client())
continue; continue;
for (auto const& p : s->resource->pointers) { for (auto const& p : s->resource->m_pointers) {
if (!p) if (!p)
continue; continue;
@ -364,7 +364,7 @@ void CSeatManager::sendTouchDown(SP<CWLSurfaceResource> surf, uint32_t timeMs, i
continue; continue;
m_state.touchFocusResource = r->resource; m_state.touchFocusResource = r->resource;
for (auto const& t : r->resource->touches) { for (auto const& t : r->resource->m_touches) {
if (!t) if (!t)
continue; continue;
@ -372,7 +372,7 @@ void CSeatManager::sendTouchDown(SP<CWLSurfaceResource> 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++; m_touchLocks++;
@ -390,7 +390,7 @@ void CSeatManager::sendTouchUp(uint32_t timeMs, int32_t id) {
continue; continue;
m_state.touchFocusResource = r->resource; m_state.touchFocusResource = r->resource;
for (auto const& t : r->resource->touches) { for (auto const& t : r->resource->m_touches) {
if (!t) if (!t)
continue; continue;
@ -412,7 +412,7 @@ void CSeatManager::sendTouchMotion(uint32_t timeMs, int32_t id, const Vector2D&
if (s->resource->client() != m_state.touchFocusResource->client()) if (s->resource->client() != m_state.touchFocusResource->client())
continue; continue;
for (auto const& t : s->resource->touches) { for (auto const& t : s->resource->m_touches) {
if (!t) if (!t)
continue; continue;
@ -429,7 +429,7 @@ void CSeatManager::sendTouchFrame() {
if (s->resource->client() != m_state.touchFocusResource->client()) if (s->resource->client() != m_state.touchFocusResource->client())
continue; continue;
for (auto const& t : s->resource->touches) { for (auto const& t : s->resource->m_touches) {
if (!t) if (!t)
continue; continue;
@ -446,7 +446,7 @@ void CSeatManager::sendTouchCancel() {
if (s->resource->client() != m_state.touchFocusResource->client()) if (s->resource->client() != m_state.touchFocusResource->client())
continue; continue;
for (auto const& t : s->resource->touches) { for (auto const& t : s->resource->m_touches) {
if (!t) if (!t)
continue; continue;
@ -463,7 +463,7 @@ void CSeatManager::sendTouchShape(int32_t id, const Vector2D& shape) {
if (s->resource->client() != m_state.touchFocusResource->client()) if (s->resource->client() != m_state.touchFocusResource->client())
continue; continue;
for (auto const& t : s->resource->touches) { for (auto const& t : s->resource->m_touches) {
if (!t) if (!t)
continue; continue;
@ -480,7 +480,7 @@ void CSeatManager::sendTouchOrientation(int32_t id, double angle) {
if (s->resource->client() != m_state.touchFocusResource->client()) if (s->resource->client() != m_state.touchFocusResource->client())
continue; continue;
for (auto const& t : s->resource->touches) { for (auto const& t : s->resource->m_touches) {
if (!t) if (!t)
continue; continue;

View File

@ -289,8 +289,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
// if we are holding a pointer button, // if we are holding a pointer button,
// and we're not dnd-ing, don't refocus. Keep focus on last surface. // 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 && if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->m_mapped &&
!m_hardInput) { g_pSeatManager->m_state.pointerFocus && !m_hardInput) {
foundSurface = g_pSeatManager->m_state.pointerFocus.lock(); foundSurface = g_pSeatManager->m_state.pointerFocus.lock();
// IME popups aren't desktop-like elements // IME popups aren't desktop-like elements
@ -1490,7 +1490,7 @@ bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
} else { } else {
// otherwise fall back to a normal refocus. // 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(); const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
g_pCompositor->focusWindow(PLASTWINDOW); g_pCompositor->focusWindow(PLASTWINDOW);
} }

View File

@ -102,7 +102,7 @@ void CInputPopup::updateBox() {
cursorBoxParent = {0, 0, (int)parentBox.w, (int)parentBox.h}; 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()); PHLMONITOR pMonitor = g_pCompositor->getMonitorFromVector(parentBox.middle());

View File

@ -135,7 +135,7 @@ void CTextInput::setFocusedSurface(SP<CWLSurfaceResource> pSurface) {
m_listeners.surfaceUnmap.reset(); m_listeners.surfaceUnmap.reset();
m_listeners.surfaceDestroy.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"); Debug::log(LOG, "Unmap TI owner1");
if (m_enterLocks) if (m_enterLocks)
@ -155,7 +155,7 @@ void CTextInput::setFocusedSurface(SP<CWLSurfaceResource> pSurface) {
g_pInputManager->m_relay.deactivateIME(this); 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"); Debug::log(LOG, "Destroy TI owner1");
if (m_enterLocks) if (m_enterLocks)
@ -181,7 +181,7 @@ bool CTextInput::isV3() {
} }
void CTextInput::enter(SP<CWLSurfaceResource> pSurface) { void CTextInput::enter(SP<CWLSurfaceResource> pSurface) {
if (!pSurface || !pSurface->mapped) if (!pSurface || !pSurface->m_mapped)
return; return;
if (pSurface == focusedSurface()) if (pSurface == focusedSurface())

View File

@ -30,7 +30,7 @@ void CAlphaModifier::setResource(SP<CWpAlphaModifierSurfaceV1> resource) {
m_fAlpha = alpha / (float)UINT32_MAX; 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()); auto surface = CWLSurface::fromResource(m_pSurface.lock());
if (surface && surface->m_alphaModifier != m_fAlpha) { if (surface && surface->m_alphaModifier != m_fAlpha) {
@ -45,7 +45,7 @@ void CAlphaModifier::setResource(SP<CWpAlphaModifierSurfaceV1> 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) if (!m_pResource)
PROTO::alphaModifier->destroyAlphaModifier(this); PROTO::alphaModifier->destroyAlphaModifier(this);
}); });

View File

@ -25,7 +25,7 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlM
if UNLIKELY (!OUTPUTRESOURCE) if UNLIKELY (!OUTPUTRESOURCE)
return; // ?! return; // ?!
const auto PMONITOR = OUTPUTRESOURCE->monitor.lock(); const auto PMONITOR = OUTPUTRESOURCE->m_monitor.lock();
if UNLIKELY (!PMONITOR) if UNLIKELY (!PMONITOR)
return; // ?!?! return; // ?!?!

View File

@ -74,7 +74,7 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
return; return;
} }
const auto PMONITOR = OUTPUTRESOURCE->monitor.lock(); const auto PMONITOR = OUTPUTRESOURCE->m_monitor.lock();
if UNLIKELY (!PMONITOR) { if UNLIKELY (!PMONITOR) {
r->error(-1, "Invalid output (2)"); r->error(-1, "Invalid output (2)");
@ -102,7 +102,7 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
return; return;
} }
if (SURF->colorManagement) { if (SURF->m_colorManagement) {
r->error(WP_COLOR_MANAGER_V1_ERROR_SURFACE_EXISTS, "CM Surface already exists"); r->error(WP_COLOR_MANAGER_V1_ERROR_SURFACE_EXISTS, "CM Surface already exists");
return; return;
} }
@ -117,7 +117,7 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour
RESOURCE->self = RESOURCE; RESOURCE->self = RESOURCE;
SURF->colorManagement = RESOURCE; SURF->m_colorManagement = RESOURCE;
}); });
m_resource->setGetSurfaceFeedback([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) { m_resource->setGetSurfaceFeedback([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) {
LOGM(TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface); LOGM(TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface);

View File

@ -19,7 +19,7 @@ CContentTypeManager::CContentTypeManager(SP<CWpContentTypeManagerV1> resource) :
return; return;
} }
if (SURF->colorManagement) { if (SURF->m_colorManagement) {
r->error(WP_CONTENT_TYPE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "CT manager already exists"); r->error(WP_CONTENT_TYPE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "CT manager already exists");
return; return;
} }
@ -33,7 +33,7 @@ CContentTypeManager::CContentTypeManager(SP<CWpContentTypeManagerV1> resource) :
RESOURCE->self = RESOURCE; RESOURCE->self = RESOURCE;
SURF->contentType = RESOURCE; SURF->m_contentType = RESOURCE;
}); });
} }
@ -42,7 +42,7 @@ bool CContentTypeManager::good() {
} }
CContentType::CContentType(WP<CWLSurfaceResource> surface) { CContentType::CContentType(WP<CWLSurfaceResource> 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<CWpContentTypeV1> resource) : m_resource(resource) { CContentType::CContentType(SP<CWpContentTypeV1> resource) : m_resource(resource) {
@ -80,8 +80,8 @@ void CContentTypeProtocol::bindManager(wl_client* client, void* data, uint32_t v
} }
SP<CContentType> CContentTypeProtocol::getContentType(WP<CWLSurfaceResource> surface) { SP<CContentType> CContentTypeProtocol::getContentType(WP<CWLSurfaceResource> surface) {
if (surface->contentType.valid()) if (surface->m_contentType.valid())
return surface->contentType.lock(); return surface->m_contentType.lock();
return m_vContentTypes.emplace_back(makeShared<CContentType>(surface)); return m_vContentTypes.emplace_back(makeShared<CContentType>(surface));
} }

View File

@ -74,38 +74,38 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurf
pendingRelease = {timeline->timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; pendingRelease = {timeline->timeline, ((uint64_t)hi << 32) | (uint64_t)lo};
}); });
listeners.surfacePrecommit = surface->events.precommit.registerListener([this](std::any d) { listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) {
if (!surface->pending.updated.buffer || !surface->pending.buffer) { if (!surface->m_pending.updated.buffer || !surface->m_pending.buffer) {
if (pendingAcquire.timeline() || pendingRelease.timeline()) { if (pendingAcquire.timeline() || pendingRelease.timeline()) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER, "Missing buffer"); resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER, "Missing buffer");
surface->pending.rejected = true; surface->m_pending.rejected = true;
} }
return; return;
} }
if (!pendingAcquire.timeline()) { if (!pendingAcquire.timeline()) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_ACQUIRE_POINT, "Missing acquire 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; return;
} }
if (!pendingRelease.timeline()) { if (!pendingRelease.timeline()) {
resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_RELEASE_POINT, "Missing release 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; return;
} }
if (pendingAcquire.timeline() == pendingRelease.timeline() && pendingAcquire.point() >= pendingRelease.point()) { 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"); 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; return;
} }
surface->pending.updated.acquire = true; surface->m_pending.updated.acquire = true;
surface->pending.acquire = pendingAcquire; surface->m_pending.acquire = pendingAcquire;
pendingAcquire = {}; pendingAcquire = {};
surface->pending.buffer->addReleasePoint(pendingRelease); surface->m_pending.buffer->addReleasePoint(pendingRelease);
pendingRelease = {}; pendingRelease = {};
}); });
} }
@ -163,7 +163,7 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjMana
return; return;
} }
if UNLIKELY (SURF->syncobj) { if UNLIKELY (SURF->m_syncobj) {
resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS, "Surface already has a syncobj attached"); resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS, "Surface already has a syncobj attached");
return; return;
} }
@ -176,7 +176,7 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjMana
return; return;
} }
SURF->syncobj = RESOURCE; SURF->m_syncobj = RESOURCE;
LOGM(LOG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get()); LOGM(LOG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get());
}); });

View File

@ -8,7 +8,7 @@
#include <wayland-server.h> #include <wayland-server.h>
CFocusGrabSurfaceState::CFocusGrabSurfaceState(CFocusGrab* grab, SP<CWLSurfaceResource> surface) { CFocusGrabSurfaceState::CFocusGrabSurfaceState(CFocusGrab* grab, SP<CWLSurfaceResource> surface) {
listeners.destroy = surface->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<CHyprlandFocusGrabV1> resource_) : resource(resource_) { CFocusGrab::CFocusGrab(SP<CHyprlandFocusGrabV1> resource_) : resource(resource_) {

View File

@ -41,7 +41,7 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
} }
if (output) { if (output) {
const auto wpMonitor = CWLOutputResource::fromResource(output)->monitor; const auto wpMonitor = CWLOutputResource::fromResource(output)->m_monitor;
if (!wpMonitor.expired()) { if (!wpMonitor.expired()) {
const auto monitor = wpMonitor.lock(); const auto monitor = wpMonitor.lock();

View File

@ -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()) if (std::ranges::find_if(m_mSurfaceScales, [surface](const auto& e) { return e.first == surface; }) == m_mSurfaceScales.end())
m_mSurfaceScales.emplace(surface, 1.F); m_mSurfaceScales.emplace(surface, 1.F);
if (surface->mapped) if (surface->m_mapped)
PADDON->setScale(m_mSurfaceScales.at(surface)); PADDON->setScale(m_mSurfaceScales.at(surface));
// clean old // clean old

View File

@ -61,7 +61,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
pClient = resource->client(); pClient = resource->client();
if (!surface->colorManagement.valid()) { if (!surface->m_colorManagement.valid()) {
const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared<CColorManagementSurface>(surface_)); const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared<CColorManagementSurface>(surface_));
if UNLIKELY (!RESOURCE) { if UNLIKELY (!RESOURCE) {
resource->noMemory(); resource->noMemory();
@ -71,12 +71,12 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
RESOURCE->self = RESOURCE; RESOURCE->self = RESOURCE;
surface->colorManagement = RESOURCE; surface->m_colorManagement = RESOURCE;
resource->setOnDestroy([this](CFrogColorManagedSurface* r) { resource->setOnDestroy([this](CFrogColorManagedSurface* r) {
LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)surface);
if (surface.valid()) if (surface.valid())
PROTO::colorManagement->destroyResource(surface->colorManagement.get()); PROTO::colorManagement->destroyResource(surface->m_colorManagement.get());
PROTO::frogColorManagement->destroyResource(this); PROTO::frogColorManagement->destroyResource(this);
}); });
} else } else
@ -94,7 +94,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, surface->id()); LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, surface->id());
switch (tf) { switch (tf) {
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ:
surface->colorManagement->m_imageDescription.transferFunction = surface->m_colorManagement->m_imageDescription.transferFunction =
convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ));
break; break;
; ;
@ -102,7 +102,7 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
if (pqIntentSent) { if (pqIntentSent) {
LOGM(TRACE, LOGM(TRACE,
"FIXME: assuming broken enum value 2 (FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22) referring to eotf value 2 (TRANSFER_FUNCTION_ST2084_PQ)"); "FIXME: assuming broken enum value 2 (FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22) referring to eotf value 2 (TRANSFER_FUNCTION_ST2084_PQ)");
surface->colorManagement->m_imageDescription.transferFunction = surface->m_colorManagement->m_imageDescription.transferFunction =
convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ));
break; break;
}; };
@ -110,40 +110,40 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SP<CFrogColorManagedSur
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_UNDEFINED: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_UNDEFINED:
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SCRGB_LINEAR: LOGM(TRACE, "FIXME: add tf support for {}", (uint32_t)tf); [[fallthrough]]; case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SCRGB_LINEAR: LOGM(TRACE, "FIXME: add tf support for {}", (uint32_t)tf); [[fallthrough]];
case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB: case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB:
surface->colorManagement->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) { resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) {
LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName); LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName);
switch (primariesName) { switch (primariesName) {
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED: case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED:
case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: surface->colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; 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->colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; 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) { resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) {
LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent); LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent);
pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; 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, 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) { uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) {
LOGM(TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll, fall); LOGM(TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll, fall);
surface->colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f}, surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f},
.green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f}, .green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f},
.blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f},
.white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}}; .white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}};
surface->colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f; surface->m_colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f;
surface->colorManagement->m_imageDescription.masteringLuminances.max = max_lum; surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum;
surface->colorManagement->m_imageDescription.maxCLL = cll; surface->m_colorManagement->m_imageDescription.maxCLL = cll;
surface->colorManagement->m_imageDescription.maxFALL = fall; surface->m_colorManagement->m_imageDescription.maxFALL = fall;
surface->colorManagement->setHasImageDescription(true); surface->m_colorManagement->setHasImageDescription(true);
}); });
} }

View File

@ -18,7 +18,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
return; return;
} }
pMonitor = OUTPUTRES->monitor; pMonitor = OUTPUTRES->m_monitor;
if UNLIKELY (!pMonitor || !pMonitor->m_output) { if UNLIKELY (!pMonitor || !pMonitor->m_output) {
LOGM(ERR, "No CMonitor"); LOGM(ERR, "No CMonitor");

View File

@ -48,10 +48,10 @@ void CHyprlandSurface::setResource(SP<CHyprlandSurfaceV1> resource) {
} }
m_bVisibleRegionChanged = true; 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()); auto surface = CWLSurface::fromResource(m_pSurface.lock());
if (surface && (surface->m_overallOpacity != m_fOpacity || m_bVisibleRegionChanged)) { if (surface && (surface->m_overallOpacity != m_fOpacity || m_bVisibleRegionChanged)) {
@ -67,7 +67,7 @@ void CHyprlandSurface::setResource(SP<CHyprlandSurfaceV1> 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) if (!m_pResource)
PROTO::hyprlandSurface->destroySurface(this); PROTO::hyprlandSurface->destroySurface(this);
}); });

View File

@ -6,7 +6,7 @@ CIdleInhibitor::CIdleInhibitor(SP<CIdleInhibitorResource> resource_, SP<CWLSurfa
} }
CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, SP<CWLSurfaceResource> surface_) : resource(resource_), surface(surface_) { CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, SP<CWLSurfaceResource> 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(); surface.reset();
listeners.destroySurface.reset(); listeners.destroySurface.reset();
destroySent = true; destroySent = true;

View File

@ -88,7 +88,7 @@ CInputMethodPopupV2::CInputMethodPopupV2(SP<CZwpInputPopupSurfaceV2> resource_,
pSurface = surface; 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) if (mapped)
events.unmap.emit(); events.unmap.emit();
@ -101,15 +101,15 @@ CInputMethodPopupV2::CInputMethodPopupV2(SP<CZwpInputPopupSurfaceV2> resource_,
pSurface.reset(); pSurface.reset();
}); });
listeners.commitSurface = surface->events.commit.registerListener([this](std::any d) { listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) {
if (pSurface->current.texture && !mapped) { if (pSurface->m_current.texture && !mapped) {
mapped = true; mapped = true;
pSurface->map(); pSurface->map();
events.map.emit(); events.map.emit();
return; return;
} }
if (!pSurface->current.texture && mapped) { if (!pSurface->m_current.texture && mapped) {
mapped = false; mapped = false;
pSurface->unmap(); pSurface->unmap();
events.unmap.emit(); events.unmap.emit();

View File

@ -33,18 +33,18 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
PROTO::layerShell->destroyResource(this); PROTO::layerShell->destroyResource(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(); events.destroy.emit();
PROTO::layerShell->destroyResource(this); 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; current = pending;
pending.committed = 0; pending.committed = 0;
bool attachedBuffer = surface->current.texture; bool attachedBuffer = surface->m_current.texture;
if (attachedBuffer && !configured) { if (attachedBuffer && !configured) {
surface->error(-1, "layerSurface was not configured, but a buffer was attached"); 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_) { 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 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); auto SURF = CWLSurfaceResource::fromResource(surface);
if UNLIKELY (!SURF) { if UNLIKELY (!SURF) {
@ -228,7 +228,7 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id
return; 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"); pMgr->error(-1, "Surface already has a different role");
return; return;
} }
@ -246,7 +246,7 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id
return; return;
} }
SURF->role = makeShared<CLayerShellRole>(RESOURCE); SURF->m_role = makeShared<CLayerShellRole>(RESOURCE);
g_pCompositor->m_layers.emplace_back(CLayerSurface::create(RESOURCE)); g_pCompositor->m_layers.emplace_back(CLayerSurface::create(RESOURCE));
LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get()); LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get());

View File

@ -68,7 +68,7 @@ void COutputPowerProtocol::onGetOutputPower(CZwlrOutputPowerManagerV1* pMgr, uin
} }
const auto CLIENT = pMgr->client(); const auto CLIENT = pMgr->client();
const auto RESOURCE = m_vOutputPowers.emplace_back(makeUnique<COutputPower>(makeShared<CZwlrOutputPowerV1>(CLIENT, pMgr->version(), id), OUTPUT->monitor.lock())).get(); const auto RESOURCE = m_vOutputPowers.emplace_back(makeUnique<COutputPower>(makeShared<CZwlrOutputPowerV1>(CLIENT, pMgr->version(), id), OUTPUT->m_monitor.lock())).get();
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory(); pMgr->noMemory();

View File

@ -22,7 +22,7 @@ CPointerConstraint::CPointerConstraint(SP<CZwpLockedPointerV1> resource_, SP<CWL
return; return;
if (region_) if (region_)
region.set(CWLRegionResource::fromResource(region_)->region); region.set(CWLRegionResource::fromResource(region_)->m_region);
resource_->setSetRegion([this](CZwpLockedPointerV1* p, wl_resource* region) { onSetRegion(region); }); resource_->setSetRegion([this](CZwpLockedPointerV1* p, wl_resource* region) { onSetRegion(region); });
resource_->setSetCursorPositionHint([this](CZwpLockedPointerV1* p, wl_fixed_t x, wl_fixed_t y) { resource_->setSetCursorPositionHint([this](CZwpLockedPointerV1* p, wl_fixed_t x, wl_fixed_t y) {
@ -61,7 +61,7 @@ CPointerConstraint::CPointerConstraint(SP<CZwpConfinedPointerV1> resource_, SP<C
return; return;
if (region_) if (region_)
region.set(CWLRegionResource::fromResource(region_)->region); region.set(CWLRegionResource::fromResource(region_)->m_region);
resource_->setSetRegion([this](CZwpConfinedPointerV1* p, wl_resource* region) { onSetRegion(region); }); resource_->setSetRegion([this](CZwpConfinedPointerV1* p, wl_resource* region) { onSetRegion(region); });
@ -151,7 +151,7 @@ void CPointerConstraint::onSetRegion(wl_resource* wlRegion) {
return; return;
} }
const auto REGION = region.set(CWLRegionResource::fromResource(wlRegion)->region); const auto REGION = region.set(CWLRegionResource::fromResource(wlRegion)->m_region);
region.set(REGION); region.set(REGION);
positionHint = region.closestPoint(positionHint); positionHint = region.closestPoint(positionHint);

View File

@ -22,7 +22,7 @@ CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, int32_t
return; return;
overlayCursor = !!overlay_cursor; overlayCursor = !!overlay_cursor;
pMonitor = CWLOutputResource::fromResource(output)->monitor; pMonitor = CWLOutputResource::fromResource(output)->m_monitor;
if (!pMonitor) { if (!pMonitor) {
LOGM(ERR, "Client requested sharing of a monitor that doesnt exist"); LOGM(ERR, "Client requested sharing of a monitor that doesnt exist");

View File

@ -23,8 +23,8 @@ CSessionLockSurface::CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_,
resource->setAckConfigure([this](CExtSessionLockSurfaceV1* r, uint32_t serial) { ackdConfigure = true; }); resource->setAckConfigure([this](CExtSessionLockSurfaceV1* r, uint32_t serial) { ackdConfigure = true; });
listeners.surfaceCommit = pSurface->events.commit.registerListener([this](std::any d) { listeners.surfaceCommit = pSurface->m_events.commit.registerListener([this](std::any d) {
if (!pSurface->current.texture) { if (!pSurface->m_current.texture) {
LOGM(ERR, "SessionLock attached a null buffer"); LOGM(ERR, "SessionLock attached a null buffer");
resource->error(EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER, "Null buffer attached"); resource->error(EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER, "Null buffer attached");
return; return;
@ -45,7 +45,7 @@ CSessionLockSurface::CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_,
committed = true; 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???"); LOGM(WARN, "SessionLockSurface object remains but surface is being destroyed???");
pSurface->unmap(); pSurface->unmap();
listeners.surfaceCommit.reset(); listeners.surfaceCommit.reset();
@ -64,7 +64,7 @@ CSessionLockSurface::CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_,
} }
CSessionLockSurface::~CSessionLockSurface() { CSessionLockSurface::~CSessionLockSurface() {
if (pSurface && pSurface->mapped) if (pSurface && pSurface->m_mapped)
pSurface->unmap(); pSurface->unmap();
listeners.surfaceCommit.reset(); listeners.surfaceCommit.reset();
listeners.surfaceDestroy.reset(); listeners.surfaceDestroy.reset();
@ -189,7 +189,7 @@ void CSessionLockProtocol::onGetLockSurface(CExtSessionLockV1* lock, uint32_t id
LOGM(LOG, "New sessionLockSurface with id {}", id); LOGM(LOG, "New sessionLockSurface with id {}", id);
auto PSURFACE = CWLSurfaceResource::fromResource(surface); auto PSURFACE = CWLSurfaceResource::fromResource(surface);
auto PMONITOR = CWLOutputResource::fromResource(output)->monitor.lock(); auto PMONITOR = CWLOutputResource::fromResource(output)->m_monitor.lock();
SP<CSessionLock> sessionLock; SP<CSessionLock> sessionLock;
for (auto const& l : m_vLocks) { for (auto const& l : m_vLocks) {

View File

@ -15,10 +15,10 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes
return; return;
} }
surface->pending.updated.viewport = true; surface->m_pending.updated.viewport = true;
if (x == -1 && y == -1) { if (x == -1 && y == -1) {
surface->pending.viewport.hasDestination = false; surface->m_pending.viewport.hasDestination = false;
return; return;
} }
@ -27,8 +27,8 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes
return; return;
} }
surface->pending.viewport.hasDestination = true; surface->m_pending.viewport.hasDestination = true;
surface->pending.viewport.destination = {x, y}; 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) { 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<CWpViewport> resource_, SP<CWLSurfaceRes
return; return;
} }
surface->pending.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); 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) { if (x == -1 && y == -1 && w == -1 && h == -1) {
surface->pending.viewport.hasSource = false; surface->m_pending.viewport.hasSource = false;
return; return;
} }
@ -51,20 +51,20 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes
return; return;
} }
surface->pending.viewport.hasSource = true; surface->m_pending.viewport.hasSource = true;
surface->pending.viewport.source = {x, y, w, h}; surface->m_pending.viewport.source = {x, y, w, h};
}); });
listeners.surfacePrecommit = surface->events.precommit.registerListener([this](std::any d) { listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) {
if (!surface || !surface->pending.buffer) if (!surface || !surface->m_pending.buffer)
return; return;
if (surface->pending.viewport.hasSource) { if (surface->m_pending.viewport.hasSource) {
auto& src = surface->pending.viewport.source; 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"); resource->error(WP_VIEWPORT_ERROR_BAD_VALUE, "Box doesn't fit");
surface->pending.rejected = true; surface->m_pending.rejected = true;
return; return;
} }
} }
@ -75,8 +75,8 @@ CViewportResource::~CViewportResource() {
if (!surface) if (!surface)
return; return;
surface->pending.viewport.hasDestination = false; surface->m_pending.viewport.hasDestination = false;
surface->pending.viewport.hasSource = false; surface->m_pending.viewport.hasSource = false;
} }
bool CViewportResource::good() { bool CViewportResource::good() {

View File

@ -121,7 +121,7 @@ void CVirtualPointerProtocol::bindManager(wl_client* client, void* data, uint32_
return; return;
} }
this->onCreatePointer(pMgr, seat, id, RES->monitor); this->onCreatePointer(pMgr, seat, id, RES->m_monitor);
} else } else
this->onCreatePointer(pMgr, seat, id, {}); this->onCreatePointer(pMgr, seat, id, {});
}); });

View File

@ -42,7 +42,7 @@ CXDGOutputProtocol::CXDGOutputProtocol(const wl_interface* iface, const int& ver
void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource) { void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource) {
const auto OUTPUT = CWLOutputResource::fromResource(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(); const auto CLIENT = mgr->client();
CXDGOutput* pXDGOutput = m_vXDGOutputs.emplace_back(makeUnique<CXDGOutput>(makeShared<CZxdgOutputV1>(CLIENT, mgr->version(), id), PMONITOR)).get(); CXDGOutput* pXDGOutput = m_vXDGOutputs.emplace_back(makeUnique<CXDGOutput>(makeShared<CZxdgOutputV1>(CLIENT, mgr->version(), id), PMONITOR)).get();
@ -52,7 +52,7 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32
#endif #endif
pXDGOutput->client = CLIENT; pXDGOutput->client = CLIENT;
pXDGOutput->outputProto = OUTPUT->owner; pXDGOutput->outputProto = OUTPUT->m_owner;
if UNLIKELY (!pXDGOutput->resource->resource()) { if UNLIKELY (!pXDGOutput->resource->resource()) {
m_vXDGOutputs.pop_back(); m_vXDGOutputs.pop_back();

View File

@ -195,7 +195,7 @@ CXDGToplevelResource::CXDGToplevelResource(SP<CXdgToplevel> resource_, SP<CXDGSu
resource->setSetFullscreen([this](CXdgToplevel* r, wl_resource* output) { resource->setSetFullscreen([this](CXdgToplevel* r, wl_resource* output) {
if (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.requestsFullscreenMonitor = PM->m_id;
state.requestsFullscreen = true; state.requestsFullscreen = true;
@ -372,7 +372,7 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP<CXdgSurface> resource_, SP<CXDGWMBas
PROTO::xdgShell->destroyResource(this); PROTO::xdgShell->destroyResource(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"); LOGM(WARN, "wl_surface destroyed before its xdg_surface role object");
listeners.surfaceDestroy.reset(); listeners.surfaceDestroy.reset();
listeners.surfaceCommit.reset(); listeners.surfaceCommit.reset();
@ -385,17 +385,17 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP<CXdgSurface> resource_, SP<CXDGWMBas
events.destroy.emit(); events.destroy.emit();
}); });
listeners.surfaceCommit = surface->events.commit.registerListener([this](std::any d) { listeners.surfaceCommit = surface->m_events.commit.registerListener([this](std::any d) {
current = pending; current = pending;
if (toplevel) if (toplevel)
toplevel->current = toplevel->pending; 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"); resource->error(-1, "Buffer attached before initial commit");
return; return;
} }
if (surface->current.texture && !mapped) { if (surface->m_current.texture && !mapped) {
// this forces apps to not draw CSD. // this forces apps to not draw CSD.
if (toplevel) if (toplevel)
toplevel->setMaximized(true); toplevel->setMaximized(true);
@ -406,7 +406,7 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP<CXdgSurface> resource_, SP<CXDGWMBas
return; return;
} }
if (!surface->current.texture && mapped) { if (!surface->m_current.texture && mapped) {
mapped = false; mapped = false;
events.unmap.emit(); events.unmap.emit();
surface->unmap(); surface->unmap();
@ -723,7 +723,7 @@ CXDGWMBase::CXDGWMBase(SP<CXdgWmBase> resource_) : resource(resource_) {
return; 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"); r->error(-1, "Surface already has a different role");
return; return;
} }
@ -738,7 +738,7 @@ CXDGWMBase::CXDGWMBase(SP<CXdgWmBase> resource_) : resource(resource_) {
RESOURCE->self = RESOURCE; RESOURCE->self = RESOURCE;
RESOURCE->surface = SURF; RESOURCE->surface = SURF;
SURF->role = makeShared<CXDGSurfaceRole>(RESOURCE); SURF->m_role = makeShared<CXDGSurfaceRole>(RESOURCE);
surfaces.emplace_back(RESOURCE); surfaces.emplace_back(RESOURCE);

View File

@ -88,7 +88,7 @@ CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(res
return; return;
} }
if (SURF->colorManagement) { if (SURF->m_colorManagement) {
r->error(XX_COLOR_MANAGER_V4_ERROR_SURFACE_EXISTS, "CM Surface already exists"); r->error(XX_COLOR_MANAGER_V4_ERROR_SURFACE_EXISTS, "CM Surface already exists");
return; return;
} }
@ -195,7 +195,7 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
pClient = resource->client(); pClient = resource->client();
if (!surface->colorManagement.valid()) { if (!surface->m_colorManagement.valid()) {
const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared<CColorManagementSurface>(surface_)); const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared<CColorManagementSurface>(surface_));
if UNLIKELY (!RESOURCE) { if UNLIKELY (!RESOURCE) {
resource->noMemory(); resource->noMemory();
@ -205,12 +205,12 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
RESOURCE->self = RESOURCE; RESOURCE->self = RESOURCE;
surface->colorManagement = RESOURCE; surface->m_colorManagement = RESOURCE;
resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) {
LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)surface); LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)surface);
if (surface.valid()) if (surface.valid())
PROTO::colorManagement->destroyResource(surface->colorManagement.get()); PROTO::colorManagement->destroyResource(surface->m_colorManagement.get());
PROTO::xxColorManagement->destroyResource(this); PROTO::xxColorManagement->destroyResource(this);
}); });
} else } else
@ -245,16 +245,16 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
} }
if (surface.valid()) { if (surface.valid()) {
surface->colorManagement->m_imageDescription = imageDescription->get()->settings; surface->m_colorManagement->m_imageDescription = imageDescription->get()->settings;
surface->colorManagement->setHasImageDescription(true); surface->m_colorManagement->setHasImageDescription(true);
} else } else
LOGM(ERR, "Set image description for invalid surface"); LOGM(ERR, "Set image description for invalid surface");
}); });
resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) { resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) {
LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r); LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r);
if (surface.valid()) { if (surface.valid()) {
surface->colorManagement->m_imageDescription = SImageDescription{}; surface->m_colorManagement->m_imageDescription = SImageDescription{};
surface->colorManagement->setHasImageDescription(false); surface->m_colorManagement->setHasImageDescription(false);
} else } else
LOGM(ERR, "Unset image description for invalid surface"); LOGM(ERR, "Unset image description for invalid surface");
}); });

View File

@ -24,129 +24,129 @@ class CDefaultSurfaceRole : public ISurfaceRole {
} }
}; };
CWLCallbackResource::CWLCallbackResource(SP<CWlCallback> resource_) : resource(resource_) { CWLCallbackResource::CWLCallbackResource(SP<CWlCallback> resource_) : m_resource(resource_) {
; ;
} }
bool CWLCallbackResource::good() { bool CWLCallbackResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CWLCallbackResource::send(const Time::steady_tp& now) { void CWLCallbackResource::send(const Time::steady_tp& now) {
resource->sendDone(Time::millis(now)); m_resource->sendDone(Time::millis(now));
} }
CWLRegionResource::CWLRegionResource(SP<CWlRegion> resource_) : resource(resource_) { CWLRegionResource::CWLRegionResource(SP<CWlRegion> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setData(this); m_resource->setData(this);
resource->setDestroy([this](CWlRegion* r) { PROTO::compositor->destroyResource(this); }); m_resource->setDestroy([this](CWlRegion* r) { PROTO::compositor->destroyResource(this); });
resource->setOnDestroy([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}); }); 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}); });
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->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() { bool CWLRegionResource::good() {
return resource->resource(); return m_resource->resource();
} }
SP<CWLRegionResource> CWLRegionResource::fromResource(wl_resource* res) { SP<CWLRegionResource> CWLRegionResource::fromResource(wl_resource* res) {
auto data = (CWLRegionResource*)(((CWlRegion*)wl_resource_get_user_data(res))->data()); 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<CWlSurface> resource_) : resource(resource_) { CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
pClient = resource->client(); m_client = m_resource->client();
resource->setData(this); m_resource->setData(this);
role = makeShared<CDefaultSurfaceRole>(); m_role = makeShared<CDefaultSurfaceRole>();
resource->setDestroy([this](CWlSurface* r) { destroy(); }); m_resource->setDestroy([this](CWlSurface* r) { destroy(); });
resource->setOnDestroy([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) { m_resource->setAttach([this](CWlSurface* r, wl_resource* buffer, int32_t x, int32_t y) {
pending.updated.buffer = true; m_pending.updated.buffer = true;
pending.updated.offset = true; m_pending.updated.offset = true;
pending.offset = {x, y}; m_pending.offset = {x, y};
if (pending.buffer) if (m_pending.buffer)
pending.buffer.drop(); m_pending.buffer.drop();
auto buf = buffer ? CWLBufferResource::fromResource(buffer) : nullptr; auto buf = buffer ? CWLBufferResource::fromResource(buffer) : nullptr;
if (buf && buf->buffer) { if (buf && buf->buffer) {
pending.buffer = CHLBufferReference(buf->buffer.lock()); m_pending.buffer = CHLBufferReference(buf->buffer.lock());
pending.texture = buf->buffer->texture; m_pending.texture = buf->buffer->texture;
pending.size = buf->buffer->size; m_pending.size = buf->buffer->size;
pending.bufferSize = buf->buffer->size; m_pending.bufferSize = buf->buffer->size;
} else { } else {
pending.buffer = {}; m_pending.buffer = {};
pending.texture.reset(); m_pending.texture.reset();
pending.size = Vector2D{}; m_pending.size = Vector2D{};
pending.bufferSize = Vector2D{}; m_pending.bufferSize = Vector2D{};
} }
if (pending.bufferSize != current.bufferSize) { if (m_pending.bufferSize != m_current.bufferSize) {
pending.updated.damage = true; m_pending.updated.damage = true;
pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}};
} }
}); });
resource->setCommit([this](CWlSurface* r) { m_resource->setCommit([this](CWlSurface* r) {
if (pending.buffer) if (m_pending.buffer)
pending.bufferDamage.intersect(CBox{{}, pending.bufferSize}); m_pending.bufferDamage.intersect(CBox{{}, m_pending.bufferSize});
if (!pending.buffer) if (!m_pending.buffer)
pending.size = {}; m_pending.size = {};
else if (pending.viewport.hasDestination) else if (m_pending.viewport.hasDestination)
pending.size = pending.viewport.destination; m_pending.size = m_pending.viewport.destination;
else if (pending.viewport.hasSource) else if (m_pending.viewport.hasSource)
pending.size = pending.viewport.source.size(); m_pending.size = m_pending.viewport.source.size();
else { else {
Vector2D tfs = pending.transform % 2 == 1 ? Vector2D{pending.bufferSize.y, pending.bufferSize.x} : pending.bufferSize; Vector2D tfs = m_pending.transform % 2 == 1 ? Vector2D{m_pending.bufferSize.y, m_pending.bufferSize.x} : m_pending.bufferSize;
pending.size = tfs / pending.scale; m_pending.size = tfs / m_pending.scale;
} }
pending.damage.intersect(CBox{{}, pending.size}); m_pending.damage.intersect(CBox{{}, m_pending.size});
events.precommit.emit(); m_events.precommit.emit();
if (pending.rejected) { if (m_pending.rejected) {
pending.rejected = false; m_pending.rejected = false;
dropPendingBuffer(); dropPendingBuffer();
return; return;
} }
if ((!pending.updated.buffer) || // no new buffer attached if ((!m_pending.updated.buffer) || // no new buffer attached
(!pending.buffer && !pending.texture) // null buffer attached (!m_pending.buffer && !m_pending.texture) // null buffer attached
) { ) {
commitState(pending); commitState(m_pending);
pending.reset(); m_pending.reset();
return; return;
} }
// save state while we wait for buffer to become ready to read // save state while we wait for buffer to become ready to read
const auto& state = pendingStates.emplace(makeUnique<SSurfaceState>(pending)); const auto& state = m_pendingStates.emplace(makeUnique<SSurfaceState>(m_pending));
pending.reset(); m_pending.reset();
auto whenReadable = [this, surf = self, state = WP<SSurfaceState>(pendingStates.back())] { auto whenReadable = [this, surf = m_self, state = WP<SSurfaceState>(m_pendingStates.back())] {
if (!surf || state.expired()) if (!surf || state.expired())
return; return;
while (!pendingStates.empty() && pendingStates.front() != state) { while (!m_pendingStates.empty() && m_pendingStates.front() != state) {
commitState(*pendingStates.front()); commitState(*m_pendingStates.front());
pendingStates.pop(); m_pendingStates.pop();
} }
commitState(*pendingStates.front()); commitState(*m_pendingStates.front());
pendingStates.pop(); m_pendingStates.pop();
}; };
if (state->updated.acquire) { if (state->updated.acquire) {
@ -169,106 +169,106 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
} }
}); });
resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { m_resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) {
pending.updated.damage = true; m_pending.updated.damage = true;
pending.damage.add(CBox{x, y, w, h}); 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) { m_resource->setDamageBuffer([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) {
pending.updated.damage = true; m_pending.updated.damage = true;
pending.bufferDamage.add(CBox{x, y, w, h}); m_pending.bufferDamage.add(CBox{x, y, w, h});
}); });
resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) { m_resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) {
if (scale == pending.scale) if (scale == m_pending.scale)
return; return;
pending.updated.scale = true; m_pending.updated.scale = true;
pending.updated.damage = true; m_pending.updated.damage = true;
pending.scale = scale; m_pending.scale = scale;
pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}};
}); });
resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) { m_resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) {
if (tr == pending.transform) if (tr == m_pending.transform)
return; return;
pending.updated.transform = true; m_pending.updated.transform = true;
pending.updated.damage = true; m_pending.updated.damage = true;
pending.transform = (wl_output_transform)tr; m_pending.transform = (wl_output_transform)tr;
pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}};
}); });
resource->setSetInputRegion([this](CWlSurface* r, wl_resource* region) { m_resource->setSetInputRegion([this](CWlSurface* r, wl_resource* region) {
pending.updated.input = true; m_pending.updated.input = true;
if (!region) { if (!region) {
pending.input = CBox{{}, {INT32_MAX, INT32_MAX}}; m_pending.input = CBox{{}, {INT32_MAX, INT32_MAX}};
return; return;
} }
auto RG = CWLRegionResource::fromResource(region); auto RG = CWLRegionResource::fromResource(region);
pending.input = RG->region; m_pending.input = RG->m_region;
}); });
resource->setSetOpaqueRegion([this](CWlSurface* r, wl_resource* region) { m_resource->setSetOpaqueRegion([this](CWlSurface* r, wl_resource* region) {
pending.updated.opaque = true; m_pending.updated.opaque = true;
if (!region) { if (!region) {
pending.opaque = CBox{{}, {}}; m_pending.opaque = CBox{{}, {}};
return; return;
} }
auto RG = CWLRegionResource::fromResource(region); auto RG = CWLRegionResource::fromResource(region);
pending.opaque = RG->region; m_pending.opaque = RG->m_region;
}); });
resource->setFrame([this](CWlSurface* r, uint32_t id) { callbacks.emplace_back(makeShared<CWLCallbackResource>(makeShared<CWlCallback>(pClient, 1, id))); }); m_resource->setFrame([this](CWlSurface* r, uint32_t id) { m_callbacks.emplace_back(makeShared<CWLCallbackResource>(makeShared<CWlCallback>(m_client, 1, id))); });
resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) { m_resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) {
pending.updated.offset = true; m_pending.updated.offset = true;
pending.offset = {x, y}; m_pending.offset = {x, y};
}); });
} }
CWLSurfaceResource::~CWLSurfaceResource() { CWLSurfaceResource::~CWLSurfaceResource() {
events.destroy.emit(); m_events.destroy.emit();
} }
void CWLSurfaceResource::destroy() { void CWLSurfaceResource::destroy() {
if (mapped) { if (m_mapped) {
events.unmap.emit(); m_events.unmap.emit();
unmap(); unmap();
} }
events.destroy.emit(); m_events.destroy.emit();
releaseBuffers(false); releaseBuffers(false);
PROTO::compositor->destroyResource(this); PROTO::compositor->destroyResource(this);
} }
void CWLSurfaceResource::dropPendingBuffer() { void CWLSurfaceResource::dropPendingBuffer() {
pending.buffer = {}; m_pending.buffer = {};
} }
void CWLSurfaceResource::dropCurrentBuffer() { void CWLSurfaceResource::dropCurrentBuffer() {
current.buffer = {}; m_current.buffer = {};
} }
SP<CWLSurfaceResource> CWLSurfaceResource::fromResource(wl_resource* res) { SP<CWLSurfaceResource> CWLSurfaceResource::fromResource(wl_resource* res) {
auto data = (CWLSurfaceResource*)(((CWlSurface*)wl_resource_get_user_data(res))->data()); 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() { bool CWLSurfaceResource::good() {
return resource->resource(); return m_resource->resource();
} }
wl_client* CWLSurfaceResource::client() { wl_client* CWLSurfaceResource::client() {
return pClient; return m_client;
} }
void CWLSurfaceResource::enter(PHLMONITOR monitor) { 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; return;
if UNLIKELY (!PROTO::outputs.contains(monitor->m_name)) { if UNLIKELY (!PROTO::outputs.contains(monitor->m_name)) {
@ -282,59 +282,59 @@ void CWLSurfaceResource::enter(PHLMONITOR monitor) {
return; 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()) { 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); LOGM(ERR, "Cannot enter surface {:x} to {}, client hasn't bound the output", (uintptr_t)this, monitor->m_name);
return; 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) { 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; 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) { if UNLIKELY (!output) {
LOGM(ERR, "Cannot leave surface {:x} from {}, client hasn't bound the output", (uintptr_t)this, monitor->m_name); LOGM(ERR, "Cannot leave surface {:x} from {}, client hasn't bound the output", (uintptr_t)this, monitor->m_name);
return; 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) { void CWLSurfaceResource::sendPreferredTransform(wl_output_transform t) {
if (resource->version() < 6) if (m_resource->version() < 6)
return; return;
resource->sendPreferredBufferTransform(t); m_resource->sendPreferredBufferTransform(t);
} }
void CWLSurfaceResource::sendPreferredScale(int32_t scale) { void CWLSurfaceResource::sendPreferredScale(int32_t scale) {
if (resource->version() < 6) if (m_resource->version() < 6)
return; return;
resource->sendPreferredBufferScale(scale); m_resource->sendPreferredBufferScale(scale);
} }
void CWLSurfaceResource::frame(const Time::steady_tp& now) { void CWLSurfaceResource::frame(const Time::steady_tp& now) {
if (callbacks.empty()) if (m_callbacks.empty())
return; return;
for (auto const& c : callbacks) { for (auto const& c : m_callbacks) {
c->send(now); c->send(now);
} }
callbacks.clear(); m_callbacks.clear();
} }
void CWLSurfaceResource::resetRole() { void CWLSurfaceResource::resetRole() {
role = makeShared<CDefaultSurfaceRole>(); m_role = makeShared<CDefaultSurfaceRole>();
} }
void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nodes, std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data) { void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nodes, std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data) {
@ -343,14 +343,14 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
// first, gather all nodes below // first, gather all nodes below
for (auto const& n : nodes) { 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 // subsurfaces is sorted lowest -> highest
for (auto const& c : n->subsurfaces) { for (auto const& c : n->m_subsurfaces) {
if (c->zIndex >= 0) if (c->m_zIndex >= 0)
break; break;
if (c->surface.expired()) if (c->m_surface.expired())
continue; continue;
nodes2.push_back(c->surface.lock()); nodes2.push_back(c->m_surface.lock());
} }
} }
@ -361,8 +361,8 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
for (auto const& n : nodes) { for (auto const& n : nodes) {
Vector2D offset = {}; Vector2D offset = {};
if (n->role->role() == SURFACE_ROLE_SUBSURFACE) { if (n->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)n->role.get())->subsurface.lock(); auto subsurface = ((CSubsurfaceRole*)n->m_role.get())->m_subsurface.lock();
offset = subsurface->posRelativeToParent(); offset = subsurface->posRelativeToParent();
} }
@ -370,12 +370,12 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
} }
for (auto const& n : nodes) { for (auto const& n : nodes) {
for (auto const& c : n->subsurfaces) { for (auto const& c : n->m_subsurfaces) {
if (c->zIndex < 0) if (c->m_zIndex < 0)
continue; continue;
if (c->surface.expired()) if (c->m_surface.expired())
continue; continue;
nodes2.push_back(c->surface.lock()); nodes2.push_back(c->m_surface.lock());
} }
} }
@ -385,17 +385,17 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
void CWLSurfaceResource::breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data) { void CWLSurfaceResource::breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data) {
std::vector<SP<CWLSurfaceResource>> surfs; std::vector<SP<CWLSurfaceResource>> surfs;
surfs.push_back(self.lock()); surfs.push_back(m_self.lock());
bfHelper(surfs, fn, data); bfHelper(surfs, fn, data);
} }
SP<CWLSurfaceResource> CWLSurfaceResource::findFirstPreorderHelper(SP<CWLSurfaceResource> root, std::function<bool(SP<CWLSurfaceResource>)> fn) { SP<CWLSurfaceResource> CWLSurfaceResource::findFirstPreorderHelper(SP<CWLSurfaceResource> root, std::function<bool(SP<CWLSurfaceResource>)> fn) {
if (fn(root)) if (fn(root))
return root; return root;
for (auto const& sub : root->subsurfaces) { for (auto const& sub : root->m_subsurfaces) {
if (sub.expired() || sub->surface.expired()) if (sub.expired() || sub->m_surface.expired())
continue; continue;
const auto found = findFirstPreorderHelper(sub->surface.lock(), fn); const auto found = findFirstPreorderHelper(sub->m_surface.lock(), fn);
if (found) if (found)
return found; return found;
} }
@ -403,7 +403,7 @@ SP<CWLSurfaceResource> CWLSurfaceResource::findFirstPreorderHelper(SP<CWLSurface
} }
SP<CWLSurfaceResource> CWLSurfaceResource::findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> fn) { SP<CWLSurfaceResource> CWLSurfaceResource::findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> fn) {
return findFirstPreorderHelper(self.lock(), fn); return findFirstPreorderHelper(m_self.lock(), fn);
} }
std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2D& localCoords, bool allowsInput) { std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2D& localCoords, bool allowsInput) {
@ -412,11 +412,11 @@ std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2
for (auto const& [surf, pos] : surfs | std::views::reverse) { for (auto const& [surf, pos] : surfs | std::views::reverse) {
if (!allowsInput) { if (!allowsInput) {
const auto BOX = CBox{pos, surf->current.size}; const auto BOX = CBox{pos, surf->m_current.size};
if (BOX.containsPoint(localCoords)) if (BOX.containsPoint(localCoords))
return {surf, localCoords - pos}; return {surf, localCoords - pos};
} else { } 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)) if (REGION.containsPoint(localCoords))
return {surf, localCoords - pos}; return {surf, localCoords - pos};
} }
@ -426,26 +426,26 @@ std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2
} }
uint32_t CWLSurfaceResource::id() { uint32_t CWLSurfaceResource::id() {
return wl_resource_get_id(resource->resource()); return wl_resource_get_id(m_resource->resource());
} }
void CWLSurfaceResource::map() { void CWLSurfaceResource::map() {
if UNLIKELY (mapped) if UNLIKELY (m_mapped)
return; return;
mapped = true; m_mapped = true;
frame(Time::steadyNow()); frame(Time::steadyNow());
current.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; m_current.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}};
pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}}; m_pending.bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}};
} }
void CWLSurfaceResource::unmap() { void CWLSurfaceResource::unmap() {
if UNLIKELY (!mapped) if UNLIKELY (!m_mapped)
return; return;
mapped = false; m_mapped = false;
// release the buffers. // release the buffers.
// this is necessary for XWayland to function correctly, // 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) { void CWLSurfaceResource::error(int code, const std::string& str) {
resource->error(code, str); m_resource->error(code, str);
} }
SP<CWlSurface> CWLSurfaceResource::getResource() { SP<CWlSurface> CWLSurfaceResource::getResource() {
return resource; return m_resource;
} }
CBox CWLSurfaceResource::extends() { CBox CWLSurfaceResource::extends() {
CRegion full = CBox{{}, current.size}; CRegion full = CBox{{}, m_current.size};
breadthfirst( breadthfirst(
[](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* d) { [](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* d) {
if (surf->role->role() != SURFACE_ROLE_SUBSURFACE) if (surf->m_role->role() != SURFACE_ROLE_SUBSURFACE)
return; return;
((CRegion*)d)->add(CBox{offset, surf->current.size}); ((CRegion*)d)->add(CBox{offset, surf->m_current.size});
}, },
&full); &full);
return full.getExtents(); return full.getExtents();
} }
void CWLSurfaceResource::commitState(SSurfaceState& state) { void CWLSurfaceResource::commitState(SSurfaceState& state) {
auto lastTexture = current.texture; auto lastTexture = m_current.texture;
current.updateFrom(state); m_current.updateFrom(state);
if (current.buffer) { if (m_current.buffer) {
if (current.buffer->isSynchronous()) if (m_current.buffer->isSynchronous())
current.updateSynchronousTexture(lastTexture); m_current.updateSynchronousTexture(lastTexture);
// if the surface is a cursor, update the shm buffer // if the surface is a cursor, update the shm buffer
// TODO: don't update the entire texture // TODO: don't update the entire texture
if (role->role() == SURFACE_ROLE_CURSOR) if (m_role->role() == SURFACE_ROLE_CURSOR)
updateCursorShm(current.accumulateBufferDamage()); updateCursorShm(m_current.accumulateBufferDamage());
} }
if (current.texture) if (m_current.texture)
current.texture->m_eTransform = wlTransformToHyprutils(current.transform); m_current.texture->m_eTransform = wlTransformToHyprutils(m_current.transform);
if (role->role() == SURFACE_ROLE_SUBSURFACE) { if (m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)role.get())->subsurface.lock(); auto subsurface = ((CSubsurfaceRole*)m_role.get())->m_subsurface.lock();
if (subsurface->sync) if (subsurface->m_sync)
return; return;
events.commit.emit(); m_events.commit.emit();
} else { } else {
// send commit to all synced surfaces in this tree. // send commit to all synced surfaces in this tree.
breadthfirst( breadthfirst(
[](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { [](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) {
if (surf->role->role() == SURFACE_ROLE_SUBSURFACE) { if (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)surf->role.get())->subsurface.lock(); auto subsurface = ((CSubsurfaceRole*)surf->m_role.get())->m_subsurface.lock();
if (!subsurface->sync) if (!subsurface->m_sync)
return; return;
} }
surf->events.commit.emit(); surf->m_events.commit.emit();
}, },
nullptr); nullptr);
} }
// release the buffer if it's synchronous (SHM) as updateSynchronousTexture() has copied the buffer data to a GPU tex // 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 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(); dropCurrentBuffer();
} }
@ -527,12 +527,12 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) {
if (damage.empty()) if (damage.empty())
return; return;
auto buf = current.buffer ? current.buffer : SP<IHLBuffer>{}; auto buf = m_current.buffer ? m_current.buffer : SP<IHLBuffer>{};
if UNLIKELY (!buf) if UNLIKELY (!buf)
return; return;
auto& shmData = CCursorSurfaceRole::cursorPixelData(self.lock()); auto& shmData = CCursorSurfaceRole::cursorPixelData(m_self.lock());
auto shmAttrs = buf->shm(); auto shmAttrs = buf->shm();
if (!shmAttrs.success) { if (!shmAttrs.success) {
@ -563,7 +563,7 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) {
void CWLSurfaceResource::presentFeedback(const Time::steady_tp& when, PHLMONITOR pMonitor, bool discarded) { void CWLSurfaceResource::presentFeedback(const Time::steady_tp& when, PHLMONITOR pMonitor, bool discarded) {
frame(when); frame(when);
auto FEEDBACK = makeShared<CQueuedPresentationData>(self.lock()); auto FEEDBACK = makeShared<CQueuedPresentationData>(m_self.lock());
FEEDBACK->attachMonitor(pMonitor); FEEDBACK->attachMonitor(pMonitor);
if (discarded) if (discarded)
FEEDBACK->discarded(); FEEDBACK->discarded();
@ -572,45 +572,45 @@ void CWLSurfaceResource::presentFeedback(const Time::steady_tp& when, PHLMONITOR
PROTO::presentation->queueData(FEEDBACK); PROTO::presentation->queueData(FEEDBACK);
} }
CWLCompositorResource::CWLCompositorResource(SP<CWlCompositor> resource_) : resource(resource_) { CWLCompositorResource::CWLCompositorResource(SP<CWlCompositor> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; 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) { m_resource->setCreateSurface([](CWlCompositor* r, uint32_t id) {
const auto RESOURCE = PROTO::compositor->m_vSurfaces.emplace_back(makeShared<CWLSurfaceResource>(makeShared<CWlSurface>(r->client(), r->version(), id))); const auto RESOURCE = PROTO::compositor->m_surfaces.emplace_back(makeShared<CWLSurfaceResource>(makeShared<CWlSurface>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::compositor->m_vSurfaces.pop_back(); PROTO::compositor->m_surfaces.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
LOGM(LOG, "New wl_surface with id {} at {:x}", id, (uintptr_t)RESOURCE.get()); 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) { m_resource->setCreateRegion([](CWlCompositor* r, uint32_t id) {
const auto RESOURCE = PROTO::compositor->m_vRegions.emplace_back(makeShared<CWLRegionResource>(makeShared<CWlRegion>(r->client(), r->version(), id))); const auto RESOURCE = PROTO::compositor->m_regions.emplace_back(makeShared<CWLRegionResource>(makeShared<CWlRegion>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::compositor->m_vRegions.pop_back(); PROTO::compositor->m_regions.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
LOGM(LOG, "New wl_region with id {} at {:x}", id, (uintptr_t)RESOURCE.get()); LOGM(LOG, "New wl_region with id {} at {:x}", id, (uintptr_t)RESOURCE.get());
}); });
} }
bool CWLCompositorResource::good() { 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) { 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) { void CWLCompositorProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CWLCompositorResource>(makeShared<CWlCompositor>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CWLCompositorResource>(makeShared<CWlCompositor>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CWLCompositorProtocol::destroyResource(CWLCompositorResource* resource) { 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) { 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) { 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<void(SP<CWLSurfaceResource>)> fn) { void CWLCompositorProtocol::forEachSurface(std::function<void(SP<CWLSurfaceResource>)> fn) {
for (auto& surf : m_vSurfaces) { for (auto& surf : m_surfaces) {
fn(surf); fn(surf);
} }
} }

View File

@ -40,7 +40,7 @@ class CWLCallbackResource {
void send(const Time::steady_tp& now); void send(const Time::steady_tp& now);
private: private:
SP<CWlCallback> resource; SP<CWlCallback> m_resource;
}; };
class CWLRegionResource { class CWLRegionResource {
@ -50,11 +50,11 @@ class CWLRegionResource {
bool good(); bool good();
CRegion region; CRegion m_region;
WP<CWLRegionResource> self; WP<CWLRegionResource> m_self;
private: private:
SP<CWlRegion> resource; SP<CWlRegion> m_resource;
}; };
class CWLSurfaceResource { class CWLSurfaceResource {
@ -86,22 +86,22 @@ class CWLSurfaceResource {
CSignal unmap; CSignal unmap;
CSignal newSubsurface; CSignal newSubsurface;
CSignal destroy; CSignal destroy;
} events; } m_events;
SSurfaceState current, pending; SSurfaceState m_current;
std::queue<UP<SSurfaceState>> pendingStates; SSurfaceState m_pending;
std::queue<UP<SSurfaceState>> m_pendingStates;
std::vector<SP<CWLCallbackResource>> callbacks; std::vector<SP<CWLCallbackResource>> m_callbacks;
WP<CWLSurfaceResource> self; WP<CWLSurfaceResource> m_self;
WP<CWLSurface> hlSurface; WP<CWLSurface> m_hlSurface;
std::vector<PHLMONITORREF> enteredOutputs; std::vector<PHLMONITORREF> m_enteredOutputs;
bool mapped = false; bool m_mapped = false;
std::vector<WP<CWLSubsurfaceResource>> subsurfaces; std::vector<WP<CWLSubsurfaceResource>> m_subsurfaces;
SP<ISurfaceRole> role; SP<ISurfaceRole> m_role;
WP<CViewportResource> viewportResource; WP<CDRMSyncobjSurfaceResource> m_syncobj; // may not be present
WP<CDRMSyncobjSurfaceResource> syncobj; // may not be present WP<CColorManagementSurface> m_colorManagement;
WP<CColorManagementSurface> colorManagement; WP<CContentType> m_contentType;
WP<CContentType> contentType;
void breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data); void breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data);
SP<CWLSurfaceResource> findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> fn); SP<CWLSurfaceResource> findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> fn);
@ -113,8 +113,8 @@ class CWLSurfaceResource {
std::pair<SP<CWLSurfaceResource>, Vector2D> at(const Vector2D& localCoords, bool allowsInput = false); std::pair<SP<CWLSurfaceResource>, Vector2D> at(const Vector2D& localCoords, bool allowsInput = false);
private: private:
SP<CWlSurface> resource; SP<CWlSurface> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
void destroy(); void destroy();
void releaseBuffers(bool onlyCurrent = true); void releaseBuffers(bool onlyCurrent = true);
@ -134,7 +134,7 @@ class CWLCompositorResource {
bool good(); bool good();
private: private:
SP<CWlCompositor> resource; SP<CWlCompositor> m_resource;
}; };
class CWLCompositorProtocol : public IWaylandProtocol { class CWLCompositorProtocol : public IWaylandProtocol {
@ -147,7 +147,7 @@ class CWLCompositorProtocol : public IWaylandProtocol {
struct { struct {
CSignal newSurface; // SP<CWLSurfaceResource> CSignal newSurface; // SP<CWLSurfaceResource>
} events; } m_events;
private: private:
void destroyResource(CWLCompositorResource* resource); void destroyResource(CWLCompositorResource* resource);
@ -155,9 +155,9 @@ class CWLCompositorProtocol : public IWaylandProtocol {
void destroyResource(CWLRegionResource* resource); void destroyResource(CWLRegionResource* resource);
// //
std::vector<SP<CWLCompositorResource>> m_vManagers; std::vector<SP<CWLCompositorResource>> m_managers;
std::vector<SP<CWLSurfaceResource>> m_vSurfaces; std::vector<SP<CWLSurfaceResource>> m_surfaces;
std::vector<SP<CWLRegionResource>> m_vRegions; std::vector<SP<CWLRegionResource>> m_regions;
friend class CWLSurfaceResource; friend class CWLSurfaceResource;
friend class CWLCompositorResource; friend class CWLCompositorResource;

View File

@ -16,60 +16,60 @@
#include "../../xwayland/Dnd.hpp" #include "../../xwayland/Dnd.hpp"
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_) : source(source_), resource(resource_) { CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_) : m_source(source_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); }); m_resource->setDestroy([this](CWlDataOffer* r) { PROTO::data->destroyResource(this); });
resource->setOnDestroy([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) { m_resource->setAccept([this](CWlDataOffer* r, uint32_t serial, const char* mime) {
if (!source) { if (!m_source) {
LOGM(WARN, "Possible bug: Accept on an offer w/o a source"); LOGM(WARN, "Possible bug: Accept on an offer w/o a source");
return; return;
} }
if (dead) { if (m_dead) {
LOGM(WARN, "Possible bug: Accept on an offer that's dead"); LOGM(WARN, "Possible bug: Accept on an offer that's dead");
return; 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 : ""); m_source->accepted(mime ? mime : "");
accepted = 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}; CFileDescriptor sendFd{fd};
if (!source) { if (!m_source) {
LOGM(WARN, "Possible bug: Receive on an offer w/o a source"); LOGM(WARN, "Possible bug: Receive on an offer w/o a source");
return; return;
} }
if (dead) { if (m_dead) {
LOGM(WARN, "Possible bug: Receive on an offer that's dead"); LOGM(WARN, "Possible bug: Receive on an offer that's dead");
return; return;
} }
LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)source.get()); LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get());
if (!accepted) { if (!m_accepted) {
LOGM(WARN, "Offer was never accepted, sending accept first"); 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()) // if (source->hasDnd())
// PROTO::data->completeDrag(); // PROTO::data->completeDrag();
}); });
resource->setFinish([this](CWlDataOffer* r) { m_resource->setFinish([this](CWlDataOffer* r) {
dead = true; m_dead = true;
if (!source || !recvd || !accepted) if (!m_source || !m_recvd || !m_accepted)
PROTO::data->abortDrag(); PROTO::data->abortDrag();
else else
PROTO::data->completeDrag(); PROTO::data->completeDrag();
@ -77,37 +77,37 @@ CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataS
} }
CWLDataOfferResource::~CWLDataOfferResource() { CWLDataOfferResource::~CWLDataOfferResource() {
if (!source || !source->hasDnd() || dead) if (!m_source || !m_source->hasDnd() || m_dead)
return; return;
source->sendDndFinished(); m_source->sendDndFinished();
} }
bool CWLDataOfferResource::good() { bool CWLDataOfferResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CWLDataOfferResource::sendData() { void CWLDataOfferResource::sendData() {
if (!source) if (!m_source)
return; return;
const auto SOURCEACTIONS = source->actions(); const auto SOURCEACTIONS = m_source->actions();
if (resource->version() >= 3 && SOURCEACTIONS > 0) { if (m_resource->version() >= 3 && SOURCEACTIONS > 0) {
resource->sendSourceActions(SOURCEACTIONS); m_resource->sendSourceActions(SOURCEACTIONS);
if (SOURCEACTIONS & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE) 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) 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 { else {
LOGM(ERR, "Client bug? dnd source has no action move or copy. Sending move, f this."); 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); 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> CWLDataOfferResource::getWayland() { SP<CWLDataOfferResource> CWLDataOfferResource::getWayland() {
return self.lock(); return m_self.lock();
} }
SP<CX11DataOffer> CWLDataOfferResource::getX11() { SP<CX11DataOffer> CWLDataOfferResource::getX11() {
@ -124,127 +124,127 @@ SP<CX11DataOffer> CWLDataOfferResource::getX11() {
} }
SP<IDataSource> CWLDataOfferResource::getSource() { SP<IDataSource> CWLDataOfferResource::getSource() {
return source.lock(); return m_source.lock();
} }
CWLDataSourceResource::CWLDataSourceResource(SP<CWlDataSource> resource_, SP<CWLDataDeviceResource> device_) : device(device_), resource(resource_) { CWLDataSourceResource::CWLDataSourceResource(SP<CWlDataSource> resource_, SP<CWLDataDeviceResource> device_) : m_device(device_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setData(this); m_resource->setData(this);
resource->setDestroy([this](CWlDataSource* r) { m_resource->setDestroy([this](CWlDataSource* r) {
events.destroy.emit(); events.destroy.emit();
PROTO::data->onDestroyDataSource(self); PROTO::data->onDestroyDataSource(m_self);
PROTO::data->destroyResource(this); PROTO::data->destroyResource(this);
}); });
resource->setOnDestroy([this](CWlDataSource* r) { m_resource->setOnDestroy([this](CWlDataSource* r) {
events.destroy.emit(); events.destroy.emit();
PROTO::data->onDestroyDataSource(self); PROTO::data->onDestroyDataSource(m_self);
PROTO::data->destroyResource(this); PROTO::data->destroyResource(this);
}); });
resource->setOffer([this](CWlDataSource* r, const char* mime) { mimeTypes.emplace_back(mime); }); m_resource->setOffer([this](CWlDataSource* r, const char* mime) { m_mimeTypes.emplace_back(mime); });
resource->setSetActions([this](CWlDataSource* r, uint32_t a) { m_resource->setSetActions([this](CWlDataSource* r, uint32_t a) {
LOGM(LOG, "DataSource {:x} actions {}", (uintptr_t)this, a); LOGM(LOG, "DataSource {:x} actions {}", (uintptr_t)this, a);
supportedActions = a; m_supportedActions = a;
}); });
} }
CWLDataSourceResource::~CWLDataSourceResource() { CWLDataSourceResource::~CWLDataSourceResource() {
events.destroy.emit(); events.destroy.emit();
PROTO::data->onDestroyDataSource(self); PROTO::data->onDestroyDataSource(m_self);
} }
SP<CWLDataSourceResource> CWLDataSourceResource::fromResource(wl_resource* res) { SP<CWLDataSourceResource> CWLDataSourceResource::fromResource(wl_resource* res) {
auto data = (CWLDataSourceResource*)(((CWlDataSource*)wl_resource_get_user_data(res))->data()); 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() { bool CWLDataSourceResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CWLDataSourceResource::accepted(const std::string& mime) { void CWLDataSourceResource::accepted(const std::string& mime) {
if (mime.empty()) { if (mime.empty()) {
resource->sendTarget(nullptr); m_resource->sendTarget(nullptr);
return; 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"); LOGM(ERR, "Compositor/App bug: CWLDataSourceResource::sendAccepted with non-existent mime");
return; return;
} }
resource->sendTarget(mime.c_str()); m_resource->sendTarget(mime.c_str());
} }
std::vector<std::string> CWLDataSourceResource::mimes() { std::vector<std::string> CWLDataSourceResource::mimes() {
return mimeTypes; return m_mimeTypes;
} }
void CWLDataSourceResource::send(const std::string& mime, CFileDescriptor fd) { 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"); LOGM(ERR, "Compositor/App bug: CWLDataSourceResource::sendAskSend with non-existent mime");
return; return;
} }
resource->sendSend(mime.c_str(), fd.get()); m_resource->sendSend(mime.c_str(), fd.get());
} }
void CWLDataSourceResource::cancelled() { void CWLDataSourceResource::cancelled() {
resource->sendCancelled(); m_resource->sendCancelled();
} }
bool CWLDataSourceResource::hasDnd() { bool CWLDataSourceResource::hasDnd() {
return dnd; return m_dnd;
} }
bool CWLDataSourceResource::dndDone() { bool CWLDataSourceResource::dndDone() {
return dndSuccess; return m_dndSuccess;
} }
void CWLDataSourceResource::error(uint32_t code, const std::string& msg) { void CWLDataSourceResource::error(uint32_t code, const std::string& msg) {
resource->error(code, msg); m_resource->error(code, msg);
} }
void CWLDataSourceResource::sendDndDropPerformed() { void CWLDataSourceResource::sendDndDropPerformed() {
if (resource->version() < 3) if (m_resource->version() < 3)
return; return;
resource->sendDndDropPerformed(); m_resource->sendDndDropPerformed();
dropped = true; m_dropped = true;
} }
void CWLDataSourceResource::sendDndFinished() { void CWLDataSourceResource::sendDndFinished() {
if (resource->version() < 3) if (m_resource->version() < 3)
return; return;
resource->sendDndFinished(); m_resource->sendDndFinished();
} }
void CWLDataSourceResource::sendDndAction(wl_data_device_manager_dnd_action a) { void CWLDataSourceResource::sendDndAction(wl_data_device_manager_dnd_action a) {
if (resource->version() < 3) if (m_resource->version() < 3)
return; return;
resource->sendAction(a); m_resource->sendAction(a);
} }
uint32_t CWLDataSourceResource::actions() { uint32_t CWLDataSourceResource::actions() {
return supportedActions; return m_supportedActions;
} }
eDataSourceType CWLDataSourceResource::type() { eDataSourceType CWLDataSourceResource::type() {
return DATA_SOURCE_TYPE_WAYLAND; return DATA_SOURCE_TYPE_WAYLAND;
} }
CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : resource(resource_) { CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setRelease([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); }); m_resource->setRelease([this](CWlDataDevice* r) { PROTO::data->destroyResource(this); });
resource->setOnDestroy([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<CWLDataSourceResource>{}; auto source = sourceR ? CWLDataSourceResource::fromResource(sourceR) : CSharedPointer<CWLDataSourceResource>{};
if (!source) { if (!source) {
LOGM(LOG, "Reset selection received"); LOGM(LOG, "Reset selection received");
@ -252,7 +252,7 @@ CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : reso
return; 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."); LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed(); source->markUsed();
@ -260,63 +260,63 @@ CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : reso
g_pSeatManager->setCurrentSelection(source); 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); auto source = CWLDataSourceResource::fromResource(sourceR);
if (!source) { if (!source) {
LOGM(ERR, "No source in drag"); LOGM(ERR, "No source in drag");
return; 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."); LOGM(WARN, "setSelection on a used resource. By protocol, this is a violation, but firefox et al insist on doing this.");
source->markUsed(); source->markUsed();
source->dnd = true; source->m_dnd = true;
PROTO::data->initiateDrag(source, icon ? CWLSurfaceResource::fromResource(icon) : nullptr, CWLSurfaceResource::fromResource(origin)); PROTO::data->initiateDrag(source, icon ? CWLSurfaceResource::fromResource(icon) : nullptr, CWLSurfaceResource::fromResource(origin));
}); });
} }
bool CWLDataDeviceResource::good() { bool CWLDataDeviceResource::good() {
return resource->resource(); return m_resource->resource();
} }
wl_client* CWLDataDeviceResource::client() { wl_client* CWLDataDeviceResource::client() {
return pClient; return m_client;
} }
void CWLDataDeviceResource::sendDataOffer(SP<IDataOffer> offer) { void CWLDataDeviceResource::sendDataOffer(SP<IDataOffer> offer) {
if (!offer) if (!offer)
resource->sendDataOfferRaw(nullptr); m_resource->sendDataOfferRaw(nullptr);
else if (const auto WL = offer->getWayland(); WL) else if (const auto WL = offer->getWayland(); WL)
resource->sendDataOffer(WL->resource.get()); m_resource->sendDataOffer(WL->m_resource.get());
//FIXME: X11 //FIXME: X11
} }
void CWLDataDeviceResource::sendEnter(uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& local, SP<IDataOffer> offer) { void CWLDataDeviceResource::sendEnter(uint32_t serial, SP<CWLSurfaceResource> surf, const Vector2D& local, SP<IDataOffer> offer) {
if (const auto WL = offer->getWayland(); WL) 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 // FIXME: X11
} }
void CWLDataDeviceResource::sendLeave() { void CWLDataDeviceResource::sendLeave() {
resource->sendLeave(); m_resource->sendLeave();
} }
void CWLDataDeviceResource::sendMotion(uint32_t timeMs, const Vector2D& local) { 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() { void CWLDataDeviceResource::sendDrop() {
resource->sendDrop(); m_resource->sendDrop();
} }
void CWLDataDeviceResource::sendSelection(SP<IDataOffer> offer) { void CWLDataDeviceResource::sendSelection(SP<IDataOffer> offer) {
if (!offer) if (!offer)
resource->sendSelectionRaw(nullptr); m_resource->sendSelectionRaw(nullptr);
else if (const auto WL = offer->getWayland(); WL) else if (const auto WL = offer->getWayland(); WL)
resource->sendSelection(WL->resource.get()); m_resource->sendSelection(WL->m_resource.get());
} }
eDataSourceType CWLDataDeviceResource::type() { eDataSourceType CWLDataDeviceResource::type() {
@ -324,55 +324,55 @@ eDataSourceType CWLDataDeviceResource::type() {
} }
SP<CWLDataDeviceResource> CWLDataDeviceResource::getWayland() { SP<CWLDataDeviceResource> CWLDataDeviceResource::getWayland() {
return self.lock(); return m_self.lock();
} }
SP<CX11DataDevice> CWLDataDeviceResource::getX11() { SP<CX11DataDevice> CWLDataDeviceResource::getX11() {
return nullptr; return nullptr;
} }
CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP<CWlDataDeviceManager> resource_) : resource(resource_) { CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP<CWlDataDeviceManager> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; 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) { m_resource->setCreateDataSource([this](CWlDataDeviceManager* r, uint32_t id) {
std::erase_if(sources, [](const auto& e) { return e.expired(); }); std::erase_if(m_sources, [](const auto& e) { return e.expired(); });
const auto RESOURCE = PROTO::data->m_vSources.emplace_back(makeShared<CWLDataSourceResource>(makeShared<CWlDataSource>(r->client(), r->version(), id), device.lock())); const auto RESOURCE = PROTO::data->m_sources.emplace_back(makeShared<CWLDataSourceResource>(makeShared<CWlDataSource>(r->client(), r->version(), id), m_device.lock()));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::data->m_vSources.pop_back(); PROTO::data->m_sources.pop_back();
return; return;
} }
if (!device) if (!m_device)
LOGM(WARN, "New data source before a device was created"); LOGM(WARN, "New data source before a device was created");
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
sources.emplace_back(RESOURCE); m_sources.emplace_back(RESOURCE);
LOGM(LOG, "New data source bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(LOG, "New data source bound at {:x}", (uintptr_t)RESOURCE.get());
}); });
resource->setGetDataDevice([this](CWlDataDeviceManager* r, uint32_t id, wl_resource* seat) { m_resource->setGetDataDevice([this](CWlDataDeviceManager* r, uint32_t id, wl_resource* seat) {
const auto RESOURCE = PROTO::data->m_vDevices.emplace_back(makeShared<CWLDataDeviceResource>(makeShared<CWlDataDevice>(r->client(), r->version(), id))); const auto RESOURCE = PROTO::data->m_devices.emplace_back(makeShared<CWLDataDeviceResource>(makeShared<CWlDataDevice>(r->client(), r->version(), id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::data->m_vDevices.pop_back(); PROTO::data->m_devices.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
for (auto const& s : sources) { for (auto const& s : m_sources) {
if (!s) if (!s)
continue; continue;
s->device = RESOURCE; s->m_device = RESOURCE;
} }
LOGM(LOG, "New data device bound at {:x}", (uintptr_t)RESOURCE.get()); LOGM(LOG, "New data device bound at {:x}", (uintptr_t)RESOURCE.get());
@ -380,22 +380,22 @@ CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP<CWlDataDeviceManag
} }
bool CWLDataDeviceManagerResource::good() { bool CWLDataDeviceManagerResource::good() {
return resource->resource(); return m_resource->resource();
} }
CWLDataDeviceProtocol::CWLDataDeviceProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CWLDataDeviceProtocol::CWLDataDeviceProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
g_pEventLoopManager->doLater([this]() { g_pEventLoopManager->doLater([this]() {
listeners.onKeyboardFocusChange = g_pSeatManager->m_events.keyboardFocusChange.registerListener([this](std::any d) { onKeyboardFocus(); }); m_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.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) { void CWLDataDeviceProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CWLDataDeviceManagerResource>(makeShared<CWlDataDeviceManager>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CWLDataDeviceManagerResource>(makeShared<CWlDataDeviceManager>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
@ -403,19 +403,19 @@ void CWLDataDeviceProtocol::bindManager(wl_client* client, void* data, uint32_t
} }
void CWLDataDeviceProtocol::destroyResource(CWLDataDeviceManagerResource* seat) { 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) { 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) { 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) { 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<IDataDevice> CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) { SP<IDataDevice> CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) {
@ -424,8 +424,8 @@ SP<IDataDevice> CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) {
return g_pXWayland->pWM->getDataDevice(); return g_pXWayland->pWM->getDataDevice();
#endif #endif
auto it = std::find_if(m_vDevices.begin(), m_vDevices.end(), [c](const auto& e) { return e->client() == c; }); auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; });
if (it == m_vDevices.end()) if (it == m_devices.end())
return nullptr; return nullptr;
return *it; return *it;
} }
@ -439,14 +439,14 @@ void CWLDataDeviceProtocol::sendSelectionToDevice(SP<IDataDevice> dev, SP<IDataS
SP<IDataOffer> offer; SP<IDataOffer> offer;
if (const auto WL = dev->getWayland(); WL) { if (const auto WL = dev->getWayland(); WL) {
const auto OFFER = m_vOffers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->resource->client(), WL->resource->version(), 0), sel)); const auto OFFER = m_offers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->m_resource->client(), WL->m_resource->version(), 0), sel));
if UNLIKELY (!OFFER->good()) { if UNLIKELY (!OFFER->good()) {
WL->resource->noMemory(); WL->m_resource->noMemory();
m_vOffers.pop_back(); m_offers.pop_back();
return; return;
} }
OFFER->source = sel; OFFER->m_source = sel;
OFFER->self = OFFER; OFFER->m_self = OFFER;
offer = OFFER; offer = OFFER;
} }
#ifndef NO_XWAYLAND #ifndef NO_XWAYLAND
@ -468,15 +468,15 @@ void CWLDataDeviceProtocol::sendSelectionToDevice(SP<IDataDevice> dev, SP<IDataS
} }
void CWLDataDeviceProtocol::onDestroyDataSource(WP<CWLDataSourceResource> source) { void CWLDataDeviceProtocol::onDestroyDataSource(WP<CWLDataSourceResource> source) {
if (dnd.currentSource == source) if (m_dnd.currentSource == source)
abortDrag(); abortDrag();
} }
void CWLDataDeviceProtocol::setSelection(SP<IDataSource> source) { void CWLDataDeviceProtocol::setSelection(SP<IDataSource> source) {
for (auto const& o : m_vOffers) { for (auto const& o : m_offers) {
if (o->source && o->source->hasDnd()) if (o->m_source && o->m_source->hasDnd())
continue; continue;
o->dead = true; o->m_dead = true;
} }
if (!source) { if (!source) {
@ -527,20 +527,20 @@ void CWLDataDeviceProtocol::updateSelection() {
} }
void CWLDataDeviceProtocol::onKeyboardFocus() { void CWLDataDeviceProtocol::onKeyboardFocus() {
for (auto const& o : m_vOffers) { for (auto const& o : m_offers) {
if (o->source && o->source->hasDnd()) if (o->m_source && o->m_source->hasDnd())
continue; continue;
o->dead = true; o->m_dead = true;
} }
updateSelection(); updateSelection();
} }
void CWLDataDeviceProtocol::onDndPointerFocus() { void CWLDataDeviceProtocol::onDndPointerFocus() {
for (auto const& o : m_vOffers) { for (auto const& o : m_offers) {
if (o->source && !o->source->hasDnd()) if (o->m_source && !o->m_source->hasDnd())
continue; continue;
o->dead = true; o->m_dead = true;
} }
updateDrag(); updateDrag();
@ -548,37 +548,37 @@ void CWLDataDeviceProtocol::onDndPointerFocus() {
void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource, SP<CWLSurfaceResource> dragSurface, SP<CWLSurfaceResource> origin) { void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource, SP<CWLSurfaceResource> dragSurface, SP<CWLSurfaceResource> origin) {
if (dnd.currentSource) { if (m_dnd.currentSource) {
LOGM(WARN, "New drag started while old drag still active??"); LOGM(WARN, "New drag started while old drag still active??");
abortDrag(); abortDrag();
} }
g_pInputManager->setCursorImageUntilUnset("grabbing"); 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); 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; m_dnd.currentSource = currentSource;
dnd.originSurface = origin; m_dnd.originSurface = origin;
dnd.dndSurface = dragSurface; m_dnd.dndSurface = dragSurface;
if (dragSurface) { if (dragSurface) {
dnd.dndSurfaceDestroy = dragSurface->events.destroy.registerListener([this](std::any d) { abortDrag(); }); m_dnd.dndSurfaceDestroy = dragSurface->m_events.destroy.registerListener([this](std::any d) { abortDrag(); });
dnd.dndSurfaceCommit = dragSurface->events.commit.registerListener([this](std::any d) { m_dnd.dndSurfaceCommit = dragSurface->m_events.commit.registerListener([this](std::any d) {
if (dnd.dndSurface->current.texture && !dnd.dndSurface->mapped) { if (m_dnd.dndSurface->m_current.texture && !m_dnd.dndSurface->m_mapped) {
dnd.dndSurface->map(); m_dnd.dndSurface->map();
return; return;
} }
if (dnd.dndSurface->current.texture <= 0 && dnd.dndSurface->mapped) { if (m_dnd.dndSurface->m_current.texture <= 0 && m_dnd.dndSurface->m_mapped) {
dnd.dndSurface->unmap(); m_dnd.dndSurface->unmap();
return; 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<IPointer::SButtonEvent>(e); auto E = std::any_cast<IPointer::SButtonEvent>(e);
if (E.state == WL_POINTER_BUTTON_STATE_RELEASED) { if (E.state == WL_POINTER_BUTTON_STATE_RELEASED) {
LOGM(LOG, "Dropping drag on mouseUp"); LOGM(LOG, "Dropping drag on mouseUp");
@ -586,14 +586,14 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> 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"); LOGM(LOG, "Dropping drag on touchUp");
dropDrag(); 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<const Vector2D>(e); auto V = std::any_cast<const Vector2D>(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()); auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
if (!surf) if (!surf)
@ -604,14 +604,14 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
if (!box.has_value()) if (!box.has_value())
return; 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()); 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<ITouch::SMotionEvent>(e); auto E = std::any_cast<ITouch::SMotionEvent>(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()); auto surf = CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
if (!surf) if (!surf)
@ -622,7 +622,7 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
if (!box.has_value()) if (!box.has_value())
return; return;
dnd.focusedDevice->sendMotion(E.timeMs, E.pos); m_dnd.focusedDevice->sendMotion(E.timeMs, E.pos);
LOGM(LOG, "Drag motion {}", E.pos); LOGM(LOG, "Drag motion {}", E.pos);
} }
}); });
@ -642,34 +642,34 @@ void CWLDataDeviceProtocol::updateDrag() {
if (!dndActive()) if (!dndActive())
return; return;
if (dnd.focusedDevice) if (m_dnd.focusedDevice)
dnd.focusedDevice->sendLeave(); m_dnd.focusedDevice->sendLeave();
if (!g_pSeatManager->m_state.dndPointerFocus) if (!g_pSeatManager->m_state.dndPointerFocus)
return; 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; return;
SP<IDataOffer> offer; SP<IDataOffer> offer;
if (const auto WL = dnd.focusedDevice->getWayland(); WL) { if (const auto WL = m_dnd.focusedDevice->getWayland(); WL) {
const auto OFFER = const auto OFFER =
m_vOffers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->resource->client(), WL->resource->version(), 0), dnd.currentSource.lock())); m_offers.emplace_back(makeShared<CWLDataOfferResource>(makeShared<CWlDataOffer>(WL->m_resource->client(), WL->m_resource->version(), 0), m_dnd.currentSource.lock()));
if (!OFFER->good()) { if (!OFFER->good()) {
WL->resource->noMemory(); WL->m_resource->noMemory();
m_vOffers.pop_back(); m_offers.pop_back();
return; return;
} }
OFFER->source = dnd.currentSource; OFFER->m_source = m_dnd.currentSource;
OFFER->self = OFFER; OFFER->m_self = OFFER;
offer = OFFER; offer = OFFER;
} }
#ifndef NO_XWAYLAND #ifndef NO_XWAYLAND
else if (const auto X11 = dnd.focusedDevice->getX11(); X11) else if (const auto X11 = m_dnd.focusedDevice->getX11(); X11)
offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), dnd.currentSource.lock()); offer = g_pXWayland->pWM->createX11DataOffer(g_pSeatManager->m_state.keyboardFocus.lock(), m_dnd.currentSource.lock());
#endif #endif
if (!offer) { 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(), 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) if (const auto WL = offer->getWayland(); WL)
WL->sendData(); WL->sendData();
dnd.focusedDevice->sendEnter(wl_display_next_serial(g_pCompositor->m_wlDisplay), g_pSeatManager->m_state.dndPointerFocus.lock(), m_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); g_pSeatManager->m_state.dndPointerFocus->m_current.size / 2.F, offer);
} }
void CWLDataDeviceProtocol::cleanupDndState(bool resetDevice, bool resetSource, bool simulateInput) { void CWLDataDeviceProtocol::cleanupDndState(bool resetDevice, bool resetSource, bool simulateInput) {
dnd.dndSurface.reset(); m_dnd.dndSurface.reset();
dnd.dndSurfaceCommit.reset(); m_dnd.dndSurfaceCommit.reset();
dnd.dndSurfaceDestroy.reset(); m_dnd.dndSurfaceDestroy.reset();
dnd.mouseButton.reset(); m_dnd.mouseButton.reset();
dnd.mouseMove.reset(); m_dnd.mouseMove.reset();
dnd.touchUp.reset(); m_dnd.touchUp.reset();
dnd.touchMove.reset(); m_dnd.touchMove.reset();
if (resetDevice) if (resetDevice)
dnd.focusedDevice.reset(); m_dnd.focusedDevice.reset();
if (resetSource) if (resetSource)
dnd.currentSource.reset(); m_dnd.currentSource.reset();
if (simulateInput) { if (simulateInput) {
g_pInputManager->simulateMouseMovement(); g_pInputManager->simulateMouseMovement();
@ -708,8 +708,8 @@ void CWLDataDeviceProtocol::cleanupDndState(bool resetDevice, bool resetSource,
} }
void CWLDataDeviceProtocol::dropDrag() { void CWLDataDeviceProtocol::dropDrag() {
if (!dnd.focusedDevice || !dnd.currentSource) { if (!m_dnd.focusedDevice || !m_dnd.currentSource) {
if (dnd.currentSource) if (m_dnd.currentSource)
abortDrag(); abortDrag();
return; return;
} }
@ -719,40 +719,40 @@ void CWLDataDeviceProtocol::dropDrag() {
return; return;
} }
dnd.focusedDevice->sendDrop(); m_dnd.focusedDevice->sendDrop();
#ifndef NO_XWAYLAND #ifndef NO_XWAYLAND
if (dnd.focusedDevice->getX11()) { if (m_dnd.focusedDevice->getX11()) {
dnd.focusedDevice->sendLeave(); m_dnd.focusedDevice->sendLeave();
if (dnd.overriddenCursor) if (m_dnd.overriddenCursor)
g_pInputManager->unsetCursorImage(); g_pInputManager->unsetCursorImage();
dnd.overriddenCursor = false; m_dnd.overriddenCursor = false;
cleanupDndState(true, true, true); cleanupDndState(true, true, true);
return; return;
} }
#endif #endif
dnd.focusedDevice->sendLeave(); m_dnd.focusedDevice->sendLeave();
if (dnd.overriddenCursor) if (m_dnd.overriddenCursor)
g_pInputManager->unsetCursorImage(); g_pInputManager->unsetCursorImage();
dnd.overriddenCursor = false; m_dnd.overriddenCursor = false;
cleanupDndState(false, false, false); cleanupDndState(false, false, false);
} }
bool CWLDataDeviceProtocol::wasDragSuccessful() { bool CWLDataDeviceProtocol::wasDragSuccessful() {
if (!dnd.currentSource) if (!m_dnd.currentSource)
return false; return false;
for (auto const& o : m_vOffers) { for (auto const& o : m_offers) {
if (o->dead || o->source != dnd.currentSource) if (o->m_dead || o->m_source != m_dnd.currentSource)
continue; continue;
if (o->recvd || o->accepted) if (o->m_recvd || o->m_accepted)
return true; return true;
} }
#ifndef NO_XWAYLAND #ifndef NO_XWAYLAND
if (dnd.focusedDevice->getX11()) if (m_dnd.focusedDevice->getX11())
return true; return true;
#endif #endif
@ -760,12 +760,12 @@ bool CWLDataDeviceProtocol::wasDragSuccessful() {
} }
void CWLDataDeviceProtocol::completeDrag() { void CWLDataDeviceProtocol::completeDrag() {
if (!dnd.focusedDevice && !dnd.currentSource) if (!m_dnd.focusedDevice && !m_dnd.currentSource)
return; return;
if (dnd.currentSource) { if (m_dnd.currentSource) {
dnd.currentSource->sendDndDropPerformed(); m_dnd.currentSource->sendDndDropPerformed();
dnd.currentSource->sendDndFinished(); m_dnd.currentSource->sendDndFinished();
} }
cleanupDndState(true, true, true); cleanupDndState(true, true, true);
@ -774,56 +774,56 @@ void CWLDataDeviceProtocol::completeDrag() {
void CWLDataDeviceProtocol::abortDrag() { void CWLDataDeviceProtocol::abortDrag() {
cleanupDndState(false, false, false); cleanupDndState(false, false, false);
if (dnd.overriddenCursor) if (m_dnd.overriddenCursor)
g_pInputManager->unsetCursorImage(); g_pInputManager->unsetCursorImage();
dnd.overriddenCursor = false; m_dnd.overriddenCursor = false;
if (!dnd.focusedDevice && !dnd.currentSource) if (!m_dnd.focusedDevice && !m_dnd.currentSource)
return; return;
if (dnd.focusedDevice) { if (m_dnd.focusedDevice) {
#ifndef NO_XWAYLAND #ifndef NO_XWAYLAND
if (auto x11Device = dnd.focusedDevice->getX11(); x11Device) if (auto x11Device = m_dnd.focusedDevice->getX11(); x11Device)
x11Device->forceCleanupDnd(); x11Device->forceCleanupDnd();
#endif #endif
dnd.focusedDevice->sendLeave(); m_dnd.focusedDevice->sendLeave();
} }
if (dnd.currentSource) if (m_dnd.currentSource)
dnd.currentSource->cancelled(); m_dnd.currentSource->cancelled();
dnd.focusedDevice.reset(); m_dnd.focusedDevice.reset();
dnd.currentSource.reset(); m_dnd.currentSource.reset();
g_pInputManager->simulateMouseMovement(); g_pInputManager->simulateMouseMovement();
g_pSeatManager->resendEnterEvents(); g_pSeatManager->resendEnterEvents();
} }
void CWLDataDeviceProtocol::renderDND(PHLMONITOR pMonitor, const Time::steady_tp& when) { 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; return;
const auto POS = g_pInputManager->getMouseCoordsInternal(); const auto POS = g_pInputManager->getMouseCoordsInternal();
Vector2D surfacePos = POS; 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; CTexPassElement::SRenderData data;
data.tex = dnd.dndSurface->current.texture; data.tex = m_dnd.dndSurface->m_current.texture;
data.box = box; data.box = box;
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data)); g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(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); g_pHyprRenderer->damageBox(damageBox);
dnd.dndSurface->frame(when); m_dnd.dndSurface->frame(when);
} }
bool CWLDataDeviceProtocol::dndActive() { bool CWLDataDeviceProtocol::dndActive() {
return dnd.currentSource; return m_dnd.currentSource;
} }
void CWLDataDeviceProtocol::abortDndIfPresent() { void CWLDataDeviceProtocol::abortDndIfPresent() {

View File

@ -40,17 +40,15 @@ class CWLDataOfferResource : public IDataOffer {
virtual SP<CX11DataOffer> getX11(); virtual SP<CX11DataOffer> getX11();
virtual SP<IDataSource> getSource(); virtual SP<IDataSource> getSource();
WP<IDataSource> source; WP<IDataSource> m_source;
WP<CWLDataOfferResource> self; WP<CWLDataOfferResource> m_self;
bool dead = false; bool m_dead = false;
bool accepted = false; bool m_accepted = false;
bool recvd = false; bool m_recvd = false;
uint32_t actions = 0;
private: private:
SP<CWlDataOffer> resource; SP<CWlDataOffer> m_resource;
friend class CWLDataDeviceResource; friend class CWLDataDeviceResource;
}; };
@ -76,19 +74,19 @@ class CWLDataSourceResource : public IDataSource {
virtual void sendDndDropPerformed(); virtual void sendDndDropPerformed();
virtual void sendDndAction(wl_data_device_manager_dnd_action a); virtual void sendDndAction(wl_data_device_manager_dnd_action a);
bool used = false; bool m_used = false;
bool dnd = false; bool m_dnd = false;
bool dndSuccess = false; bool m_dndSuccess = false;
bool dropped = false; bool m_dropped = false;
WP<CWLDataDeviceResource> device; WP<CWLDataDeviceResource> m_device;
WP<CWLDataSourceResource> self; WP<CWLDataSourceResource> m_self;
std::vector<std::string> mimeTypes; std::vector<std::string> m_mimeTypes;
uint32_t supportedActions = 0; uint32_t m_supportedActions = 0;
private: private:
SP<CWlDataSource> resource; SP<CWlDataSource> m_resource;
friend class CWLDataDeviceProtocol; friend class CWLDataDeviceProtocol;
}; };
@ -110,11 +108,11 @@ class CWLDataDeviceResource : public IDataDevice {
virtual void sendSelection(SP<IDataOffer> offer); virtual void sendSelection(SP<IDataOffer> offer);
virtual eDataSourceType type(); virtual eDataSourceType type();
WP<CWLDataDeviceResource> self; WP<CWLDataDeviceResource> m_self;
private: private:
SP<CWlDataDevice> resource; SP<CWlDataDevice> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
friend class CWLDataDeviceProtocol; friend class CWLDataDeviceProtocol;
}; };
@ -125,11 +123,11 @@ class CWLDataDeviceManagerResource {
bool good(); bool good();
WP<CWLDataDeviceResource> device; WP<CWLDataDeviceResource> m_device;
std::vector<WP<CWLDataSourceResource>> sources; std::vector<WP<CWLDataSourceResource>> m_sources;
private: private:
SP<CWlDataDeviceManager> resource; SP<CWlDataDeviceManager> m_resource;
}; };
class CWLDataDeviceProtocol : public IWaylandProtocol { class CWLDataDeviceProtocol : public IWaylandProtocol {
@ -154,10 +152,10 @@ class CWLDataDeviceProtocol : public IWaylandProtocol {
void destroyResource(CWLDataOfferResource* resource); void destroyResource(CWLDataOfferResource* resource);
// //
std::vector<SP<CWLDataDeviceManagerResource>> m_vManagers; std::vector<SP<CWLDataDeviceManagerResource>> m_managers;
std::vector<SP<CWLDataDeviceResource>> m_vDevices; std::vector<SP<CWLDataDeviceResource>> m_devices;
std::vector<SP<CWLDataSourceResource>> m_vSources; std::vector<SP<CWLDataSourceResource>> m_sources;
std::vector<SP<CWLDataOfferResource>> m_vOffers; std::vector<SP<CWLDataOfferResource>> m_offers;
// //
@ -182,7 +180,7 @@ class CWLDataDeviceProtocol : public IWaylandProtocol {
SP<HOOK_CALLBACK_FN> mouseButton; SP<HOOK_CALLBACK_FN> mouseButton;
SP<HOOK_CALLBACK_FN> touchUp; SP<HOOK_CALLBACK_FN> touchUp;
SP<HOOK_CALLBACK_FN> touchMove; SP<HOOK_CALLBACK_FN> touchMove;
} dnd; } m_dnd;
void abortDrag(); void abortDrag();
void initiateDrag(WP<CWLDataSourceResource> currentSource, SP<CWLSurfaceResource> dragSurface, SP<CWLSurfaceResource> origin); void initiateDrag(WP<CWLDataSourceResource> currentSource, SP<CWLSurfaceResource> dragSurface, SP<CWLSurfaceResource> origin);
@ -204,7 +202,7 @@ class CWLDataDeviceProtocol : public IWaylandProtocol {
struct { struct {
CHyprSignalListener onKeyboardFocusChange; CHyprSignalListener onKeyboardFocusChange;
CHyprSignalListener onDndPointerFocusChange; CHyprSignalListener onDndPointerFocusChange;
} listeners; } m_listeners;
}; };
namespace PROTO { namespace PROTO {

View File

@ -3,29 +3,29 @@
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
#include "../../helpers/Monitor.hpp" #include "../../helpers/Monitor.hpp"
CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonitor) : monitor(pMonitor), resource(resource_) { CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonitor) : m_monitor(pMonitor), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setData(this); m_resource->setData(this);
pClient = resource->client(); m_client = m_resource->client();
if (!monitor) if (!m_monitor)
return; return;
resource->setOnDestroy([this](CWlOutput* r) { m_resource->setOnDestroy([this](CWlOutput* r) {
if (monitor && PROTO::outputs.contains(monitor->m_name)) if (m_monitor && PROTO::outputs.contains(m_monitor->m_name))
PROTO::outputs.at(monitor->m_name)->destroyResource(this); PROTO::outputs.at(m_monitor->m_name)->destroyResource(this);
}); });
resource->setRelease([this](CWlOutput* r) { m_resource->setRelease([this](CWlOutput* r) {
if (monitor && PROTO::outputs.contains(monitor->m_name)) if (m_monitor && PROTO::outputs.contains(m_monitor->m_name))
PROTO::outputs.at(monitor->m_name)->destroyResource(this); PROTO::outputs.at(m_monitor->m_name)->destroyResource(this);
}); });
if (resource->version() >= 4) { if (m_resource->version() >= 4) {
resource->sendName(monitor->m_name.c_str()); m_resource->sendName(m_monitor->m_name.c_str());
resource->sendDescription(monitor->m_description.c_str()); m_resource->sendDescription(m_monitor->m_description.c_str());
} }
updateState(); updateState();
@ -52,72 +52,72 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonito
SP<CWLOutputResource> CWLOutputResource::fromResource(wl_resource* res) { SP<CWLOutputResource> CWLOutputResource::fromResource(wl_resource* res) {
auto data = (CWLOutputResource*)(((CWlOutput*)wl_resource_get_user_data(res))->data()); 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() { bool CWLOutputResource::good() {
return resource->resource(); return m_resource->resource();
} }
wl_client* CWLOutputResource::client() { wl_client* CWLOutputResource::client() {
return pClient; return m_client;
} }
SP<CWlOutput> CWLOutputResource::getResource() { SP<CWlOutput> CWLOutputResource::getResource() {
return resource; return m_resource;
} }
void CWLOutputResource::updateState() { void CWLOutputResource::updateState() {
if (!monitor || (owner && owner->defunct)) if (!m_monitor || (m_owner && m_owner->m_defunct))
return; return;
if (resource->version() >= 2) if (m_resource->version() >= 2)
resource->sendScale(std::ceil(monitor->m_scale)); 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, 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,
monitor->m_output->make.c_str(), monitor->m_output->model.c_str(), monitor->m_transform); m_monitor->m_output->make.c_str(), m_monitor->m_output->model.c_str(), m_monitor->m_transform);
if (resource->version() >= 2) if (m_resource->version() >= 2)
resource->sendDone(); m_resource->sendDone();
} }
CWLOutputProtocol::CWLOutputProtocol(const wl_interface* iface, const int& ver, const std::string& name, PHLMONITOR pMonitor) : 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) { m_listeners.modeChanged = m_monitor->m_events.modeChanged.registerListener([this](std::any d) {
for (auto const& o : m_vOutputs) { for (auto const& o : m_outputs) {
o->updateState(); o->updateState();
} }
}); });
} }
void CWLOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { 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."); Debug::log(WARN, "[wl_output] Binding a wl_output that's inert?? Possible client bug.");
const auto RESOURCE = m_vOutputs.emplace_back(makeShared<CWLOutputResource>(makeShared<CWlOutput>(client, ver, id), monitor.lock())); const auto RESOURCE = m_outputs.emplace_back(makeShared<CWLOutputResource>(makeShared<CWlOutput>(client, ver, id), m_monitor.lock()));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vOutputs.pop_back(); m_outputs.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
RESOURCE->owner = self; RESOURCE->m_owner = m_self;
} }
void CWLOutputProtocol::destroyResource(CWLOutputResource* resource) { 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) if (m_outputs.empty() && m_defunct)
PROTO::outputs.erase(szName); PROTO::outputs.erase(m_name);
} }
SP<CWLOutputResource> CWLOutputProtocol::outputResourceFrom(wl_client* client) { SP<CWLOutputResource> CWLOutputProtocol::outputResourceFrom(wl_client* client) {
for (auto const& r : m_vOutputs) { for (auto const& r : m_outputs) {
if (r->client() != client) if (r->client() != client)
continue; continue;
@ -128,22 +128,22 @@ SP<CWLOutputResource> CWLOutputProtocol::outputResourceFrom(wl_client* client) {
} }
void CWLOutputProtocol::remove() { void CWLOutputProtocol::remove() {
if UNLIKELY (defunct) if UNLIKELY (m_defunct)
return; return;
defunct = true; m_defunct = true;
removeGlobal(); removeGlobal();
} }
bool CWLOutputProtocol::isDefunct() { bool CWLOutputProtocol::isDefunct() {
return defunct; return m_defunct;
} }
void CWLOutputProtocol::sendDone() { void CWLOutputProtocol::sendDone() {
if UNLIKELY (defunct) if UNLIKELY (m_defunct)
return; return;
for (auto const& r : m_vOutputs) { for (auto const& r : m_outputs) {
r->resource->sendDone(); r->m_resource->sendDone();
} }
} }

View File

@ -19,13 +19,13 @@ class CWLOutputResource {
SP<CWlOutput> getResource(); SP<CWlOutput> getResource();
void updateState(); void updateState();
PHLMONITORREF monitor; PHLMONITORREF m_monitor;
WP<CWLOutputProtocol> owner; WP<CWLOutputProtocol> m_owner;
WP<CWLOutputResource> self; WP<CWLOutputResource> m_self;
private: private:
SP<CWlOutput> resource; SP<CWlOutput> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
friend class CWLOutputProtocol; friend class CWLOutputProtocol;
}; };
@ -39,8 +39,8 @@ class CWLOutputProtocol : public IWaylandProtocol {
SP<CWLOutputResource> outputResourceFrom(wl_client* client); SP<CWLOutputResource> outputResourceFrom(wl_client* client);
void sendDone(); void sendDone();
PHLMONITORREF monitor; PHLMONITORREF m_monitor;
WP<CWLOutputProtocol> self; WP<CWLOutputProtocol> 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) // 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(); void remove();
@ -50,13 +50,13 @@ class CWLOutputProtocol : public IWaylandProtocol {
void destroyResource(CWLOutputResource* resource); void destroyResource(CWLOutputResource* resource);
// //
std::vector<SP<CWLOutputResource>> m_vOutputs; std::vector<SP<CWLOutputResource>> m_outputs;
bool defunct = false; bool m_defunct = false;
std::string szName = ""; std::string m_name = "";
struct { struct {
CHyprSignalListener modeChanged; CHyprSignalListener modeChanged;
} listeners; } m_listeners;
friend class CWLOutputResource; friend class CWLOutputResource;
}; };

View File

@ -10,292 +10,292 @@
#include <fcntl.h> #include <fcntl.h>
CWLTouchResource::CWLTouchResource(SP<CWlTouch> resource_, SP<CWLSeatResource> owner_) : owner(owner_), resource(resource_) { CWLTouchResource::CWLTouchResource(SP<CWlTouch> resource_, SP<CWLSeatResource> owner_) : m_owner(owner_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setRelease([this](CWlTouch* r) { PROTO::seat->destroyResource(this); }); m_resource->setRelease([this](CWlTouch* r) { PROTO::seat->destroyResource(this); });
resource->setOnDestroy([this](CWlTouch* r) { PROTO::seat->destroyResource(this); }); m_resource->setOnDestroy([this](CWlTouch* r) { PROTO::seat->destroyResource(this); });
} }
bool CWLTouchResource::good() { bool CWLTouchResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CWLTouchResource::sendDown(SP<CWLSurfaceResource> surface, uint32_t timeMs, int32_t id, const Vector2D& local) { void CWLTouchResource::sendDown(SP<CWLSurfaceResource> surface, uint32_t timeMs, int32_t id, const Vector2D& local) {
if (!owner || !surface || !surface->getResource()->resource()) if (!m_owner || !surface || !surface->getResource()->resource())
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH))
return; return;
ASSERT(surface->client() == owner->client()); ASSERT(surface->client() == m_owner->client());
currentSurface = surface; m_currentSurface = surface;
listeners.destroySurface = surface->events.destroy.registerListener([this, timeMs, id](std::any d) { sendUp(timeMs + 10 /* hack */, id); }); 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) { void CWLTouchResource::sendUp(uint32_t timeMs, int32_t id) {
if (!owner) if (!m_owner)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH))
return; return;
resource->sendUp(g_pSeatManager->nextSerial(owner.lock()), timeMs, id); m_resource->sendUp(g_pSeatManager->nextSerial(m_owner.lock()), timeMs, id);
fingers--; m_fingers--;
if (fingers <= 0) { if (m_fingers <= 0) {
currentSurface.reset(); m_currentSurface.reset();
listeners.destroySurface.reset(); m_listeners.destroySurface.reset();
fingers = 0; m_fingers = 0;
} }
} }
void CWLTouchResource::sendMotion(uint32_t timeMs, int32_t id, const Vector2D& local) { void CWLTouchResource::sendMotion(uint32_t timeMs, int32_t id, const Vector2D& local) {
if (!owner) if (!m_owner)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH))
return; 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() { void CWLTouchResource::sendFrame() {
if (!owner) if (!m_owner)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH))
return; return;
resource->sendFrame(); m_resource->sendFrame();
} }
void CWLTouchResource::sendCancel() { void CWLTouchResource::sendCancel() {
if (!owner || !currentSurface) if (!m_owner || !m_currentSurface)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH))
return; return;
resource->sendCancel(); m_resource->sendCancel();
} }
void CWLTouchResource::sendShape(int32_t id, const Vector2D& shape) { 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; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH))
return; 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) { void CWLTouchResource::sendOrientation(int32_t id, double angle) {
if (!owner || !currentSurface || resource->version() < 6) if (!m_owner || !m_currentSurface || m_resource->version() < 6)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH))
return; return;
resource->sendOrientation(id, wl_fixed_from_double(angle)); m_resource->sendOrientation(id, wl_fixed_from_double(angle));
} }
CWLPointerResource::CWLPointerResource(SP<CWlPointer> resource_, SP<CWLSeatResource> owner_) : owner(owner_), resource(resource_) { CWLPointerResource::CWLPointerResource(SP<CWlPointer> resource_, SP<CWLSeatResource> owner_) : m_owner(owner_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setRelease([this](CWlPointer* r) { PROTO::seat->destroyResource(this); }); m_resource->setRelease([this](CWlPointer* r) { PROTO::seat->destroyResource(this); });
resource->setOnDestroy([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) { m_resource->setSetCursor([this](CWlPointer* r, uint32_t serial, wl_resource* surf, int32_t hotX, int32_t hotY) {
if (!owner) { if (!m_owner) {
LOGM(ERR, "Client bug: setCursor when seatClient is already dead"); LOGM(ERR, "Client bug: setCursor when seatClient is already dead");
return; return;
} }
auto surfResource = surf ? CWLSurfaceResource::fromResource(surf) : nullptr; 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"); r->error(-1, "Cursor surface already has a different role");
return; return;
} }
if (surfResource && surfResource->role->role() != SURFACE_ROLE_CURSOR) { if (surfResource && surfResource->m_role->role() != SURFACE_ROLE_CURSOR) {
surfResource->role = makeShared<CCursorSurfaceRole>(); surfResource->m_role = makeShared<CCursorSurfaceRole>();
surfResource->updateCursorShm(); 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 */); 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() { int CWLPointerResource::version() {
return resource->version(); return m_resource->version();
} }
bool CWLPointerResource::good() { bool CWLPointerResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CWLPointerResource::sendEnter(SP<CWLSurfaceResource> surface, const Vector2D& local) { void CWLPointerResource::sendEnter(SP<CWLSurfaceResource> surface, const Vector2D& local) {
if (!owner || currentSurface == surface || !surface->getResource()->resource()) if (!m_owner || m_currentSurface == surface || !surface->getResource()->resource())
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
if (currentSurface) { if (m_currentSurface) {
LOGM(WARN, "requested CWLPointerResource::sendEnter without sendLeave first."); LOGM(WARN, "requested CWLPointerResource::sendEnter without sendLeave first.");
sendLeave(); sendLeave();
} }
ASSERT(surface->client() == owner->client()); ASSERT(surface->client() == m_owner->client());
currentSurface = surface; m_currentSurface = surface;
listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { sendLeave(); }); 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() { void CWLPointerResource::sendLeave() {
if (!owner || !currentSurface || !currentSurface->getResource()->resource()) if (!m_owner || !m_currentSurface || !m_currentSurface->getResource()->resource())
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
// release all buttons unless we have a dnd going on in which case // release all buttons unless we have a dnd going on in which case
// the events shall be lost. // the events shall be lost.
if (!PROTO::data->dndActive()) { 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); 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()); m_resource->sendLeave(g_pSeatManager->nextSerial(m_owner.lock()), m_currentSurface->getResource().get());
currentSurface.reset(); m_currentSurface.reset();
listeners.destroySurface.reset(); m_listeners.destroySurface.reset();
} }
void CWLPointerResource::sendMotion(uint32_t timeMs, const Vector2D& local) { void CWLPointerResource::sendMotion(uint32_t timeMs, const Vector2D& local) {
if (!owner || !currentSurface) if (!m_owner || !m_currentSurface)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; 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) { void CWLPointerResource::sendButton(uint32_t timeMs, uint32_t button, wl_pointer_button_state state) {
if (!owner || !currentSurface) if (!m_owner || !m_currentSurface)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; 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"); LOGM(ERR, "sendButton release on a non-pressed button");
return; 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"); LOGM(ERR, "sendButton press on a non-pressed button");
return; return;
} }
if (state == WL_POINTER_BUTTON_STATE_RELEASED) if (state == WL_POINTER_BUTTON_STATE_RELEASED)
std::erase(pressedButtons, button); std::erase(m_pressedButtons, button);
else if (state == WL_POINTER_BUTTON_STATE_PRESSED) 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) { void CWLPointerResource::sendAxis(uint32_t timeMs, wl_pointer_axis axis, double value) {
if (!owner || !currentSurface) if (!m_owner || !m_currentSurface)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
resource->sendAxis(timeMs, axis, wl_fixed_from_double(value)); m_resource->sendAxis(timeMs, axis, wl_fixed_from_double(value));
} }
void CWLPointerResource::sendFrame() { void CWLPointerResource::sendFrame() {
if (!owner || resource->version() < 5) if (!m_owner || m_resource->version() < 5)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
resource->sendFrame(); m_resource->sendFrame();
} }
void CWLPointerResource::sendAxisSource(wl_pointer_axis_source source) { void CWLPointerResource::sendAxisSource(wl_pointer_axis_source source) {
if (!owner || !currentSurface || resource->version() < 5) if (!m_owner || !m_currentSurface || m_resource->version() < 5)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
resource->sendAxisSource(source); m_resource->sendAxisSource(source);
} }
void CWLPointerResource::sendAxisStop(uint32_t timeMs, wl_pointer_axis axis) { 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; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
resource->sendAxisStop(timeMs, axis); m_resource->sendAxisStop(timeMs, axis);
} }
void CWLPointerResource::sendAxisDiscrete(wl_pointer_axis axis, int32_t discrete) { 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; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
resource->sendAxisDiscrete(axis, discrete); m_resource->sendAxisDiscrete(axis, discrete);
} }
void CWLPointerResource::sendAxisValue120(wl_pointer_axis axis, int32_t value120) { 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; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
resource->sendAxisValue120(axis, value120); m_resource->sendAxisValue120(axis, value120);
} }
void CWLPointerResource::sendAxisRelativeDirection(wl_pointer_axis axis, wl_pointer_axis_relative_direction direction) { 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; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return; return;
resource->sendAxisRelativeDirection(axis, direction); m_resource->sendAxisRelativeDirection(axis, direction);
} }
CWLKeyboardResource::CWLKeyboardResource(SP<CWlKeyboard> resource_, SP<CWLSeatResource> owner_) : owner(owner_), resource(resource_) { CWLKeyboardResource::CWLKeyboardResource(SP<CWlKeyboard> resource_, SP<CWLSeatResource> owner_) : m_owner(owner_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setRelease([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); }); m_resource->setRelease([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); });
resource->setOnDestroy([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); }); m_resource->setOnDestroy([this](CWlKeyboard* r) { PROTO::seat->destroyResource(this); });
if (!g_pSeatManager->m_keyboard) { if (!g_pSeatManager->m_keyboard) {
LOGM(ERR, "No keyboard on bound wl_keyboard??"); LOGM(ERR, "No keyboard on bound wl_keyboard??");
@ -305,160 +305,160 @@ CWLKeyboardResource::CWLKeyboardResource(SP<CWlKeyboard> resource_, SP<CWLSeatRe
sendKeymap(g_pSeatManager->m_keyboard.lock()); sendKeymap(g_pSeatManager->m_keyboard.lock());
repeatInfo(g_pSeatManager->m_keyboard->m_repeatRate, g_pSeatManager->m_keyboard->m_repeatDelay); 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()); sendEnter(g_pSeatManager->m_state.keyboardFocus.lock());
} }
bool CWLKeyboardResource::good() { bool CWLKeyboardResource::good() {
return resource->resource(); return m_resource->resource();
} }
void CWLKeyboardResource::sendKeymap(SP<IKeyboard> keyboard) { void CWLKeyboardResource::sendKeymap(SP<IKeyboard> keyboard) {
if (!keyboard) if (!keyboard)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD))
return; return;
std::string_view keymap = keyboard->m_xkbKeymapString; std::string_view keymap = keyboard->m_xkbKeymapString;
Hyprutils::OS::CFileDescriptor& fd = keyboard->m_xkbKeymapFD; Hyprutils::OS::CFileDescriptor& fd = keyboard->m_xkbKeymapFD;
uint32_t size = keyboard->m_xkbKeymapString.length() + 1; uint32_t size = keyboard->m_xkbKeymapString.length() + 1;
if (keymap == lastKeymap) if (keymap == m_lastKeymap)
return; 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; 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<CWLSurfaceResource> surface) { void CWLKeyboardResource::sendEnter(SP<CWLSurfaceResource> surface) {
if (!owner || currentSurface == surface || !surface->getResource()->resource()) if (!m_owner || m_currentSurface == surface || !surface->getResource()->resource())
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD))
return; return;
if (currentSurface) { if (m_currentSurface) {
LOGM(WARN, "requested CWLKeyboardResource::sendEnter without sendLeave first."); LOGM(WARN, "requested CWLKeyboardResource::sendEnter without sendLeave first.");
sendLeave(); sendLeave();
} }
ASSERT(surface->client() == owner->client()); ASSERT(surface->client() == m_owner->client());
currentSurface = surface; m_currentSurface = surface;
listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) { sendLeave(); }); m_listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { sendLeave(); });
wl_array arr; wl_array arr;
wl_array_init(&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); wl_array_release(&arr);
} }
void CWLKeyboardResource::sendLeave() { void CWLKeyboardResource::sendLeave() {
if (!owner || !currentSurface || !currentSurface->getResource()->resource()) if (!m_owner || !m_currentSurface || !m_currentSurface->getResource()->resource())
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD))
return; return;
resource->sendLeave(g_pSeatManager->nextSerial(owner.lock()), currentSurface->getResource().get()); m_resource->sendLeave(g_pSeatManager->nextSerial(m_owner.lock()), m_currentSurface->getResource().get());
currentSurface.reset(); m_currentSurface.reset();
listeners.destroySurface.reset(); m_listeners.destroySurface.reset();
} }
void CWLKeyboardResource::sendKey(uint32_t timeMs, uint32_t key, wl_keyboard_key_state state) { void CWLKeyboardResource::sendKey(uint32_t timeMs, uint32_t key, wl_keyboard_key_state state) {
if (!owner || !currentSurface) if (!m_owner || !m_currentSurface)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD))
return; 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) { void CWLKeyboardResource::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
if (!owner || !currentSurface) if (!m_owner || !m_currentSurface)
return; return;
if (!(PROTO::seat->currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD))
return; 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) { 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; return;
lastRate = rate; m_lastRate = rate;
lastDelayMs = delayMs; m_lastDelayMs = delayMs;
resource->sendRepeatInfo(rate, delayMs); m_resource->sendRepeatInfo(rate, delayMs);
} }
CWLSeatResource::CWLSeatResource(SP<CWlSeat> resource_) : resource(resource_) { CWLSeatResource::CWLSeatResource(SP<CWlSeat> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWlSeat* r) { m_resource->setOnDestroy([this](CWlSeat* r) {
events.destroy.emit(); m_events.destroy.emit();
PROTO::seat->destroyResource(this); PROTO::seat->destroyResource(this);
}); });
resource->setRelease([this](CWlSeat* r) { m_resource->setRelease([this](CWlSeat* r) {
events.destroy.emit(); m_events.destroy.emit();
PROTO::seat->destroyResource(this); PROTO::seat->destroyResource(this);
}); });
pClient = resource->client(); m_client = m_resource->client();
resource->setGetKeyboard([this](CWlSeat* r, uint32_t id) { m_resource->setGetKeyboard([this](CWlSeat* r, uint32_t id) {
const auto RESOURCE = PROTO::seat->m_vKeyboards.emplace_back(makeShared<CWLKeyboardResource>(makeShared<CWlKeyboard>(r->client(), r->version(), id), self.lock())); const auto RESOURCE = PROTO::seat->m_keyboards.emplace_back(makeShared<CWLKeyboardResource>(makeShared<CWlKeyboard>(r->client(), r->version(), id), m_self.lock()));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::seat->m_vKeyboards.pop_back(); PROTO::seat->m_keyboards.pop_back();
return; return;
} }
keyboards.emplace_back(RESOURCE); m_keyboards.emplace_back(RESOURCE);
}); });
resource->setGetPointer([this](CWlSeat* r, uint32_t id) { m_resource->setGetPointer([this](CWlSeat* r, uint32_t id) {
const auto RESOURCE = PROTO::seat->m_vPointers.emplace_back(makeShared<CWLPointerResource>(makeShared<CWlPointer>(r->client(), r->version(), id), self.lock())); const auto RESOURCE = PROTO::seat->m_pointers.emplace_back(makeShared<CWLPointerResource>(makeShared<CWlPointer>(r->client(), r->version(), id), m_self.lock()));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::seat->m_vPointers.pop_back(); PROTO::seat->m_pointers.pop_back();
return; return;
} }
pointers.emplace_back(RESOURCE); m_pointers.emplace_back(RESOURCE);
}); });
resource->setGetTouch([this](CWlSeat* r, uint32_t id) { m_resource->setGetTouch([this](CWlSeat* r, uint32_t id) {
const auto RESOURCE = PROTO::seat->m_vTouches.emplace_back(makeShared<CWLTouchResource>(makeShared<CWlTouch>(r->client(), r->version(), id), self.lock())); const auto RESOURCE = PROTO::seat->m_touches.emplace_back(makeShared<CWLTouchResource>(makeShared<CWlTouch>(r->client(), r->version(), id), m_self.lock()));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::seat->m_vTouches.pop_back(); PROTO::seat->m_touches.pop_back();
return; return;
} }
touches.emplace_back(RESOURCE); m_touches.emplace_back(RESOURCE);
}); });
if (resource->version() >= 2) if (m_resource->version() >= 2)
resource->sendName(HL_SEAT_NAME); m_resource->sendName(HL_SEAT_NAME);
sendCapabilities(PROTO::seat->currentCaps); sendCapabilities(PROTO::seat->m_currentCaps);
} }
CWLSeatResource::~CWLSeatResource() { CWLSeatResource::~CWLSeatResource() {
events.destroy.emit(); m_events.destroy.emit();
} }
void CWLSeatResource::sendCapabilities(uint32_t caps) { void CWLSeatResource::sendCapabilities(uint32_t caps) {
@ -470,15 +470,15 @@ void CWLSeatResource::sendCapabilities(uint32_t caps) {
if (caps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH) if (caps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)
wlCaps |= WL_SEAT_CAPABILITY_TOUCH; wlCaps |= WL_SEAT_CAPABILITY_TOUCH;
resource->sendCapabilities((wl_seat_capability)wlCaps); m_resource->sendCapabilities((wl_seat_capability)wlCaps);
} }
bool CWLSeatResource::good() { bool CWLSeatResource::good() {
return resource->resource(); return m_resource->resource();
} }
wl_client* CWLSeatResource::client() { 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) { 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) { void CWLSeatProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vSeatResources.emplace_back(makeShared<CWLSeatResource>(makeShared<CWlSeat>(client, ver, id))); const auto RESOURCE = m_seatResources.emplace_back(makeShared<CWLSeatResource>(makeShared<CWlSeat>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vSeatResources.pop_back(); m_seatResources.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
LOGM(LOG, "New seat resource bound at {:x}", (uintptr_t)RESOURCE.get()); 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) { 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) { 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) { 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) { 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) { void CWLSeatProtocol::updateCapabilities(uint32_t caps) {
if (caps == currentCaps) if (caps == m_currentCaps)
return; return;
currentCaps = caps; m_currentCaps = caps;
for (auto const& s : m_vSeatResources) { for (auto const& s : m_seatResources) {
s->sendCapabilities(caps); s->sendCapabilities(caps);
} }
} }
void CWLSeatProtocol::updateKeymap() { void CWLSeatProtocol::updateKeymap() {
if (!(currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD)) if (!(m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_KEYBOARD))
return; return;
for (auto const& k : m_vKeyboards) { for (auto const& k : m_keyboards) {
k->sendKeymap(g_pSeatManager->m_keyboard.lock()); k->sendKeymap(g_pSeatManager->m_keyboard.lock());
} }
} }
void CWLSeatProtocol::updateRepeatInfo(uint32_t rate, uint32_t delayMs) { 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; return;
for (auto const& k : m_vKeyboards) { for (auto const& k : m_keyboards) {
k->repeatInfo(rate, delayMs); k->repeatInfo(rate, delayMs);
} }
} }
SP<CWLSeatResource> CWLSeatProtocol::seatResourceForClient(wl_client* client) { SP<CWLSeatResource> CWLSeatProtocol::seatResourceForClient(wl_client* client) {
for (auto const& r : m_vSeatResources) { for (auto const& r : m_seatResources) {
if (r->client() == client) if (r->client() == client)
return r; return r;
} }
@ -556,8 +556,8 @@ SP<CWLSeatResource> CWLSeatProtocol::seatResourceForClient(wl_client* client) {
} }
std::vector<uint8_t>& CCursorSurfaceRole::cursorPixelData(SP<CWLSurfaceResource> surface) { std::vector<uint8_t>& CCursorSurfaceRole::cursorPixelData(SP<CWLSurfaceResource> 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(); auto role = (CCursorSurfaceRole*)surface->m_role.get();
return role->cursorShmPixelData; return role->m_cursorShmPixelData;
} }

View File

@ -38,7 +38,7 @@ class CCursorSurfaceRole : public ISurfaceRole {
static std::vector<uint8_t>& cursorPixelData(SP<CWLSurfaceResource> surface); static std::vector<uint8_t>& cursorPixelData(SP<CWLSurfaceResource> surface);
private: private:
std::vector<uint8_t> cursorShmPixelData; std::vector<uint8_t> m_cursorShmPixelData;
}; };
class CWLTouchResource { class CWLTouchResource {
@ -54,17 +54,17 @@ class CWLTouchResource {
void sendShape(int32_t id, const Vector2D& shape); void sendShape(int32_t id, const Vector2D& shape);
void sendOrientation(int32_t id, double angle); void sendOrientation(int32_t id, double angle);
WP<CWLSeatResource> owner; WP<CWLSeatResource> m_owner;
private: private:
SP<CWlTouch> resource; SP<CWlTouch> m_resource;
WP<CWLSurfaceResource> currentSurface; WP<CWLSurfaceResource> m_currentSurface;
int fingers = 0; int m_fingers = 0;
struct { struct {
CHyprSignalListener destroySurface; CHyprSignalListener destroySurface;
} listeners; } m_listeners;
}; };
class CWLPointerResource { class CWLPointerResource {
@ -85,17 +85,17 @@ class CWLPointerResource {
void sendAxisValue120(wl_pointer_axis axis, int32_t value120); void sendAxisValue120(wl_pointer_axis axis, int32_t value120);
void sendAxisRelativeDirection(wl_pointer_axis axis, wl_pointer_axis_relative_direction direction); void sendAxisRelativeDirection(wl_pointer_axis axis, wl_pointer_axis_relative_direction direction);
WP<CWLSeatResource> owner; WP<CWLSeatResource> m_owner;
private: private:
SP<CWlPointer> resource; SP<CWlPointer> m_resource;
WP<CWLSurfaceResource> currentSurface; WP<CWLSurfaceResource> m_currentSurface;
std::vector<uint32_t> pressedButtons; std::vector<uint32_t> m_pressedButtons;
struct { struct {
CHyprSignalListener destroySurface; CHyprSignalListener destroySurface;
} listeners; } m_listeners;
}; };
class CWLKeyboardResource { class CWLKeyboardResource {
@ -110,19 +110,19 @@ class CWLKeyboardResource {
void sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group); void sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
void repeatInfo(uint32_t rate, uint32_t delayMs); void repeatInfo(uint32_t rate, uint32_t delayMs);
WP<CWLSeatResource> owner; WP<CWLSeatResource> m_owner;
private: private:
SP<CWlKeyboard> resource; SP<CWlKeyboard> m_resource;
WP<CWLSurfaceResource> currentSurface; WP<CWLSurfaceResource> m_currentSurface;
struct { struct {
CHyprSignalListener destroySurface; CHyprSignalListener destroySurface;
} listeners; } m_listeners;
std::string lastKeymap = "<none>"; std::string m_lastKeymap = "<none>";
uint32_t lastRate = 0; uint32_t m_lastRate = 0;
uint32_t lastDelayMs = 0; uint32_t m_lastDelayMs = 0;
}; };
class CWLSeatResource { class CWLSeatResource {
@ -135,19 +135,19 @@ class CWLSeatResource {
bool good(); bool good();
wl_client* client(); wl_client* client();
std::vector<WP<CWLPointerResource>> pointers; std::vector<WP<CWLPointerResource>> m_pointers;
std::vector<WP<CWLKeyboardResource>> keyboards; std::vector<WP<CWLKeyboardResource>> m_keyboards;
std::vector<WP<CWLTouchResource>> touches; std::vector<WP<CWLTouchResource>> m_touches;
WP<CWLSeatResource> self; WP<CWLSeatResource> m_self;
struct { struct {
CSignal destroy; CSignal destroy;
} events; } m_events;
private: private:
SP<CWlSeat> resource; SP<CWlSeat> m_resource;
wl_client* pClient = nullptr; wl_client* m_client = nullptr;
}; };
class CWLSeatProtocol : public IWaylandProtocol { class CWLSeatProtocol : public IWaylandProtocol {
@ -158,7 +158,7 @@ class CWLSeatProtocol : public IWaylandProtocol {
struct { struct {
CSignal newSeatResource; // SP<CWLSeatResource> CSignal newSeatResource; // SP<CWLSeatResource>
} events; } m_events;
private: private:
void updateCapabilities(uint32_t caps); // in IHID caps void updateCapabilities(uint32_t caps); // in IHID caps
@ -171,15 +171,15 @@ class CWLSeatProtocol : public IWaylandProtocol {
void destroyResource(CWLPointerResource* resource); void destroyResource(CWLPointerResource* resource);
// //
std::vector<SP<CWLSeatResource>> m_vSeatResources; std::vector<SP<CWLSeatResource>> m_seatResources;
std::vector<SP<CWLKeyboardResource>> m_vKeyboards; std::vector<SP<CWLKeyboardResource>> m_keyboards;
std::vector<SP<CWLTouchResource>> m_vTouches; std::vector<SP<CWLTouchResource>> m_touches;
std::vector<SP<CWLPointerResource>> m_vPointers; std::vector<SP<CWLPointerResource>> m_pointers;
SP<CWLSeatResource> seatResourceForClient(wl_client* client); SP<CWLSeatResource> seatResourceForClient(wl_client* client);
// //
uint32_t currentCaps = 0; uint32_t m_currentCaps = 0;
friend class CWLSeatResource; friend class CWLSeatResource;
friend class CWLKeyboardResource; friend class CWLKeyboardResource;

View File

@ -10,22 +10,22 @@
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
CWLSHMBuffer::CWLSHMBuffer(SP<CWLSHMPoolResource> pool_, uint32_t id, int32_t offset_, const Vector2D& size_, int32_t stride_, uint32_t fmt_) { CWLSHMBuffer::CWLSHMBuffer(SP<CWLSHMPoolResource> 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; return;
g_pHyprRenderer->makeEGLCurrent(); g_pHyprRenderer->makeEGLCurrent();
size = size_; size = size_;
pool = pool_->pool; m_pool = pool_->m_pool;
stride = stride_; m_stride = stride_;
fmt = fmt_; m_fmt = fmt_;
offset = offset_; m_offset = offset_;
opaque = NFormatUtils::isFormatOpaque(NFormatUtils::shmToDRM(fmt_)); opaque = NFormatUtils::isFormatOpaque(NFormatUtils::shmToDRM(fmt_));
resource = CWLBufferResource::create(makeShared<CWlBuffer>(pool_->resource->client(), 1, id)); resource = CWLBufferResource::create(makeShared<CWlBuffer>(pool_->m_resource->client(), 1, id));
listeners.bufferResourceDestroy = events.destroy.registerListener([this](std::any d) { m_listeners.bufferResourceDestroy = events.destroy.registerListener([this](std::any d) {
listeners.bufferResourceDestroy.reset(); m_listeners.bufferResourceDestroy.reset();
PROTO::shm->destroyResource(this); PROTO::shm->destroyResource(this);
}); });
} }
@ -50,16 +50,16 @@ bool CWLSHMBuffer::isSynchronous() {
Aquamarine::SSHMAttrs CWLSHMBuffer::shm() { Aquamarine::SSHMAttrs CWLSHMBuffer::shm() {
Aquamarine::SSHMAttrs attrs; Aquamarine::SSHMAttrs attrs;
attrs.success = true; attrs.success = true;
attrs.fd = pool->fd.get(); attrs.fd = m_pool->m_fd.get();
attrs.format = NFormatUtils::shmToDRM(fmt); attrs.format = NFormatUtils::shmToDRM(m_fmt);
attrs.size = size; attrs.size = size;
attrs.stride = stride; attrs.stride = m_stride;
attrs.offset = offset; attrs.offset = m_offset;
return attrs; return attrs;
} }
std::tuple<uint8_t*, uint32_t, size_t> CWLSHMBuffer::beginDataPtr(uint32_t flags) { std::tuple<uint8_t*, uint32_t, size_t> 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() { 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() { CSHMPool::~CSHMPool() {
munmap(data, size); munmap(m_data, m_size);
} }
void CSHMPool::resize(size_t 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) if (m_data)
munmap(data, size); munmap(m_data, m_size);
size = size_; m_size = size_;
data = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd.get(), 0); m_data = mmap(nullptr, m_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd.get(), 0);
if UNLIKELY (data == MAP_FAILED) if UNLIKELY (m_data == MAP_FAILED)
LOGM(ERR, "Couldn't mmap {} bytes from fd {} of shm client", size, fd.get()); LOGM(ERR, "Couldn't mmap {} bytes from fd {} of shm client", m_size, m_fd.get());
} }
static int shmIsSizeValid(CFileDescriptor& fd, size_t size) { 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; return (size_t)st.st_size >= size;
} }
CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor fd_, size_t size_) : resource(resource_) { CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor fd_, size_t size_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
@ -113,31 +113,31 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor
return; return;
} }
pool = makeShared<CSHMPool>(std::move(fd_), size_); m_pool = makeShared<CSHMPool>(std::move(fd_), size_);
resource->setDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); }); m_resource->setDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); });
resource->setOnDestroy([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_) { m_resource->setResize([this](CWlShmPool* r, int32_t size_) {
if UNLIKELY (size_ < (int32_t)pool->size) { if UNLIKELY (size_ < (int32_t)m_pool->m_size) {
r->error(-1, "Shrinking a shm pool is illegal"); r->error(-1, "Shrinking a shm pool is illegal");
return; 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"); r->error(-1, "The size of the file is not big enough for the shm pool");
return; 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) { 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 (!pool || !pool->data) { if UNLIKELY (!m_pool || !m_pool->m_data) {
r->error(-1, "The provided shm pool failed to allocate properly"); r->error(-1, "The provided shm pool failed to allocate properly");
return; 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"); r->error(WL_SHM_ERROR_INVALID_FORMAT, "Format invalid");
return; return;
} }
@ -147,11 +147,11 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor
return; return;
} }
const auto RESOURCE = PROTO::shm->m_vBuffers.emplace_back(makeShared<CWLSHMBuffer>(self.lock(), id, offset, Vector2D{w, h}, stride, fmt)); const auto RESOURCE = PROTO::shm->m_buffers.emplace_back(makeShared<CWLSHMBuffer>(m_self.lock(), id, offset, Vector2D{w, h}, stride, fmt));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::shm->m_vBuffers.pop_back(); PROTO::shm->m_buffers.pop_back();
return; return;
} }
@ -159,41 +159,41 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor
RESOURCE->resource->buffer = RESOURCE; RESOURCE->resource->buffer = RESOURCE;
}); });
if UNLIKELY (pool->data == MAP_FAILED) if UNLIKELY (m_pool->m_data == MAP_FAILED)
resource->error(WL_SHM_ERROR_INVALID_FD, "Couldn't mmap from fd"); m_resource->error(WL_SHM_ERROR_INVALID_FD, "Couldn't mmap from fd");
} }
bool CWLSHMPoolResource::good() { bool CWLSHMPoolResource::good() {
return resource->resource(); return m_resource->resource();
} }
CWLSHMResource::CWLSHMResource(SP<CWlShm> resource_) : resource(resource_) { CWLSHMResource::CWLSHMResource(SP<CWlShm> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; 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}; CFileDescriptor poolFd{fd};
const auto RESOURCE = PROTO::shm->m_vPools.emplace_back(makeShared<CWLSHMPoolResource>(makeShared<CWlShmPool>(r->client(), r->version(), id), std::move(poolFd), size)); const auto RESOURCE = PROTO::shm->m_pools.emplace_back(makeShared<CWLSHMPoolResource>(makeShared<CWlShmPool>(r->client(), r->version(), id), std::move(poolFd), size));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::shm->m_vPools.pop_back(); PROTO::shm->m_pools.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
}); });
// send a few supported formats. No need for any other I think? // send a few supported formats. No need for any other I think?
for (auto const& s : PROTO::shm->shmFormats) { for (auto const& s : PROTO::shm->m_shmFormats) {
resource->sendFormat((wl_shm_format)s); m_resource->sendFormat((wl_shm_format)s);
} }
} }
bool CWLSHMResource::good() { 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) { 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) { void CWLSHMProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
if (shmFormats.empty()) { if (m_shmFormats.empty()) {
shmFormats.push_back(WL_SHM_FORMAT_ARGB8888); m_shmFormats.push_back(WL_SHM_FORMAT_ARGB8888);
shmFormats.push_back(WL_SHM_FORMAT_XRGB8888); m_shmFormats.push_back(WL_SHM_FORMAT_XRGB8888);
static const std::array<DRMFormat, 6> supportedShmFourccFormats = { static const std::array<DRMFormat, 6> supportedShmFourccFormats = {
DRM_FORMAT_XBGR8888, DRM_FORMAT_ABGR8888, DRM_FORMAT_XRGB2101010, DRM_FORMAT_ARGB2101010, DRM_FORMAT_XBGR2101010, DRM_FORMAT_ABGR2101010, DRM_FORMAT_XBGR8888, DRM_FORMAT_ABGR8888, DRM_FORMAT_XRGB2101010, DRM_FORMAT_ARGB2101010, DRM_FORMAT_XBGR2101010, DRM_FORMAT_ABGR2101010,
}; };
for (auto const& fmt : supportedShmFourccFormats) { for (auto const& fmt : supportedShmFourccFormats) {
shmFormats.push_back(fmt); m_shmFormats.push_back(fmt);
} }
} }
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CWLSHMResource>(makeShared<CWlShm>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CWLSHMResource>(makeShared<CWlShm>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CWLSHMProtocol::destroyResource(CWLSHMResource* resource) { 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) { 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) { 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; });
} }

View File

@ -23,9 +23,9 @@ class CSHMPool {
CSHMPool(Hyprutils::OS::CFileDescriptor fd, size_t size); CSHMPool(Hyprutils::OS::CFileDescriptor fd, size_t size);
~CSHMPool(); ~CSHMPool();
Hyprutils::OS::CFileDescriptor fd; Hyprutils::OS::CFileDescriptor m_fd;
size_t size = 0; size_t m_size = 0;
void* data = nullptr; void* m_data = nullptr;
void resize(size_t size); void resize(size_t size);
}; };
@ -45,14 +45,15 @@ class CWLSHMBuffer : public IHLBuffer {
bool good(); bool good();
int32_t offset = 0, stride = 0; int32_t m_offset = 0;
uint32_t fmt = 0; int32_t m_stride = 0;
SP<CSHMPool> pool; uint32_t m_fmt = 0;
SP<CSHMPool> m_pool;
private: private:
struct { struct {
CHyprSignalListener bufferResourceDestroy; CHyprSignalListener bufferResourceDestroy;
} listeners; } m_listeners;
}; };
class CWLSHMPoolResource { class CWLSHMPoolResource {
@ -61,12 +62,12 @@ class CWLSHMPoolResource {
bool good(); bool good();
SP<CSHMPool> pool; SP<CSHMPool> m_pool;
WP<CWLSHMPoolResource> self; WP<CWLSHMPoolResource> m_self;
private: private:
SP<CWlShmPool> resource; SP<CWlShmPool> m_resource;
friend class CWLSHMBuffer; friend class CWLSHMBuffer;
}; };
@ -78,7 +79,7 @@ class CWLSHMResource {
bool good(); bool good();
private: private:
SP<CWlShm> resource; SP<CWlShm> m_resource;
}; };
class CWLSHMProtocol : public IWaylandProtocol { class CWLSHMProtocol : public IWaylandProtocol {
@ -93,12 +94,12 @@ class CWLSHMProtocol : public IWaylandProtocol {
void destroyResource(CWLSHMBuffer* resource); void destroyResource(CWLSHMBuffer* resource);
// //
std::vector<SP<CWLSHMResource>> m_vManagers; std::vector<SP<CWLSHMResource>> m_managers;
std::vector<SP<CWLSHMPoolResource>> m_vPools; std::vector<SP<CWLSHMPoolResource>> m_pools;
std::vector<SP<CWLSHMBuffer>> m_vBuffers; std::vector<SP<CWLSHMBuffer>> m_buffers;
// //
std::vector<uint32_t> shmFormats; std::vector<uint32_t> m_shmFormats;
friend class CWLSHMResource; friend class CWLSHMResource;
friend class CWLSHMPoolResource; friend class CWLSHMPoolResource;

View File

@ -3,154 +3,154 @@
#include <algorithm> #include <algorithm>
CWLSubsurfaceResource::CWLSubsurfaceResource(SP<CWlSubsurface> resource_, SP<CWLSurfaceResource> surface_, SP<CWLSurfaceResource> parent_) : CWLSubsurfaceResource::CWLSubsurfaceResource(SP<CWlSubsurface> resource_, SP<CWLSurfaceResource> surface_, SP<CWLSurfaceResource> parent_) :
surface(surface_), parent(parent_), resource(resource_) { m_surface(surface_), m_parent(parent_), m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWlSubsurface* r) { destroy(); }); m_resource->setOnDestroy([this](CWlSubsurface* r) { destroy(); });
resource->setDestroy([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; }); m_resource->setSetDesync([this](CWlSubsurface* r) { m_sync = false; });
resource->setSetSync([this](CWlSubsurface* r) { sync = true; }); 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); auto SURF = CWLSurfaceResource::fromResource(surf);
if (!parent) if (!m_parent)
return; return;
auto pushAboveIndex = [this](int idx) -> void { auto pushAboveIndex = [this](int idx) -> void {
for (auto const& c : parent->subsurfaces) { for (auto const& c : m_parent->m_subsurfaces) {
if (c->zIndex >= idx) if (c->m_zIndex >= idx)
c->zIndex++; 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"); LOGM(ERR, "Invalid surface reference in placeAbove, likely parent");
pushAboveIndex(1); pushAboveIndex(1);
parent->subsurfaces.emplace_back(self); m_parent->m_subsurfaces.emplace_back(m_self);
zIndex = 1; m_zIndex = 1;
} else { } else {
pushAboveIndex((*it)->zIndex); pushAboveIndex((*it)->m_zIndex);
zIndex = (*it)->zIndex; m_zIndex = (*it)->m_zIndex;
parent->subsurfaces.emplace_back(self); 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); auto SURF = CWLSurfaceResource::fromResource(surf);
if (!parent) if (!m_parent)
return; return;
auto pushBelowIndex = [this](int idx) -> void { auto pushBelowIndex = [this](int idx) -> void {
for (auto const& c : parent->subsurfaces) { for (auto const& c : m_parent->m_subsurfaces) {
if (c->zIndex <= idx) if (c->m_zIndex <= idx)
c->zIndex--; 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"); LOGM(ERR, "Invalid surface reference in placeBelow, likely parent");
pushBelowIndex(-1); pushBelowIndex(-1);
parent->subsurfaces.emplace_back(self); m_parent->m_subsurfaces.emplace_back(m_self);
zIndex = -1; m_zIndex = -1;
} else { } else {
pushBelowIndex((*it)->zIndex); pushBelowIndex((*it)->m_zIndex);
zIndex = (*it)->zIndex; m_zIndex = (*it)->m_zIndex;
parent->subsurfaces.emplace_back(self); 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) { m_listeners.commitSurface = m_surface->m_events.commit.registerListener([this](std::any d) {
if (surface->current.texture && !surface->mapped) { if (m_surface->m_current.texture && !m_surface->m_mapped) {
surface->map(); m_surface->map();
surface->events.map.emit(); m_surface->m_events.map.emit();
return; return;
} }
if (!surface->current.texture && surface->mapped) { if (!m_surface->m_current.texture && m_surface->m_mapped) {
surface->events.unmap.emit(); m_surface->m_events.unmap.emit();
surface->unmap(); m_surface->unmap();
return; return;
} }
}); });
} }
CWLSubsurfaceResource::~CWLSubsurfaceResource() { CWLSubsurfaceResource::~CWLSubsurfaceResource() {
events.destroy.emit(); m_events.destroy.emit();
if (surface) if (m_surface)
surface->resetRole(); m_surface->resetRole();
} }
void CWLSubsurfaceResource::destroy() { void CWLSubsurfaceResource::destroy() {
if (surface && surface->mapped) { if (m_surface && m_surface->m_mapped) {
surface->events.unmap.emit(); m_surface->m_events.unmap.emit();
surface->unmap(); m_surface->unmap();
} }
events.destroy.emit(); m_events.destroy.emit();
PROTO::subcompositor->destroyResource(this); PROTO::subcompositor->destroyResource(this);
} }
Vector2D CWLSubsurfaceResource::posRelativeToParent() { Vector2D CWLSubsurfaceResource::posRelativeToParent() {
Vector2D pos = position; Vector2D pos = m_position;
SP<CWLSurfaceResource> surf = parent.lock(); SP<CWLSurfaceResource> surf = m_parent.lock();
// some apps might create cycles, which I believe _technically_ are not a protocol error // 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 // 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. // surfaces we've visited and if we hit a surface we've visited we bail out.
std::vector<SP<CWLSurfaceResource>> surfacesVisited; std::vector<SP<CWLSurfaceResource>> 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()) { std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf); surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock(); auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock();
pos += subsurface->position; pos += subsurface->m_position;
surf = subsurface->parent.lock(); surf = subsurface->m_parent.lock();
} }
return pos; return pos;
} }
bool CWLSubsurfaceResource::good() { bool CWLSubsurfaceResource::good() {
return resource->resource(); return m_resource->resource();
} }
SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() { SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
SP<CWLSurfaceResource> surf = parent.lock(); SP<CWLSurfaceResource> surf = m_parent.lock();
std::vector<SP<CWLSurfaceResource>> surfacesVisited; std::vector<SP<CWLSurfaceResource>> 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()) { std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf); surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock(); auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock();
surf = subsurface->parent.lock(); surf = subsurface->m_parent.lock();
} }
return surf; return surf;
} }
CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource_) : resource(resource_) { CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource_) : m_resource(resource_) {
if UNLIKELY (!good()) if UNLIKELY (!good())
return; return;
resource->setOnDestroy([this](CWlSubcompositor* r) { PROTO::subcompositor->destroyResource(this); }); m_resource->setOnDestroy([this](CWlSubcompositor* r) { PROTO::subcompositor->destroyResource(this); });
resource->setDestroy([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 SURF = CWLSurfaceResource::fromResource(surface);
auto PARENT = CWLSurfaceResource::fromResource(parent); auto PARENT = CWLSurfaceResource::fromResource(parent);
@ -159,15 +159,15 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
return; 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"); r->error(-1, "Surface already has a different role");
return; return;
} }
SP<CWLSurfaceResource> t1Parent = nullptr; SP<CWLSurfaceResource> t1Parent = nullptr;
if (PARENT->role->role() == SURFACE_ROLE_SUBSURFACE) { if (PARENT->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)PARENT->role.get())->subsurface.lock(); auto subsurface = ((CSubsurfaceRole*)PARENT->m_role.get())->m_subsurface.lock();
t1Parent = subsurface->t1Parent(); t1Parent = subsurface->t1Parent();
} else } else
t1Parent = PARENT; t1Parent = PARENT;
@ -178,26 +178,26 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
} }
const auto RESOURCE = const auto RESOURCE =
PROTO::subcompositor->m_vSurfaces.emplace_back(makeShared<CWLSubsurfaceResource>(makeShared<CWlSubsurface>(r->client(), r->version(), id), SURF, PARENT)); PROTO::subcompositor->m_surfaces.emplace_back(makeShared<CWLSubsurfaceResource>(makeShared<CWlSubsurface>(r->client(), r->version(), id), SURF, PARENT));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
r->noMemory(); r->noMemory();
PROTO::subcompositor->m_vSurfaces.pop_back(); PROTO::subcompositor->m_surfaces.pop_back();
return; return;
} }
RESOURCE->self = RESOURCE; RESOURCE->m_self = RESOURCE;
SURF->role = makeShared<CSubsurfaceRole>(RESOURCE); SURF->m_role = makeShared<CSubsurfaceRole>(RESOURCE);
PARENT->subsurfaces.emplace_back(RESOURCE); PARENT->m_subsurfaces.emplace_back(RESOURCE);
LOGM(LOG, "New wl_subsurface with id {} at {:x}", id, (uintptr_t)RESOURCE.get()); 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() { 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) { 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) { void CWLSubcompositorProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CWLSubcompositorResource>(makeShared<CWlSubcompositor>(client, ver, id))); const auto RESOURCE = m_managers.emplace_back(makeShared<CWLSubcompositorResource>(makeShared<CWlSubcompositor>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) { if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
m_vManagers.pop_back(); m_managers.pop_back();
return; return;
} }
} }
void CWLSubcompositorProtocol::destroyResource(CWLSubcompositorResource* resource) { 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) { 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<CWLSubsurfaceResource> sub) : subsurface(sub) { CSubsurfaceRole::CSubsurfaceRole(SP<CWLSubsurfaceResource> sub) : m_subsurface(sub) {
; ;
} }

View File

@ -25,7 +25,7 @@ class CSubsurfaceRole : public ISurfaceRole {
return SURFACE_ROLE_SUBSURFACE; return SURFACE_ROLE_SUBSURFACE;
} }
WP<CWLSubsurfaceResource> subsurface; WP<CWLSubsurfaceResource> m_subsurface;
}; };
class CWLSubsurfaceResource { class CWLSubsurfaceResource {
@ -37,28 +37,28 @@ class CWLSubsurfaceResource {
bool good(); bool good();
SP<CWLSurfaceResource> t1Parent(); SP<CWLSurfaceResource> t1Parent();
bool sync = false; bool m_sync = false;
Vector2D position; Vector2D m_position;
WP<CWLSurfaceResource> surface; WP<CWLSurfaceResource> m_surface;
WP<CWLSurfaceResource> parent; WP<CWLSurfaceResource> m_parent;
WP<CWLSubsurfaceResource> self; WP<CWLSubsurfaceResource> m_self;
int zIndex = 1; // by default, it's above int m_zIndex = 1; // by default, it's above
struct { struct {
CSignal destroy; CSignal destroy;
} events; } m_events;
private: private:
SP<CWlSubsurface> resource; SP<CWlSubsurface> m_resource;
void destroy(); void destroy();
struct { struct {
CHyprSignalListener commitSurface; CHyprSignalListener commitSurface;
} listeners; } m_listeners;
}; };
class CWLSubcompositorResource { class CWLSubcompositorResource {
@ -68,7 +68,7 @@ class CWLSubcompositorResource {
bool good(); bool good();
private: private:
SP<CWlSubcompositor> resource; SP<CWlSubcompositor> m_resource;
}; };
class CWLSubcompositorProtocol : public IWaylandProtocol { class CWLSubcompositorProtocol : public IWaylandProtocol {
@ -82,8 +82,8 @@ class CWLSubcompositorProtocol : public IWaylandProtocol {
void destroyResource(CWLSubsurfaceResource* resource); void destroyResource(CWLSubsurfaceResource* resource);
// //
std::vector<SP<CWLSubcompositorResource>> m_vManagers; std::vector<SP<CWLSubcompositorResource>> m_managers;
std::vector<SP<CWLSubsurfaceResource>> m_vSurfaces; std::vector<SP<CWLSubsurfaceResource>> m_surfaces;
friend class CWLSubcompositorResource; friend class CWLSubcompositorResource;
friend class CWLSubsurfaceResource; friend class CWLSubsurfaceResource;

View File

@ -1568,7 +1568,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB
} }
const auto imageDescription = 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 */ const bool skipCM = !*PENABLECM || !m_bCMSupported /* CM unsupported or disabled */
|| (imageDescription == m_RenderData.pMonitor->m_imageDescription) /* Source and target have the same image description */ || (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; CRegion inverseOpaque;
pixman_box32_t surfbox = {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->current.opaque}; CRegion opaqueRegion{PSURFACE->m_current.opaque};
inverseOpaque.set(opaqueRegion).invert(&surfbox).intersect(0, 0, PSURFACE->current.size.x, PSURFACE->current.size.y); inverseOpaque.set(opaqueRegion).invert(&surfbox).intersect(0, 0, PSURFACE->m_current.size.x, PSURFACE->m_current.size.y);
if (inverseOpaque.empty()) if (inverseOpaque.empty())
return false; return false;
@ -2224,11 +2224,11 @@ void CHyprOpenGLImpl::renderTextureWithBlur(SP<CTexture> tex, const CBox& box, f
// amazing hack: the surface has an opaque region! // amazing hack: the surface has an opaque region!
CRegion inverseOpaque; CRegion inverseOpaque;
if (a >= 1.f && std::round(pSurface->current.size.x * m_RenderData.pMonitor->m_scale) == box.w && if (a >= 1.f && std::round(pSurface->m_current.size.x * m_RenderData.pMonitor->m_scale) == box.w &&
std::round(pSurface->current.size.y * m_RenderData.pMonitor->m_scale) == box.h) { std::round(pSurface->m_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}; 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->current.opaque; inverseOpaque = pSurface->m_current.opaque;
inverseOpaque.invert(&surfbox).intersect(0, 0, pSurface->current.size.x * pSurface->current.scale, pSurface->current.size.y * pSurface->current.scale); 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()) { if (inverseOpaque.empty()) {
renderTexture(tex, box, a, round, roundingPower, false, true); renderTexture(tex, box, a, round, roundingPower, false, true);

View File

@ -589,7 +589,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
pWindow->m_wlSurface->resource()->breadthfirst( pWindow->m_wlSurface->resource()->breadthfirst(
[this, &renderdata, &pWindow](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { [this, &renderdata, &pWindow](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
renderdata.localPos = offset; renderdata.localPos = offset;
renderdata.texture = s->current.texture; renderdata.texture = s->m_current.texture;
renderdata.surface = s; renderdata.surface = s;
renderdata.mainSurface = s == pWindow->m_wlSurface->resource(); renderdata.mainSurface = s == pWindow->m_wlSurface->resource();
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata)); m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
@ -657,7 +657,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
popup->m_wlSurface->resource()->breadthfirst( popup->m_wlSurface->resource()->breadthfirst(
[this, &renderdata](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { [this, &renderdata](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
renderdata.localPos = offset; renderdata.localPos = offset;
renderdata.texture = s->current.texture; renderdata.texture = s->m_current.texture;
renderdata.surface = s; renderdata.surface = s;
renderdata.mainSurface = false; renderdata.mainSurface = false;
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata)); m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
@ -739,7 +739,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s
pLayer->m_surface->resource()->breadthfirst( pLayer->m_surface->resource()->breadthfirst(
[this, &renderdata, &pLayer](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { [this, &renderdata, &pLayer](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
renderdata.localPos = offset; renderdata.localPos = offset;
renderdata.texture = s->current.texture; renderdata.texture = s->m_current.texture;
renderdata.surface = s; renderdata.surface = s;
renderdata.mainSurface = s == pLayer->m_surface->resource(); renderdata.mainSurface = s == pLayer->m_surface->resource();
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata)); m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
@ -760,7 +760,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, const Time::s
Vector2D pos = popup->coordsRelativeToParent(); Vector2D pos = popup->coordsRelativeToParent();
renderdata.localPos = pos; 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.surface = popup->m_wlSurface->resource();
renderdata.mainSurface = false; renderdata.mainSurface = false;
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata)); m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
@ -779,8 +779,8 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, con
renderdata.surface = SURF; renderdata.surface = SURF;
renderdata.decorate = false; renderdata.decorate = false;
renderdata.w = SURF->current.size.x; renderdata.w = SURF->m_current.size.x;
renderdata.h = SURF->current.size.y; renderdata.h = SURF->m_current.size.y;
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled"); static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
static auto PBLURIMES = CConfigValue<Hyprlang::INT>("decoration:blur:input_methods"); static auto PBLURIMES = CConfigValue<Hyprlang::INT>("decoration:blur:input_methods");
@ -795,7 +795,7 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, con
SURF->breadthfirst( SURF->breadthfirst(
[this, &renderdata, &SURF](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { [this, &renderdata, &SURF](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
renderdata.localPos = offset; renderdata.localPos = offset;
renderdata.texture = s->current.texture; renderdata.texture = s->m_current.texture;
renderdata.surface = s; renderdata.surface = s;
renderdata.mainSurface = s == SURF; renderdata.mainSurface = s == SURF;
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata)); m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
@ -816,7 +816,7 @@ void CHyprRenderer::renderSessionLockSurface(WP<SSessionLockSurface> pSurface, P
renderdata.surface->breadthfirst( renderdata.surface->breadthfirst(
[this, &renderdata, &pSurface](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { [this, &renderdata, &pSurface](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) {
renderdata.localPos = offset; renderdata.localPos = offset;
renderdata.texture = s->current.texture; renderdata.texture = s->m_current.texture;
renderdata.surface = s; renderdata.surface = s;
renderdata.mainSurface = s == pSurface->surface->surface(); renderdata.mainSurface = s == pSurface->surface->surface();
m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata)); m_sRenderPass.add(makeShared<CSurfacePassElement>(renderdata));
@ -1053,10 +1053,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
Vector2D uvTL; Vector2D uvTL;
Vector2D uvBR = Vector2D(1, 1); Vector2D uvBR = Vector2D(1, 1);
if (pSurface->current.viewport.hasSource) { if (pSurface->m_current.viewport.hasSource) {
// we stretch it to dest. if no dest, to 1,1 // we stretch it to dest. if no dest, to 1,1
Vector2D const& bufferSize = pSurface->current.bufferSize; Vector2D const& bufferSize = pSurface->m_current.bufferSize;
auto const& bufferSource = pSurface->current.viewport.source; auto const& bufferSource = pSurface->m_current.viewport.source;
// calculate UV for the basic src_box. Assume dest == size. Scale to dest later // calculate UV for the basic src_box. Assume dest == size. Scale to dest later
uvTL = Vector2D(bufferSource.x / bufferSize.x, bufferSource.y / bufferSize.y); uvTL = Vector2D(bufferSource.x / bufferSize.x, bufferSource.y / bufferSize.y);
@ -1071,8 +1071,8 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
if (projSize != Vector2D{} && fixMisalignedFSV1) { if (projSize != Vector2D{} && fixMisalignedFSV1) {
// instead of nearest_neighbor (we will repeat / skip) // instead of nearest_neighbor (we will repeat / skip)
// just cut off / expand surface // just cut off / expand surface
const Vector2D PIXELASUV = Vector2D{1, 1} / pSurface->current.bufferSize; const Vector2D PIXELASUV = Vector2D{1, 1} / pSurface->m_current.bufferSize;
const Vector2D MISALIGNMENT = pSurface->current.bufferSize - projSize; const Vector2D MISALIGNMENT = pSurface->m_current.bufferSize - projSize;
if (MISALIGNMENT != Vector2D{}) if (MISALIGNMENT != Vector2D{})
uvBR -= MISALIGNMENT * PIXELASUV; uvBR -= MISALIGNMENT * PIXELASUV;
} }
@ -1083,9 +1083,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
// there is no way to fix this if that's the case // there is no way to fix this if that's the case
if (*PEXPANDEDGES) { if (*PEXPANDEDGES) {
const auto MONITOR_WL_SCALE = std::ceil(pMonitor->m_scale); const auto MONITOR_WL_SCALE = std::ceil(pMonitor->m_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 = 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(); .round();
if (!SCALE_UNAWARE && (EXPECTED_SIZE.x < projSize.x || EXPECTED_SIZE.y < projSize.y)) { if (!SCALE_UNAWARE && (EXPECTED_SIZE.x < projSize.x || EXPECTED_SIZE.y < projSize.y)) {
// this will not work with shm AFAIK, idk why. // this will not work with shm AFAIK, idk why.
@ -1111,10 +1112,10 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
// ignore X and Y, adjust uv // ignore X and Y, adjust uv
if (geom.x != 0 || geom.y != 0 || geom.width > projSizeUnscaled.x || geom.height > projSizeUnscaled.y) { if (geom.x != 0 || geom.y != 0 || geom.width > projSizeUnscaled.x || geom.height > projSizeUnscaled.y) {
const auto XPERC = (double)geom.x / (double)pSurface->current.size.x; const auto XPERC = (double)geom.x / (double)pSurface->m_current.size.x;
const auto YPERC = (double)geom.y / (double)pSurface->current.size.y; const auto YPERC = (double)geom.y / (double)pSurface->m_current.size.y;
const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->current.size.x; const auto WPERC = (double)(geom.x + geom.width) / (double)pSurface->m_current.size.x;
const auto HPERC = (double)(geom.y + geom.height) / (double)pSurface->current.size.y; 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)); 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)); 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 WINDOW = pMonitor->m_activeWorkspace->getFullscreenWindow();
const auto ROOT_SURF = WINDOW->m_wlSurface->resource(); const auto ROOT_SURF = WINDOW->m_wlSurface->resource();
const auto SURF = const auto SURF =
ROOT_SURF->findFirstPreorder([ROOT_SURF](SP<CWLSurfaceResource> surf) { return surf->colorManagement.valid() && surf->extends() == ROOT_SURF->extends(); }); ROOT_SURF->findFirstPreorder([ROOT_SURF](SP<CWLSurfaceResource> surf) { return surf->m_colorManagement.valid() && surf->extends() == ROOT_SURF->extends(); });
wantHDR = PHDR && *PPASS == 2; wantHDR = PHDR && *PPASS == 2;
// we have a surface with image description and it's allowed by wantHDR // we have a surface with image description and it's allowed by wantHDR
if (SURF && SURF->colorManagement.valid() && SURF->colorManagement->hasImageDescription() && if (SURF && SURF->m_colorManagement.valid() && SURF->m_colorManagement->hasImageDescription() &&
(!wantHDR || SURF->colorManagement->imageDescription().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ)) { (!wantHDR || SURF->m_colorManagement->imageDescription().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ)) {
bool needsHdrMetadataUpdate = SURF->colorManagement->needsHdrMetadataUpdate() || pMonitor->m_previousFSWindow != WINDOW; bool needsHdrMetadataUpdate = SURF->m_colorManagement->needsHdrMetadataUpdate() || pMonitor->m_previousFSWindow != WINDOW;
if (SURF->colorManagement->needsHdrMetadataUpdate()) if (SURF->m_colorManagement->needsHdrMetadataUpdate())
SURF->colorManagement->setHDRMetadata(createHDRMetadata(SURF->colorManagement->imageDescription(), pMonitor->m_output->parsedEDID)); SURF->m_colorManagement->setHDRMetadata(createHDRMetadata(SURF->m_colorManagement->imageDescription(), pMonitor->m_output->parsedEDID));
if (needsHdrMetadataUpdate) if (needsHdrMetadataUpdate)
pMonitor->m_output->state->setHDRMetadata(SURF->colorManagement->hdrMetadata()); pMonitor->m_output->state->setHDRMetadata(SURF->m_colorManagement->hdrMetadata());
hdrIsHandled = true; hdrIsHandled = true;
} }

View File

@ -244,13 +244,13 @@ void CRenderPass::renderDebugData() {
renderHLSurface(debugData.lastWindowText, g_pCompositor->m_lastWindow->m_wlSurface->resource(), Colors::LIGHT_BLUE.modifyA(0.1F)); 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) {
if (g_pSeatManager->m_state.pointerFocus->current.input.intersect(CBox{{}, g_pSeatManager->m_state.pointerFocus->current.size}).getExtents().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->current.size) { g_pSeatManager->m_state.pointerFocus->m_current.size) {
auto hlSurface = CWLSurface::fromResource(g_pSeatManager->m_state.pointerFocus.lock()); auto hlSurface = CWLSurface::fromResource(g_pSeatManager->m_state.pointerFocus.lock());
if (hlSurface) { if (hlSurface) {
auto BOX = hlSurface->getSurfaceBoxGlobal(); auto BOX = hlSurface->getSurfaceBoxGlobal();
if (BOX) { 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) .scale(g_pHyprOpenGL->m_RenderData.pMonitor->m_scale)
.translate(BOX->pos() - g_pHyprOpenGL->m_RenderData.pMonitor->m_position); .translate(BOX->pos() - g_pHyprOpenGL->m_RenderData.pMonitor->m_position);
g_pHyprOpenGL->renderRectWithDamage(box, CHyprColor{0.8F, 0.8F, 0.2F, 0.4F}, region); g_pHyprOpenGL->renderRectWithDamage(box, CHyprColor{0.8F, 0.8F, 0.2F, 0.4F}, region);

View File

@ -72,12 +72,12 @@ void CSurfacePassElement::draw(const CRegion& damage) {
return; return;
} }
const bool MISALIGNEDFSV1 = std::floor(data.pMonitor->m_scale) != data.pMonitor->m_scale /* Fractional */ && data.surface->current.scale == 1 /* fs protocol */ && 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->current.bufferSize /* misaligned */ && DELTALESSTHAN(windowBox.width, data.surface->current.bufferSize.x, 3) && windowBox.size() != data.surface->m_current.bufferSize /* misaligned */ && DELTALESSTHAN(windowBox.width, data.surface->m_current.bufferSize.x, 3) &&
DELTALESSTHAN(windowBox.height, data.surface->current.bufferSize.y, 3) /* off by one-or-two */ && 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 */; (!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"); 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); 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 // 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 // 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()) if (data.surface->m_current.buffer && !data.surface->m_current.buffer->isSynchronous())
g_pHyprRenderer->usedAsyncBuffers.emplace_back(data.surface->current.buffer); g_pHyprRenderer->usedAsyncBuffers.emplace_back(data.surface->m_current.buffer);
g_pHyprOpenGL->blend(true); g_pHyprOpenGL->blend(true);
} }
@ -167,8 +167,8 @@ CBox CSurfacePassElement::getTexBox() {
} }
} else { // here we clamp to 2, these might be some tiny specks } 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), 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->current.size.y, 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 */) { if (data.pWindow && data.pWindow->m_realSize->isBeingAnimated() && data.surface && !data.mainSurface && data.squishOversized /* subsurface */) {
// adjust subsurfaces to the window // adjust subsurfaces to the window
windowBox.width = (windowBox.width / data.pWindow->m_reportedSize.x) * data.pWindow->m_realSize->value().x; 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) if (ALPHA < 1.F)
return {}; return {};
if (data.surface && data.surface->current.size == Vector2D{data.w, data.h}) { if (data.surface && data.surface->m_current.size == Vector2D{data.w, data.h}) {
CRegion opaqueSurf = data.surface->current.opaque.copy().intersect(CBox{{}, {data.w, data.h}}); CRegion opaqueSurf = data.surface->m_current.opaque.copy().intersect(CBox{{}, {data.w, data.h}});
const auto texBox = getTexBox(); const auto texBox = getTexBox();
opaqueSurf.scale(texBox.size() / Vector2D{data.w, data.h}); opaqueSurf.scale(texBox.size() / Vector2D{data.w, data.h});
return opaqueSurf.translate(data.pos + data.localPos - data.pMonitor->m_position).expand(-data.rounding); 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) if (!PSURFACE)
return {}; return {};
const auto& bufferSize = data.surface->current.bufferSize; const auto& bufferSize = data.surface->m_current.bufferSize;
auto visibleRegion = PSURFACE->m_visibleRegion.copy(); auto visibleRegion = PSURFACE->m_visibleRegion.copy();
if (visibleRegion.empty()) if (visibleRegion.empty())

View File

@ -52,7 +52,7 @@ void CXWaylandSurface::ensureListeners() {
listeners.destroySurface.reset(); listeners.destroySurface.reset();
listeners.commitSurface.reset(); listeners.commitSurface.reset();
} else if (!connected && surface) { } 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) if (mapped)
unmap(); unmap();
@ -62,13 +62,13 @@ void CXWaylandSurface::ensureListeners() {
events.resourceChange.emit(); events.resourceChange.emit();
}); });
listeners.commitSurface = surface->events.commit.registerListener([this](std::any d) { listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) {
if (surface->current.texture && !mapped) { if (surface->m_current.texture && !mapped) {
map(); map();
return; return;
} }
if (!surface->current.texture && mapped) { if (!surface->m_current.texture && mapped) {
unmap(); unmap();
return; return;
} }
@ -132,7 +132,7 @@ void CXWaylandSurface::considerMap() {
return; return;
} }
if (surface->current.texture) { if (surface->m_current.texture) {
Debug::log(LOG, "XWayland surface: considerMap, sure, we have a buffer"); Debug::log(LOG, "XWayland surface: considerMap, sure, we have a buffer");
map(); map();
return; return;

View File

@ -957,7 +957,7 @@ CXWM::CXWM() : connection(g_pXWayland->pServer->xwmFDs[0].get()) {
setActiveWindow(XCB_WINDOW_NONE); setActiveWindow(XCB_WINDOW_NONE);
initSelection(); initSelection();
listeners.newWLSurface = PROTO::compositor->events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast<SP<CWLSurfaceResource>>(d)); }); listeners.newWLSurface = PROTO::compositor->m_events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast<SP<CWLSurfaceResource>>(d)); });
listeners.newXShellSurface = PROTO::xwaylandShell->events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast<SP<CXWaylandSurfaceResource>>(d)); }); listeners.newXShellSurface = PROTO::xwaylandShell->events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast<SP<CXWaylandSurfaceResource>>(d)); });
createWMWindow(); createWMWindow();