compositor: refactor class member vars (#10141)

This commit is contained in:
davc0n 2025-04-22 15:23:29 +02:00 committed by GitHub
parent 3577a6be31
commit 241a4935a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
68 changed files with 751 additions and 756 deletions

View file

@ -15,7 +15,7 @@
PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
PHLLS pLS = SP<CLayerSurface>(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<CLayerShellResource> 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);

View file

@ -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();

View file

@ -115,9 +115,9 @@ CWindow::CWindow(SP<CXWaylandSurface> 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<CBaseAnimatedVariable> 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<std::string, std::string> 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<Hyprlang::INT>("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;

View file

@ -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<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> 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<bool> onlyTiled, std::optional<bool> on
int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> 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<bool> onlyTiled, std::optional<bool> 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;