diff --git a/src/Compositor.cpp b/src/Compositor.cpp index fcb678739..8495a3289 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1268,7 +1268,7 @@ void CCompositor::focusSurface(SP pSurface, PHLWINDOW pWindo SP CCompositor::vectorToLayerPopupSurface(const Vector2D& pos, PHLMONITOR monitor, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound) { for (auto const& lsl : monitor->m_layerSurfaceLayers | std::views::reverse) { for (auto const& ls : lsl | std::views::reverse) { - if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->mapped) || ls->m_alpha->value() == 0.f) + if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->m_mapped) || ls->m_alpha->value() == 0.f) continue; auto SURFACEAT = ls->m_popupHead->at(pos, true); @@ -1288,11 +1288,11 @@ SP CCompositor::vectorToLayerSurface(const Vector2D& pos, st bool aboveLockscreen) { for (auto const& ls : *layerSurfaces | std::views::reverse) { - if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->surface->m_mapped) || ls->m_alpha->value() == 0.f || + if (!ls->m_mapped || ls->m_fadingOut || !ls->m_layerSurface || (ls->m_layerSurface && !ls->m_layerSurface->m_surface->m_mapped) || ls->m_alpha->value() == 0.f || (aboveLockscreen && (!ls->m_aboveLockscreen || !ls->m_aboveLockscreenInteractable))) continue; - auto [surf, local] = ls->m_layerSurface->surface->at(pos - ls->m_geometry.pos(), true); + auto [surf, local] = ls->m_layerSurface->m_surface->at(pos - ls->m_geometry.pos(), true); if (surf) { if (surf->m_current.input.empty()) @@ -2554,13 +2554,13 @@ PHLLS CCompositor::getLayerSurfaceFromSurface(SP pSurface) { std::pair, bool> result = {pSurface, false}; for (auto const& ls : m_layers) { - if (ls->m_layerSurface && ls->m_layerSurface->surface == pSurface) + if (ls->m_layerSurface && ls->m_layerSurface->m_surface == pSurface) return ls; if (!ls->m_layerSurface || !ls->m_mapped) continue; - ls->m_layerSurface->surface->breadthfirst( + ls->m_layerSurface->m_surface->breadthfirst( [&result](SP surf, const Vector2D& offset, void* data) { if (surf == result.first) { result.second = true; diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 4d3b67c56..08024e806 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1536,15 +1536,15 @@ std::vector> CConfigManager::getMatchingRules(PHLLS pLS) { if (lr->m_targetNamespace.starts_with("address:0x")) { if (std::format("address:0x{:x}", (uintptr_t)pLS.get()) != lr->m_targetNamespace) continue; - } else if (!lr->m_targetNamespaceRegex.passes(pLS->m_layerSurface->layerNamespace)) + } else if (!lr->m_targetNamespaceRegex.passes(pLS->m_layerSurface->m_layerNamespace)) continue; // hit returns.emplace_back(lr); } - if (shouldBlurLS(pLS->m_layerSurface->layerNamespace)) - returns.emplace_back(makeShared(pLS->m_layerSurface->layerNamespace, "blur")); + if (shouldBlurLS(pLS->m_layerSurface->m_layerNamespace)) + returns.emplace_back(makeShared(pLS->m_layerSurface->m_layerNamespace, "blur")); return returns; } diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index 9818c0938..61cca4880 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -15,9 +15,9 @@ PHLLS CLayerSurface::create(SP resource) { PHLLS pLS = SP(new CLayerSurface(resource)); - auto pMonitor = resource->monitor.empty() ? g_pCompositor->m_lastMonitor.lock() : g_pCompositor->getMonitorFromName(resource->monitor); + auto pMonitor = resource->m_monitor.empty() ? g_pCompositor->m_lastMonitor.lock() : g_pCompositor->getMonitorFromName(resource->m_monitor); - pLS->m_surface->assign(resource->surface.lock(), pLS); + pLS->m_surface->assign(resource->m_surface.lock(), pLS); if (!pMonitor) { Debug::log(ERR, "New LS has no monitor??"); @@ -29,12 +29,12 @@ PHLLS CLayerSurface::create(SP resource) { pLS->m_self = pLS; - pLS->m_namespace = resource->layerNamespace; + pLS->m_namespace = resource->m_layerNamespace; - pLS->m_layer = resource->current.layer; + pLS->m_layer = resource->m_current.layer; pLS->m_popupHead = CPopup::create(pLS); pLS->m_monitor = pMonitor; - pMonitor->m_layerSurfaceLayers[resource->current.layer].emplace_back(pLS); + pMonitor->m_layerSurfaceLayers[resource->m_current.layer].emplace_back(pLS); pLS->m_forceBlur = g_pConfigManager->shouldBlurLS(pLS->m_namespace); @@ -46,7 +46,7 @@ PHLLS CLayerSurface::create(SP resource) { pLS->m_alpha->setValueAndWarp(0.f); - Debug::log(LOG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", (uintptr_t)resource.get(), resource->layerNamespace, (int)pLS->m_layer, pMonitor->m_name); + Debug::log(LOG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", (uintptr_t)resource.get(), resource->m_layerNamespace, (int)pLS->m_layer, pMonitor->m_name); return pLS; } @@ -59,10 +59,10 @@ void CLayerSurface::registerCallbacks() { } CLayerSurface::CLayerSurface(SP resource_) : m_layerSurface(resource_) { - m_listeners.commit = m_layerSurface->events.commit.registerListener([this](std::any d) { onCommit(); }); - m_listeners.map = m_layerSurface->events.map.registerListener([this](std::any d) { onMap(); }); - m_listeners.unmap = m_layerSurface->events.unmap.registerListener([this](std::any d) { onUnmap(); }); - m_listeners.destroy = m_layerSurface->events.destroy.registerListener([this](std::any d) { onDestroy(); }); + m_listeners.commit = m_layerSurface->m_events.commit.registerListener([this](std::any d) { onCommit(); }); + m_listeners.map = m_layerSurface->m_events.map.registerListener([this](std::any d) { onMap(); }); + m_listeners.unmap = m_layerSurface->m_events.unmap.registerListener([this](std::any d) { onUnmap(); }); + m_listeners.destroy = m_layerSurface->m_events.destroy.registerListener([this](std::any d) { onDestroy(); }); m_surface = CWLSurface::create(); } @@ -133,9 +133,9 @@ void CLayerSurface::onMap() { Debug::log(LOG, "LayerSurface {:x} mapped", (uintptr_t)m_layerSurface.get()); m_mapped = true; - m_interactivity = m_layerSurface->current.interactivity; + m_interactivity = m_layerSurface->m_current.interactivity; - m_layerSurface->surface->map(); + m_layerSurface->m_surface->map(); // this layer might be re-mapped. m_fadingOut = false; @@ -155,13 +155,13 @@ void CLayerSurface::onMap() { m_surface->resource()->enter(PMONITOR->m_self.lock()); - const bool ISEXCLUSIVE = m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; + const bool ISEXCLUSIVE = m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; if (ISEXCLUSIVE) g_pInputManager->m_exclusiveLSes.push_back(m_self); const bool GRABSFOCUS = ISEXCLUSIVE || - (m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE && + (m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE && // don't focus if constrained (g_pSeatManager->m_mouse.expired() || !g_pInputManager->isConstrained())); @@ -196,7 +196,7 @@ void CLayerSurface::onMap() { void CLayerSurface::onUnmap() { Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)m_layerSurface.get()); - g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", m_layerSurface->layerNamespace}); + g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", m_layerSurface->m_layerNamespace}); EMIT_HOOK_EVENT("closeLayer", m_self.lock()); std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; }); @@ -207,8 +207,8 @@ void CLayerSurface::onUnmap() { g_pCompositor->addToFadingOutSafe(m_self.lock()); m_mapped = false; - if (m_layerSurface && m_layerSurface->surface) - m_layerSurface->surface->unmap(); + if (m_layerSurface && m_layerSurface->m_surface) + m_layerSurface->m_surface->unmap(); startAnimation(false); return; @@ -224,8 +224,8 @@ void CLayerSurface::onUnmap() { startAnimation(false); m_mapped = false; - if (m_layerSurface && m_layerSurface->surface) - m_layerSurface->surface->unmap(); + if (m_layerSurface && m_layerSurface->m_surface) + m_layerSurface->m_surface->unmap(); g_pCompositor->addToFadingOutSafe(m_self.lock()); @@ -247,8 +247,8 @@ void CLayerSurface::onUnmap() { CBox geomFixed = {m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y, m_geometry.width, m_geometry.height}; g_pHyprRenderer->damageBox(geomFixed); - geomFixed = {m_geometry.x + (int)PMONITOR->m_position.x, m_geometry.y + (int)PMONITOR->m_position.y, (int)m_layerSurface->surface->m_current.size.x, - (int)m_layerSurface->surface->m_current.size.y}; + geomFixed = {m_geometry.x + (int)PMONITOR->m_position.x, m_geometry.y + (int)PMONITOR->m_position.y, (int)m_layerSurface->m_surface->m_current.size.x, + (int)m_layerSurface->m_surface->m_current.size.y}; g_pHyprRenderer->damageBox(geomFixed); g_pInputManager->simulateMouseMovement(); @@ -262,7 +262,7 @@ void CLayerSurface::onCommit() { if (!m_mapped) { // we're re-mapping if this is the case - if (m_layerSurface->surface && !m_layerSurface->surface->m_current.texture) { + if (m_layerSurface->m_surface && !m_layerSurface->m_surface->m_current.texture) { m_fadingOut = false; m_geometry = {}; g_pHyprRenderer->arrangeLayersForMonitor(monitorID()); @@ -282,20 +282,20 @@ void CLayerSurface::onCommit() { CBox geomFixed = {m_geometry.x, m_geometry.y, m_geometry.width, m_geometry.height}; g_pHyprRenderer->damageBox(geomFixed); - if (m_layerSurface->current.committed != 0) { - if (m_layerSurface->current.committed & CLayerShellResource::eCommittedState::STATE_LAYER) { + if (m_layerSurface->m_current.committed != 0) { + if (m_layerSurface->m_current.committed & CLayerShellResource::eCommittedState::STATE_LAYER) { for (auto it = PMONITOR->m_layerSurfaceLayers[m_layer].begin(); it != PMONITOR->m_layerSurfaceLayers[m_layer].end(); it++) { if (*it == m_self) { - if (m_layerSurface->current.layer == m_layer) + if (m_layerSurface->m_current.layer == m_layer) break; - PMONITOR->m_layerSurfaceLayers[m_layerSurface->current.layer].emplace_back(*it); + PMONITOR->m_layerSurfaceLayers[m_layerSurface->m_current.layer].emplace_back(*it); PMONITOR->m_layerSurfaceLayers[m_layer].erase(it); break; } } - m_layer = m_layerSurface->current.layer; + m_layer = m_layerSurface->m_current.layer; if (m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || m_layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd @@ -308,12 +308,12 @@ void CLayerSurface::onCommit() { m_position = Vector2D(m_geometry.x, m_geometry.y); // update geom if it changed - if (m_layerSurface->surface->m_current.scale == 1 && PMONITOR->m_scale != 1.f && m_layerSurface->surface->m_current.viewport.hasDestination) { + if (m_layerSurface->m_surface->m_current.scale == 1 && PMONITOR->m_scale != 1.f && m_layerSurface->m_surface->m_current.viewport.hasDestination) { // fractional scaling. Dirty hack. - m_geometry = {m_geometry.pos(), m_layerSurface->surface->m_current.viewport.destination}; + m_geometry = {m_geometry.pos(), m_layerSurface->m_surface->m_current.viewport.destination}; } else { // this is because some apps like e.g. rofi-lbonn can't fucking use the protocol correctly. - m_geometry = {m_geometry.pos(), m_layerSurface->surface->m_current.size}; + m_geometry = {m_geometry.pos(), m_layerSurface->m_surface->m_current.size}; } } @@ -330,9 +330,9 @@ void CLayerSurface::onCommit() { m_realSize->setValueAndWarp(m_geometry.size()); } - if (m_mapped && (m_layerSurface->current.committed & CLayerShellResource::eCommittedState::STATE_INTERACTIVITY)) { + if (m_mapped && (m_layerSurface->m_current.committed & CLayerShellResource::eCommittedState::STATE_INTERACTIVITY)) { bool WASLASTFOCUS = false; - m_layerSurface->surface->breadthfirst( + m_layerSurface->m_surface->breadthfirst( [&WASLASTFOCUS](SP surf, const Vector2D& offset, void* data) { WASLASTFOCUS = WASLASTFOCUS || g_pSeatManager->m_state.keyboardFocus == surf; }, nullptr); if (!WASLASTFOCUS && m_popupHead) { @@ -343,7 +343,7 @@ void CLayerSurface::onCommit() { nullptr); } const bool WASEXCLUSIVE = m_interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; - const bool ISEXCLUSIVE = m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; + const bool ISEXCLUSIVE = m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; if (!WASEXCLUSIVE && ISEXCLUSIVE) g_pInputManager->m_exclusiveLSes.push_back(m_self); @@ -351,12 +351,12 @@ void CLayerSurface::onCommit() { std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == m_self.lock(); }); // if the surface was focused and interactive but now isn't, refocus - if (WASLASTFOCUS && m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) { + if (WASLASTFOCUS && m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) { // moveMouseUnified won't focus non interactive layers but it won't unfocus them either, // so unfocus the surface here. g_pCompositor->focusSurface(nullptr); g_pInputManager->refocusLastWindow(m_monitor.lock()); - } else if (WASLASTFOCUS && WASEXCLUSIVE && m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) { + } else if (WASLASTFOCUS && WASEXCLUSIVE && m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) { g_pInputManager->simulateMouseMovement(); } else if (!WASEXCLUSIVE && ISEXCLUSIVE) { // if now exclusive and not previously @@ -370,7 +370,7 @@ void CLayerSurface::onCommit() { } } - m_interactivity = m_layerSurface->current.interactivity; + m_interactivity = m_layerSurface->m_current.interactivity; g_pHyprRenderer->damageSurface(m_surface->resource(), m_position.x, m_position.y); @@ -600,11 +600,11 @@ MONITORID CLayerSurface::monitorID() { pid_t CLayerSurface::getPID() { pid_t PID = -1; - if (!m_layerSurface || !m_layerSurface->surface || !m_layerSurface->surface->getResource() || !m_layerSurface->surface->getResource()->resource() || - !m_layerSurface->surface->getResource()->resource()->client) + if (!m_layerSurface || !m_layerSurface->m_surface || !m_layerSurface->m_surface->getResource() || !m_layerSurface->m_surface->getResource()->resource() || + !m_layerSurface->m_surface->getResource()->resource()->client) return -1; - wl_client_get_credentials(m_layerSurface->surface->getResource()->resource()->client, &PID, nullptr, nullptr); + wl_client_get_credentials(m_layerSurface->m_surface->getResource()->resource()->client, &PID, nullptr, nullptr); return PID; } diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 86928faf4..e43aa8658 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -57,7 +57,7 @@ void CPopup::initAllSignals() { m_listeners.newPopup = m_windowOwner->m_xdgSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast>(d)); }); else if (!m_layerOwner.expired()) m_listeners.newPopup = - m_layerOwner->m_layerSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast>(d)); }); + m_layerOwner->m_layerSurface->m_events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast>(d)); }); else ASSERT(false); diff --git a/src/desktop/WLSurface.cpp b/src/desktop/WLSurface.cpp index 6666ea527..853f14c0c 100644 --- a/src/desktop/WLSurface.cpp +++ b/src/desktop/WLSurface.cpp @@ -230,6 +230,6 @@ bool CWLSurface::keyboardFocusable() const { if (m_windowOwner || m_popupOwner || m_subsurfaceOwner) return true; if (m_layerOwner && m_layerOwner->m_layerSurface) - return m_layerOwner->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE; + return m_layerOwner->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE; return false; } diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 4686ecb15..05d5363e7 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1775,7 +1775,7 @@ NContentType::eContentType CWindow::getContentType() { if (!m_wlSurface || !m_wlSurface->resource() || !m_wlSurface->resource()->m_contentType.valid()) return CONTENT_TYPE_NONE; - return m_wlSurface->resource()->m_contentType->value; + return m_wlSurface->resource()->m_contentType->m_value; } void CWindow::setContentType(NContentType::eContentType contentType) { @@ -1784,7 +1784,7 @@ void CWindow::setContentType(NContentType::eContentType contentType) { // else disallow content type change if proto is used? Debug::log(INFO, "ContentType for window {}", (int)contentType); - m_wlSurface->resource()->m_contentType->value = contentType; + m_wlSurface->resource()->m_contentType->m_value = contentType; } void CWindow::deactivateGroupMembers() { diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 874298747..910220e1e 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -593,7 +593,7 @@ void Events::listener_mapWindow(void* owner, void* data) { // check LS focus grab const auto PFORCEFOCUS = g_pCompositor->getForceFocus(); const auto PLSFROMFOCUS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock()); - if (PLSFROMFOCUS && PLSFROMFOCUS->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) + if (PLSFROMFOCUS && PLSFROMFOCUS->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) PWINDOW->m_noInitialFocus = true; if (PWINDOW->m_workspace->m_hasFullscreenWindow && !requestedInternalFSMode.has_value() && !requestedClientFSMode.has_value() && !PWINDOW->m_isFloating) { diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp index e3712ce71..258b35dcf 100644 --- a/src/managers/input/IdleInhibitor.cpp +++ b/src/managers/input/IdleInhibitor.cpp @@ -8,14 +8,14 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) { const auto PINHIBIT = m_idleInhibitors.emplace_back(makeUnique()).get(); PINHIBIT->inhibitor = std::any_cast>(inhibitor); - Debug::log(LOG, "New idle inhibitor registered for surface {:x}", (uintptr_t)PINHIBIT->inhibitor->surface.get()); + Debug::log(LOG, "New idle inhibitor registered for surface {:x}", (uintptr_t)PINHIBIT->inhibitor->m_surface.get()); - PINHIBIT->inhibitor->listeners.destroy = PINHIBIT->inhibitor->resource->events.destroy.registerListener([this, PINHIBIT](std::any data) { + PINHIBIT->inhibitor->m_listeners.destroy = PINHIBIT->inhibitor->m_resource->m_events.destroy.registerListener([this, PINHIBIT](std::any data) { std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); recheckIdleInhibitorStatus(); }); - auto WLSurface = CWLSurface::fromResource(PINHIBIT->inhibitor->surface.lock()); + auto WLSurface = CWLSurface::fromResource(PINHIBIT->inhibitor->m_surface.lock()); if (!WLSurface) { Debug::log(LOG, "Inhibitor has no HL Surface attached to it, likely meaning it's a non-desktop element. Assuming it's visible."); @@ -38,7 +38,7 @@ void CInputManager::recheckIdleInhibitorStatus() { return; } - auto WLSurface = CWLSurface::fromResource(ii->inhibitor->surface.lock()); + auto WLSurface = CWLSurface::fromResource(ii->inhibitor->m_surface.lock()); if (!WLSurface) continue; @@ -80,7 +80,7 @@ bool CInputManager::isWindowInhibiting(const PHLWINDOW& w, bool onlyHl) { bool isInhibiting = false; w->m_wlSurface->resource()->breadthfirst( [&ii](SP surf, const Vector2D& pos, void* data) { - if (ii->inhibitor->surface != surf) + if (ii->inhibitor->m_surface != surf) return; auto WLSurface = CWLSurface::fromResource(surf); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 90c43988b..b3805ca2e 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -42,7 +42,7 @@ #include CInputManager::CInputManager() { - m_listeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) { + m_listeners.setCursorShape = PROTO::cursorShape->m_events.setShape.registerListener([this](std::any data) { if (!cursorImageUnlocked()) return; @@ -65,7 +65,7 @@ CInputManager::CInputManager() { g_pHyprRenderer->setCursorFromName(m_cursorSurfaceInfo.name); }); - m_listeners.newIdleInhibitor = PROTO::idleInhibit->events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); }); + m_listeners.newIdleInhibitor = PROTO::idleInhibit->m_events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); }); m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->events.newKeyboard.registerListener([this](std::any data) { this->newVirtualKeyboard(std::any_cast>(data)); updateCapabilities(); @@ -504,7 +504,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { if (!refocus && g_pCompositor->m_lastFocus) { const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock()); - if (PLS && PLS->m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) + if (PLS && PLS->m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) allowKeyboardRefocus = false; } @@ -589,8 +589,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { unsetCursorImage(); } - if (pFoundLayerSurface && (pFoundLayerSurface->m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) && FOLLOWMOUSE != 3 && - (allowKeyboardRefocus || pFoundLayerSurface->m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)) { + if (pFoundLayerSurface && (pFoundLayerSurface->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) && FOLLOWMOUSE != 3 && + (allowKeyboardRefocus || pFoundLayerSurface->m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)) { g_pCompositor->focusSurface(foundSurface); } diff --git a/src/managers/input/InputMethodPopup.cpp b/src/managers/input/InputMethodPopup.cpp index ac526c7b0..981311680 100644 --- a/src/managers/input/InputMethodPopup.cpp +++ b/src/managers/input/InputMethodPopup.cpp @@ -8,10 +8,10 @@ #include "../../render/Renderer.hpp" CInputPopup::CInputPopup(SP popup_) : m_popup(popup_) { - m_listeners.commit = popup_->events.commit.registerListener([this](std::any d) { onCommit(); }); - m_listeners.map = popup_->events.map.registerListener([this](std::any d) { onMap(); }); - m_listeners.unmap = popup_->events.unmap.registerListener([this](std::any d) { onUnmap(); }); - m_listeners.destroy = popup_->events.destroy.registerListener([this](std::any d) { onDestroy(); }); + m_listeners.commit = popup_->m_events.commit.registerListener([this](std::any d) { onCommit(); }); + m_listeners.map = popup_->m_events.map.registerListener([this](std::any d) { onMap(); }); + m_listeners.unmap = popup_->m_events.unmap.registerListener([this](std::any d) { onUnmap(); }); + m_listeners.destroy = popup_->m_events.destroy.registerListener([this](std::any d) { onDestroy(); }); m_surface = CWLSurface::create(); m_surface->assign(popup_->surface()); } @@ -77,7 +77,7 @@ void CInputPopup::damageSurface() { } void CInputPopup::updateBox() { - if (!m_popup->mapped) + if (!m_popup->m_mapped) return; const auto OWNER = queryOwner(); diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp index bafa9002d..050734a85 100644 --- a/src/managers/input/InputMethodRelay.cpp +++ b/src/managers/input/InputMethodRelay.cpp @@ -13,7 +13,7 @@ CInputMethodRelay::CInputMethodRelay() { m_listeners.newTIV3 = PROTO::textInputV3->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast>(ti)); }); m_listeners.newTIV1 = PROTO::textInputV1->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast>(ti)); }); - m_listeners.newIME = PROTO::ime->events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast>(ime)); }); + m_listeners.newIME = PROTO::ime->m_events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast>(ime)); }); } void CInputMethodRelay::onNewIME(SP pIME) { @@ -27,7 +27,7 @@ void CInputMethodRelay::onNewIME(SP pIME) { m_inputMethod = pIME; - m_listeners.commitIME = pIME->events.onCommit.registerListener([this](std::any d) { + m_listeners.commitIME = pIME->m_events.onCommit.registerListener([this](std::any d) { const auto PTI = getFocusedTextInput(); if (!PTI) { @@ -38,7 +38,7 @@ void CInputMethodRelay::onNewIME(SP pIME) { PTI->updateIMEState(m_inputMethod.lock()); }); - m_listeners.destroyIME = pIME->events.destroy.registerListener([this](std::any d) { + m_listeners.destroyIME = pIME->m_events.destroy.registerListener([this](std::any d) { const auto PTI = getFocusedTextInput(); Debug::log(LOG, "IME Destroy"); @@ -49,7 +49,7 @@ void CInputMethodRelay::onNewIME(SP pIME) { m_inputMethod.reset(); }); - m_listeners.newPopup = pIME->events.newPopup.registerListener([this](std::any d) { + m_listeners.newPopup = pIME->m_events.newPopup.registerListener([this](std::any d) { m_inputMethodPopups.emplace_back(makeUnique(std::any_cast>(d))); Debug::log(LOG, "New input popup"); diff --git a/src/managers/input/TextInput.cpp b/src/managers/input/TextInput.cpp index a629cd18c..c563f4de7 100644 --- a/src/managers/input/TextInput.cpp +++ b/src/managers/input/TextInput.cpp @@ -266,38 +266,38 @@ void CTextInput::updateIMEState(SP ime) { if (isV3()) { const auto INPUT = m_v3Input.lock(); - if (ime->current.preeditString.committed) - INPUT->preeditString(ime->current.preeditString.string, ime->current.preeditString.begin, ime->current.preeditString.end); + if (ime->m_current.preeditString.committed) + INPUT->preeditString(ime->m_current.preeditString.string, ime->m_current.preeditString.begin, ime->m_current.preeditString.end); - if (ime->current.committedString.committed) - INPUT->commitString(ime->current.committedString.string); + if (ime->m_current.committedString.committed) + INPUT->commitString(ime->m_current.committedString.string); - if (ime->current.deleteSurrounding.committed) - INPUT->deleteSurroundingText(ime->current.deleteSurrounding.before, ime->current.deleteSurrounding.after); + if (ime->m_current.deleteSurrounding.committed) + INPUT->deleteSurroundingText(ime->m_current.deleteSurrounding.before, ime->m_current.deleteSurrounding.after); INPUT->sendDone(); } else { const auto INPUT = m_v1Input.lock(); - if (ime->current.preeditString.committed) { - INPUT->preeditCursor(ime->current.preeditString.begin); - INPUT->preeditStyling(0, std::string(ime->current.preeditString.string).length(), ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT); - INPUT->preeditString(m_v1Input->serial, ime->current.preeditString.string.c_str(), ""); + if (ime->m_current.preeditString.committed) { + INPUT->preeditCursor(ime->m_current.preeditString.begin); + INPUT->preeditStyling(0, std::string(ime->m_current.preeditString.string).length(), ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT); + INPUT->preeditString(m_v1Input->serial, ime->m_current.preeditString.string.c_str(), ""); } else { INPUT->preeditCursor(0); INPUT->preeditStyling(0, 0, ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT); INPUT->preeditString(m_v1Input->serial, "", ""); } - if (ime->current.committedString.committed) - INPUT->commitString(m_v1Input->serial, ime->current.committedString.string.c_str()); + if (ime->m_current.committedString.committed) + INPUT->commitString(m_v1Input->serial, ime->m_current.committedString.string.c_str()); - if (ime->current.deleteSurrounding.committed) { - INPUT->deleteSurroundingText(std::string(ime->current.preeditString.string).length() - ime->current.deleteSurrounding.before, - ime->current.deleteSurrounding.after + ime->current.deleteSurrounding.before); + if (ime->m_current.deleteSurrounding.committed) { + INPUT->deleteSurroundingText(std::string(ime->m_current.preeditString.string).length() - ime->m_current.deleteSurrounding.before, + ime->m_current.deleteSurrounding.after + ime->m_current.deleteSurrounding.before); - if (ime->current.preeditString.committed) - INPUT->commitString(m_v1Input->serial, ime->current.preeditString.string.c_str()); + if (ime->m_current.preeditString.committed) + INPUT->commitString(m_v1Input->serial, ime->m_current.preeditString.string.c_str()); } } } diff --git a/src/protocols/AlphaModifier.cpp b/src/protocols/AlphaModifier.cpp index 87c467657..e24083970 100644 --- a/src/protocols/AlphaModifier.cpp +++ b/src/protocols/AlphaModifier.cpp @@ -4,58 +4,58 @@ #include "alpha-modifier-v1.hpp" #include "core/Compositor.hpp" -CAlphaModifier::CAlphaModifier(SP resource, SP surface) : m_pSurface(surface) { +CAlphaModifier::CAlphaModifier(SP resource, SP surface) : m_surface(surface) { setResource(std::move(resource)); } bool CAlphaModifier::good() { - return m_pResource->resource(); + return m_resource->resource(); } void CAlphaModifier::setResource(SP resource) { - m_pResource = std::move(resource); + m_resource = std::move(resource); - if UNLIKELY (!m_pResource->resource()) + if UNLIKELY (!m_resource->resource()) return; - m_pResource->setDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); }); - m_pResource->setOnDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); }); + m_resource->setDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); }); + m_resource->setOnDestroy([this](CWpAlphaModifierSurfaceV1* resource) { destroy(); }); - m_pResource->setSetMultiplier([this](CWpAlphaModifierSurfaceV1* resource, uint32_t alpha) { - if (!m_pSurface) { - m_pResource->error(WP_ALPHA_MODIFIER_SURFACE_V1_ERROR_NO_SURFACE, "set_multiplier called for destroyed wl_surface"); + m_resource->setSetMultiplier([this](CWpAlphaModifierSurfaceV1* resource, uint32_t alpha) { + if (!m_surface) { + m_resource->error(WP_ALPHA_MODIFIER_SURFACE_V1_ERROR_NO_SURFACE, "set_multiplier called for destroyed wl_surface"); return; } - m_fAlpha = alpha / (float)UINT32_MAX; + m_alpha = alpha / (float)UINT32_MAX; }); - listeners.surfaceCommitted = m_pSurface->m_events.commit.registerListener([this](std::any data) { - auto surface = CWLSurface::fromResource(m_pSurface.lock()); + m_listeners.surfaceCommitted = m_surface->m_events.commit.registerListener([this](std::any data) { + auto surface = CWLSurface::fromResource(m_surface.lock()); - if (surface && surface->m_alphaModifier != m_fAlpha) { - surface->m_alphaModifier = m_fAlpha; + if (surface && surface->m_alphaModifier != m_alpha) { + surface->m_alphaModifier = m_alpha; auto box = surface->getSurfaceBoxGlobal(); if (box.has_value()) g_pHyprRenderer->damageBox(*box); - if (!m_pResource) + if (!m_resource) PROTO::alphaModifier->destroyAlphaModifier(this); } }); - listeners.surfaceDestroyed = m_pSurface->m_events.destroy.registerListener([this](std::any data) { - if (!m_pResource) + m_listeners.surfaceDestroyed = m_surface->m_events.destroy.registerListener([this](std::any data) { + if (!m_resource) PROTO::alphaModifier->destroyAlphaModifier(this); }); } void CAlphaModifier::destroy() { - m_pResource.reset(); - m_fAlpha = 1.F; + m_resource.reset(); + m_alpha = 1.F; - if (!m_pSurface) + if (!m_surface) PROTO::alphaModifier->destroyAlphaModifier(this); } @@ -64,7 +64,7 @@ CAlphaModifierProtocol::CAlphaModifierProtocol(const wl_interface* iface, const } void CAlphaModifierProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CWpAlphaModifierV1* manager) { destroyManager(manager); }); RESOURCE->setDestroy([this](CWpAlphaModifierV1* manager) { destroyManager(manager); }); @@ -72,19 +72,19 @@ void CAlphaModifierProtocol::bindManager(wl_client* client, void* data, uint32_t } void CAlphaModifierProtocol::destroyManager(CWpAlphaModifierV1* manager) { - std::erase_if(m_vManagers, [&](const auto& p) { return p.get() == manager; }); + std::erase_if(m_managers, [&](const auto& p) { return p.get() == manager; }); } void CAlphaModifierProtocol::destroyAlphaModifier(CAlphaModifier* modifier) { - std::erase_if(m_mAlphaModifiers, [&](const auto& entry) { return entry.second.get() == modifier; }); + std::erase_if(m_alphaModifiers, [&](const auto& entry) { return entry.second.get() == modifier; }); } void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id, SP surface) { CAlphaModifier* alphaModifier = nullptr; - auto iter = std::find_if(m_mAlphaModifiers.begin(), m_mAlphaModifiers.end(), [&](const auto& entry) { return entry.second->m_pSurface == surface; }); + auto iter = std::find_if(m_alphaModifiers.begin(), m_alphaModifiers.end(), [&](const auto& entry) { return entry.second->m_surface == surface; }); - if (iter != m_mAlphaModifiers.end()) { - if (iter->second->m_pResource) { + if (iter != m_alphaModifiers.end()) { + if (iter->second->m_resource) { LOGM(ERR, "AlphaModifier already present for surface {:x}", (uintptr_t)surface.get()); manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present"); return; @@ -93,12 +93,12 @@ void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id alphaModifier = iter->second.get(); } } else { - alphaModifier = m_mAlphaModifiers.emplace(surface, makeUnique(makeShared(manager->client(), manager->version(), id), surface)) + alphaModifier = m_alphaModifiers.emplace(surface, makeUnique(makeShared(manager->client(), manager->version(), id), surface)) .first->second.get(); } if UNLIKELY (!alphaModifier->good()) { manager->noMemory(); - m_mAlphaModifiers.erase(surface); + m_alphaModifiers.erase(surface); } } diff --git a/src/protocols/AlphaModifier.hpp b/src/protocols/AlphaModifier.hpp index 9a7873ae6..99bfc2fb8 100644 --- a/src/protocols/AlphaModifier.hpp +++ b/src/protocols/AlphaModifier.hpp @@ -17,16 +17,16 @@ class CAlphaModifier { void setResource(SP resource); private: - SP m_pResource; - WP m_pSurface; - float m_fAlpha = 1.0; + SP m_resource; + WP m_surface; + float m_alpha = 1.0; void destroy(); struct { CHyprSignalListener surfaceCommitted; CHyprSignalListener surfaceDestroyed; - } listeners; + } m_listeners; friend class CAlphaModifierProtocol; }; @@ -43,8 +43,8 @@ class CAlphaModifierProtocol : public IWaylandProtocol { void getSurface(CWpAlphaModifierV1* manager, uint32_t id, SP surface); // - std::vector> m_vManagers; - std::unordered_map, UP> m_mAlphaModifiers; + std::vector> m_managers; + std::unordered_map, UP> m_alphaModifiers; friend class CAlphaModifier; }; diff --git a/src/protocols/CTMControl.cpp b/src/protocols/CTMControl.cpp index c848fab81..315941d32 100644 --- a/src/protocols/CTMControl.cpp +++ b/src/protocols/CTMControl.cpp @@ -8,16 +8,16 @@ #include "../helpers/Monitor.hpp" #include "../helpers/MiscFunctions.hpp" -CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP resource_) : resource(resource_) { +CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); }); - resource->setOnDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); }); + m_resource->setDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); }); + m_resource->setOnDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); }); - resource->setSetCtmForOutput([this](CHyprlandCtmControlManagerV1* r, wl_resource* output, wl_fixed_t mat0, wl_fixed_t mat1, wl_fixed_t mat2, wl_fixed_t mat3, wl_fixed_t mat4, - wl_fixed_t mat5, wl_fixed_t mat6, wl_fixed_t mat7, wl_fixed_t mat8) { - if (blocked) + m_resource->setSetCtmForOutput([this](CHyprlandCtmControlManagerV1* r, wl_resource* output, wl_fixed_t mat0, wl_fixed_t mat1, wl_fixed_t mat2, wl_fixed_t mat3, wl_fixed_t mat4, + wl_fixed_t mat5, wl_fixed_t mat6, wl_fixed_t mat7, wl_fixed_t mat8) { + if (m_blocked) return; const auto OUTPUTRESOURCE = CWLOutputResource::fromResource(output); @@ -35,42 +35,42 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SPerror(HYPRLAND_CTM_CONTROL_MANAGER_V1_ERROR_INVALID_MATRIX, "a matrix component was < 0"); + m_resource->error(HYPRLAND_CTM_CONTROL_MANAGER_V1_ERROR_INVALID_MATRIX, "a matrix component was < 0"); return; } } - ctms[PMONITOR->m_name] = MAT; + m_ctms[PMONITOR->m_name] = MAT; - LOGM(LOG, "CTM set for output {}: {}", PMONITOR->m_name, ctms.at(PMONITOR->m_name).toString()); + LOGM(LOG, "CTM set for output {}: {}", PMONITOR->m_name, m_ctms.at(PMONITOR->m_name).toString()); }); - resource->setCommit([this](CHyprlandCtmControlManagerV1* r) { - if (blocked) + m_resource->setCommit([this](CHyprlandCtmControlManagerV1* r) { + if (m_blocked) return; LOGM(LOG, "Committing ctms to outputs"); for (auto& m : g_pCompositor->m_monitors) { - if (!ctms.contains(m->m_name)) { + if (!m_ctms.contains(m->m_name)) { PROTO::ctm->setCTM(m, Mat3x3::identity()); continue; } - PROTO::ctm->setCTM(m, ctms.at(m->m_name)); + PROTO::ctm->setCTM(m, m_ctms.at(m->m_name)); } }); } void CHyprlandCTMControlResource::block() { - blocked = true; + m_blocked = true; - if (resource->version() >= 2) - resource->sendBlocked(); + if (m_resource->version() >= 2) + m_resource->sendBlocked(); } CHyprlandCTMControlResource::~CHyprlandCTMControlResource() { - if (blocked) + if (m_blocked) return; for (auto& m : g_pCompositor->m_monitors) { @@ -79,7 +79,7 @@ CHyprlandCTMControlResource::~CHyprlandCTMControlResource() { } bool CHyprlandCTMControlResource::good() { - return resource->resource(); + return m_resource->resource(); } CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -87,24 +87,24 @@ CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* ifa } void CHyprlandCTMControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } - if (m_pManager) + if (m_manager) RESOURCE->block(); else - m_pManager = RESOURCE; + m_manager = RESOURCE; LOGM(LOG, "New CTM Manager at 0x{:x}", (uintptr_t)RESOURCE.get()); } void CHyprlandCTMControlProtocol::destroyResource(CHyprlandCTMControlResource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; }); } bool CHyprlandCTMControlProtocol::isCTMAnimationEnabled() { @@ -129,12 +129,12 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm) return; } - std::erase_if(m_mCTMDatas, [](const auto& el) { return !el.first; }); + std::erase_if(m_ctmDatas, [](const auto& el) { return !el.first; }); - if (!m_mCTMDatas.contains(monitor)) - m_mCTMDatas[monitor] = makeUnique(); + if (!m_ctmDatas.contains(monitor)) + m_ctmDatas[monitor] = makeUnique(); - auto& data = m_mCTMDatas.at(monitor); + auto& data = m_ctmDatas.at(monitor); data->ctmFrom = data->ctmTo; data->ctmTo = ctm; @@ -145,9 +145,9 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm) monitor->setCTM(data->ctmFrom); data->progress->setUpdateCallback([monitor = PHLMONITORREF{monitor}, this](auto) { - if (!monitor || !m_mCTMDatas.contains(monitor)) + if (!monitor || !m_ctmDatas.contains(monitor)) return; - auto& data = m_mCTMDatas.at(monitor); + auto& data = m_ctmDatas.at(monitor); const auto from = data->ctmFrom.getMatrix(); const auto to = data->ctmTo.getMatrix(); const auto PROGRESS = data->progress->getPercent(); @@ -163,12 +163,12 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm) }); data->progress->setCallbackOnEnd([monitor = PHLMONITORREF{monitor}, this](auto) { - if (!monitor || !m_mCTMDatas.contains(monitor)) { + if (!monitor || !m_ctmDatas.contains(monitor)) { if (monitor) monitor->setCTM(Mat3x3::identity()); return; } - auto& data = m_mCTMDatas.at(monitor); + auto& data = m_ctmDatas.at(monitor); monitor->setCTM(data->ctmTo); }); } diff --git a/src/protocols/CTMControl.hpp b/src/protocols/CTMControl.hpp index eb54a3aae..0f2faca8c 100644 --- a/src/protocols/CTMControl.hpp +++ b/src/protocols/CTMControl.hpp @@ -19,10 +19,10 @@ class CHyprlandCTMControlResource { void block(); private: - SP resource; + SP m_resource; - std::unordered_map ctms; - bool blocked = false; + std::unordered_map m_ctms; + bool m_blocked = false; }; class CHyprlandCTMControlProtocol : public IWaylandProtocol { @@ -38,8 +38,8 @@ class CHyprlandCTMControlProtocol : public IWaylandProtocol { bool isCTMAnimationEnabled(); // - std::vector> m_vManagers; - WP m_pManager; + std::vector> m_managers; + WP m_manager; // struct SCTMData { @@ -47,7 +47,7 @@ class CHyprlandCTMControlProtocol : public IWaylandProtocol { Mat3x3 ctmFrom = Mat3x3::identity(), ctmTo = Mat3x3::identity(); PHLANIMVAR progress; }; - std::map> m_mCTMDatas; + std::map> m_ctmDatas; friend class CHyprlandCTMControlResource; }; diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp index 5810b4146..5ace1f7e9 100644 --- a/src/protocols/ColorManagement.cpp +++ b/src/protocols/ColorManagement.cpp @@ -82,15 +82,15 @@ CColorManager::CColorManager(SP resource) : m_resource(resour } const auto RESOURCE = - PROTO::colorManagement->m_vOutputs.emplace_back(makeShared(makeShared(r->client(), r->version(), id), PMONITOR)); + PROTO::colorManagement->m_outputs.emplace_back(makeShared(makeShared(r->client(), r->version(), id), PMONITOR)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vOutputs.pop_back(); + PROTO::colorManagement->m_outputs.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); m_resource->setGetSurface([](CWpColorManagerV1* r, uint32_t id, wl_resource* surface) { LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); @@ -108,14 +108,14 @@ CColorManager::CColorManager(SP resource) : m_resource(resour } const auto RESOURCE = - PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id), SURF)); + PROTO::colorManagement->m_surfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vSurfaces.pop_back(); + PROTO::colorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; SURF->m_colorManagement = RESOURCE; }); @@ -129,16 +129,16 @@ CColorManager::CColorManager(SP resource) : m_resource(resour return; } - const auto RESOURCE = PROTO::colorManagement->m_vFeedbackSurfaces.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_feedbackSurfaces.emplace_back( makeShared(makeShared(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vFeedbackSurfaces.pop_back(); + PROTO::colorManagement->m_feedbackSurfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); m_resource->setCreateIccCreator([](CWpColorManagerV1* r, uint32_t id) { LOGM(WARN, "New ICC creator for id={} (unsupported)", id); @@ -148,29 +148,29 @@ CColorManager::CColorManager(SP resource) : m_resource(resour } const auto RESOURCE = - PROTO::colorManagement->m_vIccCreators.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); + PROTO::colorManagement->m_iccCreators.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vIccCreators.pop_back(); + PROTO::colorManagement->m_iccCreators.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); m_resource->setCreateParametricCreator([](CWpColorManagerV1* r, uint32_t id) { LOGM(TRACE, "New parametric creator for id={}", id); - const auto RESOURCE = PROTO::colorManagement->m_vParametricCreators.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_parametricCreators.emplace_back( makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vParametricCreators.pop_back(); + PROTO::colorManagement->m_parametricCreators.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); m_resource->setCreateWindowsScrgb([](CWpColorManagerV1* r, uint32_t id) { LOGM(WARN, "New Windows scRGB description id={} (unsupported)", id); @@ -179,23 +179,23 @@ CColorManager::CColorManager(SP resource) : m_resource(resour return; } - const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id), false)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vImageDescriptions.pop_back(); + PROTO::colorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; - RESOURCE->settings.windowsScRGB = true; - RESOURCE->settings.primariesNamed = NColorManagement::CM_PRIMARIES_SRGB; - RESOURCE->settings.primariesNameSet = true; - RESOURCE->settings.primaries = NColorPrimaries::BT709; - RESOURCE->settings.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_EXT_LINEAR; - RESOURCE->settings.luminances.reference = 203; - RESOURCE->resource()->sendReady(RESOURCE->settings.updateId()); + RESOURCE->m_self = RESOURCE; + RESOURCE->m_settings.windowsScRGB = true; + RESOURCE->m_settings.primariesNamed = NColorManagement::CM_PRIMARIES_SRGB; + RESOURCE->m_settings.primariesNameSet = true; + RESOURCE->m_settings.primaries = NColorPrimaries::BT709; + RESOURCE->m_settings.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_EXT_LINEAR; + RESOURCE->m_settings.luminances.reference = 203; + RESOURCE->resource()->sendReady(RESOURCE->m_settings.updateId()); }); m_resource->setOnDestroy([this](CWpColorManagerV1* r) { PROTO::colorManagement->destroyResource(this); }); @@ -211,7 +211,7 @@ CColorManagementOutput::CColorManagementOutput(SP re if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); m_resource->setDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagementOutputV1* r) { PROTO::colorManagement->destroyResource(this); }); @@ -219,24 +219,24 @@ CColorManagementOutput::CColorManagementOutput(SP re m_resource->setGetImageDescription([this](CWpColorManagementOutputV1* r, uint32_t id) { LOGM(TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id); - if (imageDescription.valid()) - PROTO::colorManagement->destroyResource(imageDescription.get()); + if (m_imageDescription.valid()) + PROTO::colorManagement->destroyResource(m_imageDescription.get()); - const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id), true)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vImageDescriptions.pop_back(); + PROTO::colorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; if (!m_monitor.valid()) RESOURCE->m_resource->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_NO_OUTPUT, "No output"); else { - RESOURCE->settings = m_monitor->m_imageDescription; - RESOURCE->m_resource->sendReady(RESOURCE->settings.updateId()); + RESOURCE->m_settings = m_monitor->m_imageDescription; + RESOURCE->m_resource->sendReady(RESOURCE->m_settings.updateId()); } }); } @@ -246,25 +246,25 @@ bool CColorManagementOutput::good() { } wl_client* CColorManagementOutput::client() { - return pClient; + return m_client; } -CColorManagementSurface::CColorManagementSurface(SP surface_) : surface(surface_) { +CColorManagementSurface::CColorManagementSurface(SP surface_) : m_surface(surface_) { // only for frog cm untill wayland cm is adopted } -CColorManagementSurface::CColorManagementSurface(SP resource, SP surface_) : surface(surface_), m_resource(resource) { +CColorManagementSurface::CColorManagementSurface(SP resource, SP surface_) : m_surface(surface_), m_resource(resource) { if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); m_resource->setDestroy([this](CWpColorManagementSurfaceV1* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); + LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagementSurfaceV1* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); + LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); PROTO::colorManagement->destroyResource(this); }); @@ -281,15 +281,15 @@ CColorManagementSurface::CColorManagementSurface(SP return; } - const auto imageDescription = std::find_if(PROTO::colorManagement->m_vImageDescriptions.begin(), PROTO::colorManagement->m_vImageDescriptions.end(), + const auto imageDescription = std::find_if(PROTO::colorManagement->m_imageDescriptions.begin(), PROTO::colorManagement->m_imageDescriptions.end(), [&](const auto& other) { return other->resource()->resource() == image_description; }); - if (imageDescription == PROTO::colorManagement->m_vImageDescriptions.end()) { + if (imageDescription == PROTO::colorManagement->m_imageDescriptions.end()) { r->error(WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "Image description not found"); return; } setHasImageDescription(true); - m_imageDescription = imageDescription->get()->settings; + m_imageDescription = imageDescription->get()->m_settings; }); m_resource->setUnsetImageDescription([this](CWpColorManagementSurfaceV1* r) { LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r); @@ -303,7 +303,7 @@ bool CColorManagementSurface::good() { } wl_client* CColorManagementSurface::client() { - return pClient; + return m_client; } const SImageDescription& CColorManagementSurface::imageDescription() { @@ -340,20 +340,20 @@ bool CColorManagementSurface::needsHdrMetadataUpdate() { } CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP resource, SP surface_) : - surface(surface_), m_resource(resource) { + m_surface(surface_), m_resource(resource) { if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); m_resource->setDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); + LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); + LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(this); @@ -365,20 +365,20 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SPdestroyResource(m_currentPreferred.get()); - const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id), true)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vImageDescriptions.pop_back(); + PROTO::colorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; m_currentPreferred = RESOURCE; - m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription(); - RESOURCE->resource()->sendReady(m_currentPreferred->settings.updateId()); + m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription(); + RESOURCE->resource()->sendReady(m_currentPreferred->m_settings.updateId()); }); m_resource->setGetPreferredParametric([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) { @@ -392,26 +392,26 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SPdestroyResource(m_currentPreferred.get()); - const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id), true)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vImageDescriptions.pop_back(); + PROTO::colorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; m_currentPreferred = RESOURCE; - m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription(); - if (!PROTO::colorManagement->m_debug && m_currentPreferred->settings.icc.fd) { + m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription(); + if (!PROTO::colorManagement->m_debug && m_currentPreferred->m_settings.icc.fd) { LOGM(ERR, "FIXME: parse icc profile"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported"); return; } - RESOURCE->resource()->sendReady(m_currentPreferred->settings.updateId()); + RESOURCE->resource()->sendReady(m_currentPreferred->m_settings.updateId()); }); } @@ -420,14 +420,14 @@ bool CColorManagementFeedbackSurface::good() { } wl_client* CColorManagementFeedbackSurface::client() { - return pClient; + return m_client; } CColorManagementIccCreator::CColorManagementIccCreator(SP resource) : m_resource(resource) { if UNLIKELY (!good()) return; // - pClient = m_resource->client(); + m_client = m_resource->client(); m_resource->setOnDestroy([this](CWpImageDescriptionCreatorIccV1* r) { PROTO::colorManagement->destroyResource(this); }); @@ -435,39 +435,39 @@ CColorManagementIccCreator::CColorManagementIccCreator(SPerror(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET, "Missing required settings"); return; } - const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id), false)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vImageDescriptions.pop_back(); + PROTO::colorManagement->m_imageDescriptions.pop_back(); return; } - LOGM(ERR, "FIXME: Parse icc file {}({},{}) for id {}", settings.icc.fd, settings.icc.offset, settings.icc.length, id); + LOGM(ERR, "FIXME: Parse icc file {}({},{}) for id {}", m_settings.icc.fd, m_settings.icc.offset, m_settings.icc.length, id); // FIXME actually check support - if (settings.icc.fd < 0 || !settings.icc.length) { + if (m_settings.icc.fd < 0 || !m_settings.icc.length) { RESOURCE->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "unsupported"); return; } - RESOURCE->self = RESOURCE; - RESOURCE->settings = settings; - RESOURCE->resource()->sendReady(settings.updateId()); + RESOURCE->m_self = RESOURCE; + RESOURCE->m_settings = m_settings; + RESOURCE->resource()->sendReady(m_settings.updateId()); PROTO::colorManagement->destroyResource(this); }); m_resource->setSetIccFile([this](CWpImageDescriptionCreatorIccV1* r, int fd, uint32_t offset, uint32_t length) { - settings.icc.fd = fd; - settings.icc.offset = offset; - settings.icc.length = length; + m_settings.icc.fd = fd; + m_settings.icc.offset = offset; + m_settings.icc.length = length; }); } @@ -476,14 +476,14 @@ bool CColorManagementIccCreator::good() { } wl_client* CColorManagementIccCreator::client() { - return pClient; + return m_client; } CColorManagementParametricCreator::CColorManagementParametricCreator(SP resource) : m_resource(resource) { if UNLIKELY (!good()) return; // - pClient = m_resource->client(); + m_client = m_resource->client(); m_resource->setOnDestroy([this](CWpImageDescriptionCreatorParamsV1* r) { PROTO::colorManagement->destroyResource(this); }); @@ -491,35 +491,35 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET, "Missing required settings"); return; } - const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id), false)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::colorManagement->m_vImageDescriptions.pop_back(); + PROTO::colorManagement->m_imageDescriptions.pop_back(); return; } // FIXME actually check support - if (!valuesSet) { + if (!m_valuesSet) { RESOURCE->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "unsupported"); return; } - RESOURCE->self = RESOURCE; - RESOURCE->settings = settings; - RESOURCE->resource()->sendReady(settings.updateId()); + RESOURCE->m_self = RESOURCE; + RESOURCE->m_settings = m_settings; + RESOURCE->resource()->sendReady(m_settings.updateId()); PROTO::colorManagement->destroyResource(this); }); m_resource->setSetTfNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t tf) { LOGM(TRACE, "Set image description transfer function to {}", tf); - if (valuesSet & PC_TF) { + if (m_valuesSet & PC_TF) { r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function already set"); return; } @@ -534,12 +534,12 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Unsupported transfer function"); return; } - settings.transferFunction = convertTransferFunction((wpColorManagerV1TransferFunction)tf); - valuesSet |= PC_TF; + m_settings.transferFunction = convertTransferFunction((wpColorManagerV1TransferFunction)tf); + m_valuesSet |= PC_TF; }); m_resource->setSetTfPower([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t eexp) { LOGM(TRACE, "Set image description tf power to {}", eexp); - if (valuesSet & PC_TF_POWER) { + if (m_valuesSet & PC_TF_POWER) { r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Transfer function power already set"); return; } @@ -547,16 +547,16 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "TF power is not supported"); return; } - settings.transferFunctionPower = eexp / 10000.0f; - if (settings.transferFunctionPower < 1.0 || settings.transferFunctionPower > 10.0) { + m_settings.transferFunctionPower = eexp / 10000.0f; + if (m_settings.transferFunctionPower < 1.0 || m_settings.transferFunctionPower > 10.0) { r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Power should be between 1.0 and 10.0"); return; } - valuesSet |= PC_TF_POWER; + m_valuesSet |= PC_TF_POWER; }); m_resource->setSetPrimariesNamed([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t primaries) { LOGM(TRACE, "Set image description primaries by name {}", primaries); - if (valuesSet & PC_PRIMARIES) { + if (m_valuesSet & PC_PRIMARIES) { r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set"); return; } @@ -578,15 +578,15 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPsetSetPrimaries( [this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { LOGM(TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); - if (valuesSet & PC_PRIMARIES) { + if (m_valuesSet & PC_PRIMARIES) { r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set"); return; } @@ -594,17 +594,17 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Custom primaries aren't supported"); return; } - settings.primariesNameSet = false; - settings.primaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f}, - .green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f}, - .blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f}, - .white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}}; - valuesSet |= PC_PRIMARIES; + m_settings.primariesNameSet = false; + m_settings.primaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f}, + .green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f}, + .blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f}, + .white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}}; + m_valuesSet |= PC_PRIMARIES; }); m_resource->setSetLuminances([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { auto min = min_lum / 10000.0f; LOGM(TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum); - if (valuesSet & PC_LUMINANCES) { + if (m_valuesSet & PC_LUMINANCES) { r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Luminances already set"); return; } @@ -612,13 +612,13 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE, "Invalid luminances"); return; } - settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum}; - valuesSet |= PC_LUMINANCES; + m_settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum}; + m_valuesSet |= PC_LUMINANCES; }); m_resource->setSetMasteringDisplayPrimaries( [this](CWpImageDescriptionCreatorParamsV1* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { LOGM(TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); - if (valuesSet & PC_MASTERING_PRIMARIES) { + if (m_valuesSet & PC_MASTERING_PRIMARIES) { r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Mastering primaries already set"); return; } @@ -626,11 +626,11 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Mastering primaries are not supported"); return; } - settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f}, - .green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f}, - .blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f}, - .white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}}; - valuesSet |= PC_MASTERING_PRIMARIES; + m_settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f}, + .green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f}, + .blue = {.x = b_x / 1000000.0f, .y = b_y / 1000000.0f}, + .white = {.x = w_x / 1000000.0f, .y = w_y / 1000000.0f}}; + m_valuesSet |= PC_MASTERING_PRIMARIES; // FIXME: // If a compositor additionally supports target color volume exceeding the primary color volume, it must advertise wp_color_manager_v1.feature.extended_target_volume. @@ -652,8 +652,8 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Mastering luminances are not supported"); return; } - settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum}; - valuesSet |= PC_MASTERING_LUMINANCES; + m_settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum}; + m_valuesSet |= PC_MASTERING_LUMINANCES; }); m_resource->setSetMaxCll([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_cll) { LOGM(TRACE, "Set image description max content light level to {}", max_cll); @@ -661,8 +661,8 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max CLL already set"); // return; // } - settings.maxCLL = max_cll; - valuesSet |= PC_CLL; + m_settings.maxCLL = max_cll; + m_valuesSet |= PC_CLL; }); m_resource->setSetMaxFall([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t max_fall) { LOGM(TRACE, "Set image description max frame-average light level to {}", max_fall); @@ -670,8 +670,8 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPerror(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Max FALL already set"); // return; // } - settings.maxFALL = max_fall; - valuesSet |= PC_FALL; + m_settings.maxFALL = max_fall; + m_valuesSet |= PC_FALL; }); } @@ -680,7 +680,7 @@ bool CColorManagementParametricCreator::good() { } wl_client* CColorManagementParametricCreator::client() { - return pClient; + return m_client; } CColorManagementImageDescription::CColorManagementImageDescription(SP resource, bool allowGetInformation) : @@ -688,7 +688,7 @@ CColorManagementImageDescription::CColorManagementImageDescription(SPclient(); + m_client = m_resource->client(); m_resource->setDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpImageDescriptionV1* r) { PROTO::colorManagement->destroyResource(this); }); @@ -700,7 +700,7 @@ CColorManagementImageDescription::CColorManagementImageDescription(SP(makeShared(r->client(), r->version(), id), settings); + auto RESOURCE = makeShared(makeShared(r->client(), r->version(), id), m_settings); if UNLIKELY (!RESOURCE->good()) r->noMemory(); @@ -715,7 +715,7 @@ bool CColorManagementImageDescription::good() { } wl_client* CColorManagementImageDescription::client() { - return pClient; + return m_client; } SP CColorManagementImageDescription::resource() { @@ -723,33 +723,34 @@ SP CColorManagementImageDescription::resource() { } CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP resource, const SImageDescription& settings_) : - m_resource(resource), settings(settings_) { + m_resource(resource), m_settings(settings_) { if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); }; - if (settings.icc.fd >= 0) - m_resource->sendIccFile(settings.icc.fd, settings.icc.length); + if (m_settings.icc.fd >= 0) + m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length); // send preferred client paramateres - m_resource->sendPrimaries(toProto(settings.primaries.red.x), toProto(settings.primaries.red.y), toProto(settings.primaries.green.x), toProto(settings.primaries.green.y), - toProto(settings.primaries.blue.x), toProto(settings.primaries.blue.y), toProto(settings.primaries.white.x), toProto(settings.primaries.white.y)); - if (settings.primariesNameSet) - m_resource->sendPrimariesNamed(settings.primariesNamed); - m_resource->sendTfPower(std::round(settings.transferFunctionPower * 10000)); - m_resource->sendTfNamed(settings.transferFunction); - m_resource->sendLuminances(std::round(settings.luminances.min * 10000), settings.luminances.max, settings.luminances.reference); + m_resource->sendPrimaries(toProto(m_settings.primaries.red.x), toProto(m_settings.primaries.red.y), toProto(m_settings.primaries.green.x), + toProto(m_settings.primaries.green.y), toProto(m_settings.primaries.blue.x), toProto(m_settings.primaries.blue.y), + toProto(m_settings.primaries.white.x), toProto(m_settings.primaries.white.y)); + if (m_settings.primariesNameSet) + m_resource->sendPrimariesNamed(m_settings.primariesNamed); + m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000)); + m_resource->sendTfNamed(m_settings.transferFunction); + m_resource->sendLuminances(std::round(m_settings.luminances.min * 10000), m_settings.luminances.max, m_settings.luminances.reference); // send expexted display paramateres - m_resource->sendTargetPrimaries(toProto(settings.masteringPrimaries.red.x), toProto(settings.masteringPrimaries.red.y), toProto(settings.masteringPrimaries.green.x), - toProto(settings.masteringPrimaries.green.y), toProto(settings.masteringPrimaries.blue.x), toProto(settings.masteringPrimaries.blue.y), - toProto(settings.masteringPrimaries.white.x), toProto(settings.masteringPrimaries.white.y)); - m_resource->sendTargetLuminance(std::round(settings.masteringLuminances.min * 10000), settings.masteringLuminances.max); - m_resource->sendTargetMaxCll(settings.maxCLL); - m_resource->sendTargetMaxFall(settings.maxFALL); + m_resource->sendTargetPrimaries(toProto(m_settings.masteringPrimaries.red.x), toProto(m_settings.masteringPrimaries.red.y), toProto(m_settings.masteringPrimaries.green.x), + toProto(m_settings.masteringPrimaries.green.y), toProto(m_settings.masteringPrimaries.blue.x), toProto(m_settings.masteringPrimaries.blue.y), + toProto(m_settings.masteringPrimaries.white.x), toProto(m_settings.masteringPrimaries.white.y)); + m_resource->sendTargetLuminance(std::round(m_settings.masteringLuminances.min * 10000), m_settings.masteringLuminances.max); + m_resource->sendTargetMaxCll(m_settings.maxCLL); + m_resource->sendTargetMaxFall(m_settings.maxFALL); m_resource->sendDone(); } @@ -759,7 +760,7 @@ bool CColorManagementImageDescriptionInfo::good() { } wl_client* CColorManagementImageDescriptionInfo::client() { - return pClient; + return m_client; } CColorManagementProtocol::CColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name, bool debug) : @@ -768,11 +769,11 @@ CColorManagementProtocol::CColorManagementProtocol(const wl_interface* iface, co } void CColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } @@ -780,42 +781,42 @@ void CColorManagementProtocol::bindManager(wl_client* client, void* data, uint32 } void CColorManagementProtocol::onImagePreferredChanged(uint32_t preferredId) { - for (auto const& feedback : m_vFeedbackSurfaces) { + for (auto const& feedback : m_feedbackSurfaces) { feedback->m_resource->sendPreferredChanged(preferredId); } } void CColorManagementProtocol::onMonitorImageDescriptionChanged(WP monitor) { - for (auto const& output : m_vOutputs) { + for (auto const& output : m_outputs) { if (output->m_monitor == monitor) output->m_resource->sendImageDescriptionChanged(); } } void CColorManagementProtocol::destroyResource(CColorManager* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CColorManagementProtocol::destroyResource(CColorManagementOutput* resource) { - std::erase_if(m_vOutputs, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_outputs, [&](const auto& other) { return other.get() == resource; }); } void CColorManagementProtocol::destroyResource(CColorManagementSurface* resource) { - std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; }); } void CColorManagementProtocol::destroyResource(CColorManagementFeedbackSurface* resource) { - std::erase_if(m_vFeedbackSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_feedbackSurfaces, [&](const auto& other) { return other.get() == resource; }); } void CColorManagementProtocol::destroyResource(CColorManagementIccCreator* resource) { - std::erase_if(m_vIccCreators, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_iccCreators, [&](const auto& other) { return other.get() == resource; }); } void CColorManagementProtocol::destroyResource(CColorManagementParametricCreator* resource) { - std::erase_if(m_vParametricCreators, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_parametricCreators, [&](const auto& other) { return other.get() == resource; }); } void CColorManagementProtocol::destroyResource(CColorManagementImageDescription* resource) { - std::erase_if(m_vImageDescriptions, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_imageDescriptions, [&](const auto& other) { return other.get() == resource; }); } diff --git a/src/protocols/ColorManagement.hpp b/src/protocols/ColorManagement.hpp index 5a94920d1..fc3a8d54c 100644 --- a/src/protocols/ColorManagement.hpp +++ b/src/protocols/ColorManagement.hpp @@ -31,12 +31,12 @@ class CColorManagementOutput { bool good(); wl_client* client(); - WP self; - WP imageDescription; + WP m_self; + WP m_imageDescription; private: SP m_resource; - wl_client* pClient = nullptr; + wl_client* m_client = nullptr; WP m_monitor; friend class CColorManagementProtocol; @@ -51,8 +51,8 @@ class CColorManagementSurface { bool good(); wl_client* client(); - WP self; - WP surface; + WP m_self; + WP m_surface; const NColorManagement::SImageDescription& imageDescription(); bool hasImageDescription(); @@ -63,7 +63,7 @@ class CColorManagementSurface { private: SP m_resource; - wl_client* pClient = nullptr; + wl_client* m_client = nullptr; NColorManagement::SImageDescription m_imageDescription; NColorManagement::SImageDescription m_lastImageDescription; bool m_hasImageDescription = false; @@ -81,12 +81,12 @@ class CColorManagementFeedbackSurface { bool good(); wl_client* client(); - WP self; - WP surface; + WP m_self; + WP m_surface; private: SP m_resource; - wl_client* pClient = nullptr; + wl_client* m_client = nullptr; WP m_currentPreferred; @@ -100,13 +100,13 @@ class CColorManagementIccCreator { bool good(); wl_client* client(); - WP self; + WP m_self; - NColorManagement::SImageDescription settings; + NColorManagement::SImageDescription m_settings; private: SP m_resource; - wl_client* pClient = nullptr; + wl_client* m_client = nullptr; }; class CColorManagementParametricCreator { @@ -116,9 +116,9 @@ class CColorManagementParametricCreator { bool good(); wl_client* client(); - WP self; + WP m_self; - NColorManagement::SImageDescription settings; + NColorManagement::SImageDescription m_settings; private: enum eValuesSet : uint32_t { // NOLINT @@ -133,8 +133,8 @@ class CColorManagementParametricCreator { }; SP m_resource; - wl_client* pClient = nullptr; - uint32_t valuesSet = 0; // enum eValuesSet + wl_client* m_client = nullptr; + uint32_t m_valuesSet = 0; // enum eValuesSet }; class CColorManagementImageDescription { @@ -145,13 +145,13 @@ class CColorManagementImageDescription { wl_client* client(); SP resource(); - WP self; + WP m_self; - NColorManagement::SImageDescription settings; + NColorManagement::SImageDescription m_settings; private: SP m_resource; - wl_client* pClient = nullptr; + wl_client* m_client = nullptr; bool m_allowGetInformation = false; friend class CColorManagementOutput; @@ -166,8 +166,8 @@ class CColorManagementImageDescriptionInfo { private: SP m_resource; - wl_client* pClient = nullptr; - NColorManagement::SImageDescription settings; + wl_client* m_client = nullptr; + NColorManagement::SImageDescription m_settings; }; class CColorManagementProtocol : public IWaylandProtocol { @@ -188,13 +188,13 @@ class CColorManagementProtocol : public IWaylandProtocol { void destroyResource(CColorManagementParametricCreator* resource); void destroyResource(CColorManagementImageDescription* resource); - std::vector> m_vManagers; - std::vector> m_vOutputs; - std::vector> m_vSurfaces; - std::vector> m_vFeedbackSurfaces; - std::vector> m_vIccCreators; - std::vector> m_vParametricCreators; - std::vector> m_vImageDescriptions; + std::vector> m_managers; + std::vector> m_outputs; + std::vector> m_surfaces; + std::vector> m_feedbackSurfaces; + std::vector> m_iccCreators; + std::vector> m_parametricCreators; + std::vector> m_imageDescriptions; bool m_debug = false; friend class CColorManager; diff --git a/src/protocols/ContentType.cpp b/src/protocols/ContentType.cpp index 8ea212f1a..218c7aebe 100644 --- a/src/protocols/ContentType.cpp +++ b/src/protocols/ContentType.cpp @@ -24,14 +24,14 @@ CContentTypeManager::CContentTypeManager(SP resource) : return; } - const auto RESOURCE = PROTO::contentType->m_vContentTypes.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); + const auto RESOURCE = PROTO::contentType->m_contentTypes.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::contentType->m_vContentTypes.pop_back(); + PROTO::contentType->m_contentTypes.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; SURF->m_contentType = RESOURCE; }); @@ -42,19 +42,19 @@ bool CContentTypeManager::good() { } CContentType::CContentType(WP surface) { - destroy = surface->m_events.destroy.registerListener([this](std::any d) { PROTO::contentType->destroyResource(this); }); + m_destroy = surface->m_events.destroy.registerListener([this](std::any d) { PROTO::contentType->destroyResource(this); }); } CContentType::CContentType(SP resource) : m_resource(resource) { if UNLIKELY (!good()) return; - m_pClient = resource->client(); + m_client = resource->client(); resource->setDestroy([this](CWpContentTypeV1* r) { PROTO::contentType->destroyResource(this); }); resource->setOnDestroy([this](CWpContentTypeV1* r) { PROTO::contentType->destroyResource(this); }); - resource->setSetContentType([this](CWpContentTypeV1* r, wpContentTypeV1Type type) { value = NContentType::fromWP(type); }); + resource->setSetContentType([this](CWpContentTypeV1* r, wpContentTypeV1Type type) { m_value = NContentType::fromWP(type); }); } bool CContentType::good() { @@ -62,7 +62,7 @@ bool CContentType::good() { } wl_client* CContentType::client() { - return m_pClient; + return m_client; } CContentTypeProtocol::CContentTypeProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -70,11 +70,11 @@ CContentTypeProtocol::CContentTypeProtocol(const wl_interface* iface, const int& } void CContentTypeProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } @@ -83,13 +83,13 @@ SP CContentTypeProtocol::getContentType(WP sur if (surface->m_contentType.valid()) return surface->m_contentType.lock(); - return m_vContentTypes.emplace_back(makeShared(surface)); + return m_contentTypes.emplace_back(makeShared(surface)); } void CContentTypeProtocol::destroyResource(CContentTypeManager* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CContentTypeProtocol::destroyResource(CContentType* resource) { - std::erase_if(m_vContentTypes, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_contentTypes, [&](const auto& other) { return other.get() == resource; }); } diff --git a/src/protocols/ContentType.hpp b/src/protocols/ContentType.hpp index 4c0c445f2..4fc9bee58 100644 --- a/src/protocols/ContentType.hpp +++ b/src/protocols/ContentType.hpp @@ -22,15 +22,15 @@ class CContentType { bool good(); wl_client* client(); - NContentType::eContentType value = NContentType::CONTENT_TYPE_NONE; + NContentType::eContentType m_value = NContentType::CONTENT_TYPE_NONE; - WP self; + WP m_self; private: SP m_resource; - wl_client* m_pClient = nullptr; + wl_client* m_client = nullptr; - CHyprSignalListener destroy; + CHyprSignalListener m_destroy; friend class CContentTypeProtocol; }; @@ -47,8 +47,8 @@ class CContentTypeProtocol : public IWaylandProtocol { void destroyResource(CContentTypeManager* resource); void destroyResource(CContentType* resource); - std::vector> m_vManagers; - std::vector> m_vContentTypes; + std::vector> m_managers; + std::vector> m_contentTypes; friend class CContentTypeManager; friend class CContentType; diff --git a/src/protocols/CursorShape.cpp b/src/protocols/CursorShape.cpp index d38d5a8cd..26f79a86c 100644 --- a/src/protocols/CursorShape.cpp +++ b/src/protocols/CursorShape.cpp @@ -7,15 +7,15 @@ CCursorShapeProtocol::CCursorShapeProtocol(const wl_interface* iface, const int& } void CCursorShapeProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [res](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [res](const auto& other) { return other->resource() == res; }); } void CCursorShapeProtocol::onDeviceResourceDestroy(wl_resource* res) { - std::erase_if(m_vDevices, [res](const auto& other) { return other->resource() == res; }); + std::erase_if(m_devices, [res](const auto& other) { return other->resource() == res; }); } void CCursorShapeProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CWpCursorShapeManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CWpCursorShapeManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -33,7 +33,7 @@ void CCursorShapeProtocol::onGetTabletToolV2(CWpCursorShapeManagerV1* pMgr, uint void CCursorShapeProtocol::createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource) { const auto CLIENT = pMgr->client(); - const auto RESOURCE = m_vDevices.emplace_back(makeShared(CLIENT, pMgr->version(), id)); + const auto RESOURCE = m_devices.emplace_back(makeShared(CLIENT, pMgr->version(), id)); RESOURCE->setOnDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); }); @@ -51,5 +51,5 @@ void CCursorShapeProtocol::onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t ser event.shape = shape; event.shapeName = CURSOR_SHAPE_NAMES.at(shape); - events.setShape.emit(event); + m_events.setShape.emit(event); } \ No newline at end of file diff --git a/src/protocols/CursorShape.hpp b/src/protocols/CursorShape.hpp index 37b7e6c87..d7ae75c16 100644 --- a/src/protocols/CursorShape.hpp +++ b/src/protocols/CursorShape.hpp @@ -19,7 +19,7 @@ class CCursorShapeProtocol : public IWaylandProtocol { struct { CSignal setShape; - } events; + } m_events; private: void onManagerResourceDestroy(wl_resource* res); @@ -32,8 +32,8 @@ class CCursorShapeProtocol : public IWaylandProtocol { void createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource); // - std::vector> m_vDevices; - std::vector> m_vManagers; + std::vector> m_devices; + std::vector> m_managers; }; namespace PROTO { diff --git a/src/protocols/DRMLease.cpp b/src/protocols/DRMLease.cpp index 80c34d23a..c4b5a84ab 100644 --- a/src/protocols/DRMLease.cpp +++ b/src/protocols/DRMLease.cpp @@ -6,20 +6,20 @@ #include using namespace Hyprutils::OS; -CDRMLeaseResource::CDRMLeaseResource(SP resource_, SP request) : resource(resource_) { +CDRMLeaseResource::CDRMLeaseResource(SP resource_, SP request) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); }); - resource->setDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); }); + m_resource->setDestroy([this](CWpDrmLeaseV1* r) { PROTO::lease->destroyResource(this); }); - parent = request->parent; - requested = request->requested; + m_parent = request->m_parent; + m_requested = request->m_requested; - for (auto const& m : requested) { - if (!m->monitor || m->monitor->m_isBeingLeased) { - LOGM(ERR, "Rejecting lease: no monitor or monitor is being leased for {}", (m->monitor ? m->monitor->m_name : "null")); - resource->sendFinished(); + for (auto const& m : m_requested) { + if (!m->m_monitor || m->m_monitor->m_isBeingLeased) { + LOGM(ERR, "Rejecting lease: no monitor or monitor is being leased for {}", (m->m_monitor ? m->m_monitor->m_name : "null")); + m_resource->sendFinished(); return; } } @@ -28,97 +28,97 @@ CDRMLeaseResource::CDRMLeaseResource(SP resource_, SPmonitor->m_name); + for (auto const& o : m_requested) { + roll += std::format("{} ", o->m_monitor->m_name); } return roll; }()); std::vector> outputs; // reserve to avoid reallocations - outputs.reserve(requested.size()); + outputs.reserve(m_requested.size()); - for (auto const& m : requested) { - outputs.emplace_back(m->monitor->m_output); + for (auto const& m : m_requested) { + outputs.emplace_back(m->m_monitor->m_output); } auto aqlease = Aquamarine::CDRMLease::create(outputs); if (!aqlease) { LOGM(ERR, "Rejecting lease: backend failed to alloc a lease"); - resource->sendFinished(); + m_resource->sendFinished(); return; } - lease = aqlease; + m_lease = aqlease; - for (auto const& m : requested) { - m->monitor->m_isBeingLeased = true; + for (auto const& m : m_requested) { + m->m_monitor->m_isBeingLeased = true; } - listeners.destroyLease = lease->events.destroy.registerListener([this](std::any d) { - for (auto const& m : requested) { - if (m && m->monitor) - m->monitor->m_isBeingLeased = false; + m_listeners.destroyLease = m_lease->events.destroy.registerListener([this](std::any d) { + for (auto const& m : m_requested) { + if (m && m->m_monitor) + m->m_monitor->m_isBeingLeased = false; } - resource->sendFinished(); - LOGM(LOG, "Revoking lease for fd {}", lease->leaseFD); + m_resource->sendFinished(); + LOGM(LOG, "Revoking lease for fd {}", m_lease->leaseFD); }); - LOGM(LOG, "Granting lease, sending fd {}", lease->leaseFD); + LOGM(LOG, "Granting lease, sending fd {}", m_lease->leaseFD); - resource->sendLeaseFd(lease->leaseFD); + m_resource->sendLeaseFd(m_lease->leaseFD); - close(lease->leaseFD); + close(m_lease->leaseFD); } bool CDRMLeaseResource::good() { - return resource->resource(); + return m_resource->resource(); } CDRMLeaseResource::~CDRMLeaseResource() { // destroy in this order to ensure listener gets called - lease.reset(); - listeners.destroyLease.reset(); + m_lease.reset(); + m_listeners.destroyLease.reset(); } -CDRMLeaseRequestResource::CDRMLeaseRequestResource(SP resource_) : resource(resource_) { +CDRMLeaseRequestResource::CDRMLeaseRequestResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWpDrmLeaseRequestV1* r) { PROTO::lease->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpDrmLeaseRequestV1* r) { PROTO::lease->destroyResource(this); }); - resource->setRequestConnector([this](CWpDrmLeaseRequestV1* r, wl_resource* conn) { + m_resource->setRequestConnector([this](CWpDrmLeaseRequestV1* r, wl_resource* conn) { if (!conn) { - resource->error(-1, "Null connector"); + m_resource->error(-1, "Null connector"); return; } auto CONNECTOR = CDRMLeaseConnectorResource::fromResource(conn); - if (std::find(requested.begin(), requested.end(), CONNECTOR) != requested.end()) { - resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_DUPLICATE_CONNECTOR, "Connector already requested"); + if (std::find(m_requested.begin(), m_requested.end(), CONNECTOR) != m_requested.end()) { + m_resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_DUPLICATE_CONNECTOR, "Connector already requested"); return; } // TODO: when (if) we add multi, make sure this is from the correct device. - requested.emplace_back(CONNECTOR); + m_requested.emplace_back(CONNECTOR); }); - resource->setSubmit([this](CWpDrmLeaseRequestV1* r, uint32_t id) { - if (requested.empty()) { - resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_EMPTY_LEASE, "No connectors added"); + m_resource->setSubmit([this](CWpDrmLeaseRequestV1* r, uint32_t id) { + if (m_requested.empty()) { + m_resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_EMPTY_LEASE, "No connectors added"); return; } - auto RESOURCE = makeShared(makeShared(resource->client(), resource->version(), id), self.lock()); + auto RESOURCE = makeShared(makeShared(m_resource->client(), m_resource->version(), id), m_self.lock()); if UNLIKELY (!RESOURCE) { - resource->noMemory(); + m_resource->noMemory(); return; } - PROTO::lease->m_vLeases.emplace_back(RESOURCE); + PROTO::lease->m_leases.emplace_back(RESOURCE); // per protcol, after submit, this is dead. PROTO::lease->destroyResource(this); @@ -126,111 +126,111 @@ CDRMLeaseRequestResource::CDRMLeaseRequestResource(SP reso } bool CDRMLeaseRequestResource::good() { - return resource->resource(); + return m_resource->resource(); } SP CDRMLeaseConnectorResource::fromResource(wl_resource* res) { auto data = (CDRMLeaseConnectorResource*)(((CWpDrmLeaseConnectorV1*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } -CDRMLeaseConnectorResource::CDRMLeaseConnectorResource(SP resource_, PHLMONITOR monitor_) : monitor(monitor_), resource(resource_) { +CDRMLeaseConnectorResource::CDRMLeaseConnectorResource(SP resource_, PHLMONITOR monitor_) : m_monitor(monitor_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); }); - resource->setDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); }); + m_resource->setDestroy([this](CWpDrmLeaseConnectorV1* r) { PROTO::lease->destroyResource(this); }); - resource->setData(this); + m_resource->setData(this); - listeners.destroyMonitor = monitor->m_events.destroy.registerListener([this](std::any d) { - resource->sendWithdrawn(); - dead = true; + m_listeners.destroyMonitor = m_monitor->m_events.destroy.registerListener([this](std::any d) { + m_resource->sendWithdrawn(); + m_dead = true; }); } bool CDRMLeaseConnectorResource::good() { - return resource->resource(); + return m_resource->resource(); } void CDRMLeaseConnectorResource::sendData() { - resource->sendName(monitor->m_name.c_str()); - resource->sendDescription(monitor->m_description.c_str()); + m_resource->sendName(m_monitor->m_name.c_str()); + m_resource->sendDescription(m_monitor->m_description.c_str()); - auto AQDRMOutput = (Aquamarine::CDRMOutput*)monitor->m_output.get(); - resource->sendConnectorId(AQDRMOutput->getConnectorID()); + auto AQDRMOutput = (Aquamarine::CDRMOutput*)m_monitor->m_output.get(); + m_resource->sendConnectorId(AQDRMOutput->getConnectorID()); - resource->sendDone(); + m_resource->sendDone(); } -CDRMLeaseDeviceResource::CDRMLeaseDeviceResource(SP resource_) : resource(resource_) { +CDRMLeaseDeviceResource::CDRMLeaseDeviceResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); }); - resource->setRelease([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); }); + m_resource->setRelease([this](CWpDrmLeaseDeviceV1* r) { PROTO::lease->destroyResource(this); }); - resource->setCreateLeaseRequest([this](CWpDrmLeaseDeviceV1* r, uint32_t id) { - auto RESOURCE = makeShared(makeShared(resource->client(), resource->version(), id)); + m_resource->setCreateLeaseRequest([this](CWpDrmLeaseDeviceV1* r, uint32_t id) { + auto RESOURCE = makeShared(makeShared(m_resource->client(), m_resource->version(), id)); if UNLIKELY (!RESOURCE) { - resource->noMemory(); + m_resource->noMemory(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; - PROTO::lease->m_vRequests.emplace_back(RESOURCE); + PROTO::lease->m_requests.emplace_back(RESOURCE); LOGM(LOG, "New lease request {}", id); - RESOURCE->parent = self; + RESOURCE->m_parent = m_self; }); - CFileDescriptor fd{((Aquamarine::CDRMBackend*)PROTO::lease->primaryDevice->backend.get())->getNonMasterFD()}; + CFileDescriptor fd{((Aquamarine::CDRMBackend*)PROTO::lease->m_primaryDevice->m_backend.get())->getNonMasterFD()}; if (!fd.isValid()) { LOGM(ERR, "Failed to dup fd in lease"); return; } LOGM(LOG, "Sending DRMFD {} to new lease device", fd.get()); - resource->sendDrmFd(fd.get()); + m_resource->sendDrmFd(fd.get()); - for (auto const& m : PROTO::lease->primaryDevice->offeredOutputs) { + for (auto const& m : PROTO::lease->m_primaryDevice->m_offeredOutputs) { if (m) sendConnector(m.lock()); } - resource->sendDone(); + m_resource->sendDone(); } bool CDRMLeaseDeviceResource::good() { - return resource->resource(); + return m_resource->resource(); } void CDRMLeaseDeviceResource::sendConnector(PHLMONITOR monitor) { - if (std::find_if(connectorsSent.begin(), connectorsSent.end(), [monitor](const auto& e) { return e && !e->dead && e->monitor == monitor; }) != connectorsSent.end()) + if (std::find_if(m_connectorsSent.begin(), m_connectorsSent.end(), [monitor](const auto& e) { return e && !e->m_dead && e->m_monitor == monitor; }) != m_connectorsSent.end()) return; - auto RESOURCE = makeShared(makeShared(resource->client(), resource->version(), 0), monitor); + auto RESOURCE = makeShared(makeShared(m_resource->client(), m_resource->version(), 0), monitor); if UNLIKELY (!RESOURCE) { - resource->noMemory(); + m_resource->noMemory(); return; } - RESOURCE->parent = self; - RESOURCE->self = RESOURCE; + RESOURCE->m_parent = m_self; + RESOURCE->m_self = RESOURCE; LOGM(LOG, "Sending new connector {}", monitor->m_name); - connectorsSent.emplace_back(RESOURCE); - PROTO::lease->m_vConnectors.emplace_back(RESOURCE); + m_connectorsSent.emplace_back(RESOURCE); + PROTO::lease->m_connectors.emplace_back(RESOURCE); - resource->sendConnector(RESOURCE->resource.get()); + m_resource->sendConnector(RESOURCE->m_resource.get()); RESOURCE->sendData(); } -CDRMLeaseDevice::CDRMLeaseDevice(SP drmBackend) : backend(drmBackend) { +CDRMLeaseDevice::CDRMLeaseDevice(SP drmBackend) : m_backend(drmBackend) { auto drm = (Aquamarine::CDRMBackend*)drmBackend.get(); CFileDescriptor fd{drm->getNonMasterFD()}; @@ -240,8 +240,8 @@ CDRMLeaseDevice::CDRMLeaseDevice(SP drmBackend) : backe return; } - success = true; - name = drm->gpuName; + m_success = true; + m_name = drm->gpuName; } CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -251,64 +251,64 @@ CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver, auto drm = ((Aquamarine::CDRMBackend*)b.get())->self.lock(); - primaryDevice = makeShared(drm); + m_primaryDevice = makeShared(drm); - if (primaryDevice->success) + if (m_primaryDevice->m_success) break; } - if (!primaryDevice || !primaryDevice->success) + if (!m_primaryDevice || !m_primaryDevice->m_success) g_pEventLoopManager->doLater([]() { PROTO::lease.reset(); }); } void CDRMLeaseProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; } void CDRMLeaseProtocol::destroyResource(CDRMLeaseDeviceResource* resource) { - std::erase_if(m_vManagers, [resource](const auto& e) { return e.get() == resource; }); + std::erase_if(m_managers, [resource](const auto& e) { return e.get() == resource; }); } void CDRMLeaseProtocol::destroyResource(CDRMLeaseConnectorResource* resource) { - for (const auto& m : m_vManagers) { - std::erase_if(m->connectorsSent, [resource](const auto& e) { return e.expired() || e->dead || e.get() == resource; }); + for (const auto& m : m_managers) { + std::erase_if(m->m_connectorsSent, [resource](const auto& e) { return e.expired() || e->m_dead || e.get() == resource; }); } - std::erase_if(m_vConnectors, [resource](const auto& e) { return e.get() == resource; }); + std::erase_if(m_connectors, [resource](const auto& e) { return e.get() == resource; }); } void CDRMLeaseProtocol::destroyResource(CDRMLeaseRequestResource* resource) { - std::erase_if(m_vRequests, [resource](const auto& e) { return e.get() == resource; }); + std::erase_if(m_requests, [resource](const auto& e) { return e.get() == resource; }); } void CDRMLeaseProtocol::destroyResource(CDRMLeaseResource* resource) { - std::erase_if(m_vLeases, [resource](const auto& e) { return e.get() == resource; }); + std::erase_if(m_leases, [resource](const auto& e) { return e.get() == resource; }); } void CDRMLeaseProtocol::offer(PHLMONITOR monitor) { - std::erase_if(primaryDevice->offeredOutputs, [](const auto& e) { return e.expired(); }); - if (std::find(primaryDevice->offeredOutputs.begin(), primaryDevice->offeredOutputs.end(), monitor) != primaryDevice->offeredOutputs.end()) + std::erase_if(m_primaryDevice->m_offeredOutputs, [](const auto& e) { return e.expired(); }); + if (std::find(m_primaryDevice->m_offeredOutputs.begin(), m_primaryDevice->m_offeredOutputs.end(), monitor) != m_primaryDevice->m_offeredOutputs.end()) return; if (monitor->m_output->getBackend()->type() != Aquamarine::AQ_BACKEND_DRM) return; - if (monitor->m_output->getBackend() != primaryDevice->backend) { + if (monitor->m_output->getBackend() != m_primaryDevice->m_backend) { LOGM(ERR, "Monitor {} cannot be leased: primaryDevice lease is for a different device", monitor->m_name); return; } - primaryDevice->offeredOutputs.emplace_back(monitor); + m_primaryDevice->m_offeredOutputs.emplace_back(monitor); - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->sendConnector(monitor); - m->resource->sendDone(); + m->m_resource->sendDone(); } } diff --git a/src/protocols/DRMLease.hpp b/src/protocols/DRMLease.hpp index c7849149d..5ea1c4e23 100644 --- a/src/protocols/DRMLease.hpp +++ b/src/protocols/DRMLease.hpp @@ -26,18 +26,16 @@ class CDRMLeaseResource { bool good(); - WP parent; - std::vector> requested; - SP lease; - - int leaseFD = -1; + WP m_parent; + std::vector> m_requested; + SP m_lease; struct { CHyprSignalListener destroyLease; - } listeners; + } m_listeners; private: - SP resource; + SP m_resource; }; class CDRMLeaseRequestResource { @@ -46,12 +44,12 @@ class CDRMLeaseRequestResource { bool good(); - WP parent; - WP self; - std::vector> requested; + WP m_parent; + WP m_self; + std::vector> m_requested; private: - SP resource; + SP m_resource; }; class CDRMLeaseConnectorResource { @@ -62,17 +60,17 @@ class CDRMLeaseConnectorResource { bool good(); void sendData(); - WP self; - WP parent; - PHLMONITORREF monitor; - bool dead = false; + WP m_self; + WP m_parent; + PHLMONITORREF m_monitor; + bool m_dead = false; private: - SP resource; + SP m_resource; struct { CHyprSignalListener destroyMonitor; - } listeners; + } m_listeners; friend class CDRMLeaseDeviceResource; }; @@ -84,12 +82,12 @@ class CDRMLeaseDeviceResource { bool good(); void sendConnector(PHLMONITOR monitor); - std::vector> connectorsSent; + std::vector> m_connectorsSent; - WP self; + WP m_self; private: - SP resource; + SP m_resource; friend class CDRMLeaseProtocol; }; @@ -98,11 +96,11 @@ class CDRMLeaseDevice { public: CDRMLeaseDevice(SP drmBackend); - std::string name = ""; - bool success = false; - SP backend; + std::string m_name = ""; + bool m_success = false; + SP m_backend; - std::vector offeredOutputs; + std::vector m_offeredOutputs; }; class CDRMLeaseProtocol : public IWaylandProtocol { @@ -120,12 +118,12 @@ class CDRMLeaseProtocol : public IWaylandProtocol { void destroyResource(CDRMLeaseResource* resource); // - std::vector> m_vManagers; - std::vector> m_vConnectors; - std::vector> m_vRequests; - std::vector> m_vLeases; + std::vector> m_managers; + std::vector> m_connectors; + std::vector> m_requests; + std::vector> m_leases; - SP primaryDevice; + SP m_primaryDevice; friend class CDRMLeaseDeviceResource; friend class CDRMLeaseConnectorResource; diff --git a/src/protocols/DRMSyncobj.cpp b/src/protocols/DRMSyncobj.cpp index 2da2340a4..611f7cb2d 100644 --- a/src/protocols/DRMSyncobj.cpp +++ b/src/protocols/DRMSyncobj.cpp @@ -45,95 +45,96 @@ void CDRMSyncPointState::signal() { } CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP&& resource_, SP surface_) : - surface(surface_), resource(std::move(resource_)) { + m_surface(surface_), m_resource(std::move(resource_)) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setOnDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); }); - resource->setDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); }); + m_resource->setDestroy([this](CWpLinuxDrmSyncobjSurfaceV1* r) { PROTO::sync->destroyResource(this); }); - resource->setSetAcquirePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) { - if (!surface) { - resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); + m_resource->setSetAcquirePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) { + if (!m_surface) { + m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); return; } - auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); - pendingAcquire = {timeline->timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; + auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); + m_pendingAcquire = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; }); - resource->setSetReleasePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) { - if (!surface) { - resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); + m_resource->setSetReleasePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) { + if (!m_surface) { + m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); return; } - auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); - pendingRelease = {timeline->timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; + auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_); + m_pendingRelease = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo}; }); - listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) { - if (!surface->m_pending.updated.buffer || !surface->m_pending.buffer) { - if (pendingAcquire.timeline() || pendingRelease.timeline()) { - resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER, "Missing buffer"); - surface->m_pending.rejected = true; + m_listeners.surfacePrecommit = m_surface->m_events.precommit.registerListener([this](std::any d) { + if (!m_surface->m_pending.updated.buffer || !m_surface->m_pending.buffer) { + if (m_pendingAcquire.timeline() || m_pendingRelease.timeline()) { + m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_BUFFER, "Missing buffer"); + m_surface->m_pending.rejected = true; } return; } - if (!pendingAcquire.timeline()) { - resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_ACQUIRE_POINT, "Missing acquire timeline"); - surface->m_pending.rejected = true; + if (!m_pendingAcquire.timeline()) { + m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_ACQUIRE_POINT, "Missing acquire timeline"); + m_surface->m_pending.rejected = true; return; } - if (!pendingRelease.timeline()) { - resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_RELEASE_POINT, "Missing release timeline"); - surface->m_pending.rejected = true; + if (!m_pendingRelease.timeline()) { + m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_NO_RELEASE_POINT, "Missing release timeline"); + m_surface->m_pending.rejected = true; return; } - if (pendingAcquire.timeline() == pendingRelease.timeline() && pendingAcquire.point() >= pendingRelease.point()) { - resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_CONFLICTING_POINTS, "Acquire and release points are on the same timeline, and acquire >= release"); - surface->m_pending.rejected = true; + if (m_pendingAcquire.timeline() == m_pendingRelease.timeline() && m_pendingAcquire.point() >= m_pendingRelease.point()) { + m_resource->error(WP_LINUX_DRM_SYNCOBJ_SURFACE_V1_ERROR_CONFLICTING_POINTS, "Acquire and release points are on the same timeline, and acquire >= release"); + m_surface->m_pending.rejected = true; return; } - surface->m_pending.updated.acquire = true; - surface->m_pending.acquire = pendingAcquire; - pendingAcquire = {}; + m_surface->m_pending.updated.acquire = true; + m_surface->m_pending.acquire = m_pendingAcquire; + m_pendingAcquire = {}; - surface->m_pending.buffer->addReleasePoint(pendingRelease); - pendingRelease = {}; + m_surface->m_pending.buffer->addReleasePoint(m_pendingRelease); + m_pendingRelease = {}; }); } bool CDRMSyncobjSurfaceResource::good() { - return resource->resource(); + return m_resource->resource(); } -CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(UP&& resource_, CFileDescriptor&& fd_) : fd(std::move(fd_)), resource(std::move(resource_)) { +CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(UP&& resource_, CFileDescriptor&& fd_) : + m_fd(std::move(fd_)), m_resource(std::move(resource_)) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setOnDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); }); - resource->setDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); }); + m_resource->setDestroy([this](CWpLinuxDrmSyncobjTimelineV1* r) { PROTO::sync->destroyResource(this); }); - timeline = CSyncTimeline::create(PROTO::sync->drmFD, std::move(fd)); + m_timeline = CSyncTimeline::create(PROTO::sync->m_drmFD, std::move(m_fd)); - if (!timeline) { - resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_INVALID_TIMELINE, "Timeline failed importing"); + if (!m_timeline) { + m_resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_INVALID_TIMELINE, "Timeline failed importing"); return; } } WP CDRMSyncobjTimelineResource::fromResource(wl_resource* res) { - for (const auto& r : PROTO::sync->m_vTimelines) { - if (r && r->resource && r->resource->resource() == res) + for (const auto& r : PROTO::sync->m_timelines) { + if (r && r->m_resource && r->m_resource->resource() == res) return r; } @@ -141,38 +142,38 @@ WP CDRMSyncobjTimelineResource::fromResource(wl_res } bool CDRMSyncobjTimelineResource::good() { - return resource->resource(); + return m_resource->resource(); } -CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP&& resource_) : resource(std::move(resource_)) { +CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP&& resource_) : m_resource(std::move(resource_)) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); }); - resource->setDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); }); + m_resource->setOnDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); }); + m_resource->setDestroy([this](CWpLinuxDrmSyncobjManagerV1* r) { PROTO::sync->destroyResource(this); }); - resource->setGetSurface([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, wl_resource* surf) { + m_resource->setGetSurface([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, wl_resource* surf) { if UNLIKELY (!surf) { - resource->error(-1, "Invalid surface"); + m_resource->error(-1, "Invalid surface"); return; } auto SURF = CWLSurfaceResource::fromResource(surf); if UNLIKELY (!SURF) { - resource->error(-1, "Invalid surface (2)"); + m_resource->error(-1, "Invalid surface (2)"); return; } if UNLIKELY (SURF->m_syncobj) { - resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS, "Surface already has a syncobj attached"); + m_resource->error(WP_LINUX_DRM_SYNCOBJ_MANAGER_V1_ERROR_SURFACE_EXISTS, "Surface already has a syncobj attached"); return; } - const auto& RESOURCE = PROTO::sync->m_vSurfaces.emplace_back( - makeUnique(makeUnique(resource->client(), resource->version(), id), SURF)); + const auto& RESOURCE = PROTO::sync->m_surfaces.emplace_back( + makeUnique(makeUnique(m_resource->client(), m_resource->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { - resource->noMemory(); - PROTO::sync->m_vSurfaces.pop_back(); + m_resource->noMemory(); + PROTO::sync->m_surfaces.pop_back(); return; } @@ -181,12 +182,12 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UPsetImportTimeline([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, int32_t fd) { - const auto& RESOURCE = PROTO::sync->m_vTimelines.emplace_back( - makeUnique(makeUnique(resource->client(), resource->version(), id), CFileDescriptor{fd})); + m_resource->setImportTimeline([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, int32_t fd) { + const auto& RESOURCE = PROTO::sync->m_timelines.emplace_back( + makeUnique(makeUnique(m_resource->client(), m_resource->version(), id), CFileDescriptor{fd})); if UNLIKELY (!RESOURCE->good()) { - resource->noMemory(); - PROTO::sync->m_vTimelines.pop_back(); + m_resource->noMemory(); + PROTO::sync->m_timelines.pop_back(); return; } @@ -195,29 +196,30 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UPresource(); + return m_resource->resource(); } -CDRMSyncobjProtocol::CDRMSyncobjProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name), drmFD(g_pCompositor->m_drmFD) {} +CDRMSyncobjProtocol::CDRMSyncobjProtocol(const wl_interface* iface, const int& ver, const std::string& name) : + IWaylandProtocol(iface, ver, name), m_drmFD(g_pCompositor->m_drmFD) {} void CDRMSyncobjProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto& RESOURCE = m_vManagers.emplace_back(makeUnique(makeUnique(client, ver, id))); + const auto& RESOURCE = m_managers.emplace_back(makeUnique(makeUnique(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjManagerResource* resource) { - std::erase_if(m_vManagers, [resource](const auto& e) { return e.get() == resource; }); + std::erase_if(m_managers, [resource](const auto& e) { return e.get() == resource; }); } void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjTimelineResource* resource) { - std::erase_if(m_vTimelines, [resource](const auto& e) { return e.get() == resource; }); + std::erase_if(m_timelines, [resource](const auto& e) { return e.get() == resource; }); } void CDRMSyncobjProtocol::destroyResource(CDRMSyncobjSurfaceResource* resource) { - std::erase_if(m_vSurfaces, [resource](const auto& e) { return e.get() == resource; }); + std::erase_if(m_surfaces, [resource](const auto& e) { return e.get() == resource; }); } diff --git a/src/protocols/DRMSyncobj.hpp b/src/protocols/DRMSyncobj.hpp index a724258b7..ed15b199e 100644 --- a/src/protocols/DRMSyncobj.hpp +++ b/src/protocols/DRMSyncobj.hpp @@ -43,15 +43,15 @@ class CDRMSyncobjSurfaceResource { bool good(); private: - WP surface; - UP resource; + WP m_surface; + UP m_resource; - CDRMSyncPointState pendingAcquire; - CDRMSyncPointState pendingRelease; + CDRMSyncPointState m_pendingAcquire; + CDRMSyncPointState m_pendingRelease; struct { CHyprSignalListener surfacePrecommit; - } listeners; + } m_listeners; }; class CDRMSyncobjTimelineResource { @@ -62,11 +62,11 @@ class CDRMSyncobjTimelineResource { bool good(); - Hyprutils::OS::CFileDescriptor fd; - SP timeline; + Hyprutils::OS::CFileDescriptor m_fd; + SP m_timeline; private: - UP resource; + UP m_resource; }; class CDRMSyncobjManagerResource { @@ -77,7 +77,7 @@ class CDRMSyncobjManagerResource { bool good(); private: - UP resource; + UP m_resource; }; class CDRMSyncobjProtocol : public IWaylandProtocol { @@ -93,12 +93,12 @@ class CDRMSyncobjProtocol : public IWaylandProtocol { void destroyResource(CDRMSyncobjSurfaceResource* resource); // - std::vector> m_vManagers; - std::vector> m_vTimelines; - std::vector> m_vSurfaces; + std::vector> m_managers; + std::vector> m_timelines; + std::vector> m_surfaces; // - int drmFD = -1; + int m_drmFD = -1; friend class CDRMSyncobjManagerResource; friend class CDRMSyncobjTimelineResource; diff --git a/src/protocols/DataDeviceWlr.cpp b/src/protocols/DataDeviceWlr.cpp index a79e71af4..2e9c032b0 100644 --- a/src/protocols/DataDeviceWlr.cpp +++ b/src/protocols/DataDeviceWlr.cpp @@ -4,60 +4,60 @@ #include "core/Seat.hpp" using namespace Hyprutils::OS; -CWLRDataOffer::CWLRDataOffer(SP resource_, SP source_) : source(source_), resource(resource_) { +CWLRDataOffer::CWLRDataOffer(SP resource_, SP source_) : m_source(source_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); }); - resource->setOnDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); }); + m_resource->setDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); }); - resource->setReceive([this](CZwlrDataControlOfferV1* r, const char* mime, int32_t fd) { + m_resource->setReceive([this](CZwlrDataControlOfferV1* r, const char* mime, int32_t fd) { CFileDescriptor sendFd{fd}; - if (!source) { + if (!m_source) { LOGM(WARN, "Possible bug: Receive on an offer w/o a source"); return; } - if (dead) { + if (m_dead) { LOGM(WARN, "Possible bug: Receive on an offer that's dead"); return; } - LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)source.get()); + LOGM(LOG, "Offer {:x} asks to send data from source {:x}", (uintptr_t)this, (uintptr_t)m_source.get()); - source->send(mime, std::move(sendFd)); + m_source->send(mime, std::move(sendFd)); }); } bool CWLRDataOffer::good() { - return resource->resource(); + return m_resource->resource(); } void CWLRDataOffer::sendData() { - if UNLIKELY (!source) + if UNLIKELY (!m_source) return; - for (auto const& m : source->mimes()) { - resource->sendOffer(m.c_str()); + for (auto const& m : m_source->mimes()) { + m_resource->sendOffer(m.c_str()); } } -CWLRDataSource::CWLRDataSource(SP resource_, SP device_) : device(device_), resource(resource_) { +CWLRDataSource::CWLRDataSource(SP resource_, SP device_) : m_device(device_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setData(this); + m_resource->setData(this); - resource->setDestroy([this](CZwlrDataControlSourceV1* r) { + m_resource->setDestroy([this](CZwlrDataControlSourceV1* r) { m_events.destroy.emit(); PROTO::dataWlr->destroyResource(this); }); - resource->setOnDestroy([this](CZwlrDataControlSourceV1* r) { + m_resource->setOnDestroy([this](CZwlrDataControlSourceV1* r) { m_events.destroy.emit(); PROTO::dataWlr->destroyResource(this); }); - resource->setOffer([this](CZwlrDataControlSourceV1* r, const char* mime) { mimeTypes.emplace_back(mime); }); + m_resource->setOffer([this](CZwlrDataControlSourceV1* r, const char* mime) { m_mimeTypes.emplace_back(mime); }); } CWLRDataSource::~CWLRDataSource() { @@ -66,51 +66,51 @@ CWLRDataSource::~CWLRDataSource() { SP CWLRDataSource::fromResource(wl_resource* res) { auto data = (CWLRDataSource*)(((CZwlrDataControlSourceV1*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } bool CWLRDataSource::good() { - return resource->resource(); + return m_resource->resource(); } std::vector CWLRDataSource::mimes() { - return mimeTypes; + return m_mimeTypes; } void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) { - if (std::find(mimeTypes.begin(), mimeTypes.end(), mime) == mimeTypes.end()) { + if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) { LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAskSend with non-existent mime"); return; } - resource->sendSend(mime.c_str(), fd.get()); + m_resource->sendSend(mime.c_str(), fd.get()); } void CWLRDataSource::accepted(const std::string& mime) { - if (std::find(mimeTypes.begin(), mimeTypes.end(), mime) == mimeTypes.end()) + if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAccepted with non-existent mime"); // wlr has no accepted } void CWLRDataSource::cancelled() { - resource->sendCancelled(); + m_resource->sendCancelled(); } void CWLRDataSource::error(uint32_t code, const std::string& msg) { - resource->error(code, msg); + m_resource->error(code, msg); } -CWLRDataDevice::CWLRDataDevice(SP resource_) : resource(resource_) { +CWLRDataDevice::CWLRDataDevice(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - resource->setDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); }); - resource->setOnDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); }); + m_resource->setDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwlrDataControlDeviceV1* r) { PROTO::dataWlr->destroyResource(this); }); - resource->setSetSelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { + m_resource->setSetSelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer{}; if (!source) { LOGM(LOG, "wlr reset selection received"); @@ -127,7 +127,7 @@ CWLRDataDevice::CWLRDataDevice(SP resource_) : resourc g_pSeatManager->setCurrentSelection(source); }); - resource->setSetPrimarySelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { + m_resource->setSetPrimarySelection([](CZwlrDataControlDeviceV1* r, wl_resource* sourceR) { auto source = sourceR ? CWLRDataSource::fromResource(sourceR) : CSharedPointer{}; if (!source) { LOGM(LOG, "wlr reset primary selection received"); @@ -146,11 +146,11 @@ CWLRDataDevice::CWLRDataDevice(SP resource_) : resourc } bool CWLRDataDevice::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CWLRDataDevice::client() { - return pClient; + return m_client; } void CWLRDataDevice::sendInitialSelections() { @@ -159,40 +159,40 @@ void CWLRDataDevice::sendInitialSelections() { } void CWLRDataDevice::sendDataOffer(SP offer) { - resource->sendDataOffer(offer->resource.get()); + m_resource->sendDataOffer(offer->m_resource.get()); } void CWLRDataDevice::sendSelection(SP selection) { - resource->sendSelection(selection->resource.get()); + m_resource->sendSelection(selection->m_resource.get()); } void CWLRDataDevice::sendPrimarySelection(SP selection) { - resource->sendPrimarySelection(selection->resource.get()); + m_resource->sendPrimarySelection(selection->m_resource.get()); } -CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP resource_) : resource(resource_) { +CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); }); - resource->setOnDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); }); + m_resource->setDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); }); - resource->setGetDataDevice([this](CZwlrDataControlManagerV1* r, uint32_t id, wl_resource* seat) { - const auto RESOURCE = PROTO::dataWlr->m_vDevices.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); + m_resource->setGetDataDevice([this](CZwlrDataControlManagerV1* r, uint32_t id, wl_resource* seat) { + const auto RESOURCE = PROTO::dataWlr->m_devices.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::dataWlr->m_vDevices.pop_back(); + PROTO::dataWlr->m_devices.pop_back(); return; } RESOURCE->self = RESOURCE; - device = RESOURCE; + m_device = RESOURCE; - for (auto const& s : sources) { + for (auto const& s : m_sources) { if (!s) continue; - s->device = RESOURCE; + s->m_device = RESOURCE; } RESOURCE->sendInitialSelections(); @@ -200,31 +200,31 @@ CWLRDataControlManagerResource::CWLRDataControlManagerResource(SPsetCreateDataSource([this](CZwlrDataControlManagerV1* r, uint32_t id) { - std::erase_if(sources, [](const auto& e) { return e.expired(); }); + m_resource->setCreateDataSource([this](CZwlrDataControlManagerV1* r, uint32_t id) { + std::erase_if(m_sources, [](const auto& e) { return e.expired(); }); const auto RESOURCE = - PROTO::dataWlr->m_vSources.emplace_back(makeShared(makeShared(r->client(), r->version(), id), device.lock())); + PROTO::dataWlr->m_sources.emplace_back(makeShared(makeShared(r->client(), r->version(), id), m_device.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::dataWlr->m_vSources.pop_back(); + PROTO::dataWlr->m_sources.pop_back(); return; } - if (!device) + if (!m_device) LOGM(WARN, "New data source before a device was created"); - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; - sources.emplace_back(RESOURCE); + m_sources.emplace_back(RESOURCE); LOGM(LOG, "New wlr data source bound at {:x}", (uintptr_t)RESOURCE.get()); }); } bool CWLRDataControlManagerResource::good() { - return resource->resource(); + return m_resource->resource(); } CDataDeviceWLRProtocol::CDataDeviceWLRProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -232,11 +232,11 @@ CDataDeviceWLRProtocol::CDataDeviceWLRProtocol(const wl_interface* iface, const } void CDataDeviceWLRProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } @@ -244,39 +244,39 @@ void CDataDeviceWLRProtocol::bindManager(wl_client* client, void* data, uint32_t } void CDataDeviceWLRProtocol::destroyResource(CWLRDataControlManagerResource* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CDataDeviceWLRProtocol::destroyResource(CWLRDataSource* resource) { - std::erase_if(m_vSources, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_sources, [&](const auto& other) { return other.get() == resource; }); } void CDataDeviceWLRProtocol::destroyResource(CWLRDataDevice* resource) { - std::erase_if(m_vDevices, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_devices, [&](const auto& other) { return other.get() == resource; }); } void CDataDeviceWLRProtocol::destroyResource(CWLRDataOffer* resource) { - std::erase_if(m_vOffers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_offers, [&](const auto& other) { return other.get() == resource; }); } void CDataDeviceWLRProtocol::sendSelectionToDevice(SP dev, SP sel, bool primary) { if (!sel) { if (primary) - dev->resource->sendPrimarySelectionRaw(nullptr); + dev->m_resource->sendPrimarySelectionRaw(nullptr); else - dev->resource->sendSelectionRaw(nullptr); + dev->m_resource->sendSelectionRaw(nullptr); return; } - const auto OFFER = m_vOffers.emplace_back(makeShared(makeShared(dev->resource->client(), dev->resource->version(), 0), sel)); + const auto OFFER = m_offers.emplace_back(makeShared(makeShared(dev->m_resource->client(), dev->m_resource->version(), 0), sel)); if (!OFFER->good()) { - dev->resource->noMemory(); - m_vOffers.pop_back(); + dev->m_resource->noMemory(); + m_offers.pop_back(); return; } - OFFER->primary = primary; + OFFER->m_primary = primary; LOGM(LOG, "New {}offer {:x} for data source {:x}", primary ? "primary " : " ", (uintptr_t)OFFER.get(), (uintptr_t)sel.get()); @@ -289,18 +289,18 @@ void CDataDeviceWLRProtocol::sendSelectionToDevice(SP dev, SP source, bool primary) { - for (auto const& o : m_vOffers) { - if (o->source && o->source->hasDnd()) + for (auto const& o : m_offers) { + if (o->m_source && o->m_source->hasDnd()) continue; - if (o->primary != primary) + if (o->m_primary != primary) continue; - o->dead = true; + o->m_dead = true; } if (!source) { LOGM(LOG, "resetting {}selection", primary ? "primary " : " "); - for (auto const& d : m_vDevices) { + for (auto const& d : m_devices) { sendSelectionToDevice(d, nullptr, primary); } @@ -309,14 +309,14 @@ void CDataDeviceWLRProtocol::setSelection(SP source, bool primary) LOGM(LOG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get()); - for (auto const& d : m_vDevices) { + for (auto const& d : m_devices) { sendSelectionToDevice(d, source, primary); } } SP CDataDeviceWLRProtocol::dataDeviceForClient(wl_client* c) { - auto it = std::find_if(m_vDevices.begin(), m_vDevices.end(), [c](const auto& e) { return e->client() == c; }); - if (it == m_vDevices.end()) + auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; }); + if (it == m_devices.end()) return nullptr; return *it; } diff --git a/src/protocols/DataDeviceWlr.hpp b/src/protocols/DataDeviceWlr.hpp index 7f14b320d..00f704e99 100644 --- a/src/protocols/DataDeviceWlr.hpp +++ b/src/protocols/DataDeviceWlr.hpp @@ -19,13 +19,13 @@ class CWLRDataOffer { bool good(); void sendData(); - bool dead = false; - bool primary = false; + bool m_dead = false; + bool m_primary = false; - WP source; + WP m_source; private: - SP resource; + SP m_resource; friend class CWLRDataDevice; }; @@ -44,12 +44,12 @@ class CWLRDataSource : public IDataSource { virtual void cancelled(); virtual void error(uint32_t code, const std::string& msg); - std::vector mimeTypes; - WP self; - WP device; + std::vector m_mimeTypes; + WP m_self; + WP m_device; private: - SP resource; + SP m_resource; }; class CWLRDataDevice { @@ -67,8 +67,8 @@ class CWLRDataDevice { WP self; private: - SP resource; - wl_client* pClient = nullptr; + SP m_resource; + wl_client* m_client = nullptr; friend class CDataDeviceWLRProtocol; }; @@ -79,11 +79,11 @@ class CWLRDataControlManagerResource { bool good(); - WP device; - std::vector> sources; + WP m_device; + std::vector> m_sources; private: - SP resource; + SP m_resource; }; class CDataDeviceWLRProtocol : public IWaylandProtocol { @@ -99,10 +99,10 @@ class CDataDeviceWLRProtocol : public IWaylandProtocol { void destroyResource(CWLRDataOffer* resource); // - std::vector> m_vManagers; - std::vector> m_vSources; - std::vector> m_vDevices; - std::vector> m_vOffers; + std::vector> m_managers; + std::vector> m_sources; + std::vector> m_devices; + std::vector> m_offers; // void setSelection(SP source, bool primary); diff --git a/src/protocols/FocusGrab.cpp b/src/protocols/FocusGrab.cpp index 9751666d5..9f0549530 100644 --- a/src/protocols/FocusGrab.cpp +++ b/src/protocols/FocusGrab.cpp @@ -8,23 +8,23 @@ #include CFocusGrabSurfaceState::CFocusGrabSurfaceState(CFocusGrab* grab, SP surface) { - listeners.destroy = surface->m_events.destroy.registerListener([=](std::any d) { grab->eraseSurface(surface); }); + m_listeners.destroy = surface->m_events.destroy.registerListener([=](std::any d) { grab->eraseSurface(surface); }); } -CFocusGrab::CFocusGrab(SP resource_) : resource(resource_) { - if UNLIKELY (!resource->resource()) +CFocusGrab::CFocusGrab(SP resource_) : m_resource(resource_) { + if UNLIKELY (!m_resource->resource()) return; - grab = makeShared(); - grab->m_keyboard = true; - grab->m_pointer = true; - grab->setCallback([this]() { finish(true); }); + m_grab = makeShared(); + m_grab->m_keyboard = true; + m_grab->m_pointer = true; + m_grab->setCallback([this]() { finish(true); }); - resource->setDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); }); - resource->setOnDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); }); - resource->setAddSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { addSurface(CWLSurfaceResource::fromResource(surface)); }); - resource->setRemoveSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { removeSurface(CWLSurfaceResource::fromResource(surface)); }); - resource->setCommit([this](CHyprlandFocusGrabV1* pMgr) { commit(); }); + m_resource->setDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); }); + m_resource->setOnDestroy([this](CHyprlandFocusGrabV1* pMgr) { PROTO::focusGrab->destroyGrab(this); }); + m_resource->setAddSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { addSurface(CWLSurfaceResource::fromResource(surface)); }); + m_resource->setRemoveSurface([this](CHyprlandFocusGrabV1* pMgr, wl_resource* surface) { removeSurface(CWLSurfaceResource::fromResource(surface)); }); + m_resource->setCommit([this](CHyprlandFocusGrabV1* pMgr) { commit(); }); } CFocusGrab::~CFocusGrab() { @@ -32,21 +32,21 @@ CFocusGrab::~CFocusGrab() { } bool CFocusGrab::good() { - return resource->resource(); + return m_resource->resource(); } bool CFocusGrab::isSurfaceComitted(SP surface) { - auto iter = std::find_if(m_mSurfaces.begin(), m_mSurfaces.end(), [surface](const auto& o) { return o.first == surface; }); - if (iter == m_mSurfaces.end()) + auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [surface](const auto& o) { return o.first == surface; }); + if (iter == m_surfaces.end()) return false; - return iter->second->state == CFocusGrabSurfaceState::Comitted; + return iter->second->m_state == CFocusGrabSurfaceState::Comitted; } void CFocusGrab::start() { - if (!m_bGrabActive) { - m_bGrabActive = true; - g_pSeatManager->setGrab(grab); + if (!m_grabActive) { + m_grabActive = true; + g_pSeatManager->setGrab(m_grab); } // Ensure new surfaces are focused if under the mouse when comitted. @@ -55,33 +55,33 @@ void CFocusGrab::start() { } void CFocusGrab::finish(bool sendCleared) { - if (m_bGrabActive) { - m_bGrabActive = false; + if (m_grabActive) { + m_grabActive = false; - if (g_pSeatManager->m_seatGrab == grab) + if (g_pSeatManager->m_seatGrab == m_grab) g_pSeatManager->setGrab(nullptr); - grab->clear(); - m_mSurfaces.clear(); + m_grab->clear(); + m_surfaces.clear(); if (sendCleared) - resource->sendCleared(); + m_resource->sendCleared(); } } void CFocusGrab::addSurface(SP surface) { - auto iter = std::find_if(m_mSurfaces.begin(), m_mSurfaces.end(), [surface](const auto& e) { return e.first == surface; }); - if (iter == m_mSurfaces.end()) - m_mSurfaces.emplace(surface, makeUnique(this, surface)); + auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [surface](const auto& e) { return e.first == surface; }); + if (iter == m_surfaces.end()) + m_surfaces.emplace(surface, makeUnique(this, surface)); } void CFocusGrab::removeSurface(SP surface) { - auto iter = m_mSurfaces.find(surface); - if (iter != m_mSurfaces.end()) { - if (iter->second->state == CFocusGrabSurfaceState::PendingAddition) - m_mSurfaces.erase(iter); + auto iter = m_surfaces.find(surface); + if (iter != m_surfaces.end()) { + if (iter->second->m_state == CFocusGrabSurfaceState::PendingAddition) + m_surfaces.erase(iter); else - iter->second->state = CFocusGrabSurfaceState::PendingRemoval; + iter->second->m_state = CFocusGrabSurfaceState::PendingRemoval; } } @@ -96,8 +96,8 @@ void CFocusGrab::refocusKeyboard() { return; SP surface = nullptr; - for (auto const& [surf, state] : m_mSurfaces) { - if (state->state == CFocusGrabSurfaceState::Comitted) { + for (auto const& [surf, state] : m_surfaces) { + if (state->m_state == CFocusGrabSurfaceState::Comitted) { surface = surf.lock(); break; } @@ -112,17 +112,17 @@ void CFocusGrab::refocusKeyboard() { void CFocusGrab::commit(bool removeOnly) { auto surfacesChanged = false; auto anyComitted = false; - for (auto iter = m_mSurfaces.begin(); iter != m_mSurfaces.end();) { - switch (iter->second->state) { + for (auto iter = m_surfaces.begin(); iter != m_surfaces.end();) { + switch (iter->second->m_state) { case CFocusGrabSurfaceState::PendingRemoval: - grab->remove(iter->first.lock()); - iter = m_mSurfaces.erase(iter); + m_grab->remove(iter->first.lock()); + iter = m_surfaces.erase(iter); surfacesChanged = true; continue; case CFocusGrabSurfaceState::PendingAddition: if (!removeOnly) { - iter->second->state = CFocusGrabSurfaceState::Comitted; - grab->add(iter->first.lock()); + iter->second->m_state = CFocusGrabSurfaceState::Comitted; + m_grab->add(iter->first.lock()); surfacesChanged = true; anyComitted = true; } @@ -146,7 +146,7 @@ CFocusGrabProtocol::CFocusGrabProtocol(const wl_interface* iface, const int& ver } void CFocusGrabProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CHyprlandFocusGrabManagerV1* p) { onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CHyprlandFocusGrabManagerV1* p) { onManagerResourceDestroy(p->resource()); }); @@ -154,19 +154,19 @@ void CFocusGrabProtocol::bindManager(wl_client* client, void* data, uint32_t ver } void CFocusGrabProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CFocusGrabProtocol::destroyGrab(CFocusGrab* grab) { - std::erase_if(m_vGrabs, [&](const auto& other) { return other.get() == grab; }); + std::erase_if(m_grabs, [&](const auto& other) { return other.get() == grab; }); } void CFocusGrabProtocol::onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id) { - m_vGrabs.push_back(makeUnique(makeShared(pMgr->client(), pMgr->version(), id))); - const auto RESOURCE = m_vGrabs.back().get(); + m_grabs.push_back(makeUnique(makeShared(pMgr->client(), pMgr->version(), id))); + const auto RESOURCE = m_grabs.back().get(); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_vGrabs.pop_back(); + m_grabs.pop_back(); } } diff --git a/src/protocols/FocusGrab.hpp b/src/protocols/FocusGrab.hpp index 1445a24c1..6fb27b867 100644 --- a/src/protocols/FocusGrab.hpp +++ b/src/protocols/FocusGrab.hpp @@ -21,12 +21,12 @@ class CFocusGrabSurfaceState { PendingAddition, PendingRemoval, Comitted, - } state = PendingAddition; + } m_state = PendingAddition; private: struct { CHyprSignalListener destroy; - } listeners; + } m_listeners; }; class CFocusGrab { @@ -47,11 +47,11 @@ class CFocusGrab { void refocusKeyboard(); void commit(bool removeOnly = false); - SP resource; - std::unordered_map, UP> m_mSurfaces; - SP grab; + SP m_resource; + std::unordered_map, UP> m_surfaces; + SP m_grab; - bool m_bGrabActive = false; + bool m_grabActive = false; friend class CFocusGrabSurfaceState; }; @@ -67,8 +67,8 @@ class CFocusGrabProtocol : public IWaylandProtocol { void destroyGrab(CFocusGrab* grab); void onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id); - std::vector> m_vManagers; - std::vector> m_vGrabs; + std::vector> m_managers; + std::vector> m_grabs; friend class CFocusGrab; }; diff --git a/src/protocols/ForeignToplevel.cpp b/src/protocols/ForeignToplevel.cpp index 843e8b944..e48f0722f 100644 --- a/src/protocols/ForeignToplevel.cpp +++ b/src/protocols/ForeignToplevel.cpp @@ -2,34 +2,34 @@ #include "../Compositor.hpp" #include "../managers/HookSystemManager.hpp" -CForeignToplevelHandle::CForeignToplevelHandle(SP resource_, PHLWINDOW pWindow_) : resource(resource_), pWindow(pWindow_) { +CForeignToplevelHandle::CForeignToplevelHandle(SP resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) { if UNLIKELY (!resource_->resource()) return; - resource->setData(this); + m_resource->setData(this); - resource->setOnDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); }); - resource->setDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); }); + m_resource->setOnDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); }); + m_resource->setDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); }); } bool CForeignToplevelHandle::good() { - return resource->resource(); + return m_resource->resource(); } PHLWINDOW CForeignToplevelHandle::window() { - return pWindow.lock(); + return m_window.lock(); } -CForeignToplevelList::CForeignToplevelList(SP resource_) : resource(resource_) { +CForeignToplevelList::CForeignToplevelList(SP resource_) : m_resource(resource_) { if UNLIKELY (!resource_->resource()) return; - resource->setOnDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); }); - resource->setDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); }); + m_resource->setOnDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); }); + m_resource->setDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); }); - resource->setStop([this](CExtForeignToplevelListV1* h) { - resource->sendFinished(); - finished = true; + m_resource->setStop([this](CExtForeignToplevelListV1* h) { + m_resource->sendFinished(); + m_finished = true; LOGM(LOG, "CForeignToplevelList: finished"); }); @@ -42,75 +42,75 @@ CForeignToplevelList::CForeignToplevelList(SP resourc } void CForeignToplevelList::onMap(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; - const auto NEWHANDLE = PROTO::foreignToplevel->m_vHandles.emplace_back( - makeShared(makeShared(resource->client(), resource->version(), 0), pWindow)); + const auto NEWHANDLE = PROTO::foreignToplevel->m_handles.emplace_back( + makeShared(makeShared(m_resource->client(), m_resource->version(), 0), pWindow)); if (!NEWHANDLE->good()) { LOGM(ERR, "Couldn't create a foreign handle"); - resource->noMemory(); - PROTO::foreignToplevel->m_vHandles.pop_back(); + m_resource->noMemory(); + PROTO::foreignToplevel->m_handles.pop_back(); return; } const auto IDENTIFIER = std::format("{:08x}->{:016x}", static_cast((uintptr_t)this & 0xFFFFFFFF), (uintptr_t)pWindow.get()); LOGM(LOG, "Newly mapped window gets an identifier of {}", IDENTIFIER); - resource->sendToplevel(NEWHANDLE->resource.get()); - NEWHANDLE->resource->sendIdentifier(IDENTIFIER.c_str()); - NEWHANDLE->resource->sendAppId(pWindow->m_initialClass.c_str()); - NEWHANDLE->resource->sendTitle(pWindow->m_initialTitle.c_str()); - NEWHANDLE->resource->sendDone(); + m_resource->sendToplevel(NEWHANDLE->m_resource.get()); + NEWHANDLE->m_resource->sendIdentifier(IDENTIFIER.c_str()); + NEWHANDLE->m_resource->sendAppId(pWindow->m_initialClass.c_str()); + NEWHANDLE->m_resource->sendTitle(pWindow->m_initialTitle.c_str()); + NEWHANDLE->m_resource->sendDone(); - handles.push_back(NEWHANDLE); + m_handles.push_back(NEWHANDLE); } SP CForeignToplevelList::handleForWindow(PHLWINDOW pWindow) { - std::erase_if(handles, [](const auto& wp) { return wp.expired(); }); - const auto IT = std::find_if(handles.begin(), handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; }); - return IT == handles.end() ? SP{} : IT->lock(); + std::erase_if(m_handles, [](const auto& wp) { return wp.expired(); }); + const auto IT = std::find_if(m_handles.begin(), m_handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; }); + return IT == m_handles.end() ? SP{} : IT->lock(); } void CForeignToplevelList::onTitle(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); - if UNLIKELY (!H || H->closed) + if UNLIKELY (!H || H->m_closed) return; - H->resource->sendTitle(pWindow->m_title.c_str()); - H->resource->sendDone(); + H->m_resource->sendTitle(pWindow->m_title.c_str()); + H->m_resource->sendDone(); } void CForeignToplevelList::onClass(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); - if UNLIKELY (!H || H->closed) + if UNLIKELY (!H || H->m_closed) return; - H->resource->sendAppId(pWindow->m_class.c_str()); - H->resource->sendDone(); + H->m_resource->sendAppId(pWindow->m_class.c_str()); + H->m_resource->sendDone(); } void CForeignToplevelList::onUnmap(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); if UNLIKELY (!H) return; - H->resource->sendClosed(); - H->closed = true; + H->m_resource->sendClosed(); + H->m_closed = true; } bool CForeignToplevelList::good() { - return resource->resource(); + return m_resource->resource(); } CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -120,7 +120,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co if (!windowValidForForeign(window)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onMap(window); } }); @@ -131,7 +131,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co if (!windowValidForForeign(window)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onUnmap(window); } }); @@ -142,29 +142,29 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co if (!windowValidForForeign(window)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onTitle(window); } }); } void CForeignToplevelProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(makeShared(client, ver, id))).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(makeShared(client, ver, id))).get(); if UNLIKELY (!RESOURCE->good()) { LOGM(ERR, "Couldn't create a foreign list"); wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CForeignToplevelProtocol::onManagerResourceDestroy(CForeignToplevelList* mgr) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == mgr; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == mgr; }); } void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) { - std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; }); + std::erase_if(m_handles, [&](const auto& other) { return other.get() == handle; }); } bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) { diff --git a/src/protocols/ForeignToplevel.hpp b/src/protocols/ForeignToplevel.hpp index 2136748bd..355117e79 100644 --- a/src/protocols/ForeignToplevel.hpp +++ b/src/protocols/ForeignToplevel.hpp @@ -14,9 +14,9 @@ class CForeignToplevelHandle { PHLWINDOW window(); private: - SP resource; - PHLWINDOWREF pWindow; - bool closed = false; + SP m_resource; + PHLWINDOWREF m_window; + bool m_closed = false; friend class CForeignToplevelList; friend class CForeignToplevelProtocol; @@ -34,12 +34,12 @@ class CForeignToplevelList { bool good(); private: - SP resource; - bool finished = false; + SP m_resource; + bool m_finished = false; SP handleForWindow(PHLWINDOW pWindow); - std::vector> handles; + std::vector> m_handles; }; class CForeignToplevelProtocol : public IWaylandProtocol { @@ -55,8 +55,8 @@ class CForeignToplevelProtocol : public IWaylandProtocol { bool windowValidForForeign(PHLWINDOW pWindow); // - std::vector> m_vManagers; - std::vector> m_vHandles; + std::vector> m_managers; + std::vector> m_handles; friend class CForeignToplevelList; friend class CForeignToplevelHandle; diff --git a/src/protocols/ForeignToplevelWlr.cpp b/src/protocols/ForeignToplevelWlr.cpp index 38ce60d23..8807c2255 100644 --- a/src/protocols/ForeignToplevelWlr.cpp +++ b/src/protocols/ForeignToplevelWlr.cpp @@ -6,17 +6,17 @@ #include "../managers/HookSystemManager.hpp" #include "../managers/EventManager.hpp" -CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP resource_, PHLWINDOW pWindow_) : resource(resource_), pWindow(pWindow_) { +CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) { if UNLIKELY (!resource_->resource()) return; - resource->setData(this); + m_resource->setData(this); - resource->setOnDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); }); - resource->setDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); }); + m_resource->setOnDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); }); + m_resource->setDestroy([this](CZwlrForeignToplevelHandleV1* h) { PROTO::foreignToplevelWlr->destroyHandle(this); }); - resource->setActivate([this](CZwlrForeignToplevelHandleV1* p, wl_resource* seat) { - const auto PWINDOW = pWindow.lock(); + m_resource->setActivate([this](CZwlrForeignToplevelHandleV1* p, wl_resource* seat) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -26,8 +26,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPactivate(true); }); - resource->setSetFullscreen([this](CZwlrForeignToplevelHandleV1* p, wl_resource* output) { - const auto PWINDOW = pWindow.lock(); + m_resource->setSetFullscreen([this](CZwlrForeignToplevelHandleV1* p, wl_resource* output) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -57,8 +57,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPdamageWindow(PWINDOW); }); - resource->setUnsetFullscreen([this](CZwlrForeignToplevelHandleV1* p) { - const auto PWINDOW = pWindow.lock(); + m_resource->setUnsetFullscreen([this](CZwlrForeignToplevelHandleV1* p) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -69,8 +69,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPchangeWindowFullscreenModeClient(PWINDOW, FSMODE_FULLSCREEN, false); }); - resource->setSetMaximized([this](CZwlrForeignToplevelHandleV1* p) { - const auto PWINDOW = pWindow.lock(); + m_resource->setSetMaximized([this](CZwlrForeignToplevelHandleV1* p) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -86,8 +86,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPchangeWindowFullscreenModeClient(PWINDOW, FSMODE_MAXIMIZED, true); }); - resource->setUnsetMaximized([this](CZwlrForeignToplevelHandleV1* p) { - const auto PWINDOW = pWindow.lock(); + m_resource->setUnsetMaximized([this](CZwlrForeignToplevelHandleV1* p) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -98,8 +98,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPchangeWindowFullscreenModeClient(PWINDOW, FSMODE_MAXIMIZED, false); }); - resource->setSetMinimized([this](CZwlrForeignToplevelHandleV1* p) { - const auto PWINDOW = pWindow.lock(); + m_resource->setSetMinimized([this](CZwlrForeignToplevelHandleV1* p) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -110,8 +110,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPpostEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},1", (uintptr_t)PWINDOW.get())}); }); - resource->setUnsetMinimized([this](CZwlrForeignToplevelHandleV1* p) { - const auto PWINDOW = pWindow.lock(); + m_resource->setUnsetMinimized([this](CZwlrForeignToplevelHandleV1* p) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -122,8 +122,8 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPpostEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},0", (uintptr_t)PWINDOW.get())}); }); - resource->setClose([this](CZwlrForeignToplevelHandleV1* p) { - const auto PWINDOW = pWindow.lock(); + m_resource->setClose([this](CZwlrForeignToplevelHandleV1* p) { + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW) return; @@ -133,42 +133,42 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SPresource(); + return m_resource->resource(); } PHLWINDOW CForeignToplevelHandleWlr::window() { - return pWindow.lock(); + return m_window.lock(); } wl_resource* CForeignToplevelHandleWlr::res() { - return resource->resource(); + return m_resource->resource(); } void CForeignToplevelHandleWlr::sendMonitor(PHLMONITOR pMonitor) { - if (lastMonitorID == pMonitor->m_id) + if (m_lastMonitorID == pMonitor->m_id) return; - const auto CLIENT = resource->client(); + const auto CLIENT = m_resource->client(); - if (const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(lastMonitorID); PLASTMONITOR && PROTO::outputs.contains(PLASTMONITOR->m_name)) { + if (const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(m_lastMonitorID); PLASTMONITOR && PROTO::outputs.contains(PLASTMONITOR->m_name)) { const auto OLDRESOURCE = PROTO::outputs.at(PLASTMONITOR->m_name)->outputResourceFrom(CLIENT); if LIKELY (OLDRESOURCE) - resource->sendOutputLeave(OLDRESOURCE->getResource()->resource()); + m_resource->sendOutputLeave(OLDRESOURCE->getResource()->resource()); } if (PROTO::outputs.contains(pMonitor->m_name)) { const auto NEWRESOURCE = PROTO::outputs.at(pMonitor->m_name)->outputResourceFrom(CLIENT); if LIKELY (NEWRESOURCE) - resource->sendOutputEnter(NEWRESOURCE->getResource()->resource()); + m_resource->sendOutputEnter(NEWRESOURCE->getResource()->resource()); } - lastMonitorID = pMonitor->m_id; + m_lastMonitorID = pMonitor->m_id; } void CForeignToplevelHandleWlr::sendState() { - const auto PWINDOW = pWindow.lock(); + const auto PWINDOW = m_window.lock(); if UNLIKELY (!PWINDOW || !PWINDOW->m_workspace || !PWINDOW->m_isMapped) return; @@ -189,20 +189,20 @@ void CForeignToplevelHandleWlr::sendState() { *p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED; } - resource->sendState(&state); + m_resource->sendState(&state); wl_array_release(&state); } -CForeignToplevelWlrManager::CForeignToplevelWlrManager(SP resource_) : resource(resource_) { +CForeignToplevelWlrManager::CForeignToplevelWlrManager(SP resource_) : m_resource(resource_) { if UNLIKELY (!resource_->resource()) return; - resource->setOnDestroy([this](CZwlrForeignToplevelManagerV1* h) { PROTO::foreignToplevelWlr->onManagerResourceDestroy(this); }); + m_resource->setOnDestroy([this](CZwlrForeignToplevelManagerV1* h) { PROTO::foreignToplevelWlr->onManagerResourceDestroy(this); }); - resource->setStop([this](CZwlrForeignToplevelManagerV1* h) { - resource->sendFinished(); - finished = true; + m_resource->setStop([this](CZwlrForeignToplevelManagerV1* h) { + m_resource->sendFinished(); + m_finished = true; LOGM(LOG, "CForeignToplevelWlrManager: finished"); PROTO::foreignToplevelWlr->onManagerResourceDestroy(this); }); @@ -214,84 +214,84 @@ CForeignToplevelWlrManager::CForeignToplevelWlrManager(SPm_lastWindow; + m_lastFocus = g_pCompositor->m_lastWindow; } void CForeignToplevelWlrManager::onMap(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; - const auto NEWHANDLE = PROTO::foreignToplevelWlr->m_vHandles.emplace_back( - makeShared(makeShared(resource->client(), resource->version(), 0), pWindow)); + const auto NEWHANDLE = PROTO::foreignToplevelWlr->m_handles.emplace_back( + makeShared(makeShared(m_resource->client(), m_resource->version(), 0), pWindow)); if UNLIKELY (!NEWHANDLE->good()) { LOGM(ERR, "Couldn't create a foreign handle"); - resource->noMemory(); - PROTO::foreignToplevelWlr->m_vHandles.pop_back(); + m_resource->noMemory(); + PROTO::foreignToplevelWlr->m_handles.pop_back(); return; } LOGM(LOG, "Newly mapped window {:016x}", (uintptr_t)pWindow.get()); - resource->sendToplevel(NEWHANDLE->resource.get()); - NEWHANDLE->resource->sendAppId(pWindow->m_class.c_str()); - NEWHANDLE->resource->sendTitle(pWindow->m_title.c_str()); + m_resource->sendToplevel(NEWHANDLE->m_resource.get()); + NEWHANDLE->m_resource->sendAppId(pWindow->m_class.c_str()); + NEWHANDLE->m_resource->sendTitle(pWindow->m_title.c_str()); if LIKELY (const auto PMONITOR = pWindow->m_monitor.lock(); PMONITOR) NEWHANDLE->sendMonitor(PMONITOR); NEWHANDLE->sendState(); - NEWHANDLE->resource->sendDone(); + NEWHANDLE->m_resource->sendDone(); - handles.push_back(NEWHANDLE); + m_handles.push_back(NEWHANDLE); } SP CForeignToplevelWlrManager::handleForWindow(PHLWINDOW pWindow) { - std::erase_if(handles, [](const auto& wp) { return wp.expired(); }); - const auto IT = std::find_if(handles.begin(), handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; }); - return IT == handles.end() ? SP{} : IT->lock(); + std::erase_if(m_handles, [](const auto& wp) { return wp.expired(); }); + const auto IT = std::find_if(m_handles.begin(), m_handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; }); + return IT == m_handles.end() ? SP{} : IT->lock(); } void CForeignToplevelWlrManager::onTitle(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); - if UNLIKELY (!H || H->closed) + if UNLIKELY (!H || H->m_closed) return; - H->resource->sendTitle(pWindow->m_title.c_str()); - H->resource->sendDone(); + H->m_resource->sendTitle(pWindow->m_title.c_str()); + H->m_resource->sendDone(); } void CForeignToplevelWlrManager::onClass(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); - if UNLIKELY (!H || H->closed) + if UNLIKELY (!H || H->m_closed) return; - H->resource->sendAppId(pWindow->m_class.c_str()); - H->resource->sendDone(); + H->m_resource->sendAppId(pWindow->m_class.c_str()); + H->m_resource->sendDone(); } void CForeignToplevelWlrManager::onUnmap(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); if UNLIKELY (!H) return; - H->resource->sendClosed(); - H->resource->sendDone(); - H->closed = true; + H->m_resource->sendClosed(); + H->m_resource->sendDone(); + H->m_closed = true; } void CForeignToplevelWlrManager::onMoveMonitor(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); - if UNLIKELY (!H || H->closed) + if UNLIKELY (!H || H->m_closed) return; const auto PMONITOR = pWindow->m_monitor.lock(); @@ -300,42 +300,42 @@ void CForeignToplevelWlrManager::onMoveMonitor(PHLWINDOW pWindow) { return; H->sendMonitor(PMONITOR); - H->resource->sendDone(); + H->m_resource->sendDone(); } void CForeignToplevelWlrManager::onFullscreen(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; const auto H = handleForWindow(pWindow); - if UNLIKELY (!H || H->closed) + if UNLIKELY (!H || H->m_closed) return; H->sendState(); - H->resource->sendDone(); + H->m_resource->sendDone(); } void CForeignToplevelWlrManager::onNewFocus(PHLWINDOW pWindow) { - if UNLIKELY (finished) + if UNLIKELY (m_finished) return; - if LIKELY (const auto HOLD = handleForWindow(lastFocus.lock()); HOLD) { + if LIKELY (const auto HOLD = handleForWindow(m_lastFocus.lock()); HOLD) { HOLD->sendState(); - HOLD->resource->sendDone(); + HOLD->m_resource->sendDone(); } - lastFocus = pWindow; + m_lastFocus = pWindow; const auto H = handleForWindow(pWindow); - if UNLIKELY (!H || H->closed) + if UNLIKELY (!H || H->m_closed) return; H->sendState(); - H->resource->sendDone(); + H->m_resource->sendDone(); } bool CForeignToplevelWlrManager::good() { - return resource->resource(); + return m_resource->resource(); } CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -345,7 +345,7 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa if (!windowValidForForeign(PWINDOW)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onMap(PWINDOW); } }); @@ -356,7 +356,7 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa if (!windowValidForForeign(PWINDOW)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onUnmap(PWINDOW); } }); @@ -367,7 +367,7 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa if (!windowValidForForeign(PWINDOW)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onTitle(PWINDOW); } }); @@ -378,14 +378,14 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa if (PWINDOW && !windowValidForForeign(PWINDOW)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onNewFocus(PWINDOW); } }); static auto P4 = g_pHookSystem->hookDynamic("moveWindow", [this](void* self, SCallbackInfo& info, std::any data) { const auto PWINDOW = std::any_cast(std::any_cast>(data).at(0)); - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onMoveMonitor(PWINDOW); } }); @@ -396,29 +396,29 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa if (!windowValidForForeign(PWINDOW)) return; - for (auto const& m : m_vManagers) { + for (auto const& m : m_managers) { m->onFullscreen(PWINDOW); } }); } void CForeignToplevelWlrProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(makeShared(client, ver, id))).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(makeShared(client, ver, id))).get(); if UNLIKELY (!RESOURCE->good()) { LOGM(ERR, "Couldn't create a foreign list"); wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CForeignToplevelWlrProtocol::onManagerResourceDestroy(CForeignToplevelWlrManager* mgr) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == mgr; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == mgr; }); } void CForeignToplevelWlrProtocol::destroyHandle(CForeignToplevelHandleWlr* handle) { - std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; }); + std::erase_if(m_handles, [&](const auto& other) { return other.get() == handle; }); } PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res) { diff --git a/src/protocols/ForeignToplevelWlr.hpp b/src/protocols/ForeignToplevelWlr.hpp index d0479d986..c72344c11 100644 --- a/src/protocols/ForeignToplevelWlr.hpp +++ b/src/protocols/ForeignToplevelWlr.hpp @@ -16,10 +16,10 @@ class CForeignToplevelHandleWlr { wl_resource* res(); private: - SP resource; - PHLWINDOWREF pWindow; - bool closed = false; - MONITORID lastMonitorID = MONITOR_INVALID; + SP m_resource; + PHLWINDOWREF m_window; + bool m_closed = false; + MONITORID m_lastMonitorID = MONITOR_INVALID; void sendMonitor(PHLMONITOR pMonitor); void sendState(); @@ -42,13 +42,13 @@ class CForeignToplevelWlrManager { bool good(); private: - SP resource; - bool finished = false; - PHLWINDOWREF lastFocus; // READ-ONLY + SP m_resource; + bool m_finished = false; + PHLWINDOWREF m_lastFocus; // READ-ONLY SP handleForWindow(PHLWINDOW pWindow); - std::vector> handles; + std::vector> m_handles; }; class CForeignToplevelWlrProtocol : public IWaylandProtocol { @@ -65,8 +65,8 @@ class CForeignToplevelWlrProtocol : public IWaylandProtocol { bool windowValidForForeign(PHLWINDOW pWindow); // - std::vector> m_vManagers; - std::vector> m_vHandles; + std::vector> m_managers; + std::vector> m_handles; friend class CForeignToplevelWlrManager; friend class CForeignToplevelHandleWlr; diff --git a/src/protocols/FractionalScale.cpp b/src/protocols/FractionalScale.cpp index a9fbcb163..899d1390f 100644 --- a/src/protocols/FractionalScale.cpp +++ b/src/protocols/FractionalScale.cpp @@ -7,7 +7,7 @@ CFractionalScaleProtocol::CFractionalScaleProtocol(const wl_interface* iface, co } void CFractionalScaleProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CWpFractionalScaleManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CWpFractionalScaleManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -16,15 +16,15 @@ void CFractionalScaleProtocol::bindManager(wl_client* client, void* data, uint32 } void CFractionalScaleProtocol::removeAddon(CFractionalScaleAddon* addon) { - m_mAddons.erase(addon->surf()); + m_addons.erase(addon->surf()); } void CFractionalScaleProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [res](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [res](const auto& other) { return other->resource() == res; }); } void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, SP surface) { - for (auto const& [k, v] : m_mAddons) { + for (auto const& [k, v] : m_addons) { if (k == surface) { LOGM(ERR, "Surface {:x} already has a fractionalScale addon", (uintptr_t)surface.get()); pMgr->error(WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale already exists"); @@ -33,10 +33,10 @@ void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* } const auto PADDON = - m_mAddons.emplace(surface, makeUnique(makeShared(pMgr->client(), pMgr->version(), id), surface)).first->second.get(); + m_addons.emplace(surface, makeUnique(makeShared(pMgr->client(), pMgr->version(), id), surface)).first->second.get(); if UNLIKELY (!PADDON->good()) { - m_mAddons.erase(surface); + m_addons.erase(surface); pMgr->noMemory(); return; } @@ -44,20 +44,20 @@ void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* PADDON->m_resource->setOnDestroy([this, PADDON](CWpFractionalScaleV1* self) { this->removeAddon(PADDON); }); PADDON->m_resource->setDestroy([this, PADDON](CWpFractionalScaleV1* self) { this->removeAddon(PADDON); }); - if (std::ranges::find_if(m_mSurfaceScales, [surface](const auto& e) { return e.first == surface; }) == m_mSurfaceScales.end()) - m_mSurfaceScales.emplace(surface, 1.F); + if (std::ranges::find_if(m_surfaceScales, [surface](const auto& e) { return e.first == surface; }) == m_surfaceScales.end()) + m_surfaceScales.emplace(surface, 1.F); if (surface->m_mapped) - PADDON->setScale(m_mSurfaceScales.at(surface)); + PADDON->setScale(m_surfaceScales.at(surface)); // clean old - std::erase_if(m_mSurfaceScales, [](const auto& e) { return e.first.expired(); }); + std::erase_if(m_surfaceScales, [](const auto& e) { return e.first.expired(); }); } void CFractionalScaleProtocol::sendScale(SP surf, const float& scale) { - m_mSurfaceScales[surf] = scale; - if (m_mAddons.contains(surf)) - m_mAddons[surf]->setScale(scale); + m_surfaceScales[surf] = scale; + if (m_addons.contains(surf)) + m_addons[surf]->setScale(scale); } CFractionalScaleAddon::CFractionalScaleAddon(SP resource_, SP surf_) : m_resource(resource_), m_surface(surf_) { diff --git a/src/protocols/FractionalScale.hpp b/src/protocols/FractionalScale.hpp index ba896c018..c4aff560e 100644 --- a/src/protocols/FractionalScale.hpp +++ b/src/protocols/FractionalScale.hpp @@ -49,9 +49,9 @@ class CFractionalScaleProtocol : public IWaylandProtocol { // - std::unordered_map, float> m_mSurfaceScales; - std::unordered_map, UP> m_mAddons; - std::vector> m_vManagers; + std::unordered_map, float> m_surfaceScales; + std::unordered_map, UP> m_addons; + std::vector> m_managers; friend class CFractionalScaleAddon; }; diff --git a/src/protocols/FrogColorManagement.cpp b/src/protocols/FrogColorManagement.cpp index 870b573fe..42d3c496e 100644 --- a/src/protocols/FrogColorManagement.cpp +++ b/src/protocols/FrogColorManagement.cpp @@ -22,14 +22,14 @@ static wpColorManagerV1Primaries getWPPrimaries(frogColorManagedSurfacePrimaries return (wpColorManagerV1Primaries)(primaries + 1); } -CFrogColorManager::CFrogColorManager(SP resource_) : resource(resource_) { +CFrogColorManager::CFrogColorManager(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); }); - resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); }); + m_resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); }); + m_resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); }); - resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) { + m_resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) { LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); auto SURF = CWLSurfaceResource::fromResource(surface); @@ -39,70 +39,70 @@ CFrogColorManager::CFrogColorManager(SP resource_ return; } - const auto RESOURCE = PROTO::frogColorManagement->m_vSurfaces.emplace_back( - makeShared(makeShared(r->client(), r->version(), id), SURF)); + const auto RESOURCE = + PROTO::frogColorManagement->m_surfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::frogColorManagement->m_vSurfaces.pop_back(); + PROTO::frogColorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); } bool CFrogColorManager::good() { - return resource->resource(); + return m_resource->resource(); } -CFrogColorManagementSurface::CFrogColorManagementSurface(SP resource_, SP surface_) : surface(surface_), resource(resource_) { +CFrogColorManagementSurface::CFrogColorManagementSurface(SP resource_, SP surface_) : m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - if (!surface->m_colorManagement.valid()) { - const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared(surface_)); + if (!m_surface->m_colorManagement.valid()) { + const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared(surface_)); if UNLIKELY (!RESOURCE) { - resource->noMemory(); - PROTO::colorManagement->m_vSurfaces.pop_back(); + m_resource->noMemory(); + PROTO::colorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; - surface->m_colorManagement = RESOURCE; + m_surface->m_colorManagement = RESOURCE; - resource->setOnDestroy([this](CFrogColorManagedSurface* r) { - LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)surface); - if (surface.valid()) - PROTO::colorManagement->destroyResource(surface->m_colorManagement.get()); + m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) { + LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)m_surface); + if (m_surface.valid()) + PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get()); PROTO::frogColorManagement->destroyResource(this); }); } else - resource->setOnDestroy([this](CFrogColorManagedSurface* r) { - LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)surface); + m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) { + LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface); PROTO::frogColorManagement->destroyResource(this); }); - resource->setDestroy([this](CFrogColorManagedSurface* r) { - LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)surface); + m_resource->setDestroy([this](CFrogColorManagedSurface* r) { + LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface); PROTO::frogColorManagement->destroyResource(this); }); - resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) { - LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, surface->id()); + m_resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) { + LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, m_surface->id()); switch (tf) { case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ: - surface->m_colorManagement->m_imageDescription.transferFunction = + m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); break; ; case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22: - if (pqIntentSent) { + if (m_pqIntentSent) { 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)"); - surface->m_colorManagement->m_imageDescription.transferFunction = + m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); break; }; @@ -110,49 +110,49 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SPm_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); + m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); - surface->m_colorManagement->setHasImageDescription(true); + m_surface->m_colorManagement->setHasImageDescription(true); } }); - resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) { + m_resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) { LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName); switch (primariesName) { case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED: - case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break; - case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break; + case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break; + case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break; } - surface->m_colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName)); + m_surface->m_colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName)); - surface->m_colorManagement->setHasImageDescription(true); + m_surface->m_colorManagement->setHasImageDescription(true); }); - resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) { + m_resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) { LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent); - pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; - surface->m_colorManagement->setHasImageDescription(true); + m_pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; + m_surface->m_colorManagement->setHasImageDescription(true); }); - resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y, - uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) { + m_resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, + uint32_t w_y, uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) { LOGM(TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll, fall); - surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f}, - .green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f}, - .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, - .white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}}; - surface->m_colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f; - surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum; - surface->m_colorManagement->m_imageDescription.maxCLL = cll; - surface->m_colorManagement->m_imageDescription.maxFALL = fall; + m_surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f}, + .green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f}, + .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, + .white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}}; + m_surface->m_colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f; + m_surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum; + m_surface->m_colorManagement->m_imageDescription.maxCLL = cll; + m_surface->m_colorManagement->m_imageDescription.maxFALL = fall; - surface->m_colorManagement->setHasImageDescription(true); + m_surface->m_colorManagement->setHasImageDescription(true); }); } bool CFrogColorManagementSurface::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CFrogColorManagementSurface::client() { - return pClient; + return m_client; } CFrogColorManagementProtocol::CFrogColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -160,11 +160,11 @@ CFrogColorManagementProtocol::CFrogColorManagementProtocol(const wl_interface* i } void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } @@ -172,9 +172,9 @@ void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, ui } void CFrogColorManagementProtocol::destroyResource(CFrogColorManager* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CFrogColorManagementProtocol::destroyResource(CFrogColorManagementSurface* resource) { - std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; }); } diff --git a/src/protocols/FrogColorManagement.hpp b/src/protocols/FrogColorManagement.hpp index db467b1de..32e2202c6 100644 --- a/src/protocols/FrogColorManagement.hpp +++ b/src/protocols/FrogColorManagement.hpp @@ -12,7 +12,7 @@ class CFrogColorManager { bool good(); private: - SP resource; + SP m_resource; }; class CFrogColorManagementSurface { @@ -22,14 +22,14 @@ class CFrogColorManagementSurface { bool good(); wl_client* client(); - WP self; - WP surface; + WP m_self; + WP m_surface; - bool pqIntentSent = false; + bool m_pqIntentSent = false; private: - SP resource; - wl_client* pClient = nullptr; + SP m_resource; + wl_client* m_client = nullptr; }; class CFrogColorManagementProtocol : public IWaylandProtocol { @@ -42,8 +42,8 @@ class CFrogColorManagementProtocol : public IWaylandProtocol { void destroyResource(CFrogColorManager* resource); void destroyResource(CFrogColorManagementSurface* resource); - std::vector> m_vManagers; - std::vector> m_vSurfaces; + std::vector> m_managers; + std::vector> m_surfaces; friend class CFrogColorManager; friend class CFrogColorManagementSurface; diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp index 1309ffc51..1d5b4fd5b 100644 --- a/src/protocols/GammaControl.cpp +++ b/src/protocols/GammaControl.cpp @@ -6,7 +6,7 @@ #include "../render/Renderer.hpp" using namespace Hyprutils::OS; -CGammaControl::CGammaControl(SP resource_, wl_resource* output) : resource(resource_) { +CGammaControl::CGammaControl(SP resource_, wl_resource* output) : m_resource(resource_) { if UNLIKELY (!resource_->resource()) return; @@ -14,144 +14,144 @@ CGammaControl::CGammaControl(SP resource_, wl_resource* out if UNLIKELY (!OUTPUTRES) { LOGM(ERR, "No output in CGammaControl"); - resource->sendFailed(); + m_resource->sendFailed(); return; } - pMonitor = OUTPUTRES->m_monitor; + m_monitor = OUTPUTRES->m_monitor; - if UNLIKELY (!pMonitor || !pMonitor->m_output) { + if UNLIKELY (!m_monitor || !m_monitor->m_output) { LOGM(ERR, "No CMonitor"); - resource->sendFailed(); + m_resource->sendFailed(); return; } - for (auto const& g : PROTO::gamma->m_vGammaControllers) { - if UNLIKELY (g->pMonitor == pMonitor) { - resource->sendFailed(); + for (auto const& g : PROTO::gamma->m_gammaControllers) { + if UNLIKELY (g->m_monitor == m_monitor) { + m_resource->sendFailed(); return; } } - gammaSize = pMonitor->m_output->getGammaSize(); + m_gammaSize = m_monitor->m_output->getGammaSize(); - if UNLIKELY (gammaSize <= 0) { - LOGM(ERR, "Output {} doesn't support gamma", pMonitor->m_name); - resource->sendFailed(); + if UNLIKELY (m_gammaSize <= 0) { + LOGM(ERR, "Output {} doesn't support gamma", m_monitor->m_name); + m_resource->sendFailed(); return; } - gammaTable.resize(gammaSize * 3); + m_gammaTable.resize(m_gammaSize * 3); - resource->setDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); }); - resource->setOnDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); }); + m_resource->setDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); }); + m_resource->setOnDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); }); - resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) { + m_resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) { CFileDescriptor gammaFd{fd}; - if UNLIKELY (!pMonitor) { + if UNLIKELY (!m_monitor) { LOGM(ERR, "setGamma for a dead monitor"); - resource->sendFailed(); + m_resource->sendFailed(); return; } - LOGM(LOG, "setGamma for {}", pMonitor->m_name); + LOGM(LOG, "setGamma for {}", m_monitor->m_name); // TODO: make CFileDescriptor getflags use F_GETFL int fdFlags = fcntl(gammaFd.get(), F_GETFL, 0); if UNLIKELY (fdFlags < 0) { LOGM(ERR, "Failed to get fd flags"); - resource->sendFailed(); + m_resource->sendFailed(); return; } // TODO: make CFileDescriptor setflags use F_SETFL if UNLIKELY (fcntl(gammaFd.get(), F_SETFL, fdFlags | O_NONBLOCK) < 0) { LOGM(ERR, "Failed to set fd flags"); - resource->sendFailed(); + m_resource->sendFailed(); return; } - ssize_t readBytes = pread(gammaFd.get(), gammaTable.data(), gammaTable.size() * sizeof(uint16_t), 0); - if (readBytes < 0 || (size_t)readBytes != gammaTable.size() * sizeof(uint16_t)) { + ssize_t readBytes = pread(gammaFd.get(), m_gammaTable.data(), m_gammaTable.size() * sizeof(uint16_t), 0); + if (readBytes < 0 || (size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) { LOGM(ERR, "Failed to read bytes"); - if ((size_t)readBytes != gammaTable.size() * sizeof(uint16_t)) { + if ((size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) { gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch"); return; } - resource->sendFailed(); + m_resource->sendFailed(); return; } - gammaTableSet = true; + m_gammaTableSet = true; // translate the table to AQ format std::vector red, green, blue; - red.resize(gammaTable.size() / 3); - green.resize(gammaTable.size() / 3); - blue.resize(gammaTable.size() / 3); - for (size_t i = 0; i < gammaTable.size() / 3; ++i) { - red.at(i) = gammaTable.at(i); - green.at(i) = gammaTable.at(gammaTable.size() / 3 + i); - blue.at(i) = gammaTable.at((gammaTable.size() / 3) * 2 + i); + red.resize(m_gammaTable.size() / 3); + green.resize(m_gammaTable.size() / 3); + blue.resize(m_gammaTable.size() / 3); + for (size_t i = 0; i < m_gammaTable.size() / 3; ++i) { + red.at(i) = m_gammaTable.at(i); + green.at(i) = m_gammaTable.at(m_gammaTable.size() / 3 + i); + blue.at(i) = m_gammaTable.at((m_gammaTable.size() / 3) * 2 + i); } - for (size_t i = 0; i < gammaTable.size() / 3; ++i) { - gammaTable.at(i * 3) = red.at(i); - gammaTable.at(i * 3 + 1) = green.at(i); - gammaTable.at(i * 3 + 2) = blue.at(i); + for (size_t i = 0; i < m_gammaTable.size() / 3; ++i) { + m_gammaTable.at(i * 3) = red.at(i); + m_gammaTable.at(i * 3 + 1) = green.at(i); + m_gammaTable.at(i * 3 + 2) = blue.at(i); } applyToMonitor(); }); - resource->sendGammaSize(gammaSize); + m_resource->sendGammaSize(m_gammaSize); - listeners.monitorDestroy = pMonitor->m_events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); }); - listeners.monitorDisconnect = pMonitor->m_events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); }); + m_listeners.monitorDestroy = m_monitor->m_events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); }); + m_listeners.monitorDisconnect = m_monitor->m_events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); }); } CGammaControl::~CGammaControl() { - if (!gammaTableSet || !pMonitor || !pMonitor->m_output) + if (!m_gammaTableSet || !m_monitor || !m_monitor->m_output) return; // reset the LUT if the client dies for whatever reason and doesn't unset the gamma - pMonitor->m_output->state->setGammaLut({}); + m_monitor->m_output->state->setGammaLut({}); } bool CGammaControl::good() { - return resource->resource(); + return m_resource->resource(); } void CGammaControl::applyToMonitor() { - if UNLIKELY (!pMonitor || !pMonitor->m_output) + if UNLIKELY (!m_monitor || !m_monitor->m_output) return; // ?? - LOGM(LOG, "setting to monitor {}", pMonitor->m_name); + LOGM(LOG, "setting to monitor {}", m_monitor->m_name); - if (!gammaTableSet) { - pMonitor->m_output->state->setGammaLut({}); + if (!m_gammaTableSet) { + m_monitor->m_output->state->setGammaLut({}); return; } - pMonitor->m_output->state->setGammaLut(gammaTable); + m_monitor->m_output->state->setGammaLut(m_gammaTable); - if (!pMonitor->m_state.test()) { - LOGM(LOG, "setting to monitor {} failed", pMonitor->m_name); - pMonitor->m_output->state->setGammaLut({}); + if (!m_monitor->m_state.test()) { + LOGM(LOG, "setting to monitor {} failed", m_monitor->m_name); + m_monitor->m_output->state->setGammaLut({}); } - g_pHyprRenderer->damageMonitor(pMonitor.lock()); + g_pHyprRenderer->damageMonitor(m_monitor.lock()); } PHLMONITOR CGammaControl::getMonitor() { - return pMonitor ? pMonitor.lock() : nullptr; + return m_monitor ? m_monitor.lock() : nullptr; } void CGammaControl::onMonitorDestroy() { - LOGM(LOG, "Destroying gamma control for {}", pMonitor->m_name); - resource->sendFailed(); + LOGM(LOG, "Destroying gamma control for {}", m_monitor->m_name); + m_resource->sendFailed(); } CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -159,7 +159,7 @@ CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const in } void CGammaControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CZwlrGammaControlManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CZwlrGammaControlManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -167,26 +167,26 @@ void CGammaControlProtocol::bindManager(wl_client* client, void* data, uint32_t } void CGammaControlProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CGammaControlProtocol::destroyGammaControl(CGammaControl* gamma) { - std::erase_if(m_vGammaControllers, [&](const auto& other) { return other.get() == gamma; }); + std::erase_if(m_gammaControllers, [&](const auto& other) { return other.get() == gamma; }); } void CGammaControlProtocol::onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output) { const auto CLIENT = pMgr->client(); - const auto RESOURCE = m_vGammaControllers.emplace_back(makeUnique(makeShared(CLIENT, pMgr->version(), id), output)).get(); + const auto RESOURCE = m_gammaControllers.emplace_back(makeUnique(makeShared(CLIENT, pMgr->version(), id), output)).get(); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_vGammaControllers.pop_back(); + m_gammaControllers.pop_back(); return; } } void CGammaControlProtocol::applyGammaToState(PHLMONITOR pMonitor) { - for (auto const& g : m_vGammaControllers) { + for (auto const& g : m_gammaControllers) { if (g->getMonitor() != pMonitor) continue; diff --git a/src/protocols/GammaControl.hpp b/src/protocols/GammaControl.hpp index 9e21ef084..525f5b676 100644 --- a/src/protocols/GammaControl.hpp +++ b/src/protocols/GammaControl.hpp @@ -18,18 +18,18 @@ class CGammaControl { PHLMONITOR getMonitor(); private: - SP resource; - PHLMONITORREF pMonitor; - size_t gammaSize = 0; - bool gammaTableSet = false; - std::vector gammaTable; // [r,g,b]+ + SP m_resource; + PHLMONITORREF m_monitor; + size_t m_gammaSize = 0; + bool m_gammaTableSet = false; + std::vector m_gammaTable; // [r,g,b]+ void onMonitorDestroy(); struct { CHyprSignalListener monitorDisconnect; CHyprSignalListener monitorDestroy; - } listeners; + } m_listeners; }; class CGammaControlProtocol : public IWaylandProtocol { @@ -46,8 +46,8 @@ class CGammaControlProtocol : public IWaylandProtocol { void onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output); // - std::vector> m_vManagers; - std::vector> m_vGammaControllers; + std::vector> m_managers; + std::vector> m_gammaControllers; friend class CGammaControl; }; diff --git a/src/protocols/GlobalShortcuts.cpp b/src/protocols/GlobalShortcuts.cpp index 04e4e0910..50e7434d6 100644 --- a/src/protocols/GlobalShortcuts.cpp +++ b/src/protocols/GlobalShortcuts.cpp @@ -1,21 +1,21 @@ #include "GlobalShortcuts.hpp" #include "../helpers/time/Time.hpp" -CShortcutClient::CShortcutClient(SP resource_) : resource(resource_) { +CShortcutClient::CShortcutClient(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); }); - resource->setDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); }); + m_resource->setOnDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); }); + m_resource->setDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); }); - resource->setRegisterShortcut([this](CHyprlandGlobalShortcutsManagerV1* pMgr, uint32_t shortcut, const char* id, const char* app_id, const char* description, - const char* trigger_description) { + m_resource->setRegisterShortcut([this](CHyprlandGlobalShortcutsManagerV1* pMgr, uint32_t shortcut, const char* id, const char* app_id, const char* description, + const char* trigger_description) { if UNLIKELY (PROTO::globalShortcuts->isTaken(id, app_id)) { - resource->error(HYPRLAND_GLOBAL_SHORTCUTS_MANAGER_V1_ERROR_ALREADY_TAKEN, "Combination is taken"); + m_resource->error(HYPRLAND_GLOBAL_SHORTCUTS_MANAGER_V1_ERROR_ALREADY_TAKEN, "Combination is taken"); return; } - const auto PSHORTCUT = shortcuts.emplace_back(makeShared(makeShared(resource->client(), resource->version(), shortcut))); + const auto PSHORTCUT = m_shortcuts.emplace_back(makeShared(makeShared(m_resource->client(), m_resource->version(), shortcut))); PSHORTCUT->id = id; PSHORTCUT->description = description; PSHORTCUT->appid = app_id; @@ -23,16 +23,16 @@ CShortcutClient::CShortcutClient(SP resource_ if UNLIKELY (!PSHORTCUT->resource->resource()) { PSHORTCUT->resource->noMemory(); - shortcuts.pop_back(); + m_shortcuts.pop_back(); return; } - PSHORTCUT->resource->setDestroy([this](CHyprlandGlobalShortcutV1* pMgr) { std::erase_if(shortcuts, [&](const auto& other) { return other->resource.get() == pMgr; }); }); + PSHORTCUT->resource->setDestroy([this](CHyprlandGlobalShortcutV1* pMgr) { std::erase_if(m_shortcuts, [&](const auto& other) { return other->resource.get() == pMgr; }); }); }); } bool CShortcutClient::good() { - return resource->resource(); + return m_resource->resource(); } CGlobalShortcutsProtocol::CGlobalShortcutsProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -40,22 +40,22 @@ CGlobalShortcutsProtocol::CGlobalShortcutsProtocol(const wl_interface* iface, co } void CGlobalShortcutsProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESROUCE = m_vClients.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESROUCE = m_clients.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESROUCE->good()) { wl_client_post_no_memory(client); - m_vClients.pop_back(); + m_clients.pop_back(); return; } } void CGlobalShortcutsProtocol::destroyResource(CShortcutClient* client) { - std::erase_if(m_vClients, [&](const auto& other) { return other.get() == client; }); + std::erase_if(m_clients, [&](const auto& other) { return other.get() == client; }); } bool CGlobalShortcutsProtocol::isTaken(std::string appid, std::string trigger) { - for (auto const& c : m_vClients) { - for (auto const& sh : c->shortcuts) { + for (auto const& c : m_clients) { + for (auto const& sh : c->m_shortcuts) { if (sh->appid == appid && sh->id == trigger) { return true; } @@ -66,8 +66,8 @@ bool CGlobalShortcutsProtocol::isTaken(std::string appid, std::string trigger) { } void CGlobalShortcutsProtocol::sendGlobalShortcutEvent(std::string appid, std::string trigger, bool pressed) { - for (auto const& c : m_vClients) { - for (auto const& sh : c->shortcuts) { + for (auto const& c : m_clients) { + for (auto const& sh : c->m_shortcuts) { if (sh->appid == appid && sh->id == trigger) { const auto [sec, nsec] = Time::secNsec(Time::steadyNow()); uint32_t tvSecHi = (sizeof(sec) > 4) ? sec >> 32 : 0; @@ -87,15 +87,15 @@ std::vector CGlobalShortcutsProtocol::getAllShortcuts() { // and potential reallocation is more costly then the added precompute overhead of looping // and finding the total size. size_t totalShortcuts = 0; - for (const auto& c : m_vClients) { - totalShortcuts += c->shortcuts.size(); + for (const auto& c : m_clients) { + totalShortcuts += c->m_shortcuts.size(); } // reserve number of elements to avoid reallocations copy.reserve(totalShortcuts); - for (const auto& c : m_vClients) { - for (const auto& sh : c->shortcuts) { + for (const auto& c : m_clients) { + for (const auto& sh : c->m_shortcuts) { copy.push_back(*sh); } } diff --git a/src/protocols/GlobalShortcuts.hpp b/src/protocols/GlobalShortcuts.hpp index 14f6ee0b9..a4d5baf97 100644 --- a/src/protocols/GlobalShortcuts.hpp +++ b/src/protocols/GlobalShortcuts.hpp @@ -17,8 +17,8 @@ class CShortcutClient { bool good(); private: - SP resource; - std::vector> shortcuts; + SP m_resource; + std::vector> m_shortcuts; friend class CGlobalShortcutsProtocol; }; @@ -35,7 +35,7 @@ class CGlobalShortcutsProtocol : IWaylandProtocol { std::vector getAllShortcuts(); private: - std::vector> m_vClients; + std::vector> m_clients; }; namespace PROTO { diff --git a/src/protocols/HyprlandSurface.cpp b/src/protocols/HyprlandSurface.cpp index 13d5a49a1..9c66fba45 100644 --- a/src/protocols/HyprlandSurface.cpp +++ b/src/protocols/HyprlandSurface.cpp @@ -6,83 +6,83 @@ #include #include -CHyprlandSurface::CHyprlandSurface(SP resource, SP surface) : m_pSurface(surface) { +CHyprlandSurface::CHyprlandSurface(SP resource, SP surface) : m_surface(surface) { setResource(std::move(resource)); } bool CHyprlandSurface::good() const { - return m_pResource->resource(); + return m_resource->resource(); } void CHyprlandSurface::setResource(SP resource) { - m_pResource = std::move(resource); + m_resource = std::move(resource); - if UNLIKELY (!m_pResource->resource()) + if UNLIKELY (!m_resource->resource()) return; - m_pResource->setDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); }); - m_pResource->setOnDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); }); + m_resource->setDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); }); + m_resource->setOnDestroy([this](CHyprlandSurfaceV1* resource) { destroy(); }); - m_pResource->setSetOpacity([this](CHyprlandSurfaceV1* resource, uint32_t opacity) { - if UNLIKELY (!m_pSurface) { - m_pResource->error(HYPRLAND_SURFACE_V1_ERROR_NO_SURFACE, "set_opacity called for destroyed wl_surface"); + m_resource->setSetOpacity([this](CHyprlandSurfaceV1* resource, uint32_t opacity) { + if UNLIKELY (!m_surface) { + m_resource->error(HYPRLAND_SURFACE_V1_ERROR_NO_SURFACE, "set_opacity called for destroyed wl_surface"); return; } auto fOpacity = wl_fixed_to_double(opacity); if UNLIKELY (fOpacity < 0.0 || fOpacity > 1.0) { - m_pResource->error(HYPRLAND_SURFACE_V1_ERROR_OUT_OF_RANGE, "set_opacity called with an opacity value larger than 1.0 or smaller than 0.0."); + m_resource->error(HYPRLAND_SURFACE_V1_ERROR_OUT_OF_RANGE, "set_opacity called with an opacity value larger than 1.0 or smaller than 0.0."); return; } - m_fOpacity = fOpacity; + m_opacity = fOpacity; }); - m_pResource->setSetVisibleRegion([this](CHyprlandSurfaceV1* resource, wl_resource* region) { + m_resource->setSetVisibleRegion([this](CHyprlandSurfaceV1* resource, wl_resource* region) { if (!region) { if (!m_visibleRegion.empty()) - m_bVisibleRegionChanged = true; + m_visibleRegionChanged = true; m_visibleRegion.clear(); return; } - m_bVisibleRegionChanged = true; - m_visibleRegion = CWLRegionResource::fromResource(region)->m_region; + m_visibleRegionChanged = true; + m_visibleRegion = CWLRegionResource::fromResource(region)->m_region; }); - listeners.surfaceCommitted = m_pSurface->m_events.commit.registerListener([this](std::any data) { - auto surface = CWLSurface::fromResource(m_pSurface.lock()); + m_listeners.surfaceCommitted = m_surface->m_events.commit.registerListener([this](std::any data) { + auto surface = CWLSurface::fromResource(m_surface.lock()); - if (surface && (surface->m_overallOpacity != m_fOpacity || m_bVisibleRegionChanged)) { - surface->m_overallOpacity = m_fOpacity; + if (surface && (surface->m_overallOpacity != m_opacity || m_visibleRegionChanged)) { + surface->m_overallOpacity = m_opacity; surface->m_visibleRegion = m_visibleRegion; auto box = surface->getSurfaceBoxGlobal(); if (box.has_value()) g_pHyprRenderer->damageBox(*box); - if (!m_pResource) + if (!m_resource) PROTO::hyprlandSurface->destroySurface(this); } }); - listeners.surfaceDestroyed = m_pSurface->m_events.destroy.registerListener([this](std::any data) { - if (!m_pResource) + m_listeners.surfaceDestroyed = m_surface->m_events.destroy.registerListener([this](std::any data) { + if (!m_resource) PROTO::hyprlandSurface->destroySurface(this); }); } void CHyprlandSurface::destroy() { - m_pResource.reset(); - m_fOpacity = 1.F; + m_resource.reset(); + m_opacity = 1.F; if (!m_visibleRegion.empty()) - m_bVisibleRegionChanged = true; + m_visibleRegionChanged = true; m_visibleRegion.clear(); - if (!m_pSurface) + if (!m_surface) PROTO::hyprlandSurface->destroySurface(this); } @@ -91,7 +91,7 @@ CHyprlandSurfaceProtocol::CHyprlandSurfaceProtocol(const wl_interface* iface, co } void CHyprlandSurfaceProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - auto manager = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + auto manager = m_managers.emplace_back(makeUnique(client, ver, id)).get(); manager->setOnDestroy([this](CHyprlandSurfaceManagerV1* manager) { destroyManager(manager); }); manager->setDestroy([this](CHyprlandSurfaceManagerV1* manager) { destroyManager(manager); }); @@ -100,19 +100,19 @@ void CHyprlandSurfaceProtocol::bindManager(wl_client* client, void* data, uint32 } void CHyprlandSurfaceProtocol::destroyManager(CHyprlandSurfaceManagerV1* manager) { - std::erase_if(m_vManagers, [&](const auto& p) { return p.get() == manager; }); + std::erase_if(m_managers, [&](const auto& p) { return p.get() == manager; }); } void CHyprlandSurfaceProtocol::destroySurface(CHyprlandSurface* surface) { - std::erase_if(m_mSurfaces, [&](const auto& entry) { return entry.second.get() == surface; }); + std::erase_if(m_surfaces, [&](const auto& entry) { return entry.second.get() == surface; }); } void CHyprlandSurfaceProtocol::getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP surface) { CHyprlandSurface* hyprlandSurface = nullptr; - auto iter = std::find_if(m_mSurfaces.begin(), m_mSurfaces.end(), [&](const auto& entry) { return entry.second->m_pSurface == surface; }); + auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [&](const auto& entry) { return entry.second->m_surface == surface; }); - if (iter != m_mSurfaces.end()) { - if (iter->second->m_pResource) { + if (iter != m_surfaces.end()) { + if (iter->second->m_resource) { LOGM(ERR, "HyprlandSurface already present for surface {:x}", (uintptr_t)surface.get()); manager->error(HYPRLAND_SURFACE_MANAGER_V1_ERROR_ALREADY_CONSTRUCTED, "HyprlandSurface already present"); return; @@ -122,11 +122,11 @@ void CHyprlandSurfaceProtocol::getSurface(CHyprlandSurfaceManagerV1* manager, ui } } else { hyprlandSurface = - m_mSurfaces.emplace(surface, makeUnique(makeShared(manager->client(), manager->version(), id), surface)).first->second.get(); + m_surfaces.emplace(surface, makeUnique(makeShared(manager->client(), manager->version(), id), surface)).first->second.get(); } if UNLIKELY (!hyprlandSurface->good()) { manager->noMemory(); - m_mSurfaces.erase(surface); + m_surfaces.erase(surface); } } diff --git a/src/protocols/HyprlandSurface.hpp b/src/protocols/HyprlandSurface.hpp index 5c1181c47..5402e916d 100644 --- a/src/protocols/HyprlandSurface.hpp +++ b/src/protocols/HyprlandSurface.hpp @@ -18,10 +18,10 @@ class CHyprlandSurface { void setResource(SP resource); private: - SP m_pResource; - WP m_pSurface; - float m_fOpacity = 1.0; - bool m_bVisibleRegionChanged = false; + SP m_resource; + WP m_surface; + float m_opacity = 1.0; + bool m_visibleRegionChanged = false; CRegion m_visibleRegion; void destroy(); @@ -29,7 +29,7 @@ class CHyprlandSurface { struct { CHyprSignalListener surfaceCommitted; CHyprSignalListener surfaceDestroyed; - } listeners; + } m_listeners; friend class CHyprlandSurfaceProtocol; }; @@ -45,8 +45,8 @@ class CHyprlandSurfaceProtocol : public IWaylandProtocol { void destroySurface(CHyprlandSurface* surface); void getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP surface); - std::vector> m_vManagers; - std::unordered_map, UP> m_mSurfaces; + std::vector> m_managers; + std::unordered_map, UP> m_surfaces; friend class CHyprlandSurface; }; diff --git a/src/protocols/IdleInhibit.cpp b/src/protocols/IdleInhibit.cpp index b8ba01e20..f8031d22f 100644 --- a/src/protocols/IdleInhibit.cpp +++ b/src/protocols/IdleInhibit.cpp @@ -1,25 +1,25 @@ #include "IdleInhibit.hpp" #include "core/Compositor.hpp" -CIdleInhibitor::CIdleInhibitor(SP resource_, SP surf_) : resource(resource_), surface(surf_) { +CIdleInhibitor::CIdleInhibitor(SP resource_, SP surf_) : m_resource(resource_), m_surface(surf_) { ; } -CIdleInhibitorResource::CIdleInhibitorResource(SP resource_, SP surface_) : resource(resource_), surface(surface_) { - listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { - surface.reset(); - listeners.destroySurface.reset(); - destroySent = true; - events.destroy.emit(); +CIdleInhibitorResource::CIdleInhibitorResource(SP resource_, SP surface_) : m_resource(resource_), m_surface(surface_) { + m_listeners.destroySurface = m_surface->m_events.destroy.registerListener([this](std::any d) { + m_surface.reset(); + m_listeners.destroySurface.reset(); + m_destroySent = true; + m_events.destroy.emit(); }); - resource->setOnDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); - resource->setDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); + m_resource->setOnDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); + m_resource->setDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); } CIdleInhibitorResource::~CIdleInhibitorResource() { - if (!destroySent) - events.destroy.emit(); + if (!m_destroySent) + m_events.destroy.emit(); } CIdleInhibitProtocol::CIdleInhibitProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -27,11 +27,11 @@ CIdleInhibitProtocol::CIdleInhibitProtocol(const wl_interface* iface, const int& } void CIdleInhibitProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [res](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [res](const auto& other) { return other->resource() == res; }); } void CIdleInhibitProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CZwpIdleInhibitManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CZwpIdleInhibitManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -40,13 +40,13 @@ void CIdleInhibitProtocol::bindManager(wl_client* client, void* data, uint32_t v } void CIdleInhibitProtocol::removeInhibitor(CIdleInhibitorResource* resource) { - std::erase_if(m_vInhibitors, [resource](const auto& el) { return el.get() == resource; }); + std::erase_if(m_inhibitors, [resource](const auto& el) { return el.get() == resource; }); } void CIdleInhibitProtocol::onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, SP surface) { const auto CLIENT = pMgr->client(); - const auto RESOURCE = m_vInhibitors.emplace_back(makeShared(makeShared(CLIENT, pMgr->version(), id), surface)); + const auto RESOURCE = m_inhibitors.emplace_back(makeShared(makeShared(CLIENT, pMgr->version(), id), surface)); - RESOURCE->inhibitor = makeShared(RESOURCE, surface); - events.newIdleInhibitor.emit(RESOURCE->inhibitor); + RESOURCE->m_inhibitor = makeShared(RESOURCE, surface); + m_events.newIdleInhibitor.emit(RESOURCE->m_inhibitor); } \ No newline at end of file diff --git a/src/protocols/IdleInhibit.hpp b/src/protocols/IdleInhibit.hpp index 2e024a7a8..791d83f9e 100644 --- a/src/protocols/IdleInhibit.hpp +++ b/src/protocols/IdleInhibit.hpp @@ -14,10 +14,10 @@ class CIdleInhibitor { struct { CHyprSignalListener destroy; - } listeners; + } m_listeners; - WP resource; - WP surface; + WP m_resource; + WP m_surface; }; class CIdleInhibitorResource { @@ -25,20 +25,20 @@ class CIdleInhibitorResource { CIdleInhibitorResource(SP resource_, SP surface_); ~CIdleInhibitorResource(); - SP inhibitor; + SP m_inhibitor; struct { CSignal destroy; - } events; + } m_events; private: - SP resource; - WP surface; - bool destroySent = false; + SP m_resource; + WP m_surface; + bool m_destroySent = false; struct { CHyprSignalListener destroySurface; - } listeners; + } m_listeners; }; class CIdleInhibitProtocol : public IWaylandProtocol { @@ -49,7 +49,7 @@ class CIdleInhibitProtocol : public IWaylandProtocol { struct { CSignal newIdleInhibitor; // data: SP - } events; + } m_events; private: void onManagerResourceDestroy(wl_resource* res); @@ -58,8 +58,8 @@ class CIdleInhibitProtocol : public IWaylandProtocol { void removeInhibitor(CIdleInhibitorResource*); // - std::vector> m_vManagers; - std::vector> m_vInhibitors; + std::vector> m_managers; + std::vector> m_inhibitors; friend class CIdleInhibitorResource; }; diff --git a/src/protocols/IdleNotify.cpp b/src/protocols/IdleNotify.cpp index 14a5f3e1f..82bd59b1f 100644 --- a/src/protocols/IdleNotify.cpp +++ b/src/protocols/IdleNotify.cpp @@ -11,15 +11,15 @@ static int onTimer(SP self, void* data) { } CExtIdleNotification::CExtIdleNotification(SP resource_, uint32_t timeoutMs_, bool obeyInhibitors_) : - resource(resource_), timeoutMs(timeoutMs_), obeyInhibitors(obeyInhibitors_) { + m_resource(resource_), m_timeoutMs(timeoutMs_), m_obeyInhibitors(obeyInhibitors_) { if UNLIKELY (!resource_->resource()) return; - resource->setDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); }); - resource->setOnDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); }); + m_resource->setDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); }); + m_resource->setOnDestroy([this](CExtIdleNotificationV1* r) { PROTO::idle->destroyNotification(this); }); - timer = makeShared(std::nullopt, onTimer, this); - g_pEventLoopManager->addTimer(timer); + m_timer = makeShared(std::nullopt, onTimer, this); + g_pEventLoopManager->addTimer(m_timer); updateTimer(); @@ -27,36 +27,36 @@ CExtIdleNotification::CExtIdleNotification(SP resource_, } CExtIdleNotification::~CExtIdleNotification() { - g_pEventLoopManager->removeTimer(timer); - timer.reset(); + g_pEventLoopManager->removeTimer(m_timer); + m_timer.reset(); } bool CExtIdleNotification::good() { - return resource->resource(); + return m_resource->resource(); } void CExtIdleNotification::updateTimer() { - if (PROTO::idle->isInhibited && obeyInhibitors) - timer->updateTimeout(std::nullopt); + if (PROTO::idle->isInhibited && m_obeyInhibitors) + m_timer->updateTimeout(std::nullopt); else - timer->updateTimeout(std::chrono::milliseconds(timeoutMs)); + m_timer->updateTimeout(std::chrono::milliseconds(m_timeoutMs)); } void CExtIdleNotification::onTimerFired() { - resource->sendIdled(); - idled = true; + m_resource->sendIdled(); + m_idled = true; } void CExtIdleNotification::onActivity() { - if (idled) - resource->sendResumed(); + if (m_idled) + m_resource->sendResumed(); - idled = false; + m_idled = false; updateTimer(); } bool CExtIdleNotification::inhibitorsAreObeyed() const { - return obeyInhibitors; + return m_obeyInhibitors; } CIdleNotifyProtocol::CIdleNotifyProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -64,7 +64,7 @@ CIdleNotifyProtocol::CIdleNotifyProtocol(const wl_interface* iface, const int& v } void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CExtIdleNotifierV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CExtIdleNotifierV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -75,34 +75,34 @@ void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ve } void CIdleNotifyProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CIdleNotifyProtocol::destroyNotification(CExtIdleNotification* notif) { - std::erase_if(m_vNotifications, [&](const auto& other) { return other.get() == notif; }); + std::erase_if(m_notifications, [&](const auto& other) { return other.get() == notif; }); } void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors) { const auto CLIENT = pMgr->client(); const auto RESOURCE = - m_vNotifications.emplace_back(makeShared(makeShared(CLIENT, pMgr->version(), id), timeout, obeyInhibitors)).get(); + m_notifications.emplace_back(makeShared(makeShared(CLIENT, pMgr->version(), id), timeout, obeyInhibitors)).get(); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_vNotifications.pop_back(); + m_notifications.pop_back(); return; } } void CIdleNotifyProtocol::onActivity() { - for (auto const& n : m_vNotifications) { + for (auto const& n : m_notifications) { n->onActivity(); } } void CIdleNotifyProtocol::setInhibit(bool inhibited) { isInhibited = inhibited; - for (auto const& n : m_vNotifications) { + for (auto const& n : m_notifications) { if (n->inhibitorsAreObeyed()) n->onActivity(); } diff --git a/src/protocols/IdleNotify.hpp b/src/protocols/IdleNotify.hpp index efc3acccc..02b59e656 100644 --- a/src/protocols/IdleNotify.hpp +++ b/src/protocols/IdleNotify.hpp @@ -19,12 +19,12 @@ class CExtIdleNotification { bool inhibitorsAreObeyed() const; private: - SP resource; - uint32_t timeoutMs = 0; - SP timer; + SP m_resource; + uint32_t m_timeoutMs = 0; + SP m_timer; - bool idled = false; - bool obeyInhibitors = false; + bool m_idled = false; + bool m_obeyInhibitors = false; void updateTimer(); }; @@ -46,8 +46,8 @@ class CIdleNotifyProtocol : public IWaylandProtocol { bool isInhibited = false; // - std::vector> m_vManagers; - std::vector> m_vNotifications; + std::vector> m_managers; + std::vector> m_notifications; friend class CExtIdleNotification; }; diff --git a/src/protocols/InputMethodV2.cpp b/src/protocols/InputMethodV2.cpp index ae575250f..63f9f33fb 100644 --- a/src/protocols/InputMethodV2.cpp +++ b/src/protocols/InputMethodV2.cpp @@ -6,12 +6,12 @@ #include "core/Compositor.hpp" #include -CInputMethodKeyboardGrabV2::CInputMethodKeyboardGrabV2(SP resource_, SP owner_) : resource(resource_), owner(owner_) { - if UNLIKELY (!resource->resource()) +CInputMethodKeyboardGrabV2::CInputMethodKeyboardGrabV2(SP resource_, SP owner_) : m_resource(resource_), m_owner(owner_) { + if UNLIKELY (!m_resource->resource()) return; - resource->setRelease([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); }); - resource->setOnDestroy([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); }); + m_resource->setRelease([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwpInputMethodKeyboardGrabV2* r) { PROTO::ime->destroyResource(this); }); if (!g_pSeatManager->m_keyboard) { LOGM(ERR, "IME called but no active keyboard???"); @@ -22,16 +22,16 @@ CInputMethodKeyboardGrabV2::CInputMethodKeyboardGrabV2(SPgrabs, [](const auto& g) { return g.expired(); }); + if (!m_owner.expired()) + std::erase_if(m_owner->m_grabs, [](const auto& g) { return g.expired(); }); } void CInputMethodKeyboardGrabV2::sendKeyboardData(SP keyboard) { - if (keyboard == pLastKeyboard) + if (keyboard == m_lastKeyboard) return; - pLastKeyboard = keyboard; + m_lastKeyboard = keyboard; auto keymapFD = allocateSHMFile(keyboard->m_xkbKeymapString.length() + 1); if UNLIKELY (!keymapFD.isValid()) { @@ -48,95 +48,96 @@ void CInputMethodKeyboardGrabV2::sendKeyboardData(SP keyboard) { memcpy(data, keyboard->m_xkbKeymapString.c_str(), keyboard->m_xkbKeymapString.length()); munmap(data, keyboard->m_xkbKeymapString.length() + 1); - resource->sendKeymap(WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymapFD.get(), keyboard->m_xkbKeymapString.length() + 1); + m_resource->sendKeymap(WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymapFD.get(), keyboard->m_xkbKeymapString.length() + 1); sendMods(keyboard->m_modifiersState.depressed, keyboard->m_modifiersState.latched, keyboard->m_modifiersState.locked, keyboard->m_modifiersState.group); - resource->sendRepeatInfo(keyboard->m_repeatRate, keyboard->m_repeatDelay); + m_resource->sendRepeatInfo(keyboard->m_repeatRate, keyboard->m_repeatDelay); } void CInputMethodKeyboardGrabV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) { - const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(resource->client())); + const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client())); - resource->sendKey(SERIAL, time, key, (uint32_t)state); + m_resource->sendKey(SERIAL, time, key, (uint32_t)state); } void CInputMethodKeyboardGrabV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { - const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(resource->client())); + const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client())); - resource->sendModifiers(SERIAL, depressed, latched, locked, group); + m_resource->sendModifiers(SERIAL, depressed, latched, locked, group); } bool CInputMethodKeyboardGrabV2::good() { - return resource->resource(); + return m_resource->resource(); } SP CInputMethodKeyboardGrabV2::getOwner() { - return owner.lock(); + return m_owner.lock(); } wl_client* CInputMethodKeyboardGrabV2::client() { - return resource->resource() ? resource->client() : nullptr; + return m_resource->resource() ? m_resource->client() : nullptr; } -CInputMethodPopupV2::CInputMethodPopupV2(SP resource_, SP owner_, SP surface) : resource(resource_), owner(owner_) { - if UNLIKELY (!resource->resource()) +CInputMethodPopupV2::CInputMethodPopupV2(SP resource_, SP owner_, SP surface) : + m_resource(resource_), m_owner(owner_) { + if UNLIKELY (!m_resource->resource()) return; - resource->setDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); }); - resource->setOnDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); }); + m_resource->setDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwpInputPopupSurfaceV2* r) { PROTO::ime->destroyResource(this); }); - pSurface = surface; + m_surface = surface; - listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { - if (mapped) - events.unmap.emit(); + m_listeners.destroySurface = surface->m_events.destroy.registerListener([this](std::any d) { + if (m_mapped) + m_events.unmap.emit(); - listeners.destroySurface.reset(); - listeners.commitSurface.reset(); + m_listeners.destroySurface.reset(); + m_listeners.commitSurface.reset(); - if (g_pCompositor->m_lastFocus == pSurface) + if (g_pCompositor->m_lastFocus == m_surface) g_pCompositor->m_lastFocus.reset(); - pSurface.reset(); + m_surface.reset(); }); - listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) { - if (pSurface->m_current.texture && !mapped) { - mapped = true; - pSurface->map(); - events.map.emit(); + m_listeners.commitSurface = surface->m_events.commit.registerListener([this](std::any d) { + if (m_surface->m_current.texture && !m_mapped) { + m_mapped = true; + m_surface->map(); + m_events.map.emit(); return; } - if (!pSurface->m_current.texture && mapped) { - mapped = false; - pSurface->unmap(); - events.unmap.emit(); + if (!m_surface->m_current.texture && m_mapped) { + m_mapped = false; + m_surface->unmap(); + m_events.unmap.emit(); return; } - events.commit.emit(); + m_events.commit.emit(); }); } CInputMethodPopupV2::~CInputMethodPopupV2() { - if (!owner.expired()) - std::erase_if(owner->popups, [](const auto& p) { return p.expired(); }); + if (!m_owner.expired()) + std::erase_if(m_owner->m_popups, [](const auto& p) { return p.expired(); }); - events.destroy.emit(); + m_events.destroy.emit(); } bool CInputMethodPopupV2::good() { - return resource->resource(); + return m_resource->resource(); } void CInputMethodPopupV2::sendInputRectangle(const CBox& box) { - resource->sendTextInputRectangle(box.x, box.y, box.w, box.h); + m_resource->sendTextInputRectangle(box.x, box.y, box.w, box.h); } SP CInputMethodPopupV2::surface() { - return pSurface.lock(); + return m_surface.lock(); } void CInputMethodV2::SState::reset() { @@ -145,127 +146,127 @@ void CInputMethodV2::SState::reset() { preeditString.committed = false; } -CInputMethodV2::CInputMethodV2(SP resource_) : resource(resource_) { - if UNLIKELY (!resource->resource()) +CInputMethodV2::CInputMethodV2(SP resource_) : m_resource(resource_) { + if UNLIKELY (!m_resource->resource()) return; - resource->setDestroy([this](CZwpInputMethodV2* r) { - events.destroy.emit(); + m_resource->setDestroy([this](CZwpInputMethodV2* r) { + m_events.destroy.emit(); PROTO::ime->destroyResource(this); }); - resource->setOnDestroy([this](CZwpInputMethodV2* r) { - events.destroy.emit(); + m_resource->setOnDestroy([this](CZwpInputMethodV2* r) { + m_events.destroy.emit(); PROTO::ime->destroyResource(this); }); - resource->setCommitString([this](CZwpInputMethodV2* r, const char* str) { - pending.committedString.string = str; - pending.committedString.committed = true; + m_resource->setCommitString([this](CZwpInputMethodV2* r, const char* str) { + m_pending.committedString.string = str; + m_pending.committedString.committed = true; }); - resource->setDeleteSurroundingText([this](CZwpInputMethodV2* r, uint32_t before, uint32_t after) { - pending.deleteSurrounding.before = before; - pending.deleteSurrounding.after = after; - pending.deleteSurrounding.committed = true; + m_resource->setDeleteSurroundingText([this](CZwpInputMethodV2* r, uint32_t before, uint32_t after) { + m_pending.deleteSurrounding.before = before; + m_pending.deleteSurrounding.after = after; + m_pending.deleteSurrounding.committed = true; }); - resource->setSetPreeditString([this](CZwpInputMethodV2* r, const char* str, int32_t begin, int32_t end) { - pending.preeditString.string = str; - pending.preeditString.begin = begin; - pending.preeditString.end = end; - pending.preeditString.committed = true; + m_resource->setSetPreeditString([this](CZwpInputMethodV2* r, const char* str, int32_t begin, int32_t end) { + m_pending.preeditString.string = str; + m_pending.preeditString.begin = begin; + m_pending.preeditString.end = end; + m_pending.preeditString.committed = true; }); - resource->setCommit([this](CZwpInputMethodV2* r, uint32_t serial) { - current = pending; - pending.reset(); - events.onCommit.emit(); + m_resource->setCommit([this](CZwpInputMethodV2* r, uint32_t serial) { + m_current = m_pending; + m_pending.reset(); + m_events.onCommit.emit(); }); - resource->setGetInputPopupSurface([this](CZwpInputMethodV2* r, uint32_t id, wl_resource* surface) { - const auto RESOURCE = PROTO::ime->m_vPopups.emplace_back( - makeShared(makeShared(r->client(), r->version(), id), self.lock(), CWLSurfaceResource::fromResource(surface))); + m_resource->setGetInputPopupSurface([this](CZwpInputMethodV2* r, uint32_t id, wl_resource* surface) { + const auto RESOURCE = PROTO::ime->m_popups.emplace_back( + makeShared(makeShared(r->client(), r->version(), id), m_self.lock(), CWLSurfaceResource::fromResource(surface))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::ime->m_vPopups.pop_back(); + PROTO::ime->m_popups.pop_back(); return; } LOGM(LOG, "New IME Popup with resource id {}", id); - popups.emplace_back(RESOURCE); + m_popups.emplace_back(RESOURCE); - events.newPopup.emit(RESOURCE); + m_events.newPopup.emit(RESOURCE); }); - resource->setGrabKeyboard([this](CZwpInputMethodV2* r, uint32_t id) { + m_resource->setGrabKeyboard([this](CZwpInputMethodV2* r, uint32_t id) { const auto RESOURCE = - PROTO::ime->m_vGrabs.emplace_back(makeShared(makeShared(r->client(), r->version(), id), self.lock())); + PROTO::ime->m_grabs.emplace_back(makeShared(makeShared(r->client(), r->version(), id), m_self.lock())); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::ime->m_vGrabs.pop_back(); + PROTO::ime->m_grabs.pop_back(); return; } LOGM(LOG, "New IME Grab with resource id {}", id); - grabs.emplace_back(RESOURCE); + m_grabs.emplace_back(RESOURCE); }); } CInputMethodV2::~CInputMethodV2() { - events.destroy.emit(); + m_events.destroy.emit(); } bool CInputMethodV2::good() { - return resource->resource(); + return m_resource->resource(); } void CInputMethodV2::activate() { - if (active) + if (m_active) return; - resource->sendActivate(); - active = true; + m_resource->sendActivate(); + m_active = true; } void CInputMethodV2::deactivate() { - if (!active) + if (!m_active) return; - resource->sendDeactivate(); - active = false; + m_resource->sendDeactivate(); + m_active = false; } void CInputMethodV2::surroundingText(const std::string& text, uint32_t cursor, uint32_t anchor) { - resource->sendSurroundingText(text.c_str(), cursor, anchor); + m_resource->sendSurroundingText(text.c_str(), cursor, anchor); } void CInputMethodV2::textChangeCause(zwpTextInputV3ChangeCause changeCause) { - resource->sendTextChangeCause((uint32_t)changeCause); + m_resource->sendTextChangeCause((uint32_t)changeCause); } void CInputMethodV2::textContentType(zwpTextInputV3ContentHint hint, zwpTextInputV3ContentPurpose purpose) { - resource->sendContentType((uint32_t)hint, (uint32_t)purpose); + m_resource->sendContentType((uint32_t)hint, (uint32_t)purpose); } void CInputMethodV2::done() { - resource->sendDone(); + m_resource->sendDone(); } void CInputMethodV2::unavailable() { - resource->sendUnavailable(); + m_resource->sendUnavailable(); } bool CInputMethodV2::hasGrab() { - return !grabs.empty(); + return !m_grabs.empty(); } wl_client* CInputMethodV2::grabClient() { - if (grabs.empty()) + if (m_grabs.empty()) return nullptr; - for (auto const& gw : grabs) { + for (auto const& gw : m_grabs) { auto g = gw.lock(); if (!g) @@ -278,19 +279,19 @@ wl_client* CInputMethodV2::grabClient() { } void CInputMethodV2::sendInputRectangle(const CBox& box) { - inputRectangle = box; - for (auto const& wp : popups) { + m_inputRectangle = box; + for (auto const& wp : m_popups) { auto p = wp.lock(); if (!p) continue; - p->sendInputRectangle(inputRectangle); + p->sendInputRectangle(m_inputRectangle); } } void CInputMethodV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) { - for (auto const& gw : grabs) { + for (auto const& gw : m_grabs) { auto g = gw.lock(); if (!g) @@ -301,7 +302,7 @@ void CInputMethodV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state } void CInputMethodV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { - for (auto const& gw : grabs) { + for (auto const& gw : m_grabs) { auto g = gw.lock(); if (!g) @@ -312,7 +313,7 @@ void CInputMethodV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t loc } void CInputMethodV2::setKeyboard(SP keyboard) { - for (auto const& gw : grabs) { + for (auto const& gw : m_grabs) { auto g = gw.lock(); if (!g) @@ -323,7 +324,7 @@ void CInputMethodV2::setKeyboard(SP keyboard) { } wl_client* CInputMethodV2::client() { - return resource->client(); + return m_resource->client(); } CInputMethodV2Protocol::CInputMethodV2Protocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -331,7 +332,7 @@ CInputMethodV2Protocol::CInputMethodV2Protocol(const wl_interface* iface, const } void CInputMethodV2Protocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CZwpInputMethodManagerV2* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CZwpInputMethodManagerV2* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -339,33 +340,33 @@ void CInputMethodV2Protocol::bindManager(wl_client* client, void* data, uint32_t } void CInputMethodV2Protocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CInputMethodV2Protocol::destroyResource(CInputMethodPopupV2* popup) { - std::erase_if(m_vPopups, [&](const auto& other) { return other.get() == popup; }); + std::erase_if(m_popups, [&](const auto& other) { return other.get() == popup; }); } void CInputMethodV2Protocol::destroyResource(CInputMethodKeyboardGrabV2* grab) { - std::erase_if(m_vGrabs, [&](const auto& other) { return other.get() == grab; }); + std::erase_if(m_grabs, [&](const auto& other) { return other.get() == grab; }); } void CInputMethodV2Protocol::destroyResource(CInputMethodV2* ime) { - std::erase_if(m_vIMEs, [&](const auto& other) { return other.get() == ime; }); + std::erase_if(m_imes, [&](const auto& other) { return other.get() == ime; }); } void CInputMethodV2Protocol::onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource* seat, uint32_t id) { - const auto RESOURCE = m_vIMEs.emplace_back(makeShared(makeShared(mgr->client(), mgr->version(), id))); + const auto RESOURCE = m_imes.emplace_back(makeShared(makeShared(mgr->client(), mgr->version(), id))); if UNLIKELY (!RESOURCE->good()) { mgr->noMemory(); - m_vIMEs.pop_back(); + m_imes.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; LOGM(LOG, "New IME with resource id {}", id); - events.newIME.emit(RESOURCE); + m_events.newIME.emit(RESOURCE); } diff --git a/src/protocols/InputMethodV2.hpp b/src/protocols/InputMethodV2.hpp index 0c249c6c1..74efcbb30 100644 --- a/src/protocols/InputMethodV2.hpp +++ b/src/protocols/InputMethodV2.hpp @@ -21,7 +21,7 @@ class CInputMethodV2 { CSignal onCommit; CSignal destroy; CSignal newPopup; - } events; + } m_events; struct SState { void reset(); @@ -43,7 +43,8 @@ class CInputMethodV2 { } deleteSurrounding; }; - SState pending, current; + SState m_pending; + SState m_current; bool good(); void activate(); @@ -64,15 +65,15 @@ class CInputMethodV2 { wl_client* grabClient(); private: - SP resource; - std::vector> grabs; - std::vector> popups; + SP m_resource; + std::vector> m_grabs; + std::vector> m_popups; - WP self; + WP m_self; - bool active = false; + bool m_active = false; - CBox inputRectangle; + CBox m_inputRectangle; friend class CInputMethodPopupV2; friend class CInputMethodKeyboardGrabV2; @@ -93,10 +94,10 @@ class CInputMethodKeyboardGrabV2 { void sendKeyboardData(SP keyboard); private: - SP resource; - WP owner; + SP m_resource; + WP m_owner; - WP pLastKeyboard; + WP m_lastKeyboard; }; class CInputMethodPopupV2 { @@ -113,19 +114,19 @@ class CInputMethodPopupV2 { CSignal unmap; CSignal commit; CSignal destroy; - } events; + } m_events; - bool mapped = false; + bool m_mapped = false; private: - SP resource; - WP owner; - WP pSurface; + SP m_resource; + WP m_owner; + WP m_surface; struct { CHyprSignalListener destroySurface; CHyprSignalListener commitSurface; - } listeners; + } m_listeners; }; class CInputMethodV2Protocol : public IWaylandProtocol { @@ -136,7 +137,7 @@ class CInputMethodV2Protocol : public IWaylandProtocol { struct { CSignal newIME; // SP - } events; + } m_events; private: void onManagerResourceDestroy(wl_resource* res); @@ -147,10 +148,10 @@ class CInputMethodV2Protocol : public IWaylandProtocol { void onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource* seat, uint32_t id); // - std::vector> m_vManagers; - std::vector> m_vIMEs; - std::vector> m_vGrabs; - std::vector> m_vPopups; + std::vector> m_managers; + std::vector> m_imes; + std::vector> m_grabs; + std::vector> m_popups; friend class CInputMethodPopupV2; friend class CInputMethodKeyboardGrabV2; diff --git a/src/protocols/LayerShell.cpp b/src/protocols/LayerShell.cpp index bc4112fa9..1f37f622d 100644 --- a/src/protocols/LayerShell.cpp +++ b/src/protocols/LayerShell.cpp @@ -17,107 +17,107 @@ void CLayerShellResource::SState::reset() { } CLayerShellResource::CLayerShellResource(SP resource_, SP surf_, std::string namespace_, PHLMONITOR pMonitor, - zwlrLayerShellV1Layer layer) : layerNamespace(namespace_), surface(surf_), resource(resource_) { + zwlrLayerShellV1Layer layer) : m_layerNamespace(namespace_), m_surface(surf_), m_resource(resource_) { if UNLIKELY (!good()) return; - current.layer = layer; - monitor = pMonitor ? pMonitor->m_name : ""; + m_current.layer = layer; + m_monitor = pMonitor ? pMonitor->m_name : ""; - resource->setDestroy([this](CZwlrLayerSurfaceV1* r) { - events.destroy.emit(); + m_resource->setDestroy([this](CZwlrLayerSurfaceV1* r) { + m_events.destroy.emit(); PROTO::layerShell->destroyResource(this); }); - resource->setOnDestroy([this](CZwlrLayerSurfaceV1* r) { - events.destroy.emit(); + m_resource->setOnDestroy([this](CZwlrLayerSurfaceV1* r) { + m_events.destroy.emit(); PROTO::layerShell->destroyResource(this); }); - listeners.destroySurface = surf_->m_events.destroy.registerListener([this](std::any d) { - events.destroy.emit(); + m_listeners.destroySurface = surf_->m_events.destroy.registerListener([this](std::any d) { + m_events.destroy.emit(); PROTO::layerShell->destroyResource(this); }); - listeners.unmapSurface = surf_->m_events.unmap.registerListener([this](std::any d) { events.unmap.emit(); }); + m_listeners.unmapSurface = surf_->m_events.unmap.registerListener([this](std::any d) { m_events.unmap.emit(); }); - listeners.commitSurface = surf_->m_events.commit.registerListener([this](std::any d) { - current = pending; - pending.committed = 0; + m_listeners.commitSurface = surf_->m_events.commit.registerListener([this](std::any d) { + m_current = m_pending; + m_pending.committed = 0; - bool attachedBuffer = surface->m_current.texture; + bool attachedBuffer = m_surface->m_current.texture; - if (attachedBuffer && !configured) { - surface->error(-1, "layerSurface was not configured, but a buffer was attached"); + if (attachedBuffer && !m_configured) { + m_surface->error(-1, "layerSurface was not configured, but a buffer was attached"); return; } constexpr uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; constexpr uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; - if (current.desiredSize.x <= 0 && (current.anchor & horiz) != horiz) { - surface->error(-1, "x == 0 but anchor doesn't have left and right"); + if (m_current.desiredSize.x <= 0 && (m_current.anchor & horiz) != horiz) { + m_surface->error(-1, "x == 0 but anchor doesn't have left and right"); return; } - if (current.desiredSize.y <= 0 && (current.anchor & vert) != vert) { - surface->error(-1, "y == 0 but anchor doesn't have top and bottom"); + if (m_current.desiredSize.y <= 0 && (m_current.anchor & vert) != vert) { + m_surface->error(-1, "y == 0 but anchor doesn't have top and bottom"); return; } - if (attachedBuffer && !mapped) { - mapped = true; - surface->map(); - events.map.emit(); + if (attachedBuffer && !m_mapped) { + m_mapped = true; + m_surface->map(); + m_events.map.emit(); return; } - if (!attachedBuffer && mapped) { - mapped = false; - events.unmap.emit(); - surface->unmap(); - configured = false; + if (!attachedBuffer && m_mapped) { + m_mapped = false; + m_events.unmap.emit(); + m_surface->unmap(); + m_configured = false; return; } - events.commit.emit(); + m_events.commit.emit(); }); - resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) { - pending.committed |= STATE_SIZE; - pending.desiredSize = {(int)x, (int)y}; + m_resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) { + m_pending.committed |= STATE_SIZE; + m_pending.desiredSize = {(int)x, (int)y}; }); - resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { + m_resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { if (anchor > (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR, "Invalid anchor"); return; } - pending.committed |= STATE_ANCHOR; - pending.anchor = anchor; + m_pending.committed |= STATE_ANCHOR; + m_pending.anchor = anchor; }); - resource->setSetExclusiveZone([this](CZwlrLayerSurfaceV1* r, int32_t zone) { - pending.committed |= STATE_EXCLUSIVE; - pending.exclusive = zone; + m_resource->setSetExclusiveZone([this](CZwlrLayerSurfaceV1* r, int32_t zone) { + m_pending.committed |= STATE_EXCLUSIVE; + m_pending.exclusive = zone; }); - resource->setSetMargin([this](CZwlrLayerSurfaceV1* r, int32_t top, int32_t right, int32_t bottom, int32_t left) { - pending.committed |= STATE_MARGIN; - pending.margin = {left, right, top, bottom}; + m_resource->setSetMargin([this](CZwlrLayerSurfaceV1* r, int32_t top, int32_t right, int32_t bottom, int32_t left) { + m_pending.committed |= STATE_MARGIN; + m_pending.margin = {left, right, top, bottom}; }); - resource->setSetKeyboardInteractivity([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1KeyboardInteractivity kbi) { + m_resource->setSetKeyboardInteractivity([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1KeyboardInteractivity kbi) { if (kbi > ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) { r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_KEYBOARD_INTERACTIVITY, "Invalid keyboard interactivity"); return; } - pending.committed |= STATE_INTERACTIVITY; - pending.interactivity = kbi; + m_pending.committed |= STATE_INTERACTIVITY; + m_pending.interactivity = kbi; }); - resource->setGetPopup([this](CZwlrLayerSurfaceV1* r, wl_resource* popup_) { + m_resource->setGetPopup([this](CZwlrLayerSurfaceV1* r, wl_resource* popup_) { auto popup = CXDGPopupResource::fromResource(popup_); if (popup->taken) { @@ -126,74 +126,74 @@ CLayerShellResource::CLayerShellResource(SP resource_, SPtaken = true; - events.newPopup.emit(popup); + m_events.newPopup.emit(popup); }); - resource->setAckConfigure([this](CZwlrLayerSurfaceV1* r, uint32_t serial) { - auto serialFound = std::find_if(serials.begin(), serials.end(), [serial](const auto& e) { return e.first == serial; }); + m_resource->setAckConfigure([this](CZwlrLayerSurfaceV1* r, uint32_t serial) { + auto serialFound = std::find_if(m_serials.begin(), m_serials.end(), [serial](const auto& e) { return e.first == serial; }); - if (serialFound == serials.end()) { + if (serialFound == m_serials.end()) { r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE, "Serial invalid in ack_configure"); return; } - configured = true; - size = serialFound->second; + m_configured = true; + m_size = serialFound->second; - serials.erase(serialFound); + m_serials.erase(serialFound); }); - resource->setSetLayer([this](CZwlrLayerSurfaceV1* r, uint32_t layer) { + m_resource->setSetLayer([this](CZwlrLayerSurfaceV1* r, uint32_t layer) { if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) { r->error(ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER, "Invalid layer"); return; } - pending.committed |= STATE_LAYER; - pending.layer = (zwlrLayerShellV1Layer)layer; + m_pending.committed |= STATE_LAYER; + m_pending.layer = (zwlrLayerShellV1Layer)layer; }); - resource->setSetExclusiveEdge([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { + m_resource->setSetExclusiveEdge([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) { if (anchor > (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Invalid exclusive edge"); return; } - if (anchor && (!pending.anchor || !(pending.anchor & anchor))) { + if (anchor && (!m_pending.anchor || !(m_pending.anchor & anchor))) { r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Exclusive edge doesn't align with anchor"); return; } - pending.committed |= STATE_EDGE; - pending.exclusiveEdge = anchor; + m_pending.committed |= STATE_EDGE; + m_pending.exclusiveEdge = anchor; }); } CLayerShellResource::~CLayerShellResource() { - events.destroy.emit(); - if (surface) - surface->resetRole(); + m_events.destroy.emit(); + if (m_surface) + m_surface->resetRole(); } bool CLayerShellResource::good() { - return resource->resource(); + return m_resource->resource(); } void CLayerShellResource::sendClosed() { - if (closed) + if (m_closed) return; - closed = true; - resource->sendClosed(); + m_closed = true; + m_resource->sendClosed(); } void CLayerShellResource::configure(const Vector2D& size_) { - size = size_; + m_size = size_; auto serial = wl_display_next_serial(g_pCompositor->m_wlDisplay); - serials.push_back({serial, size_}); + m_serials.push_back({serial, size_}); - resource->sendConfigure(serial, size_.x, size_.y); + m_resource->sendConfigure(serial, size_.x, size_.y); } CLayerShellProtocol::CLayerShellProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -201,7 +201,7 @@ CLayerShellProtocol::CLayerShellProtocol(const wl_interface* iface, const int& v } void CLayerShellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeUnique(client, ver, id)).get(); + const auto RESOURCE = m_managers.emplace_back(makeUnique(client, ver, id)).get(); RESOURCE->setOnDestroy([this](CZwlrLayerShellV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CZwlrLayerShellV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); @@ -211,11 +211,11 @@ void CLayerShellProtocol::bindManager(wl_client* client, void* data, uint32_t ve } void CLayerShellProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); + std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; }); } void CLayerShellProtocol::destroyResource(CLayerShellResource* surf) { - std::erase_if(m_vLayers, [&](const auto& other) { return other.get() == surf; }); + std::erase_if(m_layers, [&](const auto& other) { return other.get() == surf; }); } void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_) { @@ -238,11 +238,11 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id return; } - const auto RESOURCE = m_vLayers.emplace_back(makeShared(makeShared(CLIENT, pMgr->version(), id), SURF, namespace_, PMONITOR, layer)); + const auto RESOURCE = m_layers.emplace_back(makeShared(makeShared(CLIENT, pMgr->version(), id), SURF, namespace_, PMONITOR, layer)); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); - m_vLayers.pop_back(); + m_layers.pop_back(); return; } @@ -252,6 +252,6 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id LOGM(LOG, "New wlr_layer_surface {:x}", (uintptr_t)RESOURCE.get()); } -CLayerShellRole::CLayerShellRole(SP ls) : layerSurface(ls) { +CLayerShellRole::CLayerShellRole(SP ls) : m_layerSurface(ls) { ; } diff --git a/src/protocols/LayerShell.hpp b/src/protocols/LayerShell.hpp index b634c63c7..c6c162a33 100644 --- a/src/protocols/LayerShell.hpp +++ b/src/protocols/LayerShell.hpp @@ -21,8 +21,9 @@ class CLayerShellRole : public ISurfaceRole { return SURFACE_ROLE_LAYER_SHELL; } - WP layerSurface; + WP m_layerSurface; }; + class CLayerShellResource { public: CLayerShellResource(SP resource_, SP surf_, std::string namespace_, PHLMONITOR pMonitor, zwlrLayerShellV1Layer layer); @@ -48,7 +49,7 @@ class CLayerShellResource { CSignal map; CSignal unmap; CSignal newPopup; // wlr_xdg_popup* - } events; + } m_events; struct SState { uint32_t anchor = 0; @@ -64,27 +65,27 @@ class CLayerShellResource { } margin; void reset(); - } current, pending; + } m_current, m_pending; - Vector2D size; - std::string layerNamespace; - std::string monitor = ""; - WP surface; - bool mapped = false; - bool configured = false; + Vector2D m_size; + std::string m_layerNamespace; + std::string m_monitor = ""; + WP m_surface; + bool m_mapped = false; + bool m_configured = false; private: - SP resource; + SP m_resource; struct { CHyprSignalListener commitSurface; CHyprSignalListener destroySurface; CHyprSignalListener unmapSurface; - } listeners; + } m_listeners; - bool closed = false; + bool m_closed = false; - std::vector> serials; + std::vector> m_serials; }; class CLayerShellProtocol : public IWaylandProtocol { @@ -99,8 +100,8 @@ class CLayerShellProtocol : public IWaylandProtocol { void onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_); // - std::vector> m_vManagers; - std::vector> m_vLayers; + std::vector> m_managers; + std::vector> m_layers; friend class CLayerShellResource; }; diff --git a/src/protocols/LinuxDMABUF.cpp b/src/protocols/LinuxDMABUF.cpp index 189a25557..ee64415b7 100644 --- a/src/protocols/LinuxDMABUF.cpp +++ b/src/protocols/LinuxDMABUF.cpp @@ -24,7 +24,7 @@ static std::optional devIDFromFD(int fd) { } CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vector> tranches_) : - rendererTranche(_rendererTranche), monitorTranches(tranches_) { + m_rendererTranche(_rendererTranche), m_monitorTranches(tranches_) { std::vector formatsVec; std::set> formats; @@ -32,14 +32,14 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec // insert formats into vec if they got inserted into set, meaning they're unique size_t i = 0; - rendererTranche.indicies.clear(); - for (auto const& fmt : rendererTranche.formats) { + m_rendererTranche.indicies.clear(); + for (auto const& fmt : m_rendererTranche.formats) { for (auto const& mod : fmt.modifiers) { auto format = std::make_pair<>(fmt.drmFormat, mod); auto [_, inserted] = formats.insert(format); if (inserted) { // if it was inserted into set, then its unique and will have a new index in vec - rendererTranche.indicies.push_back(i++); + m_rendererTranche.indicies.push_back(i++); formatsVec.push_back(SDMABUFFormatTableEntry{ .fmt = fmt.drmFormat, .modifier = mod, @@ -48,12 +48,12 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec // if it wasn't inserted then find its index in vec auto it = std::find_if(formatsVec.begin(), formatsVec.end(), [fmt, mod](const SDMABUFFormatTableEntry& oth) { return oth.fmt == fmt.drmFormat && oth.modifier == mod; }); - rendererTranche.indicies.push_back(it - formatsVec.begin()); + m_rendererTranche.indicies.push_back(it - formatsVec.begin()); } } } - for (auto& [monitor, tranche] : monitorTranches) { + for (auto& [monitor, tranche] : m_monitorTranches) { tranche.indicies.clear(); for (auto const& fmt : tranche.formats) { for (auto const& mod : fmt.modifiers) { @@ -77,12 +77,12 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec } } - tableSize = formatsVec.size() * sizeof(SDMABUFFormatTableEntry); + m_tableSize = formatsVec.size() * sizeof(SDMABUFFormatTableEntry); CFileDescriptor fds[2]; - allocateSHMFilePair(tableSize, fds[0], fds[1]); + allocateSHMFilePair(m_tableSize, fds[0], fds[1]); - auto arr = (SDMABUFFormatTableEntry*)mmap(nullptr, tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0); + auto arr = (SDMABUFFormatTableEntry*)mmap(nullptr, m_tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0); if (arr == MAP_FAILED) { LOGM(ERR, "mmap failed"); @@ -91,50 +91,50 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec std::copy(formatsVec.begin(), formatsVec.end(), arr); - munmap(arr, tableSize); + munmap(arr, m_tableSize); - tableFD = std::move(fds[1]); + m_tableFD = std::move(fds[1]); } CLinuxDMABuffer::CLinuxDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs) { - buffer = makeShared(id, client, attrs); + m_buffer = makeShared(id, client, attrs); - buffer->m_resource->m_buffer = buffer; + m_buffer->m_resource->m_buffer = m_buffer; - listeners.bufferResourceDestroy = buffer->events.destroy.registerListener([this](std::any d) { - listeners.bufferResourceDestroy.reset(); + m_listeners.bufferResourceDestroy = m_buffer->events.destroy.registerListener([this](std::any d) { + m_listeners.bufferResourceDestroy.reset(); PROTO::linuxDma->destroyResource(this); }); - if (!buffer->m_success) + if (!m_buffer->m_success) LOGM(ERR, "Possibly compositor bug: buffer failed to create"); } CLinuxDMABuffer::~CLinuxDMABuffer() { - if (buffer && buffer->m_resource) - buffer->m_resource->sendRelease(); + if (m_buffer && m_buffer->m_resource) + m_buffer->m_resource->sendRelease(); - buffer.reset(); - listeners.bufferResourceDestroy.reset(); + m_buffer.reset(); + m_listeners.bufferResourceDestroy.reset(); } bool CLinuxDMABuffer::good() { - return buffer && buffer->good(); + return m_buffer && m_buffer->good(); } -CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP resource_) : resource(resource_) { +CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); }); - resource->setDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); }); + m_resource->setDestroy([this](CZwpLinuxBufferParamsV1* r) { PROTO::linuxDma->destroyResource(this); }); - attrs = makeShared(); + m_attrs = makeShared(); - attrs->success = true; + m_attrs->success = true; - resource->setAdd([this](CZwpLinuxBufferParamsV1* r, int32_t fd, uint32_t plane, uint32_t offset, uint32_t stride, uint32_t modHi, uint32_t modLo) { - if (used) { + m_resource->setAdd([this](CZwpLinuxBufferParamsV1* r, int32_t fd, uint32_t plane, uint32_t offset, uint32_t stride, uint32_t modHi, uint32_t modLo) { + if (m_used) { r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used"); return; } @@ -144,19 +144,19 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SPfds.at(plane) != -1) { + if (m_attrs->fds.at(plane) != -1) { r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, "plane used"); return; } - attrs->fds[plane] = fd; - attrs->strides[plane] = stride; - attrs->offsets[plane] = offset; - attrs->modifier = ((uint64_t)modHi << 32) | modLo; + m_attrs->fds[plane] = fd; + m_attrs->strides[plane] = stride; + m_attrs->offsets[plane] = offset; + m_attrs->modifier = ((uint64_t)modHi << 32) | modLo; }); - resource->setCreate([this](CZwpLinuxBufferParamsV1* r, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) { - if (used) { + m_resource->setCreate([this](CZwpLinuxBufferParamsV1* r, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) { + if (m_used) { r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used"); return; } @@ -167,15 +167,15 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SPsize = {w, h}; - attrs->format = fmt; - attrs->planes = 4 - std::count(attrs->fds.begin(), attrs->fds.end(), -1); + m_attrs->size = {w, h}; + m_attrs->format = fmt; + m_attrs->planes = 4 - std::count(m_attrs->fds.begin(), m_attrs->fds.end(), -1); create(0); }); - resource->setCreateImmed([this](CZwpLinuxBufferParamsV1* r, uint32_t id, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) { - if (used) { + m_resource->setCreateImmed([this](CZwpLinuxBufferParamsV1* r, uint32_t id, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) { + if (m_used) { r->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED, "Already used"); return; } @@ -186,20 +186,20 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SPsize = {w, h}; - attrs->format = fmt; - attrs->planes = 4 - std::count(attrs->fds.begin(), attrs->fds.end(), -1); + m_attrs->size = {w, h}; + m_attrs->format = fmt; + m_attrs->planes = 4 - std::count(m_attrs->fds.begin(), m_attrs->fds.end(), -1); create(id); }); } bool CLinuxDMABUFParamsResource::good() { - return resource->resource(); + return m_resource->resource(); } void CLinuxDMABUFParamsResource::create(uint32_t id) { - used = true; + m_used = true; if UNLIKELY (!verify()) { LOGM(ERR, "Failed creating a dmabuf: verify() said no"); @@ -208,42 +208,42 @@ void CLinuxDMABUFParamsResource::create(uint32_t id) { if UNLIKELY (!commence()) { LOGM(ERR, "Failed creating a dmabuf: commence() said no"); - resource->sendFailed(); + m_resource->sendFailed(); return; } - LOGM(LOG, "Creating a dmabuf, with id {}: size {}, fmt {}, planes {}", id, attrs->size, NFormatUtils::drmFormatName(attrs->format), attrs->planes); - for (int i = 0; i < attrs->planes; ++i) { - LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs->modifier, attrs->fds[i], attrs->strides[i], attrs->offsets[i]); + LOGM(LOG, "Creating a dmabuf, with id {}: size {}, fmt {}, planes {}", id, m_attrs->size, NFormatUtils::drmFormatName(m_attrs->format), m_attrs->planes); + for (int i = 0; i < m_attrs->planes; ++i) { + LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, m_attrs->modifier, m_attrs->fds[i], m_attrs->strides[i], m_attrs->offsets[i]); } - auto buf = PROTO::linuxDma->m_vBuffers.emplace_back(makeShared(id, resource->client(), *attrs)); + auto buf = PROTO::linuxDma->m_buffers.emplace_back(makeShared(id, m_resource->client(), *m_attrs)); - if UNLIKELY (!buf->good() || !buf->buffer->m_success) { - resource->sendFailed(); - PROTO::linuxDma->m_vBuffers.pop_back(); + if UNLIKELY (!buf->good() || !buf->m_buffer->m_success) { + m_resource->sendFailed(); + PROTO::linuxDma->m_buffers.pop_back(); return; } if (!id) - resource->sendCreated(PROTO::linuxDma->m_vBuffers.back()->buffer->m_resource->getResource()); + m_resource->sendCreated(PROTO::linuxDma->m_buffers.back()->m_buffer->m_resource->getResource()); - createdBuffer = buf; + m_createdBuffer = buf; } bool CLinuxDMABUFParamsResource::commence() { - if (!PROTO::linuxDma->mainDeviceFD.isValid()) + if (!PROTO::linuxDma->m_mainDeviceFD.isValid()) return true; - for (int i = 0; i < attrs->planes; i++) { + for (int i = 0; i < m_attrs->planes; i++) { uint32_t handle = 0; - if (drmPrimeFDToHandle(PROTO::linuxDma->mainDeviceFD.get(), attrs->fds.at(i), &handle)) { + if (drmPrimeFDToHandle(PROTO::linuxDma->m_mainDeviceFD.get(), m_attrs->fds.at(i), &handle)) { LOGM(ERR, "Failed to import dmabuf fd"); return false; } - if (drmCloseBufferHandle(PROTO::linuxDma->mainDeviceFD.get(), handle)) { + if (drmCloseBufferHandle(PROTO::linuxDma->m_mainDeviceFD.get(), handle)) { LOGM(ERR, "Failed to close dmabuf handle"); return false; } @@ -253,20 +253,20 @@ bool CLinuxDMABUFParamsResource::commence() { } bool CLinuxDMABUFParamsResource::verify() { - if UNLIKELY (attrs->planes <= 0) { - resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No planes added"); + if UNLIKELY (m_attrs->planes <= 0) { + m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No planes added"); return false; } - if UNLIKELY (attrs->fds.at(0) < 0) { - resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No plane 0"); + if UNLIKELY (m_attrs->fds.at(0) < 0) { + m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, "No plane 0"); return false; } bool empty = false; - for (auto const& plane : attrs->fds) { + for (auto const& plane : m_attrs->fds) { if (empty && plane != -1) { - resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT, "Gap in planes"); + m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT, "Gap in planes"); return false; } @@ -276,16 +276,16 @@ bool CLinuxDMABUFParamsResource::verify() { } } - if UNLIKELY (attrs->size.x < 1 || attrs->size.y < 1) { - resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS, "x/y < 1"); + if UNLIKELY (m_attrs->size.x < 1 || m_attrs->size.y < 1) { + m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_DIMENSIONS, "x/y < 1"); return false; } - for (size_t i = 0; i < (size_t)attrs->planes; ++i) { - if ((uint64_t)attrs->offsets.at(i) + (uint64_t)attrs->strides.at(i) * attrs->size.y > UINT32_MAX) { - resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS, - std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, (uint64_t)attrs->offsets.at(i), - (uint64_t)attrs->strides.at(i), attrs->size.y, (uint64_t)attrs->offsets.at(i) + (uint64_t)attrs->strides.at(i))); + for (size_t i = 0; i < (size_t)m_attrs->planes; ++i) { + if ((uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i) * m_attrs->size.y > UINT32_MAX) { + m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS, + std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, (uint64_t)m_attrs->offsets.at(i), + (uint64_t)m_attrs->strides.at(i), m_attrs->size.y, (uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i))); return false; } } @@ -293,20 +293,20 @@ bool CLinuxDMABUFParamsResource::verify() { return true; } -CLinuxDMABUFFeedbackResource::CLinuxDMABUFFeedbackResource(SP resource_, SP surface_) : surface(surface_), resource(resource_) { +CLinuxDMABUFFeedbackResource::CLinuxDMABUFFeedbackResource(SP resource_, SP surface_) : m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); }); - resource->setDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); }); + m_resource->setDestroy([this](CZwpLinuxDmabufFeedbackV1* r) { PROTO::linuxDma->destroyResource(this); }); - auto& formatTable = PROTO::linuxDma->formatTable; - resource->sendFormatTable(formatTable->tableFD.get(), formatTable->tableSize); + auto& formatTable = PROTO::linuxDma->m_formatTable; + m_resource->sendFormatTable(formatTable->m_tableFD.get(), formatTable->m_tableSize); sendDefaultFeedback(); } bool CLinuxDMABUFFeedbackResource::good() { - return resource->resource(); + return m_resource->resource(); } void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) { @@ -314,95 +314,95 @@ void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) { .size = sizeof(tranche.device), .data = (void*)&tranche.device, }; - resource->sendTrancheTargetDevice(&deviceArr); + m_resource->sendTrancheTargetDevice(&deviceArr); - resource->sendTrancheFlags((zwpLinuxDmabufFeedbackV1TrancheFlags)tranche.flags); + m_resource->sendTrancheFlags((zwpLinuxDmabufFeedbackV1TrancheFlags)tranche.flags); wl_array indices = { .size = tranche.indicies.size() * sizeof(tranche.indicies.at(0)), .data = tranche.indicies.data(), }; - resource->sendTrancheFormats(&indices); - resource->sendTrancheDone(); + m_resource->sendTrancheFormats(&indices); + m_resource->sendTrancheDone(); } // default tranche is based on renderer (egl) void CLinuxDMABUFFeedbackResource::sendDefaultFeedback() { - auto mainDevice = PROTO::linuxDma->mainDevice; - auto& formatTable = PROTO::linuxDma->formatTable; + auto mainDevice = PROTO::linuxDma->m_mainDevice; + auto& formatTable = PROTO::linuxDma->m_formatTable; struct wl_array deviceArr = { .size = sizeof(mainDevice), .data = (void*)&mainDevice, }; - resource->sendMainDevice(&deviceArr); + m_resource->sendMainDevice(&deviceArr); - sendTranche(formatTable->rendererTranche); + sendTranche(formatTable->m_rendererTranche); - resource->sendDone(); + m_resource->sendDone(); - lastFeedbackWasScanout = false; + m_lastFeedbackWasScanout = false; } -CLinuxDMABUFResource::CLinuxDMABUFResource(SP resource_) : resource(resource_) { +CLinuxDMABUFResource::CLinuxDMABUFResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); }); - resource->setDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); }); + m_resource->setOnDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); }); + m_resource->setDestroy([this](CZwpLinuxDmabufV1* r) { PROTO::linuxDma->destroyResource(this); }); - resource->setGetDefaultFeedback([](CZwpLinuxDmabufV1* r, uint32_t id) { + m_resource->setGetDefaultFeedback([](CZwpLinuxDmabufV1* r, uint32_t id) { const auto RESOURCE = - PROTO::linuxDma->m_vFeedbacks.emplace_back(makeShared(makeShared(r->client(), r->version(), id), nullptr)); + PROTO::linuxDma->m_feedbacks.emplace_back(makeShared(makeShared(r->client(), r->version(), id), nullptr)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::linuxDma->m_vFeedbacks.pop_back(); + PROTO::linuxDma->m_feedbacks.pop_back(); return; } }); - resource->setGetSurfaceFeedback([](CZwpLinuxDmabufV1* r, uint32_t id, wl_resource* surf) { - const auto RESOURCE = PROTO::linuxDma->m_vFeedbacks.emplace_back( + m_resource->setGetSurfaceFeedback([](CZwpLinuxDmabufV1* r, uint32_t id, wl_resource* surf) { + const auto RESOURCE = PROTO::linuxDma->m_feedbacks.emplace_back( makeShared(makeShared(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surf))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::linuxDma->m_vFeedbacks.pop_back(); + PROTO::linuxDma->m_feedbacks.pop_back(); return; } }); - resource->setCreateParams([](CZwpLinuxDmabufV1* r, uint32_t id) { - const auto RESOURCE = PROTO::linuxDma->m_vParams.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); + m_resource->setCreateParams([](CZwpLinuxDmabufV1* r, uint32_t id) { + const auto RESOURCE = PROTO::linuxDma->m_params.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::linuxDma->m_vParams.pop_back(); + PROTO::linuxDma->m_params.pop_back(); return; } }); - if (resource->version() < 4) + if (m_resource->version() < 4) sendMods(); } bool CLinuxDMABUFResource::good() { - return resource->resource(); + return m_resource->resource(); } void CLinuxDMABUFResource::sendMods() { - for (auto const& fmt : PROTO::linuxDma->formatTable->rendererTranche.formats) { + for (auto const& fmt : PROTO::linuxDma->m_formatTable->m_rendererTranche.formats) { for (auto const& mod : fmt.modifiers) { - if (resource->version() < 3) { + if (m_resource->version() < 3) { if (mod == DRM_FORMAT_MOD_INVALID || mod == DRM_FORMAT_MOD_LINEAR) - resource->sendFormat(fmt.drmFormat); + m_resource->sendFormat(fmt.drmFormat); continue; } // TODO: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1166 - resource->sendModifier(fmt.drmFormat, mod >> 32, mod & 0xFFFFFFFF); + m_resource->sendModifier(fmt.drmFormat, mod >> 32, mod & 0xFFFFFFFF); } } } @@ -418,10 +418,10 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const return; } - mainDevice = *dev; + m_mainDevice = *dev; SDMABUFTranche eglTranche = { - .device = mainDevice, + .device = m_mainDevice, .flags = 0, // renderer isnt for ds so dont set flag. .formats = g_pHyprOpenGL->getDRMFormats(), }; @@ -434,7 +434,7 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const for (auto const& mon : g_pCompositor->m_monitors) { auto tranche = SDMABUFTranche{ - .device = mainDevice, + .device = m_mainDevice, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .formats = mon->m_output->getRenderFormats(), }; @@ -444,25 +444,25 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const static auto monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) { auto pMonitor = std::any_cast(param); auto tranche = SDMABUFTranche{ - .device = mainDevice, + .device = m_mainDevice, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .formats = pMonitor->m_output->getRenderFormats(), }; - formatTable->monitorTranches.emplace_back(std::make_pair<>(pMonitor, tranche)); + m_formatTable->m_monitorTranches.emplace_back(std::make_pair<>(pMonitor, tranche)); resetFormatTable(); }); static auto monitorRemoved = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) { auto pMonitor = std::any_cast(param); - std::erase_if(formatTable->monitorTranches, [pMonitor](std::pair pair) { return pair.first == pMonitor; }); + std::erase_if(m_formatTable->m_monitorTranches, [pMonitor](std::pair pair) { return pair.first == pMonitor; }); resetFormatTable(); }); } - formatTable = makeUnique(eglTranche, tches); + m_formatTable = makeUnique(eglTranche, tches); drmDevice* device = nullptr; - if (drmGetDeviceFromDevId(mainDevice, 0, &device) != 0) { + if (drmGetDeviceFromDevId(m_mainDevice, 0, &device) != 0) { LOGM(ERR, "failed to get drm dev, disabling linux dmabuf"); removeGlobal(); return; @@ -470,9 +470,9 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const if (device->available_nodes & (1 << DRM_NODE_RENDER)) { const char* name = device->nodes[DRM_NODE_RENDER]; - mainDeviceFD = CFileDescriptor{open(name, O_RDWR | O_CLOEXEC)}; + m_mainDeviceFD = CFileDescriptor{open(name, O_RDWR | O_CLOEXEC)}; drmFreeDevice(&device); - if (!mainDeviceFD.isValid()) { + if (!m_mainDeviceFD.isValid()) { LOGM(ERR, "failed to open drm dev, disabling linux dmabuf"); removeGlobal(); return; @@ -485,19 +485,19 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const } void CLinuxDMABufV1Protocol::resetFormatTable() { - if (!formatTable) + if (!m_formatTable) return; LOGM(LOG, "Resetting format table"); // this might be a big copy - auto newFormatTable = makeUnique(formatTable->rendererTranche, formatTable->monitorTranches); + auto newFormatTable = makeUnique(m_formatTable->m_rendererTranche, m_formatTable->m_monitorTranches); - for (auto const& feedback : m_vFeedbacks) { - feedback->resource->sendFormatTable(newFormatTable->tableFD.get(), newFormatTable->tableSize); - if (feedback->lastFeedbackWasScanout) { + for (auto const& feedback : m_feedbacks) { + feedback->m_resource->sendFormatTable(newFormatTable->m_tableFD.get(), newFormatTable->m_tableSize); + if (feedback->m_lastFeedbackWasScanout) { PHLMONITOR mon; - auto HLSurface = CWLSurface::fromResource(feedback->surface); + auto HLSurface = CWLSurface::fromResource(feedback->m_surface); if (auto w = HLSurface->getWindow(); w) if (auto m = w->m_monitor.lock(); m) mon = m->m_self.lock(); @@ -507,46 +507,46 @@ void CLinuxDMABufV1Protocol::resetFormatTable() { return; } - updateScanoutTranche(feedback->surface, mon); + updateScanoutTranche(feedback->m_surface, mon); } else { feedback->sendDefaultFeedback(); } } // delete old table after we sent new one - formatTable = std::move(newFormatTable); + m_formatTable = std::move(newFormatTable); } void CLinuxDMABufV1Protocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFResource* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFFeedbackResource* resource) { - std::erase_if(m_vFeedbacks, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_feedbacks, [&](const auto& other) { return other.get() == resource; }); } void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABUFParamsResource* resource) { - std::erase_if(m_vParams, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_params, [&](const auto& other) { return other.get() == resource; }); } void CLinuxDMABufV1Protocol::destroyResource(CLinuxDMABuffer* resource) { - std::erase_if(m_vBuffers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_buffers, [&](const auto& other) { return other.get() == resource; }); } void CLinuxDMABufV1Protocol::updateScanoutTranche(SP surface, PHLMONITOR pMonitor) { SP feedbackResource; - for (auto const& f : m_vFeedbacks) { - if (f->surface != surface) + for (auto const& f : m_feedbacks) { + if (f->m_surface != surface) continue; feedbackResource = f; @@ -564,10 +564,10 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP surface return; } - const auto& monitorTranchePair = std::find_if(formatTable->monitorTranches.begin(), formatTable->monitorTranches.end(), + const auto& monitorTranchePair = std::find_if(m_formatTable->m_monitorTranches.begin(), m_formatTable->m_monitorTranches.end(), [pMonitor](std::pair pair) { return pair.first == pMonitor; }); - if (monitorTranchePair == formatTable->monitorTranches.end()) { + if (monitorTranchePair == m_formatTable->m_monitorTranches.end()) { LOGM(LOG, "updateScanoutTranche: monitor has no tranche"); return; } @@ -577,17 +577,17 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP surface LOGM(LOG, "updateScanoutTranche: sending a scanout tranche"); struct wl_array deviceArr = { - .size = sizeof(mainDevice), - .data = (void*)&mainDevice, + .size = sizeof(m_mainDevice), + .data = (void*)&m_mainDevice, }; - feedbackResource->resource->sendMainDevice(&deviceArr); + feedbackResource->m_resource->sendMainDevice(&deviceArr); // prioritize scnaout tranche but have renderer fallback tranche // also yes formats can be duped here because different tranche flags (ds and no ds) feedbackResource->sendTranche(monitorTranche); - feedbackResource->sendTranche(formatTable->rendererTranche); + feedbackResource->sendTranche(m_formatTable->m_rendererTranche); - feedbackResource->resource->sendDone(); + feedbackResource->m_resource->sendDone(); - feedbackResource->lastFeedbackWasScanout = true; + feedbackResource->m_lastFeedbackWasScanout = true; } diff --git a/src/protocols/LinuxDMABUF.hpp b/src/protocols/LinuxDMABUF.hpp index d55ce8a7f..7e8450e1f 100644 --- a/src/protocols/LinuxDMABUF.hpp +++ b/src/protocols/LinuxDMABUF.hpp @@ -22,11 +22,11 @@ class CLinuxDMABuffer { bool good(); private: - SP buffer; + SP m_buffer; struct { CHyprSignalListener bufferResourceDestroy; - } listeners; + } m_listeners; friend class CLinuxDMABUFParamsResource; }; @@ -51,10 +51,10 @@ class CDMABUFFormatTable { CDMABUFFormatTable(SDMABUFTranche rendererTranche, std::vector> tranches); ~CDMABUFFormatTable() = default; - Hyprutils::OS::CFileDescriptor tableFD; - size_t tableSize = 0; - SDMABUFTranche rendererTranche; - std::vector> monitorTranches; + Hyprutils::OS::CFileDescriptor m_tableFD; + size_t m_tableSize = 0; + SDMABUFTranche m_rendererTranche; + std::vector> m_monitorTranches; }; class CLinuxDMABUFParamsResource { @@ -65,12 +65,12 @@ class CLinuxDMABUFParamsResource { bool good(); void create(uint32_t id); // 0 means not immed - SP attrs; - WP createdBuffer; - bool used = false; + SP m_attrs; + WP m_createdBuffer; + bool m_used = false; private: - SP resource; + SP m_resource; bool verify(); bool commence(); @@ -85,11 +85,11 @@ class CLinuxDMABUFFeedbackResource { void sendDefaultFeedback(); void sendTranche(SDMABUFTranche& tranche); - SP surface; // optional, for surface feedbacks + SP m_surface; // optional, for surface feedbacks private: - SP resource; - bool lastFeedbackWasScanout = false; + SP m_resource; + bool m_lastFeedbackWasScanout = false; friend class CLinuxDMABufV1Protocol; }; @@ -103,7 +103,7 @@ class CLinuxDMABUFResource { void sendMods(); private: - SP resource; + SP m_resource; }; class CLinuxDMABufV1Protocol : public IWaylandProtocol { @@ -123,14 +123,14 @@ class CLinuxDMABufV1Protocol : public IWaylandProtocol { void resetFormatTable(); // - std::vector> m_vManagers; - std::vector> m_vFeedbacks; - std::vector> m_vParams; - std::vector> m_vBuffers; + std::vector> m_managers; + std::vector> m_feedbacks; + std::vector> m_params; + std::vector> m_buffers; - UP formatTable; - dev_t mainDevice; - Hyprutils::OS::CFileDescriptor mainDeviceFD; + UP m_formatTable; + dev_t m_mainDevice; + Hyprutils::OS::CFileDescriptor m_mainDeviceFD; friend class CLinuxDMABUFResource; friend class CLinuxDMABUFFeedbackResource; diff --git a/src/protocols/MesaDRM.cpp b/src/protocols/MesaDRM.cpp index be5a02cd9..c85322656 100644 --- a/src/protocols/MesaDRM.cpp +++ b/src/protocols/MesaDRM.cpp @@ -11,47 +11,48 @@ CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, A LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs_.modifier, attrs_.fds[i], attrs_.strides[i], attrs_.offsets[i]); } - buffer = makeShared(id, client, attrs_); - buffer->m_resource->m_buffer = buffer; + m_buffer = makeShared(id, client, attrs_); + m_buffer->m_resource->m_buffer = m_buffer; - listeners.bufferResourceDestroy = buffer->events.destroy.registerListener([this](std::any d) { - listeners.bufferResourceDestroy.reset(); + m_listeners.bufferResourceDestroy = m_buffer->events.destroy.registerListener([this](std::any d) { + m_listeners.bufferResourceDestroy.reset(); PROTO::mesaDRM->destroyResource(this); }); - if (!buffer->m_success) + if (!m_buffer->m_success) LOGM(ERR, "Possibly compositor bug: buffer failed to create"); } CMesaDRMBufferResource::~CMesaDRMBufferResource() { - if (buffer && buffer->m_resource) - buffer->m_resource->sendRelease(); - buffer.reset(); - listeners.bufferResourceDestroy.reset(); + if (m_buffer && m_buffer->m_resource) + m_buffer->m_resource->sendRelease(); + m_buffer.reset(); + m_listeners.bufferResourceDestroy.reset(); } bool CMesaDRMBufferResource::good() { - return buffer && buffer->good(); + return m_buffer && m_buffer->good(); } -CMesaDRMResource::CMesaDRMResource(SP resource_) : resource(resource_) { +CMesaDRMResource::CMesaDRMResource(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlDrm* r) { PROTO::mesaDRM->destroyResource(this); }); + m_resource->setOnDestroy([this](CWlDrm* r) { PROTO::mesaDRM->destroyResource(this); }); - resource->setAuthenticate([this](CWlDrm* r, uint32_t token) { + m_resource->setAuthenticate([this](CWlDrm* r, uint32_t token) { // we don't need this - resource->sendAuthenticated(); + m_resource->sendAuthenticated(); }); - resource->setCreateBuffer([](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, uint32_t) { r->error(WL_DRM_ERROR_INVALID_NAME, "Not supported, use prime instead"); }); + m_resource->setCreateBuffer( + [](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, uint32_t) { r->error(WL_DRM_ERROR_INVALID_NAME, "Not supported, use prime instead"); }); - resource->setCreatePlanarBuffer([](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t) { + m_resource->setCreatePlanarBuffer([](CWlDrm* r, uint32_t, uint32_t, int32_t, int32_t, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t) { r->error(WL_DRM_ERROR_INVALID_NAME, "Not supported, use prime instead"); }); - resource->setCreatePrimeBuffer( + m_resource->setCreatePrimeBuffer( [this](CWlDrm* r, uint32_t id, int32_t nameFd, int32_t w, int32_t h, uint32_t fmt, int32_t off0, int32_t str0, int32_t off1, int32_t str1, int32_t off2, int32_t str2) { if (off0 < 0 || w <= 0 || h <= 0) { r->error(WL_DRM_ERROR_INVALID_FORMAT, "Invalid w, h, or offset"); @@ -85,29 +86,29 @@ CMesaDRMResource::CMesaDRMResource(SP resource_) : resource(resource_) { attrs.fds[0] = nameFd; attrs.format = fmt; - const auto RESOURCE = PROTO::mesaDRM->m_vBuffers.emplace_back(makeShared(id, resource->client(), attrs)); + const auto RESOURCE = PROTO::mesaDRM->m_buffers.emplace_back(makeShared(id, m_resource->client(), attrs)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::mesaDRM->m_vBuffers.pop_back(); + PROTO::mesaDRM->m_buffers.pop_back(); return; } // append instance so that buffer knows its owner - RESOURCE->buffer->m_resource->m_buffer = RESOURCE->buffer; + RESOURCE->m_buffer->m_resource->m_buffer = RESOURCE->m_buffer; }); - resource->sendDevice(PROTO::mesaDRM->nodeName.c_str()); - resource->sendCapabilities(WL_DRM_CAPABILITY_PRIME); + m_resource->sendDevice(PROTO::mesaDRM->m_nodeName.c_str()); + m_resource->sendCapabilities(WL_DRM_CAPABILITY_PRIME); auto fmts = g_pHyprOpenGL->getDRMFormats(); for (auto const& fmt : fmts) { - resource->sendFormat(fmt.drmFormat); + m_resource->sendFormat(fmt.drmFormat); } } bool CMesaDRMResource::good() { - return resource->resource(); + return m_resource->resource(); } CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -120,7 +121,7 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co } if (dev->available_nodes & (1 << DRM_NODE_RENDER)) { - nodeName = dev->nodes[DRM_NODE_RENDER]; + m_nodeName = dev->nodes[DRM_NODE_RENDER]; } else { ASSERT(dev->available_nodes & (1 << DRM_NODE_PRIMARY)); @@ -132,25 +133,25 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co } LOGM(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]); - nodeName = dev->nodes[DRM_NODE_PRIMARY]; + m_nodeName = dev->nodes[DRM_NODE_PRIMARY]; } drmFreeDevice(&dev); } void CMesaDRMProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } } void CMesaDRMProtocol::destroyResource(CMesaDRMResource* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CMesaDRMProtocol::destroyResource(CMesaDRMBufferResource* resource) { - std::erase_if(m_vBuffers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_buffers, [&](const auto& other) { return other.get() == resource; }); } diff --git a/src/protocols/MesaDRM.hpp b/src/protocols/MesaDRM.hpp index bfa604cf2..d3d3a50a8 100644 --- a/src/protocols/MesaDRM.hpp +++ b/src/protocols/MesaDRM.hpp @@ -15,11 +15,11 @@ class CMesaDRMBufferResource { bool good(); private: - SP buffer; + SP m_buffer; struct { CHyprSignalListener bufferResourceDestroy; - } listeners; + } m_listeners; friend class CMesaDRMResource; }; @@ -31,7 +31,7 @@ class CMesaDRMResource { bool good(); private: - SP resource; + SP m_resource; }; class CMesaDRMProtocol : public IWaylandProtocol { @@ -45,10 +45,10 @@ class CMesaDRMProtocol : public IWaylandProtocol { void destroyResource(CMesaDRMBufferResource* resource); // - std::vector> m_vManagers; - std::vector> m_vBuffers; + std::vector> m_managers; + std::vector> m_buffers; - std::string nodeName = ""; + std::string m_nodeName = ""; friend class CMesaDRMResource; friend class CMesaDRMBufferResource; diff --git a/src/protocols/XXColorManagement.cpp b/src/protocols/XXColorManagement.cpp index 182c2a6dc..e0a9b61d7 100644 --- a/src/protocols/XXColorManagement.cpp +++ b/src/protocols/XXColorManagement.cpp @@ -196,14 +196,14 @@ CXXColorManagementSurface::CXXColorManagementSurface(SPclient(); if (!surface->m_colorManagement.valid()) { - const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared(surface_)); + const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared(surface_)); if UNLIKELY (!RESOURCE) { resource->noMemory(); - PROTO::colorManagement->m_vSurfaces.pop_back(); + PROTO::colorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; surface->m_colorManagement = RESOURCE; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index cddc8c95e..74f4192f0 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1686,7 +1686,7 @@ void CHyprRenderer::arrangeLayerArray(PHLMONITOR pMonitor, const std::vectorm_layerSurface; - const auto PSTATE = &PLAYER->current; + const auto PSTATE = &PLAYER->m_current; if (exclusiveZone != (PSTATE->exclusive > 0)) continue;