From c0f77d237dd2a38e9e33c6da4da78a5af14e908c Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:10:41 +0100 Subject: [PATCH] properly clean layout data modified: src/desktop/Window.cpp modified: src/desktop/Window.hpp modified: src/events/Windows.cpp modified: src/layout/DwindleLayout.cpp modified: src/layout/IHyprLayout.cpp modified: src/layout/IHyprLayout.hpp modified: src/layout/MasterLayout.cpp --- src/desktop/Window.cpp | 30 ++++++++++++------------------ src/desktop/Window.hpp | 1 + src/events/Windows.cpp | 4 ++-- src/layout/DwindleLayout.cpp | 6 +++--- src/layout/IHyprLayout.cpp | 10 +--------- src/layout/IHyprLayout.hpp | 2 -- src/layout/MasterLayout.cpp | 6 +++--- 7 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index e6ac77c9..5a3b19e2 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -757,33 +757,18 @@ void CWindow::applyDynamicRule(const SWindowRule& r) { } void CWindow::updateDynamicRules() { - m_sWindowData.activeBorderColor.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.inactiveBorderColor.unset(PRIORITY_WINDOW_RULE); m_sWindowData.alpha.unset(PRIORITY_WINDOW_RULE); m_sWindowData.alphaInactive.unset(PRIORITY_WINDOW_RULE); m_sWindowData.alphaFullscreen.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.opaque.unset(PRIORITY_WINDOW_RULE); + unsetWindowData(PRIORITY_WINDOW_RULE); m_sWindowData.animationStyle.unset(PRIORITY_WINDOW_RULE); m_sWindowData.maxSize.unset(PRIORITY_WINDOW_RULE); m_sWindowData.minSize.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.dimAround.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.noAnim.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.noBlur.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.noDim.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.noBorder.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.noShadow.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.focusOnActivate.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.RGBX.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.tearing.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.keepAspectRatio.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.nearestNeighbor.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.xray.unset(PRIORITY_WINDOW_RULE); - - m_sWindowData.borderSize.unset(PRIORITY_WINDOW_RULE); - m_sWindowData.rounding.unset(PRIORITY_WINDOW_RULE); + m_sWindowData.activeBorderColor.unset(PRIORITY_WINDOW_RULE); + m_sWindowData.inactiveBorderColor.unset(PRIORITY_WINDOW_RULE); m_eIdleInhibitMode = IDLEINHIBIT_NONE; @@ -1566,3 +1551,12 @@ PHLWINDOW CWindow::getSwallower() { // if none are found (??) then just return the first one return candidates.at(0); } + +void CWindow::unsetWindowData(eOverridePriority priority) { + for (auto const& element : g_pConfigManager->mbWindowProperties) { + element.second(m_pSelf.lock())->unset(priority); + } + for (auto const& element : g_pConfigManager->miWindowProperties) { + element.second(m_pSelf.lock())->unset(priority); + } +} diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 40b6e4a7..c8f6c284 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -457,6 +457,7 @@ class CWindow { std::string fetchClass(); void warpCursor(); PHLWINDOW getSwallower(); + void unsetWindowData(eOverridePriority priority); // listeners void onAck(uint32_t serial); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 2bd6f8d9..4678ec93 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -314,7 +314,7 @@ void Events::listener_mapWindow(void* owner, void* data) { workspaceSilent = false; } - g_pLayoutManager->getCurrentLayout()->unsetLayoutWindowData(PWINDOW); + PWINDOW->updateWindowData(); if (PWINDOW->m_bIsFloating) { g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(PWINDOW); @@ -450,7 +450,7 @@ void Events::listener_mapWindow(void* owner, void* data) { const auto PFOCUSEDWINDOWPREV = g_pCompositor->m_pLastWindow.lock(); - if (PWINDOW->m_sWindowData.allowsInput.value_or_default()) { + if (PWINDOW->m_sWindowData.allowsInput.value_or_default()) { // if default value wasn't set to false getPriority() would throw an exception PWINDOW->m_sWindowData.noFocus = CWindowOverridableVar(false, PWINDOW->m_sWindowData.allowsInput.getPriority()); PWINDOW->m_bNoInitialFocus = false; PWINDOW->m_bX11ShouldntFocus = false; diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 03cc56f1..d1b4b7ca 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -139,7 +139,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for if (PWINDOW->m_bIsFullscreen && !pNode->ignoreFullscreenChecks) return; - unsetLayoutWindowData(PWINDOW); + PWINDOW->unsetWindowData(PRIORITY_LAYOUT); static auto PNOGAPSWHENONLY = CConfigValue("dwindle:no_gaps_when_only"); static auto PGAPSINDATA = CConfigValue("general:gaps_in"); @@ -496,7 +496,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) { return; } - unsetLayoutWindowData(pWindow); + pWindow->unsetWindowData(PRIORITY_LAYOUT); if (pWindow->m_bIsFullscreen) g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL); @@ -830,7 +830,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, eFullscre pWindow->m_vRealPosition = pWindow->m_vLastFloatingPosition; pWindow->m_vRealSize = pWindow->m_vLastFloatingSize; - unsetLayoutWindowData(pWindow); + pWindow->unsetWindowData(PRIORITY_LAYOUT); } } else { // if it now got fullscreen, make it fullscreen diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 6991a9bb..9d1705e0 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -542,7 +542,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) { g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID)); - g_pLayoutManager->getCurrentLayout()->unsetLayoutWindowData(pWindow); + pWindow->unsetWindowData(PRIORITY_LAYOUT); if (pWindow == m_pLastTiledWindow) m_pLastTiledWindow.reset(); @@ -712,12 +712,4 @@ Vector2D IHyprLayout::predictSizeForNewWindow(PHLWINDOW pWindow) { return sizePredicted; } -void IHyprLayout::unsetLayoutWindowData(PHLWINDOW pWindow) { - // not finished - pWindow->m_sWindowData.decorate.unset(PRIORITY_LAYOUT); - pWindow->m_sWindowData.noBorder.unset(PRIORITY_LAYOUT); - pWindow->m_sWindowData.noRounding.unset(PRIORITY_LAYOUT); - pWindow->m_sWindowData.noShadow.unset(PRIORITY_LAYOUT); -} - IHyprLayout::~IHyprLayout() {} diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index bdfd4306..74a00d19 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -195,8 +195,6 @@ class IHyprLayout { virtual Vector2D predictSizeForNewWindow(PHLWINDOW pWindow); virtual Vector2D predictSizeForNewWindowFloating(PHLWINDOW pWindow); - virtual void unsetLayoutWindowData(PHLWINDOW); - private: int m_iMouseMoveEventCount; Vector2D m_vBeginDragXY; diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index bfb77918..b5f2fa9f 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -264,7 +264,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) { const auto MASTERSLEFT = getMastersOnWorkspace(WORKSPACEID); static auto SMALLSPLIT = CConfigValue("master:allow_small_split"); - unsetLayoutWindowData(pWindow); + pWindow->unsetWindowData(PRIORITY_LAYOUT); g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL); @@ -646,7 +646,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) { if (PWINDOW->m_bIsFullscreen && !pNode->ignoreFullscreenChecks) return; - unsetLayoutWindowData(PWINDOW); + PWINDOW->unsetWindowData(PRIORITY_LAYOUT); static auto PNOGAPSWHENONLY = CConfigValue("master:no_gaps_when_only"); static auto PANIMATE = CConfigValue("misc:animate_manual_resizes"); @@ -922,7 +922,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, eFullscree pWindow->m_vRealPosition = pWindow->m_vLastFloatingPosition; pWindow->m_vRealSize = pWindow->m_vLastFloatingSize; - unsetLayoutWindowData(pWindow); + pWindow->unsetWindowData(PRIORITY_LAYOUT); } } else { // if it now got fullscreen, make it fullscreen