From 241a4935a244f403fa7108259075b04c81ed258f Mon Sep 17 00:00:00 2001 From: davc0n Date: Tue, 22 Apr 2025 15:23:29 +0200 Subject: compositor: refactor class member vars (#10141) --- src/desktop/LayerSurface.cpp | 14 +++++++------- src/desktop/Subsurface.cpp | 2 +- src/desktop/Window.cpp | 30 +++++++++++++++--------------- src/desktop/Workspace.cpp | 24 ++++++++++++------------ 4 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/desktop') diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index c92169bc..c8081143 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -15,7 +15,7 @@ PHLLS CLayerSurface::create(SP resource) { PHLLS pLS = SP(new CLayerSurface(resource)); - auto pMonitor = resource->monitor.empty() ? g_pCompositor->m_pLastMonitor.lock() : g_pCompositor->getMonitorFromName(resource->monitor); + auto pMonitor = resource->monitor.empty() ? g_pCompositor->m_lastMonitor.lock() : g_pCompositor->getMonitorFromName(resource->monitor); pLS->surface->assign(resource->surface.lock(), pLS); @@ -25,7 +25,7 @@ PHLLS CLayerSurface::create(SP resource) { } if (pMonitor->pMirrorOf) - pMonitor = g_pCompositor->m_vMonitors.front(); + pMonitor = g_pCompositor->m_monitors.front(); pLS->self = pLS; @@ -76,7 +76,7 @@ CLayerSurface::~CLayerSurface() { g_pHyprRenderer->makeEGLCurrent(); std::erase_if(g_pHyprOpenGL->m_mLayerFramebuffers, [&](const auto& other) { return other.first.expired() || other.first.lock() == self.lock(); }); - for (auto const& mon : g_pCompositor->m_vRealMonitors) { + for (auto const& mon : g_pCompositor->m_realMonitors) { for (auto& lsl : mon->m_aLayerSurfaceLayers) { std::erase_if(lsl, [this](auto& ls) { return ls.expired() || ls.get() == this; }); } @@ -201,7 +201,7 @@ void CLayerSurface::onUnmap() { std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == self.lock(); }); - if (!monitor || g_pCompositor->m_bUnsafeState) { + if (!monitor || g_pCompositor->m_unsafeState) { Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring."); g_pCompositor->addToFadingOutSafe(self.lock()); @@ -238,11 +238,11 @@ void CLayerSurface::onUnmap() { // refocus if needed // vvvvvvvvvvvvv if there is a last focus and the last focus is not keyboard focusable, fallback to window - if (WASLASTFOCUS || (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus->hlSurface && !g_pCompositor->m_pLastFocus->hlSurface->keyboardFocusable())) { + if (WASLASTFOCUS || (g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->hlSurface && !g_pCompositor->m_lastFocus->hlSurface->keyboardFocusable())) { if (!g_pInputManager->refocusLastWindow(PMONITOR)) g_pInputManager->refocus(); - } else if (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus != surface->resource()) - g_pSeatManager->setKeyboardFocus(g_pCompositor->m_pLastFocus.lock()); + } else if (g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus != surface->resource()) + g_pSeatManager->setKeyboardFocus(g_pCompositor->m_lastFocus.lock()); CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height}; g_pHyprRenderer->damageBox(geomFixed); diff --git a/src/desktop/Subsurface.cpp b/src/desktop/Subsurface.cpp index 4e77f36f..e4ac070c 100644 --- a/src/desktop/Subsurface.cpp +++ b/src/desktop/Subsurface.cpp @@ -166,7 +166,7 @@ void CSubsurface::onMap() { void CSubsurface::onUnmap() { damageLastArea(); - if (m_pWLSurface->resource() == g_pCompositor->m_pLastFocus) + if (m_pWLSurface->resource() == g_pCompositor->m_lastFocus) g_pInputManager->releaseAllMouseButtons(); g_pInputManager->simulateMouseMovement(); diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index e2131133..a37424c8 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -115,9 +115,9 @@ CWindow::CWindow(SP surface) : m_pXWaylandSurface(surface) { } CWindow::~CWindow() { - if (g_pCompositor->m_pLastWindow == m_pSelf) { - g_pCompositor->m_pLastFocus.reset(); - g_pCompositor->m_pLastWindow.reset(); + if (g_pCompositor->m_lastWindow == m_pSelf) { + g_pCompositor->m_lastFocus.reset(); + g_pCompositor->m_lastWindow.reset(); } events.destroy.emit(); @@ -372,7 +372,7 @@ void CWindow::updateToplevel() { } void CWindow::updateSurfaceScaleTransformDetails(bool force) { - if (!m_bIsMapped || m_bHidden || g_pCompositor->m_bUnsafeState) + if (!m_bIsMapped || m_bHidden || g_pCompositor->m_unsafeState) return; const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(m_iLastSurfaceMonitorID); @@ -489,7 +489,7 @@ PHLWINDOW CWindow::x11TransientFor() { if (s == m_pXWaylandSurface) return nullptr; // dead-ass circle - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pXWaylandSurface != s) continue; return w; @@ -516,7 +516,7 @@ void CWindow::onUnmap() { m_iLastWorkspace = m_pWorkspace->m_iID; - std::erase_if(g_pCompositor->m_vWindowFocusHistory, [this](const auto& other) { return other.expired() || other == m_pSelf; }); + std::erase_if(g_pCompositor->m_windowFocusHistory, [this](const auto& other) { return other.expired() || other == m_pSelf; }); if (*PCLOSEONLASTSPECIAL && m_pWorkspace && m_pWorkspace->getWindows() == 0 && onSpecialWorkspace()) { const auto PMONITOR = m_pMonitor.lock(); @@ -577,7 +577,7 @@ void CWindow::onMap() { m_fMovingFromWorkspaceAlpha->setValueAndWarp(1.F); - g_pCompositor->m_vWindowFocusHistory.push_back(m_pSelf); + g_pCompositor->m_windowFocusHistory.push_back(m_pSelf); m_vReportedSize = m_vPendingReportedSize; m_bAnimatingIn = true; @@ -612,8 +612,8 @@ void CWindow::onBorderAngleAnimEnd(WP pav) { void CWindow::setHidden(bool hidden) { m_bHidden = hidden; - if (hidden && g_pCompositor->m_pLastWindow == m_pSelf) - g_pCompositor->m_pLastWindow.reset(); + if (hidden && g_pCompositor->m_lastWindow == m_pSelf) + g_pCompositor->m_lastWindow.reset(); setSuspended(hidden); } @@ -1039,7 +1039,7 @@ void CWindow::setGroupCurrent(PHLWINDOW pWindow) { const auto WORKSPACE = PCURRENT->m_pWorkspace; const auto MODE = PCURRENT->m_sFullscreenState.internal; - const auto CURRENTISFOCUS = PCURRENT == g_pCompositor->m_pLastWindow.lock(); + const auto CURRENTISFOCUS = PCURRENT == g_pCompositor->m_lastWindow.lock(); if (FULLSCREEN) g_pCompositor->setWindowFullscreenInternal(PCURRENT, FSMODE_NONE); @@ -1392,7 +1392,7 @@ std::unordered_map CWindow::getEnv() { } void CWindow::activate(bool force) { - if (g_pCompositor->m_pLastWindow == m_pSelf) + if (g_pCompositor->m_lastWindow == m_pSelf) return; static auto PFOCUSONACTIVATE = CConfigValue("misc:focus_on_activate"); @@ -1458,7 +1458,7 @@ void CWindow::onUpdateMeta() { g_pEventManager->postEvent(SHyprIPCEvent{"windowtitlev2", std::format("{:x},{}", (uintptr_t)this, m_szTitle)}); EMIT_HOOK_EVENT("windowTitle", m_pSelf.lock()); - if (m_pSelf == g_pCompositor->m_pLastWindow) { // if it's the active, let's post an event to update others + if (m_pSelf == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", m_szClass + "," + m_szTitle}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", std::format("{:x}", (uintptr_t)this)}); EMIT_HOOK_EVENT("activeWindow", m_pSelf.lock()); @@ -1472,7 +1472,7 @@ void CWindow::onUpdateMeta() { if (m_szClass != NEWCLASS) { m_szClass = NEWCLASS; - if (m_pSelf == g_pCompositor->m_pLastWindow) { // if it's the active, let's post an event to update others + if (m_pSelf == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", m_szClass + "," + m_szTitle}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", std::format("{:x}", (uintptr_t)this)}); EMIT_HOOK_EVENT("activeWindow", m_pSelf.lock()); @@ -1618,7 +1618,7 @@ PHLWINDOW CWindow::getSwallower() { if (!currentPid) break; - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (!w->m_bIsMapped || w->isHidden()) continue; @@ -1643,7 +1643,7 @@ PHLWINDOW CWindow::getSwallower() { return candidates[0]; // walk up the focus history and find the last focused - for (auto const& w : g_pCompositor->m_vWindowFocusHistory) { + for (auto const& w : g_pCompositor->m_windowFocusHistory) { if (!w) continue; diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index 322c4e33..5907c970 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -85,7 +85,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) { // set floating windows offset callbacks m_vRenderOffset->setUpdateCallback([&](auto) { - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (!validMapped(w) || w->workspaceID() != m_iID) continue; @@ -524,7 +524,7 @@ MONITORID CWorkspace::monitorID() { } PHLWINDOW CWorkspace::getFullscreenWindow() { - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pWorkspace == m_pSelf && w->isFullscreen()) return w; } @@ -546,7 +546,7 @@ bool CWorkspace::isVisibleNotCovered() { int CWorkspace::getWindows(std::optional onlyTiled, std::optional onlyPinned, std::optional onlyVisible) { int no = 0; - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->workspaceID() != m_iID || !w->m_bIsMapped) continue; if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value()) @@ -563,7 +563,7 @@ int CWorkspace::getWindows(std::optional onlyTiled, std::optional on int CWorkspace::getGroups(std::optional onlyTiled, std::optional onlyPinned, std::optional onlyVisible) { int no = 0; - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->workspaceID() != m_iID || !w->m_bIsMapped) continue; if (!w->m_sGroupData.head) @@ -580,7 +580,7 @@ int CWorkspace::getGroups(std::optional onlyTiled, std::optional onl } PHLWINDOW CWorkspace::getFirstWindow() { - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pWorkspace == m_pSelf && w->m_bIsMapped && !w->isHidden()) return w; } @@ -591,7 +591,7 @@ PHLWINDOW CWorkspace::getFirstWindow() { PHLWINDOW CWorkspace::getTopLeftWindow() { const auto PMONITOR = m_pMonitor.lock(); - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pWorkspace != m_pSelf || !w->m_bIsMapped || w->isHidden()) continue; @@ -604,7 +604,7 @@ PHLWINDOW CWorkspace::getTopLeftWindow() { } bool CWorkspace::hasUrgentWindow() { - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pWorkspace == m_pSelf && w->m_bIsMapped && w->m_bIsUrgent) return true; } @@ -613,7 +613,7 @@ bool CWorkspace::hasUrgentWindow() { } void CWorkspace::updateWindowDecos() { - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pWorkspace != m_pSelf) continue; @@ -624,7 +624,7 @@ void CWorkspace::updateWindowDecos() { void CWorkspace::updateWindowData() { const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_pSelf.lock()); - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pWorkspace != m_pSelf) continue; @@ -633,7 +633,7 @@ void CWorkspace::updateWindowData() { } void CWorkspace::forceReportSizesToWindows() { - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (w->m_pWorkspace != m_pSelf || !w->m_bIsMapped || w->isHidden()) continue; @@ -658,9 +658,9 @@ void CWorkspace::rename(const std::string& name) { } void CWorkspace::updateWindows() { - m_bHasFullscreenWindow = std::ranges::any_of(g_pCompositor->m_vWindows, [this](const auto& w) { return w->m_bIsMapped && w->m_pWorkspace == m_pSelf && w->isFullscreen(); }); + m_bHasFullscreenWindow = std::ranges::any_of(g_pCompositor->m_windows, [this](const auto& w) { return w->m_bIsMapped && w->m_pWorkspace == m_pSelf && w->isFullscreen(); }); - for (auto const& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_windows) { if (!w->m_bIsMapped || w->m_pWorkspace != m_pSelf) continue; -- cgit v1.2.3