mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-05 14:42:01 -07:00
Workspace/core: Refactor workspace storage (#5380)
* refactor workspaces to use ptrs * clang-format
This commit is contained in:
@@ -751,20 +751,20 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
|
||||
auto floating = [&](bool aboveFullscreen) -> CWindow* {
|
||||
for (auto& w : m_vWindows | std::views::reverse) {
|
||||
|
||||
if (special && !isWorkspaceSpecial(w->m_iWorkspaceID)) // because special floating may creep up into regular
|
||||
if (special && !w->onSpecialWorkspace()) // because special floating may creep up into regular
|
||||
continue;
|
||||
|
||||
const auto BB = w->getWindowBoxUnified(properties);
|
||||
const auto PWINDOWMONITOR = getMonitorFromID(w->m_iMonitorID);
|
||||
|
||||
// to avoid focusing windows behind special workspaces from other monitors
|
||||
if (!*PSPECIALFALLTHRU && PWINDOWMONITOR && PWINDOWMONITOR->specialWorkspaceID && w->m_iWorkspaceID != PWINDOWMONITOR->specialWorkspaceID &&
|
||||
if (!*PSPECIALFALLTHRU && PWINDOWMONITOR && PWINDOWMONITOR->activeSpecialWorkspace && w->m_pWorkspace != PWINDOWMONITOR->activeSpecialWorkspace &&
|
||||
BB.x >= PWINDOWMONITOR->vecPosition.x && BB.y >= PWINDOWMONITOR->vecPosition.y &&
|
||||
BB.x + BB.width <= PWINDOWMONITOR->vecPosition.x + PWINDOWMONITOR->vecSize.x && BB.y + BB.height <= PWINDOWMONITOR->vecPosition.y + PWINDOWMONITOR->vecSize.y)
|
||||
continue;
|
||||
|
||||
CBox box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA};
|
||||
if (w->m_bIsFloating && w->m_bIsMapped && isWorkspaceVisible(w->m_iWorkspaceID) && !w->isHidden() && !w->m_bPinned && !w->m_sAdditionalConfigData.noFocus &&
|
||||
if (w->m_bIsFloating && w->m_bIsMapped && isWorkspaceVisible(w->workspaceID()) && !w->isHidden() && !w->m_bPinned && !w->m_sAdditionalConfigData.noFocus &&
|
||||
w.get() != pIgnoreWindow && (!aboveFullscreen || w->m_bCreatedOverFullscreen)) {
|
||||
// OR windows should add focus to parent
|
||||
if (w->m_bX11ShouldntFocus && w->m_iX11Type != 2)
|
||||
@@ -801,7 +801,7 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
|
||||
if (properties & FLOATING_ONLY)
|
||||
return floating(false);
|
||||
|
||||
const int64_t WORKSPACEID = special ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
|
||||
const int64_t WORKSPACEID = special ? PMONITOR->activeSpecialWorkspaceID() : PMONITOR->activeWorkspaceID();
|
||||
const auto PWORKSPACE = getWorkspaceByID(WORKSPACEID);
|
||||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow)
|
||||
@@ -813,10 +813,10 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
|
||||
|
||||
// for windows, we need to check their extensions too, first.
|
||||
for (auto& w : m_vWindows) {
|
||||
if (special != isWorkspaceSpecial(w->m_iWorkspaceID))
|
||||
if (special != w->onSpecialWorkspace())
|
||||
continue;
|
||||
|
||||
if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus &&
|
||||
if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->workspaceID() == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus &&
|
||||
!w->m_sAdditionalConfigData.noFocus && w.get() != pIgnoreWindow) {
|
||||
if (w->hasPopupAt(pos))
|
||||
return w.get();
|
||||
@@ -824,11 +824,11 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
|
||||
}
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (special != isWorkspaceSpecial(w->m_iWorkspaceID))
|
||||
if (special != w->onSpecialWorkspace())
|
||||
continue;
|
||||
|
||||
CBox box = (properties & USE_PROP_TILED) ? w->getWindowBoxUnified(properties) : CBox{w->m_vPosition, w->m_vSize};
|
||||
if (!w->m_bIsFloating && w->m_bIsMapped && box.containsPoint(pos) && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus &&
|
||||
if (!w->m_bIsFloating && w->m_bIsMapped && box.containsPoint(pos) && w->workspaceID() == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus &&
|
||||
!w->m_sAdditionalConfigData.noFocus && w.get() != pIgnoreWindow)
|
||||
return w.get();
|
||||
}
|
||||
@@ -837,10 +837,10 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
|
||||
};
|
||||
|
||||
// special workspace
|
||||
if (PMONITOR->specialWorkspaceID && !*PSPECIALFALLTHRU)
|
||||
if (PMONITOR->activeSpecialWorkspace && !*PSPECIALFALLTHRU)
|
||||
return windowForWorkspace(true);
|
||||
|
||||
if (PMONITOR->specialWorkspaceID) {
|
||||
if (PMONITOR->activeSpecialWorkspace) {
|
||||
const auto PWINDOW = windowForWorkspace(true);
|
||||
|
||||
if (PWINDOW)
|
||||
@@ -997,15 +997,15 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
||||
return;
|
||||
|
||||
if (pWindow->m_bPinned)
|
||||
pWindow->m_iWorkspaceID = m_pLastMonitor->activeWorkspace;
|
||||
pWindow->m_pWorkspace = m_pLastMonitor->activeWorkspace;
|
||||
|
||||
const auto PMONITOR = getMonitorFromID(pWindow->m_iMonitorID);
|
||||
|
||||
if (!isWorkspaceVisible(pWindow->m_iWorkspaceID)) {
|
||||
const auto PWORKSPACE = getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
if (!isWorkspaceVisible(pWindow->workspaceID())) {
|
||||
const auto PWORKSPACE = pWindow->m_pWorkspace;
|
||||
// This is to fix incorrect feedback on the focus history.
|
||||
PWORKSPACE->m_pLastFocusedWindow = pWindow;
|
||||
PWORKSPACE->rememberPrevWorkspace(getWorkspaceByID(m_pLastMonitor->activeWorkspace));
|
||||
PWORKSPACE->rememberPrevWorkspace(m_pLastMonitor->activeWorkspace);
|
||||
PMONITOR->changeWorkspace(PWORKSPACE, false, true);
|
||||
// changeworkspace already calls focusWindow
|
||||
return;
|
||||
@@ -1016,7 +1016,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
||||
|
||||
/* If special fallthrough is enabled, this behavior will be disabled, as I have no better idea of nicely tracking which
|
||||
window focuses are "via keybinds" and which ones aren't. */
|
||||
if (PMONITOR->specialWorkspaceID && PMONITOR->specialWorkspaceID != pWindow->m_iWorkspaceID && !pWindow->m_bPinned && !*PSPECIALFALLTHROUGH)
|
||||
if (PMONITOR->activeSpecialWorkspace && PMONITOR->activeSpecialWorkspace != pWindow->m_pWorkspace && !pWindow->m_bPinned && !*PSPECIALFALLTHROUGH)
|
||||
PMONITOR->setSpecialWorkspace(nullptr);
|
||||
|
||||
// we need to make the PLASTWINDOW not equal to m_pLastWindow so that RENDERDATA is correct for an unfocused window
|
||||
@@ -1233,7 +1233,7 @@ CWindow* CCompositor::getWindowFromZWLRHandle(wl_resource* handle) {
|
||||
|
||||
CWindow* CCompositor::getFullscreenWindowOnWorkspace(const int& ID) {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == ID && w->m_bIsFullscreen)
|
||||
if (w->workspaceID() == ID && w->m_bIsFullscreen)
|
||||
return w.get();
|
||||
}
|
||||
|
||||
@@ -1242,20 +1242,20 @@ CWindow* CCompositor::getFullscreenWindowOnWorkspace(const int& ID) {
|
||||
|
||||
bool CCompositor::isWorkspaceVisible(const int& w) {
|
||||
for (auto& m : m_vMonitors) {
|
||||
if (m->activeWorkspace == w)
|
||||
if (m->activeWorkspaceID() == w)
|
||||
return true;
|
||||
|
||||
if (m->specialWorkspaceID == w)
|
||||
if (m->activeSpecialWorkspaceID() == w)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CWorkspace* CCompositor::getWorkspaceByID(const int& id) {
|
||||
PHLWORKSPACE CCompositor::getWorkspaceByID(const int& id) {
|
||||
for (auto& w : m_vWorkspaces) {
|
||||
if (w->m_iID == id)
|
||||
return w.get();
|
||||
if (w->m_iID == id && !w->inert())
|
||||
return w;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -1265,7 +1265,7 @@ void CCompositor::sanityCheckWorkspaces() {
|
||||
auto it = m_vWorkspaces.begin();
|
||||
while (it != m_vWorkspaces.end()) {
|
||||
|
||||
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(it->get());
|
||||
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(*it);
|
||||
bool isPersistent = false;
|
||||
for (auto& wsRule : WORKSPACERULES) {
|
||||
if (wsRule.isPersistent)
|
||||
@@ -1290,10 +1290,11 @@ void CCompositor::sanityCheckWorkspaces() {
|
||||
|
||||
const auto PMONITOR = getMonitorFromID(WORKSPACE->m_iMonitorID);
|
||||
|
||||
if (PMONITOR && PMONITOR->specialWorkspaceID == WORKSPACE->m_iID)
|
||||
if (PMONITOR && PMONITOR->activeSpecialWorkspace == WORKSPACE)
|
||||
PMONITOR->setSpecialWorkspace(nullptr);
|
||||
}
|
||||
|
||||
it->get()->markInert();
|
||||
it = m_vWorkspaces.erase(it);
|
||||
continue;
|
||||
}
|
||||
@@ -1314,7 +1315,7 @@ void CCompositor::sanityCheckWorkspaces() {
|
||||
int CCompositor::getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled) {
|
||||
int no = 0;
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == id && w->m_bIsMapped && !(onlyTiled.has_value() && !w->m_bIsFloating != onlyTiled.value()))
|
||||
if (w->workspaceID() == id && w->m_bIsMapped && !(onlyTiled.has_value() && !w->m_bIsFloating != onlyTiled.value()))
|
||||
no++;
|
||||
}
|
||||
|
||||
@@ -1332,7 +1333,7 @@ CWindow* CCompositor::getUrgentWindow() {
|
||||
|
||||
bool CCompositor::hasUrgentWindowOnWorkspace(const int& id) {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == id && w->m_bIsMapped && w->m_bIsUrgent)
|
||||
if (w->workspaceID() == id && w->m_bIsMapped && w->m_bIsUrgent)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1341,7 +1342,7 @@ bool CCompositor::hasUrgentWindowOnWorkspace(const int& id) {
|
||||
|
||||
CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == id && w->m_bIsMapped && !w->isHidden())
|
||||
if (w->workspaceID() == id && w->m_bIsMapped && !w->isHidden())
|
||||
return w.get();
|
||||
}
|
||||
|
||||
@@ -1357,7 +1358,7 @@ CWindow* CCompositor::getTopLeftWindowOnWorkspace(const int& id) {
|
||||
const auto PMONITOR = getMonitorFromID(PWORKSPACE->m_iMonitorID);
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID != id || !w->m_bIsMapped || w->isHidden())
|
||||
if (w->workspaceID() != id || !w->m_bIsMapped || w->isHidden())
|
||||
continue;
|
||||
|
||||
const auto WINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
|
||||
@@ -1575,7 +1576,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||
const auto POSA = Vector2D(WINDOWIDEALBB.x, WINDOWIDEALBB.y);
|
||||
const auto SIZEA = Vector2D(WINDOWIDEALBB.width, WINDOWIDEALBB.height);
|
||||
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
const auto PWORKSPACE = pWindow->m_pWorkspace;
|
||||
auto leaderValue = -1;
|
||||
CWindow* leaderWindow = nullptr;
|
||||
|
||||
@@ -1583,10 +1584,10 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||
|
||||
// for tiled windows, we calc edges
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w.get() == pWindow || !w->m_bIsMapped || w->isHidden() || (!w->m_bIsFullscreen && w->m_bIsFloating) || !isWorkspaceVisible(w->m_iWorkspaceID))
|
||||
if (w.get() == pWindow || !w->m_bIsMapped || w->isHidden() || (!w->m_bIsFullscreen && w->m_bIsFloating) || !isWorkspaceVisible(w->workspaceID()))
|
||||
continue;
|
||||
|
||||
if (pWindow->m_iMonitorID == w->m_iMonitorID && pWindow->m_iWorkspaceID != w->m_iWorkspaceID)
|
||||
if (pWindow->m_iMonitorID == w->m_iMonitorID && pWindow->m_pWorkspace != w->m_pWorkspace)
|
||||
continue;
|
||||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow && !w->m_bIsFullscreen && !w->m_bCreatedOverFullscreen)
|
||||
@@ -1672,10 +1673,10 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||
constexpr float THRESHOLD = 0.3 * M_PI;
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w.get() == pWindow || !w->m_bIsMapped || w->isHidden() || (!w->m_bIsFullscreen && !w->m_bIsFloating) || !isWorkspaceVisible(w->m_iWorkspaceID))
|
||||
if (w.get() == pWindow || !w->m_bIsMapped || w->isHidden() || (!w->m_bIsFullscreen && !w->m_bIsFloating) || !isWorkspaceVisible(w->workspaceID()))
|
||||
continue;
|
||||
|
||||
if (pWindow->m_iMonitorID == w->m_iMonitorID && pWindow->m_iWorkspaceID != w->m_iWorkspaceID)
|
||||
if (pWindow->m_iMonitorID == w->m_iMonitorID && pWindow->m_pWorkspace != w->m_pWorkspace)
|
||||
continue;
|
||||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow && !w->m_bIsFullscreen && !w->m_bCreatedOverFullscreen)
|
||||
@@ -1718,7 +1719,7 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableO
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
|
||||
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
if (w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
return w.get();
|
||||
}
|
||||
|
||||
@@ -1726,7 +1727,7 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableO
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
|
||||
if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
if (w.get() != pWindow && w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
return w.get();
|
||||
}
|
||||
|
||||
@@ -1747,7 +1748,7 @@ CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableO
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
|
||||
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
if (w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
return w.get();
|
||||
}
|
||||
|
||||
@@ -1755,7 +1756,7 @@ CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableO
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
|
||||
if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
if (w.get() != pWindow && w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
return w.get();
|
||||
}
|
||||
|
||||
@@ -1772,16 +1773,16 @@ int CCompositor::getNextAvailableNamedWorkspace() {
|
||||
return lowest - 1;
|
||||
}
|
||||
|
||||
CWorkspace* CCompositor::getWorkspaceByName(const std::string& name) {
|
||||
PHLWORKSPACE CCompositor::getWorkspaceByName(const std::string& name) {
|
||||
for (auto& w : m_vWorkspaces) {
|
||||
if (w->m_szName == name)
|
||||
return w.get();
|
||||
if (w->m_szName == name && !w->inert())
|
||||
return w;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) {
|
||||
PHLWORKSPACE CCompositor::getWorkspaceByString(const std::string& str) {
|
||||
if (str.starts_with("name:")) {
|
||||
return getWorkspaceByName(str.substr(str.find_first_of(':') + 1));
|
||||
}
|
||||
@@ -1896,7 +1897,7 @@ void CCompositor::updateAllWindowsAnimatedDecorationValues() {
|
||||
|
||||
void CCompositor::updateWorkspaceWindows(const int64_t& id) {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (!w->m_bIsMapped || w->m_iWorkspaceID != id)
|
||||
if (!w->m_bIsMapped || w->workspaceID() != id)
|
||||
continue;
|
||||
|
||||
w->updateDynamicRules();
|
||||
@@ -1964,7 +1965,7 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
||||
pWindow->m_fBorderAngleAnimationProgress.setValueAndWarp(0.f);
|
||||
|
||||
// opacity
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
const auto PWORKSPACE = pWindow->m_pWorkspace;
|
||||
if (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
|
||||
pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
|
||||
} else {
|
||||
@@ -2020,16 +2021,16 @@ int CCompositor::getNextAvailableMonitorID(std::string const& name) {
|
||||
|
||||
void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB) {
|
||||
|
||||
const auto PWORKSPACEA = g_pCompositor->getWorkspaceByID(pMonitorA->activeWorkspace);
|
||||
const auto PWORKSPACEB = g_pCompositor->getWorkspaceByID(pMonitorB->activeWorkspace);
|
||||
const auto PWORKSPACEA = pMonitorA->activeWorkspace;
|
||||
const auto PWORKSPACEB = pMonitorB->activeWorkspace;
|
||||
|
||||
PWORKSPACEA->m_iMonitorID = pMonitorB->ID;
|
||||
PWORKSPACEA->moveToMonitor(pMonitorB->ID);
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == PWORKSPACEA->m_iID) {
|
||||
if (w->m_pWorkspace == PWORKSPACEA) {
|
||||
if (w->m_bPinned) {
|
||||
w->m_iWorkspaceID = PWORKSPACEB->m_iID;
|
||||
w->m_pWorkspace = PWORKSPACEB;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2052,9 +2053,9 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
|
||||
PWORKSPACEB->moveToMonitor(pMonitorA->ID);
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == PWORKSPACEB->m_iID) {
|
||||
if (w->m_pWorkspace == PWORKSPACEB) {
|
||||
if (w->m_bPinned) {
|
||||
w->m_iWorkspaceID = PWORKSPACEA->m_iID;
|
||||
w->m_pWorkspace = PWORKSPACEA;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2073,8 +2074,8 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
|
||||
}
|
||||
}
|
||||
|
||||
pMonitorA->activeWorkspace = PWORKSPACEB->m_iID;
|
||||
pMonitorB->activeWorkspace = PWORKSPACEA->m_iID;
|
||||
pMonitorA->activeWorkspace = PWORKSPACEB;
|
||||
pMonitorB->activeWorkspace = PWORKSPACEA;
|
||||
|
||||
PWORKSPACEA->rememberPrevWorkspace(PWORKSPACEB);
|
||||
PWORKSPACEB->rememberPrevWorkspace(PWORKSPACEA);
|
||||
@@ -2099,10 +2100,10 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
|
||||
// event
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", PWORKSPACEA->m_szName + "," + pMonitorB->szName});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspacev2", std::format("{},{},{}", PWORKSPACEA->m_iID, PWORKSPACEA->m_szName, pMonitorB->szName)});
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<void*>{PWORKSPACEA, pMonitorB}));
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{PWORKSPACEA, pMonitorB}));
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", PWORKSPACEB->m_szName + "," + pMonitorA->szName});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspacev2", std::format("{},{},{}", PWORKSPACEB->m_iID, PWORKSPACEB->m_szName, pMonitorA->szName)});
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<void*>{PWORKSPACEB, pMonitorA}));
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{PWORKSPACEB, pMonitorA}));
|
||||
}
|
||||
|
||||
CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
|
||||
@@ -2179,9 +2180,9 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMonitor, bool noWarpCursor) {
|
||||
void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, CMonitor* pMonitor, bool noWarpCursor) {
|
||||
|
||||
// We trust the workspace and monitor to be correct.
|
||||
// We trust the monitor to be correct.
|
||||
|
||||
if (pWorkspace->m_iMonitorID == pMonitor->ID)
|
||||
return;
|
||||
@@ -2190,7 +2191,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||
|
||||
const auto POLDMON = getMonitorFromID(pWorkspace->m_iMonitorID);
|
||||
|
||||
const bool SWITCHINGISACTIVE = POLDMON ? POLDMON->activeWorkspace == pWorkspace->m_iID : false;
|
||||
const bool SWITCHINGISACTIVE = POLDMON ? POLDMON->activeWorkspace == pWorkspace : false;
|
||||
|
||||
// fix old mon
|
||||
int nextWorkspaceOnMonitorID = -1;
|
||||
@@ -2227,9 +2228,9 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||
pWorkspace->moveToMonitor(pMonitor->ID);
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
|
||||
if (w->m_pWorkspace == pWorkspace) {
|
||||
if (w->m_bPinned) {
|
||||
w->m_iWorkspaceID = nextWorkspaceOnMonitorID;
|
||||
w->m_pWorkspace = g_pCompositor->getWorkspaceByID(nextWorkspaceOnMonitorID);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2255,13 +2256,13 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||
}
|
||||
|
||||
if (SWITCHINGISACTIVE && POLDMON == g_pCompositor->m_pLastMonitor) { // if it was active, preserve its' status. If it wasn't, don't.
|
||||
Debug::log(LOG, "moveWorkspaceToMonitor: SWITCHINGISACTIVE, active {} -> {}", pMonitor->activeWorkspace, pWorkspace->m_iID);
|
||||
Debug::log(LOG, "moveWorkspaceToMonitor: SWITCHINGISACTIVE, active {} -> {}", pMonitor->activeWorkspaceID(), pWorkspace->m_iID);
|
||||
|
||||
if (const auto PWORKSPACE = getWorkspaceByID(pMonitor->activeWorkspace); PWORKSPACE)
|
||||
getWorkspaceByID(pMonitor->activeWorkspace)->startAnim(false, false);
|
||||
if (valid(pMonitor->activeWorkspace))
|
||||
pMonitor->activeWorkspace->startAnim(false, false);
|
||||
|
||||
setActiveMonitor(pMonitor);
|
||||
pMonitor->activeWorkspace = pWorkspace->m_iID;
|
||||
pMonitor->activeWorkspace = pWorkspace;
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID);
|
||||
|
||||
pWorkspace->startAnim(true, true, true);
|
||||
@@ -2275,7 +2276,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||
// finalize
|
||||
if (POLDMON) {
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
|
||||
updateFullscreenFadeOnWorkspace(getWorkspaceByID(POLDMON->activeWorkspace));
|
||||
updateFullscreenFadeOnWorkspace(POLDMON->activeWorkspace);
|
||||
}
|
||||
|
||||
updateFullscreenFadeOnWorkspace(pWorkspace);
|
||||
@@ -2283,7 +2284,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||
// event
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", pWorkspace->m_szName + "," + pMonitor->szName});
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspacev2", std::format("{},{},{}", pWorkspace->m_iID, pWorkspace->m_szName, pMonitor->szName)});
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<void*>{pWorkspace, pMonitor}));
|
||||
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{pWorkspace, pMonitor}));
|
||||
}
|
||||
|
||||
bool CCompositor::workspaceIDOutOfBounds(const int64_t& id) {
|
||||
@@ -2304,12 +2305,12 @@ bool CCompositor::workspaceIDOutOfBounds(const int64_t& id) {
|
||||
return std::clamp(id, lowestID, highestID) != id;
|
||||
}
|
||||
|
||||
void CCompositor::updateFullscreenFadeOnWorkspace(CWorkspace* pWorkspace) {
|
||||
void CCompositor::updateFullscreenFadeOnWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
|
||||
const auto FULLSCREEN = pWorkspace->m_bHasFullscreenWindow;
|
||||
|
||||
for (auto& w : g_pCompositor->m_vWindows) {
|
||||
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
|
||||
if (w->m_pWorkspace == pWorkspace) {
|
||||
|
||||
if (w->m_bFadingOut || w->m_bPinned || w->m_bIsFullscreen)
|
||||
continue;
|
||||
@@ -2323,7 +2324,7 @@ void CCompositor::updateFullscreenFadeOnWorkspace(CWorkspace* pWorkspace) {
|
||||
|
||||
const auto PMONITOR = getMonitorFromID(pWorkspace->m_iMonitorID);
|
||||
|
||||
if (pWorkspace->m_iID == PMONITOR->activeWorkspace || pWorkspace->m_iID == PMONITOR->specialWorkspaceID) {
|
||||
if (pWorkspace->m_iID == PMONITOR->activeWorkspaceID() || pWorkspace->m_iID == PMONITOR->activeSpecialWorkspaceID()) {
|
||||
for (auto& ls : PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
||||
if (!ls->fadingOut)
|
||||
ls->alpha = FULLSCREEN && pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL ? 0.f : 1.f;
|
||||
@@ -2347,7 +2348,7 @@ void CCompositor::setWindowFullscreen(CWindow* pWindow, bool on, eFullscreenMode
|
||||
|
||||
const auto PMONITOR = getMonitorFromID(pWindow->m_iMonitorID);
|
||||
|
||||
const auto PWORKSPACE = getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
const auto PWORKSPACE = pWindow->m_pWorkspace;
|
||||
|
||||
const auto MODE = mode == FULLSCREEN_INVALID ? PWORKSPACE->m_efFullscreenMode : mode;
|
||||
|
||||
@@ -2364,14 +2365,14 @@ void CCompositor::setWindowFullscreen(CWindow* pWindow, bool on, eFullscreenMode
|
||||
|
||||
// make all windows on the same workspace under the fullscreen window
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == PWORKSPACE->m_iID && !w->m_bIsFullscreen && !w->m_bFadingOut && !w->m_bPinned)
|
||||
if (w->m_pWorkspace == PWORKSPACE && !w->m_bIsFullscreen && !w->m_bFadingOut && !w->m_bPinned)
|
||||
w->m_bCreatedOverFullscreen = false;
|
||||
}
|
||||
updateFullscreenFadeOnWorkspace(PWORKSPACE);
|
||||
|
||||
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goal(), true);
|
||||
|
||||
forceReportSizesToWindowsOnWorkspace(pWindow->m_iWorkspaceID);
|
||||
forceReportSizesToWindowsOnWorkspace(pWindow->workspaceID());
|
||||
|
||||
g_pInputManager->recheckIdleInhibitorStatus();
|
||||
|
||||
@@ -2398,7 +2399,7 @@ CWindow* CCompositor::getX11Parent(CWindow* pWindow) {
|
||||
|
||||
void CCompositor::updateWorkspaceWindowDecos(const int& id) {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID != id)
|
||||
if (w->workspaceID() != id)
|
||||
continue;
|
||||
|
||||
w->updateWindowDecos();
|
||||
@@ -2440,7 +2441,7 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
||||
const bool FLOAT = regexp.starts_with("floating");
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (!w->m_bIsMapped || w->m_bIsFloating != FLOAT || w->m_iWorkspaceID != m_pLastWindow->m_iWorkspaceID || w->isHidden())
|
||||
if (!w->m_bIsMapped || w->m_bIsFloating != FLOAT || w->m_pWorkspace != m_pLastWindow->m_pWorkspace || w->isHidden())
|
||||
continue;
|
||||
|
||||
return w.get();
|
||||
@@ -2608,13 +2609,13 @@ Vector2D CCompositor::parseWindowVectorArgsRelative(const std::string& args, con
|
||||
|
||||
void CCompositor::forceReportSizesToWindowsOnWorkspace(const int& wid) {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_iWorkspaceID == wid && w->m_bIsMapped && !w->isHidden()) {
|
||||
if (w->workspaceID() == wid && w->m_bIsMapped && !w->isHidden()) {
|
||||
g_pXWaylandManager->setWindowSize(w.get(), w->m_vRealSize.value(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, const std::string& name) {
|
||||
PHLWORKSPACE CCompositor::createNewWorkspace(const int& id, const int& monid, const std::string& name) {
|
||||
const auto NAME = name == "" ? std::to_string(id) : name;
|
||||
auto monID = monid;
|
||||
|
||||
@@ -2625,7 +2626,7 @@ CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, con
|
||||
|
||||
const bool SPECIAL = id >= SPECIAL_WORKSPACE_START && id <= -2;
|
||||
|
||||
const auto PWORKSPACE = m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(id, monID, NAME, SPECIAL)).get();
|
||||
const auto PWORKSPACE = m_vWorkspaces.emplace_back(CWorkspace::create(id, monID, NAME, SPECIAL));
|
||||
|
||||
PWORKSPACE->m_fAlpha.setValueAndWarp(0);
|
||||
|
||||
@@ -2656,7 +2657,7 @@ void CCompositor::setActiveMonitor(CMonitor* pMonitor) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto PWORKSPACE = getWorkspaceByID(pMonitor->activeWorkspace);
|
||||
const auto PWORKSPACE = pMonitor->activeWorkspace;
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"focusedmon", pMonitor->szName + "," + (PWORKSPACE ? PWORKSPACE->m_szName : "?")});
|
||||
EMIT_HOOK_EVENT("focusedMon", pMonitor);
|
||||
@@ -2682,7 +2683,7 @@ void CCompositor::performUserChecks() {
|
||||
; // intentional
|
||||
}
|
||||
|
||||
void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace) {
|
||||
void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, PHLWORKSPACE pWorkspace) {
|
||||
if (!pWindow || !pWorkspace)
|
||||
return;
|
||||
|
||||
@@ -2690,17 +2691,17 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
|
||||
return;
|
||||
|
||||
const bool FULLSCREEN = pWindow->m_bIsFullscreen;
|
||||
const auto FULLSCREENMODE = getWorkspaceByID(pWindow->m_iWorkspaceID)->m_efFullscreenMode;
|
||||
const auto FULLSCREENMODE = pWindow->m_pWorkspace->m_efFullscreenMode;
|
||||
|
||||
if (FULLSCREEN)
|
||||
setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
|
||||
|
||||
pWindow->moveToWorkspace(pWorkspace->m_iID);
|
||||
pWindow->moveToWorkspace(pWorkspace);
|
||||
|
||||
if (!pWindow->m_bIsFloating) {
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemovedTiling(pWindow);
|
||||
pWindow->m_iWorkspaceID = pWorkspace->m_iID;
|
||||
pWindow->m_iMonitorID = pWorkspace->m_iMonitorID;
|
||||
pWindow->m_pWorkspace = pWorkspace;
|
||||
pWindow->m_iMonitorID = pWorkspace->m_iMonitorID;
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowCreatedTiling(pWindow);
|
||||
} else {
|
||||
const auto PWINDOWMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||
@@ -2708,8 +2709,8 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
|
||||
|
||||
const auto PWORKSPACEMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
|
||||
|
||||
pWindow->m_iWorkspaceID = pWorkspace->m_iID;
|
||||
pWindow->m_iMonitorID = pWorkspace->m_iMonitorID;
|
||||
pWindow->m_pWorkspace = pWorkspace;
|
||||
pWindow->m_iMonitorID = pWorkspace->m_iMonitorID;
|
||||
|
||||
pWindow->m_vRealPosition = POSTOMON + PWORKSPACEMONITOR->vecPosition;
|
||||
}
|
||||
@@ -2721,7 +2722,7 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
|
||||
if (pWindow->m_sGroupData.pNextWindow) {
|
||||
CWindow* next = pWindow->m_sGroupData.pNextWindow;
|
||||
while (next != pWindow) {
|
||||
next->moveToWorkspace(pWorkspace->m_iID);
|
||||
next->moveToWorkspace(pWorkspace);
|
||||
next->updateToplevel();
|
||||
next = next->m_sGroupData.pNextWindow;
|
||||
}
|
||||
@@ -2731,12 +2732,12 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
|
||||
setWindowFullscreen(pWindow, true, FULLSCREENMODE);
|
||||
|
||||
g_pCompositor->updateWorkspaceWindows(pWorkspace->m_iID);
|
||||
g_pCompositor->updateWorkspaceWindows(pWindow->m_iWorkspaceID);
|
||||
g_pCompositor->updateWorkspaceWindows(pWindow->workspaceID());
|
||||
}
|
||||
|
||||
CWindow* CCompositor::getForceFocus() {
|
||||
for (auto& w : m_vWindows) {
|
||||
if (!w->m_bIsMapped || w->isHidden() || !isWorkspaceVisible(w->m_iWorkspaceID))
|
||||
if (!w->m_bIsMapped || w->isHidden() || !isWorkspaceVisible(w->workspaceID()))
|
||||
continue;
|
||||
|
||||
if (!w->m_bStayFocused)
|
||||
@@ -2885,6 +2886,6 @@ void CCompositor::updateSuspendedStates() {
|
||||
if (!w->m_bIsMapped)
|
||||
continue;
|
||||
|
||||
w->setSuspended(w->isHidden() || !isWorkspaceVisible(w->m_iWorkspaceID));
|
||||
w->setSuspended(w->isHidden() || !isWorkspaceVisible(w->workspaceID()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user