diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2f972335..ff29fffc 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -875,7 +875,8 @@ void CCompositor::focusWindow(PHLWINDOW pWindow, SP pSurface if (pWindow && pWindow->m_bIsX11 && pWindow->m_iX11Type == 2 && !pWindow->m_pXWaylandSurface->wantsFocus()) return; - g_pLayoutManager->getCurrentLayout()->bringWindowToTop(pWindow); + if (pWindow) + pWindow->m_pWorkspace->getCurrentLayout()->bringWindowToTop(pWindow); if (!pWindow || !validMapped(pWindow)) { @@ -898,7 +899,8 @@ void CCompositor::focusWindow(PHLWINDOW pWindow, SP pSurface EMIT_HOOK_EVENT("activeWindow", (PHLWINDOW) nullptr); - g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(nullptr); + if (m_pLastMonitor) + m_pLastMonitor->activeWorkspace->getCurrentLayout()->onWindowFocusChange(nullptr); m_pLastFocus.reset(); @@ -971,7 +973,7 @@ void CCompositor::focusWindow(PHLWINDOW pWindow, SP pSurface EMIT_HOOK_EVENT("activeWindow", pWindow); - g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->onWindowFocusChange(pWindow); g_pInputManager->recheckIdleInhibitorStatus(); @@ -1764,7 +1766,7 @@ void CCompositor::updateWindowAnimatedDecorationValues(PHLWINDOW pWindow) { }; // border - const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow); + const auto RENDERDATA = pWindow->m_pWorkspace->getCurrentLayout()->requestRenderHints(pWindow); if (RENDERDATA.isBorderGradient) setBorderColor(*RENDERDATA.borderGradient); else { @@ -1905,8 +1907,8 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB) PWORKSPACEA->rememberPrevWorkspace(PWORKSPACEB); PWORKSPACEB->rememberPrevWorkspace(PWORKSPACEA); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorA->ID); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorB->ID); + PWORKSPACEA->getCurrentLayout()->recalculateMonitor(pMonitorB->ID); + PWORKSPACEB->getCurrentLayout()->recalculateMonitor(pMonitorA->ID); updateFullscreenFadeOnWorkspace(PWORKSPACEB); updateFullscreenFadeOnWorkspace(PWORKSPACEA); @@ -2090,7 +2092,7 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, CMonitor* pMon setActiveMonitor(pMonitor); pMonitor->activeWorkspace = pWorkspace; - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); + pWorkspace->getCurrentLayout()->recalculateMonitor(pMonitor->ID); pWorkspace->startAnim(true, true, true); pWorkspace->m_bVisible = true; @@ -2103,7 +2105,7 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, CMonitor* pMon // finalize if (POLDMON) { - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID); + POLDMON->activeWorkspace->getCurrentLayout()->recalculateMonitor(POLDMON->ID); updateFullscreenFadeOnWorkspace(POLDMON->activeWorkspace); updateSuspendedStates(); } @@ -2187,7 +2189,7 @@ void CCompositor::setWindowFullscreen(PHLWINDOW pWindow, bool on, eFullscreenMod return; } - g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(pWindow, MODE, on); + PWORKSPACE->getCurrentLayout()->fullscreenRequestForWindow(pWindow, MODE, on); g_pXWaylandManager->setWindowFullscreen(pWindow, pWindow->shouldSendFullscreenState()); @@ -2304,7 +2306,7 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp) { } for (auto& w : g_pCompositor->m_vWindows) { - if (!w->m_bIsMapped || (w->isHidden() && !g_pLayoutManager->getCurrentLayout()->isWindowReachable(w))) + if (!w->m_bIsMapped || (w->isHidden() && !w->m_pWorkspace->getCurrentLayout()->isWindowReachable(w))) continue; switch (mode) { @@ -2546,10 +2548,10 @@ void CCompositor::moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWor setWindowFullscreen(pWindow, false, FULLSCREEN_FULL); if (!pWindow->m_bIsFloating) { - g_pLayoutManager->getCurrentLayout()->onWindowRemovedTiling(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->onWindowRemovedTiling(pWindow); pWindow->moveToWorkspace(pWorkspace); pWindow->m_iMonitorID = pWorkspace->m_iMonitorID; - g_pLayoutManager->getCurrentLayout()->onWindowCreatedTiling(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->onWindowCreatedTiling(pWindow); } else { const auto PWINDOWMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); const auto POSTOMON = pWindow->m_vRealPosition.goal() - PWINDOWMONITOR->vecPosition; diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 1b069f5d..66242ecc 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -791,7 +791,7 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) { } for (auto& m : g_pCompositor->m_vMonitors) - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); + m->activeWorkspace->getCurrentLayout()->recalculateMonitor(m->ID); // Update the keyboard layout to the cfg'd one if this is not the first launch if (!isFirstLaunch) { @@ -909,7 +909,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: // invalidate layouts if they changed if (COMMAND == "monitor" || COMMAND.contains("gaps_") || COMMAND.starts_with("dwindle:") || COMMAND.starts_with("master:")) { for (auto& m : g_pCompositor->m_vMonitors) - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); + m->activeWorkspace->getCurrentLayout()->recalculateMonitor(m->ID); } // Update window border colors diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 70b886f2..2e4a381d 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -988,7 +988,7 @@ std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in) { if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source") { for (auto& m : g_pCompositor->m_vMonitors) { g_pHyprRenderer->damageMonitor(m.get()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); + m->activeWorkspace->getCurrentLayout()->recalculateMonitor(m->ID); } } @@ -1296,7 +1296,7 @@ std::string dispatchSetProp(eHyprCtlOutputFormat format, std::string request) { } for (auto& m : g_pCompositor->m_vMonitors) - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); + m->activeWorkspace->getCurrentLayout()->recalculateMonitor(m->ID); return "ok"; } @@ -1722,7 +1722,7 @@ std::string CHyprCtl::getReply(std::string request) { for (auto& m : g_pCompositor->m_vMonitors) { g_pHyprRenderer->damageMonitor(m.get()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); + m->activeWorkspace->getCurrentLayout()->recalculateMonitor(m->ID); } } diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index d153b344..5ac90c19 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -284,14 +284,14 @@ void CWindow::addWindowDeco(std::unique_ptr deco) { m_dWindowDecorations.emplace_back(std::move(deco)); g_pDecorationPositioner->forceRecalcFor(m_pSelf.lock()); updateWindowDecos(); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(m_pSelf.lock()); + m_pWorkspace->getCurrentLayout()->recalculateWindow(m_pSelf.lock()); } void CWindow::removeWindowDeco(IHyprWindowDecoration* deco) { m_vDecosToRemove.push_back(deco); g_pDecorationPositioner->forceRecalcFor(m_pSelf.lock()); updateWindowDecos(); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(m_pSelf.lock()); + m_pWorkspace->getCurrentLayout()->recalculateWindow(m_pSelf.lock()); } void CWindow::uncacheWindowDecos() { @@ -412,11 +412,11 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) { g_pCompositor->updateWorkspaceWindows(OLDWORKSPACE->m_iID); g_pCompositor->updateWorkspaceSpecialRenderData(OLDWORKSPACE->m_iID); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(OLDWORKSPACE->m_iMonitorID); + OLDWORKSPACE->getCurrentLayout()->recalculateMonitor(OLDWORKSPACE->m_iMonitorID); g_pCompositor->updateWorkspaceWindows(workspaceID()); g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); + m_pWorkspace->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); @@ -523,7 +523,7 @@ void CWindow::onUnmap() { g_pCompositor->updateWorkspaceWindows(workspaceID()); g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); + m_pWorkspace->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); m_pWorkspace.reset(); @@ -819,7 +819,7 @@ void CWindow::updateDynamicRules() { EMIT_HOOK_EVENT("windowUpdateRules", m_pSelf.lock()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); + m_pWorkspace->getCurrentLayout()->recalculateMonitor(m_iMonitorID); } // check if the point is "hidden" under a rounded corner of the window @@ -886,7 +886,7 @@ void CWindow::createGroup() { g_pCompositor->updateWorkspaceWindows(workspaceID()); g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); + m_pWorkspace->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("1,{:x}", (uintptr_t)this)}); @@ -904,7 +904,7 @@ void CWindow::destroyGroup() { updateWindowDecos(); g_pCompositor->updateWorkspaceWindows(workspaceID()); g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); + m_pWorkspace->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("0,{:x}", (uintptr_t)this)}); @@ -926,21 +926,21 @@ void CWindow::destroyGroup() { for (auto& w : members) { if (w->m_sGroupData.head) - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(curr); + m_pWorkspace->getCurrentLayout()->onWindowRemoved(curr); w->m_sGroupData.head = false; } const bool GROUPSLOCKEDPREV = g_pKeybindManager->m_bGroupsLocked; g_pKeybindManager->m_bGroupsLocked = true; for (auto& w : members) { - g_pLayoutManager->getCurrentLayout()->onWindowCreated(w); + m_pWorkspace->getCurrentLayout()->onWindowCreated(w); w->updateWindowDecos(); } g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; g_pCompositor->updateWorkspaceWindows(workspaceID()); g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); + m_pWorkspace->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); if (!addresses.empty()) @@ -1028,7 +1028,7 @@ void CWindow::setGroupCurrent(PHLWINDOW pWindow) { PCURRENT->setHidden(true); pWindow->setHidden(false); // can remove m_pLastWindow - g_pLayoutManager->getCurrentLayout()->replaceWindowDataWith(PCURRENT, pWindow); + m_pWorkspace->getCurrentLayout()->replaceWindowDataWith(PCURRENT, pWindow); if (PCURRENT->m_bIsFloating) { pWindow->m_vRealPosition.setValueAndWarp(PWINDOWPOS); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index d37ba12b..ee8cf928 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -325,7 +325,7 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->updateSpecialRenderData(); if (PWINDOW->m_bIsFloating) { - g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(PWINDOW); + PWINDOW->m_pWorkspace->getCurrentLayout()->onWindowCreatedFloating(PWINDOW); PWINDOW->m_bCreatedOverFullscreen = true; // size and move rules @@ -450,7 +450,7 @@ void Events::listener_mapWindow(void* owner, void* data) { g_pCompositor->changeWindowZOrder(PWINDOW, true); } else { - g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW); + PWINDOW->m_pWorkspace->getCurrentLayout()->onWindowCreated(PWINDOW); // Set the pseudo size here too so that it doesnt end up being 0x0 PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goal() - Vector2D(10, 10); @@ -532,11 +532,11 @@ void Events::listener_mapWindow(void* owner, void* data) { // swallow PWINDOW->m_pSwallowed = SWALLOWER; - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(SWALLOWER); + SWALLOWER->m_pWorkspace->getCurrentLayout()->onWindowRemoved(SWALLOWER); SWALLOWER->setHidden(true); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); + PWINDOW->m_pWorkspace->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); } } @@ -551,7 +551,7 @@ void Events::listener_mapWindow(void* owner, void* data) { // apply data from default decos. Borders, shadows. g_pDecorationPositioner->forceRecalcFor(PWINDOW); PWINDOW->updateWindowDecos(); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(PWINDOW); + PWINDOW->m_pWorkspace->getCurrentLayout()->recalculateWindow(PWINDOW); // do animations g_pAnimationManager->onWindowPostCreateClose(PWINDOW, false); @@ -614,7 +614,7 @@ void Events::listener_unmapWindow(void* owner, void* data) { // swallowing if (valid(PWINDOW->m_pSwallowed)) { PWINDOW->m_pSwallowed->setHidden(false); - g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW->m_pSwallowed.lock()); + PWINDOW->m_pWorkspace->getCurrentLayout()->onWindowCreated(PWINDOW->m_pSwallowed.lock()); PWINDOW->m_pSwallowed.reset(); } @@ -634,14 +634,14 @@ void Events::listener_unmapWindow(void* owner, void* data) { if (PWORKSPACE->m_bHasFullscreenWindow && PWINDOW->m_bIsFullscreen) PWORKSPACE->m_bHasFullscreenWindow = false; - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW); + PWORKSPACE->getCurrentLayout()->onWindowRemoved(PWINDOW); // do this after onWindowRemoved because otherwise it'll think the window is invalid PWINDOW->m_bIsMapped = false; // refocus on a new window if needed if (wasLastWindow) { - const auto PWINDOWCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(PWINDOW); + const auto PWINDOWCANDIDATE = PWORKSPACE->getCurrentLayout()->getNextWindowCandidate(PWINDOW); Debug::log(LOG, "On closed window, new focused candidate is {}", PWINDOWCANDIDATE); @@ -690,7 +690,7 @@ void Events::listener_commitWindow(void* owner, void* data) { PHLWINDOW PWINDOW = ((CWindow*)owner)->m_pSelf.lock(); if (!PWINDOW->m_bIsX11 && PWINDOW->m_pXDGSurface->initialCommit) { - Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow(PWINDOW); + Vector2D predSize = PWINDOW->m_pWorkspace->getCurrentLayout()->predictSizeForNewWindow(PWINDOW); Debug::log(LOG, "Layout predicts size {} for {}", predSize, PWINDOW); @@ -775,7 +775,7 @@ void Events::listener_destroyWindow(void* owner, void* data) { PWINDOW->listeners = {}; - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW); + PWINDOW->m_pWorkspace->getCurrentLayout()->onWindowRemoved(PWINDOW); PWINDOW->m_bReadyToDelete = true; diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 58687e09..39effd61 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -196,7 +196,7 @@ void CMonitor::onConnect(bool noRule) { g_pCompositor->setActiveMonitor(this); g_pHyprRenderer->arrangeLayersForMonitor(ID); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + activeWorkspace->getCurrentLayout()->recalculateMonitor(ID); // ensure VRR (will enable if necessary) g_pConfigManager->ensureVRR(this); @@ -432,7 +432,7 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) { // workspace exists, move it to the newly connected monitor g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, this); activeWorkspace = PNEWWORKSPACE; - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + activeWorkspace->getCurrentLayout()->recalculateMonitor(ID); PNEWWORKSPACE->startAnim(true, true, true); } else { if (newDefaultWorkspaceName == "") @@ -615,7 +615,7 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo if (!noMouseMove) g_pInputManager->simulateMouseMovement(); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + activeWorkspace->getCurrentLayout()->recalculateMonitor(ID); g_pEventManager->postEvent(SHyprIPCEvent{"workspace", pWorkspace->m_szName}); g_pEventManager->postEvent(SHyprIPCEvent{"workspacev2", std::format("{},{}", pWorkspace->m_iID, pWorkspace->m_szName)}); @@ -650,7 +650,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { } activeSpecialWorkspace.reset(); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + activeWorkspace->getCurrentLayout()->recalculateMonitor(ID); if (!(g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow->m_bPinned && g_pCompositor->m_pLastWindow->m_iMonitorID == ID)) { if (const auto PLAST = activeWorkspace->getLastFocusedWindow(); PLAST) @@ -678,7 +678,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { const auto PMONITORWORKSPACEOWNER = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); if (PMONITORWORKSPACEOWNER->activeSpecialWorkspace == pWorkspace) { PMONITORWORKSPACEOWNER->activeSpecialWorkspace.reset(); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITORWORKSPACEOWNER->ID); + PMONITORWORKSPACEOWNER->activeWorkspace->getCurrentLayout()->recalculateMonitor(PMONITORWORKSPACEOWNER->ID); g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMONITORWORKSPACEOWNER->szName}); const auto PACTIVEWORKSPACE = PMONITORWORKSPACEOWNER->activeWorkspace; @@ -718,7 +718,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { } } - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + activeWorkspace->getCurrentLayout()->recalculateMonitor(ID); if (!(g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow->m_bPinned && g_pCompositor->m_pLastWindow->m_iMonitorID == ID)) { if (const auto PLAST = pWorkspace->getLastFocusedWindow(); PLAST) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 172a157b..6781de80 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -308,7 +308,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir // we can't continue. make it floating. pWindow->m_bIsFloating = true; m_lDwindleNodesData.remove(*PNODE); - g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); + onWindowCreatedFloating(pWindow); return; } diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index c5784c74..a5ac54b5 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -232,7 +232,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire // we can't continue. make it floating. pWindow->m_bIsFloating = true; m_lMasterNodesData.remove(*PNODE); - g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); + onWindowCreatedFloating(pWindow); return; } } else { @@ -245,7 +245,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire // we can't continue. make it floating. pWindow->m_bIsFloating = true; m_lMasterNodesData.remove(*PNODE); - g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); + onWindowCreatedFloating(pWindow); return; } } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index eb07850c..9a86c620 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -244,13 +244,13 @@ bool CKeybindManager::ensureMouseBindState() { PHLWINDOW lastDraggedWindow = g_pInputManager->currentlyDraggedWindow.lock(); m_bIsMouseBindActive = false; - g_pLayoutManager->getCurrentLayout()->onEndDragWindow(); + lastDraggedWindow->m_pWorkspace->getCurrentLayout()->onEndDragWindow(); g_pInputManager->currentlyDraggedWindow.reset(); g_pInputManager->dragMode = MBIND_INVALID; g_pCompositor->updateWorkspaceWindows(lastDraggedWindow->workspaceID()); g_pCompositor->updateWorkspaceSpecialRenderData(lastDraggedWindow->workspaceID()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(lastDraggedWindow->m_iMonitorID); + lastDraggedWindow->m_pWorkspace->getCurrentLayout()->recalculateMonitor(lastDraggedWindow->m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); return true; @@ -962,7 +962,7 @@ static void toggleActiveFloatingCore(std::string args, std::optional float const auto PCURRENT = PWINDOW->getGroupCurrent(); PCURRENT->m_bIsFloating = !PCURRENT->m_bIsFloating; - g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PCURRENT); + PCURRENT->m_pWorkspace->getCurrentLayout()->changeWindowFloatingMode(PCURRENT); PHLWINDOW curr = PCURRENT->m_sGroupData.pNextWindow.lock(); while (curr != PCURRENT) { @@ -972,11 +972,11 @@ static void toggleActiveFloatingCore(std::string args, std::optional float } else { PWINDOW->m_bIsFloating = !PWINDOW->m_bIsFloating; - g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PWINDOW); + PWINDOW->m_pWorkspace->getCurrentLayout()->changeWindowFloatingMode(PWINDOW); } g_pCompositor->updateWorkspaceWindows(PWINDOW->workspaceID()); g_pCompositor->updateWorkspaceSpecialRenderData(PWINDOW->workspaceID()); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); + PWINDOW->m_pWorkspace->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); } @@ -1017,7 +1017,7 @@ void CKeybindManager::toggleActivePseudo(std::string args) { ACTIVEWINDOW->m_bIsPseudotiled = !ACTIVEWINDOW->m_bIsPseudotiled; if (!ACTIVEWINDOW->m_bIsFullscreen) - g_pLayoutManager->getCurrentLayout()->recalculateWindow(ACTIVEWINDOW); + ACTIVEWINDOW->m_pWorkspace->getCurrentLayout()->recalculateWindow(ACTIVEWINDOW); } void CKeybindManager::changeworkspace(std::string args) { @@ -1322,7 +1322,7 @@ void CKeybindManager::swapActive(std::string args) { return; updateRelativeCursorCoords(); - g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO); + PLASTWINDOW->m_pWorkspace->getCurrentLayout()->switchWindows(PLASTWINDOW, PWINDOWTOCHANGETO); PLASTWINDOW->warpCursor(); } @@ -1378,7 +1378,8 @@ void CKeybindManager::moveActiveTo(std::string args) { if (PWINDOWTOCHANGETO) { updateRelativeCursorCoords(); - g_pLayoutManager->getCurrentLayout()->moveWindowTo(PLASTWINDOW, args, silent); + // FIXME update previous workspace if layouts differ + PLASTWINDOW->m_pWorkspace->getCurrentLayout()->moveWindowTo(PLASTWINDOW, args, silent); if (!silent) PLASTWINDOW->warpCursor(); return; @@ -1457,7 +1458,7 @@ void CKeybindManager::toggleSplit(std::string args) { if (PWORKSPACE->m_bHasFullscreenWindow) return; - g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglesplit"); + PWORKSPACE->getCurrentLayout()->layoutMessage(header, "togglesplit"); } void CKeybindManager::swapSplit(std::string args) { @@ -1472,7 +1473,7 @@ void CKeybindManager::swapSplit(std::string args) { if (PWORKSPACE->m_bHasFullscreenWindow) return; - g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "swapsplit"); + PWORKSPACE->getCurrentLayout()->layoutMessage(header, "swapsplit"); } void CKeybindManager::alterSplitRatio(std::string args) { @@ -1495,7 +1496,7 @@ void CKeybindManager::alterSplitRatio(std::string args) { if (!PLASTWINDOW) return; - g_pLayoutManager->getCurrentLayout()->alterSplitRatio(PLASTWINDOW, splitResult.value(), exact); + PLASTWINDOW->m_pWorkspace->getCurrentLayout()->alterSplitRatio(PLASTWINDOW, splitResult.value(), exact); } void CKeybindManager::focusMonitor(std::string arg) { @@ -1606,7 +1607,7 @@ void CKeybindManager::workspaceOpt(std::string args) { const auto SAVEDSIZE = w->m_vRealSize.value(); w->m_bIsFloating = PWORKSPACE->m_bDefaultFloating; - g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(w); + w->m_pWorkspace->getCurrentLayout()->changeWindowFloatingMode(w); if (PWORKSPACE->m_bDefaultFloating) { w->m_vRealPosition.setValueAndWarp(SAVEDPOS); @@ -1623,7 +1624,7 @@ void CKeybindManager::workspaceOpt(std::string args) { } // recalc mon - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); + g_pCompositor->m_pLastMonitor->activeWorkspace->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); } void CKeybindManager::renameWorkspace(std::string args) { @@ -1813,7 +1814,7 @@ void CKeybindManager::resizeActive(std::string args) { if (SIZ.x < 1 || SIZ.y < 1) return; - g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PLASTWINDOW->m_vRealSize.goal()); + PLASTWINDOW->m_pWorkspace->getCurrentLayout()->resizeActiveWindow(SIZ - PLASTWINDOW->m_vRealSize.goal()); if (PLASTWINDOW->m_vRealSize.goal().x > 1 && PLASTWINDOW->m_vRealSize.goal().y > 1) PLASTWINDOW->setHidden(false); @@ -1827,7 +1828,7 @@ void CKeybindManager::moveActive(std::string args) { const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, PLASTWINDOW->m_vRealPosition.goal()); - g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - PLASTWINDOW->m_vRealPosition.goal()); + PLASTWINDOW->m_pWorkspace->getCurrentLayout()->moveActiveWindow(POS - PLASTWINDOW->m_vRealPosition.goal()); } void CKeybindManager::moveWindow(std::string args) { @@ -1847,7 +1848,7 @@ void CKeybindManager::moveWindow(std::string args) { const auto POS = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealPosition.goal()); - g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - PWINDOW->m_vRealPosition.goal(), PWINDOW); + PWINDOW->m_pWorkspace->getCurrentLayout()->moveActiveWindow(POS - PWINDOW->m_vRealPosition.goal(), PWINDOW); } void CKeybindManager::resizeWindow(std::string args) { @@ -1870,7 +1871,7 @@ void CKeybindManager::resizeWindow(std::string args) { if (SIZ.x < 1 || SIZ.y < 1) return; - g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goal(), CORNER_NONE, PWINDOW); + PWINDOW->m_pWorkspace->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goal(), CORNER_NONE, PWINDOW); if (PWINDOW->m_vRealSize.goal().x > 1 && PWINDOW->m_vRealSize.goal().y > 1) PWINDOW->setHidden(false); @@ -2217,7 +2218,7 @@ void CKeybindManager::sendshortcut(std::string args) { void CKeybindManager::layoutmsg(std::string msg) { SLayoutMessageHeader hd = {g_pCompositor->m_pLastWindow.lock()}; - g_pLayoutManager->getCurrentLayout()->layoutMessage(hd, msg); + g_pCompositor->m_pLastWindow->m_pWorkspace->getCurrentLayout()->layoutMessage(hd, msg); } void CKeybindManager::toggleOpaque(std::string unused) { @@ -2291,7 +2292,7 @@ void CKeybindManager::swapnext(std::string arg) { toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true); } - g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap); + PLASTWINDOW->m_pWorkspace->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap); PLASTWINDOW->m_pLastCycledWindow = toSwap; @@ -2360,12 +2361,12 @@ void CKeybindManager::mouse(std::string args) { g_pInputManager->currentlyDraggedWindow = pWindow; g_pInputManager->dragMode = MBIND_MOVE; - g_pLayoutManager->getCurrentLayout()->onBeginDragWindow(); + g_pInputManager->currentlyDraggedWindow->m_pWorkspace->getCurrentLayout()->onBeginDragWindow(); } else { g_pKeybindManager->m_bIsMouseBindActive = false; if (!g_pInputManager->currentlyDraggedWindow.expired()) { - g_pLayoutManager->getCurrentLayout()->onEndDragWindow(); + g_pInputManager->currentlyDraggedWindow->m_pWorkspace->getCurrentLayout()->onEndDragWindow(); g_pInputManager->currentlyDraggedWindow.reset(); g_pInputManager->dragMode = MBIND_INVALID; } @@ -2384,12 +2385,12 @@ void CKeybindManager::mouse(std::string args) { default: g_pInputManager->dragMode = MBIND_RESIZE; } } catch (std::exception& e) { g_pInputManager->dragMode = MBIND_RESIZE; } - g_pLayoutManager->getCurrentLayout()->onBeginDragWindow(); + g_pInputManager->currentlyDraggedWindow->m_pWorkspace->getCurrentLayout()->onBeginDragWindow(); } else { g_pKeybindManager->m_bIsMouseBindActive = false; if (!g_pInputManager->currentlyDraggedWindow.expired()) { - g_pLayoutManager->getCurrentLayout()->onEndDragWindow(); + g_pInputManager->currentlyDraggedWindow->m_pWorkspace->getCurrentLayout()->onEndDragWindow(); g_pInputManager->currentlyDraggedWindow.reset(); g_pInputManager->dragMode = MBIND_INVALID; } @@ -2470,7 +2471,7 @@ void CKeybindManager::moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowIn updateRelativeCursorCoords(); - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow); // This removes groupped property! + pWindow->m_pWorkspace->getCurrentLayout()->onWindowRemoved(pWindow); // This removes groupped property! static auto USECURRPOS = CConfigValue("group:insert_after_current"); pWindowInDirection = *USECURRPOS ? pWindowInDirection : pWindowInDirection->getGroupTail(); @@ -2478,7 +2479,7 @@ void CKeybindManager::moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowIn pWindowInDirection->insertWindowToGroup(pWindow); pWindowInDirection->setGroupCurrent(pWindow); pWindow->updateWindowDecos(); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->recalculateWindow(pWindow); g_pCompositor->focusWindow(pWindow); pWindow->warpCursor(); @@ -2508,12 +2509,12 @@ void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& if (pWindow->m_sGroupData.pNextWindow.lock() == pWindow) { pWindow->destroyGroup(); } else { - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->onWindowRemoved(pWindow); const auto GROUPSLOCKEDPREV = g_pKeybindManager->m_bGroupsLocked; g_pKeybindManager->m_bGroupsLocked = true; - g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow, direction); + pWindow->m_pWorkspace->getCurrentLayout()->onWindowCreated(pWindow, direction); g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; } @@ -2593,7 +2594,7 @@ void CKeybindManager::moveWindowOrGroup(std::string args) { return; if (!*PIGNOREGROUPLOCK && g_pKeybindManager->m_bGroupsLocked) { - g_pLayoutManager->getCurrentLayout()->moveWindowTo(PWINDOW, args); + PWINDOW->m_pWorkspace->getCurrentLayout()->moveWindowTo(PWINDOW, args); return; } @@ -2608,20 +2609,20 @@ void CKeybindManager::moveWindowOrGroup(std::string args) { // note: PWINDOWINDIR is not null implies !PWINDOW->m_bIsFloating if (PWINDOWINDIR && PWINDOWINDIR->m_sGroupData.pNextWindow) { // target is group if (!*PIGNOREGROUPLOCK && (PWINDOWINDIR->getGroupHead()->m_sGroupData.locked || ISWINDOWGROUPLOCKED || PWINDOW->m_sGroupData.deny)) { - g_pLayoutManager->getCurrentLayout()->moveWindowTo(PWINDOW, args); + PWINDOW->m_pWorkspace->getCurrentLayout()->moveWindowTo(PWINDOW, args); PWINDOW->warpCursor(); } else moveWindowIntoGroup(PWINDOW, PWINDOWINDIR); } else if (PWINDOWINDIR) { // target is regular window if ((!*PIGNOREGROUPLOCK && ISWINDOWGROUPLOCKED) || !ISWINDOWGROUP || (ISWINDOWGROUPSINGLE && PWINDOW->m_eGroupRules & GROUP_SET_ALWAYS)) { - g_pLayoutManager->getCurrentLayout()->moveWindowTo(PWINDOW, args); + PWINDOW->m_pWorkspace->getCurrentLayout()->moveWindowTo(PWINDOW, args); PWINDOW->warpCursor(); } else moveWindowOutOfGroup(PWINDOW, args); } else if ((*PIGNOREGROUPLOCK || !ISWINDOWGROUPLOCKED) && ISWINDOWGROUP) { // no target window moveWindowOutOfGroup(PWINDOW, args); } else if (!PWINDOWINDIR && !ISWINDOWGROUP) { // no target in dir and not in group - g_pLayoutManager->getCurrentLayout()->moveWindowTo(PWINDOW, args); + PWINDOW->m_pWorkspace->getCurrentLayout()->moveWindowTo(PWINDOW, args); PWINDOW->warpCursor(); } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 81a46f97..4831047d 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -258,7 +258,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } } - g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal()); + PMONITOR->activeWorkspace->getCurrentLayout()->onMouseMove(getMouseCoordsInternal()); if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor.get() && (*PMOUSEFOCUSMON || refocus) && m_pForcedFocus.expired()) g_pCompositor->setActiveMonitor(PMONITOR); diff --git a/src/plugins/PluginAPI.cpp b/src/plugins/PluginAPI.cpp index 6e09ba2c..ce503371 100644 --- a/src/plugins/PluginAPI.cpp +++ b/src/plugins/PluginAPI.cpp @@ -112,7 +112,7 @@ APICALL bool HyprlandAPI::addWindowDecoration(HANDLE handle, PHLWINDOW pWindow, pWindow->addWindowDeco(std::move(pDecoration)); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->recalculateWindow(pWindow); return true; } diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 19b646a4..7217d2b2 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1168,7 +1168,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { else Debug::log(LOG, "NoFrameSchedule hit for {}.", pMonitor->szName); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); + pMonitor->activeWorkspace->getCurrentLayout()->recalculateMonitor(pMonitor->ID); if (pMonitor->framesToSkip > 10) pMonitor->framesToSkip = 0; @@ -1189,7 +1189,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { if (pMonitor->scheduledRecalc) { pMonitor->scheduledRecalc = false; - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); + pMonitor->activeWorkspace->getCurrentLayout()->recalculateMonitor(pMonitor->ID); } // tearing and DS first @@ -1642,8 +1642,8 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vectorgetMonitorFromID(monitor); +void CHyprRenderer::arrangeLayersForMonitor(const int& monitorID) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID); if (!PMONITOR) return; @@ -1676,7 +1676,7 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) { // damage the monitor if can damageMonitor(PMONITOR); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor); + PMONITOR->activeWorkspace->getCurrentLayout()->recalculateMonitor(monitorID); } void CHyprRenderer::damageSurface(SP pSurface, double x, double y, double scale) { diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index e461ba08..f47e3f4b 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -55,7 +55,7 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() { void CHyprGroupBarDecoration::onPositioningReply(const SDecorationPositioningReply& reply) { m_bAssignedBox = reply.assignedGeometry; - g_pLayoutManager->getCurrentLayout()->recalculateWindow(m_pWindow.lock()); + m_pWindow->m_pWorkspace->getCurrentLayout()->recalculateWindow(m_pWindow.lock()); } eDecorationType CHyprGroupBarDecoration::getDecorationType() { @@ -385,11 +385,11 @@ bool CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) { PHLWINDOW pWindow = m_pWindow->getGroupWindowByIndex(WINDOWINDEX); // hack - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->onWindowRemoved(pWindow); if (!pWindow->m_bIsFloating) { const bool GROUPSLOCKEDPREV = g_pKeybindManager->m_bGroupsLocked; g_pKeybindManager->m_bGroupsLocked = true; - g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->onWindowCreated(pWindow); g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; } @@ -430,7 +430,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND w->m_sGroupData.pNextWindow.reset(); w->m_sGroupData.head = false; w->m_sGroupData.locked = false; - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(w); + w->m_pWorkspace->getCurrentLayout()->onWindowRemoved(w); } // restores the group @@ -443,7 +443,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND members[0]->m_sGroupData.head = true; members[0]->m_sGroupData.locked = WASLOCKED; } else { - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pDraggedWindow); + pDraggedWindow->m_pWorkspace->getCurrentLayout()->onWindowRemoved(pDraggedWindow); } pWindowInsertAfter->insertWindowToGroup(pDraggedWindow); @@ -454,7 +454,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND m_pWindow->setGroupCurrent(pDraggedWindow); pDraggedWindow->applyGroupRules(); pDraggedWindow->updateWindowDecos(); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(pDraggedWindow); + pDraggedWindow->m_pWorkspace->getCurrentLayout()->recalculateWindow(pDraggedWindow); if (!pDraggedWindow->getDecorationByType(DECORATION_GROUPBAR)) pDraggedWindow->addWindowDeco(std::make_unique(pDraggedWindow)); diff --git a/src/render/decorations/DecorationPositioner.cpp b/src/render/decorations/DecorationPositioner.cpp index 17f6d913..e89bd563 100644 --- a/src/render/decorations/DecorationPositioner.cpp +++ b/src/render/decorations/DecorationPositioner.cpp @@ -273,7 +273,7 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) { if (WINDOWDATA->extents != SWindowDecorationExtents{{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}}) { WINDOWDATA->extents = {{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}}; - g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow); + pWindow->m_pWorkspace->getCurrentLayout()->recalculateWindow(pWindow); } }