refactor workspaces to use ptrs

This commit is contained in:
Vaxry 2024-04-02 03:29:48 +01:00
parent 2e5b146e57
commit b07ca870a4
37 changed files with 506 additions and 466 deletions

View file

@ -751,20 +751,20 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
auto floating = [&](bool aboveFullscreen) -> CWindow* { auto floating = [&](bool aboveFullscreen) -> CWindow* {
for (auto& w : m_vWindows | std::views::reverse) { 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; continue;
const auto BB = w->getWindowBoxUnified(properties); const auto BB = w->getWindowBoxUnified(properties);
const auto PWINDOWMONITOR = getMonitorFromID(w->m_iMonitorID); const auto PWINDOWMONITOR = getMonitorFromID(w->m_iMonitorID);
// to avoid focusing windows behind special workspaces from other monitors // 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 >= 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) BB.x + BB.width <= PWINDOWMONITOR->vecPosition.x + PWINDOWMONITOR->vecSize.x && BB.y + BB.height <= PWINDOWMONITOR->vecPosition.y + PWINDOWMONITOR->vecSize.y)
continue; 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}; 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)) { w.get() != pIgnoreWindow && (!aboveFullscreen || w->m_bCreatedOverFullscreen)) {
// OR windows should add focus to parent // OR windows should add focus to parent
if (w->m_bX11ShouldntFocus && w->m_iX11Type != 2) 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) if (properties & FLOATING_ONLY)
return floating(false); 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); const auto PWORKSPACE = getWorkspaceByID(WORKSPACEID);
if (PWORKSPACE->m_bHasFullscreenWindow) 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 windows, we need to check their extensions too, first.
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (special != isWorkspaceSpecial(w->m_iWorkspaceID)) if (special != w->onSpecialWorkspace())
continue; 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) { !w->m_sAdditionalConfigData.noFocus && w.get() != pIgnoreWindow) {
if (w->hasPopupAt(pos)) if (w->hasPopupAt(pos))
return w.get(); return w.get();
@ -824,11 +824,11 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
} }
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (special != isWorkspaceSpecial(w->m_iWorkspaceID)) if (special != w->onSpecialWorkspace())
continue; continue;
CBox box = (properties & USE_PROP_TILED) ? w->getWindowBoxUnified(properties) : CBox{w->m_vPosition, w->m_vSize}; 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) !w->m_sAdditionalConfigData.noFocus && w.get() != pIgnoreWindow)
return w.get(); return w.get();
} }
@ -837,10 +837,10 @@ CWindow* CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t propert
}; };
// special workspace // special workspace
if (PMONITOR->specialWorkspaceID && !*PSPECIALFALLTHRU) if (PMONITOR->activeSpecialWorkspace && !*PSPECIALFALLTHRU)
return windowForWorkspace(true); return windowForWorkspace(true);
if (PMONITOR->specialWorkspaceID) { if (PMONITOR->activeSpecialWorkspace) {
const auto PWINDOW = windowForWorkspace(true); const auto PWINDOW = windowForWorkspace(true);
if (PWINDOW) if (PWINDOW)
@ -997,15 +997,15 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
return; return;
if (pWindow->m_bPinned) if (pWindow->m_bPinned)
pWindow->m_iWorkspaceID = m_pLastMonitor->activeWorkspace; pWindow->m_pWorkspace = m_pLastMonitor->activeWorkspace;
const auto PMONITOR = getMonitorFromID(pWindow->m_iMonitorID); const auto PMONITOR = getMonitorFromID(pWindow->m_iMonitorID);
if (!isWorkspaceVisible(pWindow->m_iWorkspaceID)) { if (!isWorkspaceVisible(pWindow->workspaceID())) {
const auto PWORKSPACE = getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
// This is to fix incorrect feedback on the focus history. // This is to fix incorrect feedback on the focus history.
PWORKSPACE->m_pLastFocusedWindow = pWindow; PWORKSPACE->m_pLastFocusedWindow = pWindow;
PWORKSPACE->rememberPrevWorkspace(getWorkspaceByID(m_pLastMonitor->activeWorkspace)); PWORKSPACE->rememberPrevWorkspace(m_pLastMonitor->activeWorkspace);
PMONITOR->changeWorkspace(PWORKSPACE, false, true); PMONITOR->changeWorkspace(PWORKSPACE, false, true);
// changeworkspace already calls focusWindow // changeworkspace already calls focusWindow
return; 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 /* 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. */ 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); PMONITOR->setSpecialWorkspace(nullptr);
// we need to make the PLASTWINDOW not equal to m_pLastWindow so that RENDERDATA is correct for an unfocused window // 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) { CWindow* CCompositor::getFullscreenWindowOnWorkspace(const int& ID) {
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == ID && w->m_bIsFullscreen) if (w->workspaceID() == ID && w->m_bIsFullscreen)
return w.get(); return w.get();
} }
@ -1242,20 +1242,20 @@ CWindow* CCompositor::getFullscreenWindowOnWorkspace(const int& ID) {
bool CCompositor::isWorkspaceVisible(const int& w) { bool CCompositor::isWorkspaceVisible(const int& w) {
for (auto& m : m_vMonitors) { for (auto& m : m_vMonitors) {
if (m->activeWorkspace == w) if (m->activeWorkspaceID() == w)
return true; return true;
if (m->specialWorkspaceID == w) if (m->activeSpecialWorkspaceID() == w)
return true; return true;
} }
return false; return false;
} }
CWorkspace* CCompositor::getWorkspaceByID(const int& id) { PHLWORKSPACE CCompositor::getWorkspaceByID(const int& id) {
for (auto& w : m_vWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w->m_iID == id) if (w->m_iID == id && !w->inert())
return w.get(); return w;
} }
return nullptr; return nullptr;
@ -1265,7 +1265,7 @@ void CCompositor::sanityCheckWorkspaces() {
auto it = m_vWorkspaces.begin(); auto it = m_vWorkspaces.begin();
while (it != m_vWorkspaces.end()) { while (it != m_vWorkspaces.end()) {
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(it->get()); const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(*it);
bool isPersistent = false; bool isPersistent = false;
for (auto& wsRule : WORKSPACERULES) { for (auto& wsRule : WORKSPACERULES) {
if (wsRule.isPersistent) if (wsRule.isPersistent)
@ -1290,10 +1290,11 @@ void CCompositor::sanityCheckWorkspaces() {
const auto PMONITOR = getMonitorFromID(WORKSPACE->m_iMonitorID); const auto PMONITOR = getMonitorFromID(WORKSPACE->m_iMonitorID);
if (PMONITOR && PMONITOR->specialWorkspaceID == WORKSPACE->m_iID) if (PMONITOR && PMONITOR->activeSpecialWorkspace == WORKSPACE)
PMONITOR->setSpecialWorkspace(nullptr); PMONITOR->setSpecialWorkspace(nullptr);
} }
it->get()->markInert();
it = m_vWorkspaces.erase(it); it = m_vWorkspaces.erase(it);
continue; continue;
} }
@ -1314,7 +1315,7 @@ void CCompositor::sanityCheckWorkspaces() {
int CCompositor::getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled) { int CCompositor::getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled) {
int no = 0; int no = 0;
for (auto& w : m_vWindows) { 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++; no++;
} }
@ -1332,7 +1333,7 @@ CWindow* CCompositor::getUrgentWindow() {
bool CCompositor::hasUrgentWindowOnWorkspace(const int& id) { bool CCompositor::hasUrgentWindowOnWorkspace(const int& id) {
for (auto& w : m_vWindows) { 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; return true;
} }
@ -1341,7 +1342,7 @@ bool CCompositor::hasUrgentWindowOnWorkspace(const int& id) {
CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) { CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) {
for (auto& w : m_vWindows) { 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(); return w.get();
} }
@ -1357,7 +1358,7 @@ CWindow* CCompositor::getTopLeftWindowOnWorkspace(const int& id) {
const auto PMONITOR = getMonitorFromID(PWORKSPACE->m_iMonitorID); const auto PMONITOR = getMonitorFromID(PWORKSPACE->m_iMonitorID);
for (auto& w : m_vWindows) { 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; continue;
const auto WINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved(); 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 POSA = Vector2D(WINDOWIDEALBB.x, WINDOWIDEALBB.y);
const auto SIZEA = Vector2D(WINDOWIDEALBB.width, WINDOWIDEALBB.height); 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; auto leaderValue = -1;
CWindow* leaderWindow = nullptr; CWindow* leaderWindow = nullptr;
@ -1583,10 +1584,10 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
// for tiled windows, we calc edges // for tiled windows, we calc edges
for (auto& w : m_vWindows) { 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; 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; continue;
if (PWORKSPACE->m_bHasFullscreenWindow && !w->m_bIsFullscreen && !w->m_bCreatedOverFullscreen) 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; constexpr float THRESHOLD = 0.3 * M_PI;
for (auto& w : m_vWindows) { 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; 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; continue;
if (PWORKSPACE->m_bHasFullscreenWindow && !w->m_bIsFullscreen && !w->m_bCreatedOverFullscreen) 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()) if (floating.has_value() && w->m_bIsFloating != floating.value())
continue; 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(); return w.get();
} }
@ -1726,7 +1727,7 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableO
if (floating.has_value() && w->m_bIsFloating != floating.value()) if (floating.has_value() && w->m_bIsFloating != floating.value())
continue; 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(); return w.get();
} }
@ -1747,7 +1748,7 @@ CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableO
if (floating.has_value() && w->m_bIsFloating != floating.value()) if (floating.has_value() && w->m_bIsFloating != floating.value())
continue; 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(); return w.get();
} }
@ -1755,7 +1756,7 @@ CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableO
if (floating.has_value() && w->m_bIsFloating != floating.value()) if (floating.has_value() && w->m_bIsFloating != floating.value())
continue; 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(); return w.get();
} }
@ -1772,16 +1773,16 @@ int CCompositor::getNextAvailableNamedWorkspace() {
return lowest - 1; return lowest - 1;
} }
CWorkspace* CCompositor::getWorkspaceByName(const std::string& name) { PHLWORKSPACE CCompositor::getWorkspaceByName(const std::string& name) {
for (auto& w : m_vWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w->m_szName == name) if (w->m_szName == name && !w->inert())
return w.get(); return w;
} }
return nullptr; return nullptr;
} }
CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) { PHLWORKSPACE CCompositor::getWorkspaceByString(const std::string& str) {
if (str.starts_with("name:")) { if (str.starts_with("name:")) {
return getWorkspaceByName(str.substr(str.find_first_of(':') + 1)); return getWorkspaceByName(str.substr(str.find_first_of(':') + 1));
} }
@ -1896,7 +1897,7 @@ void CCompositor::updateAllWindowsAnimatedDecorationValues() {
void CCompositor::updateWorkspaceWindows(const int64_t& id) { void CCompositor::updateWorkspaceWindows(const int64_t& id) {
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (!w->m_bIsMapped || w->m_iWorkspaceID != id) if (!w->m_bIsMapped || w->workspaceID() != id)
continue; continue;
w->updateDynamicRules(); w->updateDynamicRules();
@ -1964,7 +1965,7 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
pWindow->m_fBorderAngleAnimationProgress.setValueAndWarp(0.f); pWindow->m_fBorderAngleAnimationProgress.setValueAndWarp(0.f);
// opacity // 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) { if (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA; pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
} else { } else {
@ -2020,16 +2021,16 @@ int CCompositor::getNextAvailableMonitorID(std::string const& name) {
void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB) { void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB) {
const auto PWORKSPACEA = g_pCompositor->getWorkspaceByID(pMonitorA->activeWorkspace); const auto PWORKSPACEA = pMonitorA->activeWorkspace;
const auto PWORKSPACEB = g_pCompositor->getWorkspaceByID(pMonitorB->activeWorkspace); const auto PWORKSPACEB = pMonitorB->activeWorkspace;
PWORKSPACEA->m_iMonitorID = pMonitorB->ID; PWORKSPACEA->m_iMonitorID = pMonitorB->ID;
PWORKSPACEA->moveToMonitor(pMonitorB->ID); PWORKSPACEA->moveToMonitor(pMonitorB->ID);
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == PWORKSPACEA->m_iID) { if (w->m_pWorkspace == PWORKSPACEA) {
if (w->m_bPinned) { if (w->m_bPinned) {
w->m_iWorkspaceID = PWORKSPACEB->m_iID; w->m_pWorkspace = PWORKSPACEB;
continue; continue;
} }
@ -2052,9 +2053,9 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
PWORKSPACEB->moveToMonitor(pMonitorA->ID); PWORKSPACEB->moveToMonitor(pMonitorA->ID);
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == PWORKSPACEB->m_iID) { if (w->m_pWorkspace == PWORKSPACEB) {
if (w->m_bPinned) { if (w->m_bPinned) {
w->m_iWorkspaceID = PWORKSPACEA->m_iID; w->m_pWorkspace = PWORKSPACEA;
continue; continue;
} }
@ -2073,8 +2074,8 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
} }
} }
pMonitorA->activeWorkspace = PWORKSPACEB->m_iID; pMonitorA->activeWorkspace = PWORKSPACEB;
pMonitorB->activeWorkspace = PWORKSPACEA->m_iID; pMonitorB->activeWorkspace = PWORKSPACEA;
PWORKSPACEA->rememberPrevWorkspace(PWORKSPACEB); PWORKSPACEA->rememberPrevWorkspace(PWORKSPACEB);
PWORKSPACEB->rememberPrevWorkspace(PWORKSPACEA); PWORKSPACEB->rememberPrevWorkspace(PWORKSPACEA);
@ -2099,10 +2100,10 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
// event // event
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", PWORKSPACEA->m_szName + "," + pMonitorB->szName}); 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)}); 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{"moveworkspace", PWORKSPACEB->m_szName + "," + pMonitorA->szName});
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspacev2", std::format("{},{},{}", PWORKSPACEB->m_iID, 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) { CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
@ -2179,9 +2180,9 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
return nullptr; 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) if (pWorkspace->m_iMonitorID == pMonitor->ID)
return; return;
@ -2190,7 +2191,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
const auto POLDMON = getMonitorFromID(pWorkspace->m_iMonitorID); 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 // fix old mon
int nextWorkspaceOnMonitorID = -1; int nextWorkspaceOnMonitorID = -1;
@ -2227,9 +2228,9 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
pWorkspace->moveToMonitor(pMonitor->ID); pWorkspace->moveToMonitor(pMonitor->ID);
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == pWorkspace->m_iID) { if (w->m_pWorkspace == pWorkspace) {
if (w->m_bPinned) { if (w->m_bPinned) {
w->m_iWorkspaceID = nextWorkspaceOnMonitorID; w->m_pWorkspace = g_pCompositor->getWorkspaceByID(nextWorkspaceOnMonitorID);
continue; 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. 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) if (valid(pMonitor->activeWorkspace))
getWorkspaceByID(pMonitor->activeWorkspace)->startAnim(false, false); pMonitor->activeWorkspace->startAnim(false, false);
setActiveMonitor(pMonitor); setActiveMonitor(pMonitor);
pMonitor->activeWorkspace = pWorkspace->m_iID; pMonitor->activeWorkspace = pWorkspace;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID);
pWorkspace->startAnim(true, true, true); pWorkspace->startAnim(true, true, true);
@ -2275,7 +2276,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
// finalize // finalize
if (POLDMON) { if (POLDMON) {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
updateFullscreenFadeOnWorkspace(getWorkspaceByID(POLDMON->activeWorkspace)); updateFullscreenFadeOnWorkspace(POLDMON->activeWorkspace);
} }
updateFullscreenFadeOnWorkspace(pWorkspace); updateFullscreenFadeOnWorkspace(pWorkspace);
@ -2283,7 +2284,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
// event // event
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", pWorkspace->m_szName + "," + pMonitor->szName}); 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)}); 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) { 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; return std::clamp(id, lowestID, highestID) != id;
} }
void CCompositor::updateFullscreenFadeOnWorkspace(CWorkspace* pWorkspace) { void CCompositor::updateFullscreenFadeOnWorkspace(PHLWORKSPACE pWorkspace) {
const auto FULLSCREEN = pWorkspace->m_bHasFullscreenWindow; const auto FULLSCREEN = pWorkspace->m_bHasFullscreenWindow;
for (auto& w : g_pCompositor->m_vWindows) { 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) if (w->m_bFadingOut || w->m_bPinned || w->m_bIsFullscreen)
continue; continue;
@ -2323,7 +2324,7 @@ void CCompositor::updateFullscreenFadeOnWorkspace(CWorkspace* pWorkspace) {
const auto PMONITOR = getMonitorFromID(pWorkspace->m_iMonitorID); 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]) { for (auto& ls : PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
if (!ls->fadingOut) if (!ls->fadingOut)
ls->alpha = FULLSCREEN && pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL ? 0.f : 1.f; 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 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; 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 // make all windows on the same workspace under the fullscreen window
for (auto& w : m_vWindows) { 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; w->m_bCreatedOverFullscreen = false;
} }
updateFullscreenFadeOnWorkspace(PWORKSPACE); updateFullscreenFadeOnWorkspace(PWORKSPACE);
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goal(), true); g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goal(), true);
forceReportSizesToWindowsOnWorkspace(pWindow->m_iWorkspaceID); forceReportSizesToWindowsOnWorkspace(pWindow->workspaceID());
g_pInputManager->recheckIdleInhibitorStatus(); g_pInputManager->recheckIdleInhibitorStatus();
@ -2398,7 +2399,7 @@ CWindow* CCompositor::getX11Parent(CWindow* pWindow) {
void CCompositor::updateWorkspaceWindowDecos(const int& id) { void CCompositor::updateWorkspaceWindowDecos(const int& id) {
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID != id) if (w->workspaceID() != id)
continue; continue;
w->updateWindowDecos(); w->updateWindowDecos();
@ -2440,7 +2441,7 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
const bool FLOAT = regexp.starts_with("floating"); const bool FLOAT = regexp.starts_with("floating");
for (auto& w : m_vWindows) { 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; continue;
return w.get(); return w.get();
@ -2608,13 +2609,13 @@ Vector2D CCompositor::parseWindowVectorArgsRelative(const std::string& args, con
void CCompositor::forceReportSizesToWindowsOnWorkspace(const int& wid) { void CCompositor::forceReportSizesToWindowsOnWorkspace(const int& wid) {
for (auto& w : m_vWindows) { 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); 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; const auto NAME = name == "" ? std::to_string(id) : name;
auto monID = monid; 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 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); PWORKSPACE->m_fAlpha.setValueAndWarp(0);
@ -2656,7 +2657,7 @@ void CCompositor::setActiveMonitor(CMonitor* pMonitor) {
return; return;
} }
const auto PWORKSPACE = getWorkspaceByID(pMonitor->activeWorkspace); const auto PWORKSPACE = pMonitor->activeWorkspace;
g_pEventManager->postEvent(SHyprIPCEvent{"focusedmon", pMonitor->szName + "," + (PWORKSPACE ? PWORKSPACE->m_szName : "?")}); g_pEventManager->postEvent(SHyprIPCEvent{"focusedmon", pMonitor->szName + "," + (PWORKSPACE ? PWORKSPACE->m_szName : "?")});
EMIT_HOOK_EVENT("focusedMon", pMonitor); EMIT_HOOK_EVENT("focusedMon", pMonitor);
@ -2682,7 +2683,7 @@ void CCompositor::performUserChecks() {
; // intentional ; // intentional
} }
void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace) { void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, PHLWORKSPACE pWorkspace) {
if (!pWindow || !pWorkspace) if (!pWindow || !pWorkspace)
return; return;
@ -2690,16 +2691,16 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
return; return;
const bool FULLSCREEN = pWindow->m_bIsFullscreen; 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) if (FULLSCREEN)
setWindowFullscreen(pWindow, false, FULLSCREEN_FULL); setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
pWindow->moveToWorkspace(pWorkspace->m_iID); pWindow->moveToWorkspace(pWorkspace);
if (!pWindow->m_bIsFloating) { if (!pWindow->m_bIsFloating) {
g_pLayoutManager->getCurrentLayout()->onWindowRemovedTiling(pWindow); g_pLayoutManager->getCurrentLayout()->onWindowRemovedTiling(pWindow);
pWindow->m_iWorkspaceID = pWorkspace->m_iID; pWindow->m_pWorkspace = pWorkspace;
pWindow->m_iMonitorID = pWorkspace->m_iMonitorID; pWindow->m_iMonitorID = pWorkspace->m_iMonitorID;
g_pLayoutManager->getCurrentLayout()->onWindowCreatedTiling(pWindow); g_pLayoutManager->getCurrentLayout()->onWindowCreatedTiling(pWindow);
} else { } else {
@ -2708,7 +2709,7 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
const auto PWORKSPACEMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); const auto PWORKSPACEMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
pWindow->m_iWorkspaceID = pWorkspace->m_iID; pWindow->m_pWorkspace = pWorkspace;
pWindow->m_iMonitorID = pWorkspace->m_iMonitorID; pWindow->m_iMonitorID = pWorkspace->m_iMonitorID;
pWindow->m_vRealPosition = POSTOMON + PWORKSPACEMONITOR->vecPosition; pWindow->m_vRealPosition = POSTOMON + PWORKSPACEMONITOR->vecPosition;
@ -2721,7 +2722,7 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
if (pWindow->m_sGroupData.pNextWindow) { if (pWindow->m_sGroupData.pNextWindow) {
CWindow* next = pWindow->m_sGroupData.pNextWindow; CWindow* next = pWindow->m_sGroupData.pNextWindow;
while (next != pWindow) { while (next != pWindow) {
next->moveToWorkspace(pWorkspace->m_iID); next->moveToWorkspace(pWorkspace);
next->updateToplevel(); next->updateToplevel();
next = next->m_sGroupData.pNextWindow; next = next->m_sGroupData.pNextWindow;
} }
@ -2731,12 +2732,12 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
setWindowFullscreen(pWindow, true, FULLSCREENMODE); setWindowFullscreen(pWindow, true, FULLSCREENMODE);
g_pCompositor->updateWorkspaceWindows(pWorkspace->m_iID); g_pCompositor->updateWorkspaceWindows(pWorkspace->m_iID);
g_pCompositor->updateWorkspaceWindows(pWindow->m_iWorkspaceID); g_pCompositor->updateWorkspaceWindows(pWindow->workspaceID());
} }
CWindow* CCompositor::getForceFocus() { CWindow* CCompositor::getForceFocus() {
for (auto& w : m_vWindows) { 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; continue;
if (!w->m_bStayFocused) if (!w->m_bStayFocused)
@ -2885,6 +2886,6 @@ void CCompositor::updateSuspendedStates() {
if (!w->m_bIsMapped) if (!w->m_bIsMapped)
continue; continue;
w->setSuspended(w->isHidden() || !isWorkspaceVisible(w->m_iWorkspaceID)); w->setSuspended(w->isHidden() || !isWorkspaceVisible(w->workspaceID()));
} }
} }

View file

@ -92,7 +92,7 @@ class CCompositor {
std::vector<std::shared_ptr<CMonitor>> m_vMonitors; std::vector<std::shared_ptr<CMonitor>> m_vMonitors;
std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
std::vector<std::unique_ptr<CWindow>> m_vWindows; std::vector<std::unique_ptr<CWindow>> m_vWindows;
std::vector<std::unique_ptr<CWorkspace>> m_vWorkspaces; std::vector<PHLWORKSPACE> m_vWorkspaces;
std::vector<CWindow*> m_vWindowsFadingOut; std::vector<CWindow*> m_vWindowsFadingOut;
std::vector<SLayerSurface*> m_vSurfacesFadingOut; std::vector<SLayerSurface*> m_vSurfacesFadingOut;
@ -145,9 +145,9 @@ class CCompositor {
CWindow* getWindowFromHandle(uint32_t); CWindow* getWindowFromHandle(uint32_t);
CWindow* getWindowFromZWLRHandle(wl_resource*); CWindow* getWindowFromZWLRHandle(wl_resource*);
bool isWorkspaceVisible(const int&); bool isWorkspaceVisible(const int&);
CWorkspace* getWorkspaceByID(const int&); PHLWORKSPACE getWorkspaceByID(const int&);
CWorkspace* getWorkspaceByName(const std::string&); PHLWORKSPACE getWorkspaceByName(const std::string&);
CWorkspace* getWorkspaceByString(const std::string&); PHLWORKSPACE getWorkspaceByString(const std::string&);
void sanityCheckWorkspaces(); void sanityCheckWorkspaces();
void updateWorkspaceWindowDecos(const int&); void updateWorkspaceWindowDecos(const int&);
int getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {}); int getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {});
@ -172,12 +172,12 @@ class CCompositor {
void updateWorkspaceWindows(const int64_t& id); void updateWorkspaceWindows(const int64_t& id);
void updateWindowAnimatedDecorationValues(CWindow*); void updateWindowAnimatedDecorationValues(CWindow*);
int getNextAvailableMonitorID(std::string const& name); int getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*, bool noWarpCursor = false); void moveWorkspaceToMonitor(PHLWORKSPACE, CMonitor*, bool noWarpCursor = false);
void swapActiveWorkspaces(CMonitor*, CMonitor*); void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&); CMonitor* getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const int64_t&); bool workspaceIDOutOfBounds(const int64_t&);
void setWindowFullscreen(CWindow*, bool, eFullscreenMode mode = FULLSCREEN_INVALID); void setWindowFullscreen(CWindow*, bool, eFullscreenMode mode = FULLSCREEN_INVALID);
void updateFullscreenFadeOnWorkspace(CWorkspace*); void updateFullscreenFadeOnWorkspace(PHLWORKSPACE);
CWindow* getX11Parent(CWindow*); CWindow* getX11Parent(CWindow*);
void scheduleFrameForMonitor(CMonitor*); void scheduleFrameForMonitor(CMonitor*);
void addToFadingOutSafe(SLayerSurface*); void addToFadingOutSafe(SLayerSurface*);
@ -189,13 +189,13 @@ class CCompositor {
void closeWindow(CWindow*); void closeWindow(CWindow*);
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&); Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
void forceReportSizesToWindowsOnWorkspace(const int&); void forceReportSizesToWindowsOnWorkspace(const int&);
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused! PHLWORKSPACE createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
void renameWorkspace(const int&, const std::string& name = ""); void renameWorkspace(const int&, const std::string& name = "");
void setActiveMonitor(CMonitor*); void setActiveMonitor(CMonitor*);
bool isWorkspaceSpecial(const int&); bool isWorkspaceSpecial(const int&);
int getNewSpecialID(); int getNewSpecialID();
void performUserChecks(); void performUserChecks();
void moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace); void moveWindowToWorkspaceSafe(CWindow* pWindow, PHLWORKSPACE pWorkspace);
CWindow* getForceFocus(); CWindow* getForceFocus();
void notifyIdleActivity(); void notifyIdleActivity();
void setIdleActivityInhibit(bool inhibit); void setIdleActivityInhibit(bool inhibit);

View file

@ -956,7 +956,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const CMonitor& PMONITOR) {
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-INT32_MAX, -INT32_MAX), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-INT32_MAX, -INT32_MAX), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
} }
std::vector<SWorkspaceRule> CConfigManager::getWorkspaceRulesFor(CWorkspace* pWorkspace) { std::vector<SWorkspaceRule> CConfigManager::getWorkspaceRulesFor(PHLWORKSPACE pWorkspace) {
std::vector<SWorkspaceRule> results; std::vector<SWorkspaceRule> results;
for (auto& rule : m_dWorkspaceRules) { for (auto& rule : m_dWorkspaceRules) {
if (pWorkspace->matchesStaticSelector(rule.workspaceString)) if (pWorkspace->matchesStaticSelector(rule.workspaceString))
@ -1056,13 +1056,13 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow, bool
} }
if (!rule.szOnWorkspace.empty()) { if (!rule.szOnWorkspace.empty()) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
if (!PWORKSPACE || !PWORKSPACE->matchesStaticSelector(rule.szOnWorkspace)) if (!PWORKSPACE || !PWORKSPACE->matchesStaticSelector(rule.szOnWorkspace))
continue; continue;
} }
if (!rule.szWorkspace.empty()) { if (!rule.szWorkspace.empty()) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
if (!PWORKSPACE) if (!PWORKSPACE)
continue; continue;
@ -1287,7 +1287,7 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
/* fullscreen */ /* fullscreen */
m->vrrActive = true; m->vrrActive = true;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m->activeWorkspace); const auto PWORKSPACE = m->activeWorkspace;
if (!PWORKSPACE) if (!PWORKSPACE)
return; // ??? return; // ???

View file

@ -105,7 +105,7 @@ class CConfigManager {
static std::string getMainConfigPath(); static std::string getMainConfigPath();
SMonitorRule getMonitorRuleFor(const CMonitor&); SMonitorRule getMonitorRuleFor(const CMonitor&);
std::vector<SWorkspaceRule> getWorkspaceRulesFor(CWorkspace*); std::vector<SWorkspaceRule> getWorkspaceRulesFor(PHLWORKSPACE workspace);
std::string getDefaultWorkspaceFor(const std::string&); std::string getDefaultWorkspaceFor(const std::string&);
CMonitor* getBoundMonitorForWS(const std::string&); CMonitor* getBoundMonitorForWS(const std::string&);

View file

@ -24,15 +24,6 @@ static void trimTrailingComma(std::string& str) {
str.pop_back(); str.pop_back();
} }
static std::string getWorkspaceNameFromSpecialID(const int workspaceID) {
if (workspaceID == 0)
return "";
const auto* workspace = g_pCompositor->getWorkspaceByID(workspaceID);
if (!workspace)
return "";
return workspace->m_szName;
}
static std::string formatToString(uint32_t drmFormat) { static std::string formatToString(uint32_t drmFormat) {
switch (drmFormat) { switch (drmFormat) {
case DRM_FORMAT_XRGB2101010: return "XRGB2101010"; case DRM_FORMAT_XRGB2101010: return "XRGB2101010";
@ -116,8 +107,8 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
}},)#", }},)#",
m->ID, escapeJSONStrings(m->szName), escapeJSONStrings(m->szShortDescription), (m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""), m->ID, escapeJSONStrings(m->szName), escapeJSONStrings(m->szShortDescription), (m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""),
(m->output->serial ? m->output->serial : ""), (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, (m->output->serial ? m->output->serial : ""), (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y,
m->activeWorkspace, (m->activeWorkspace == -1 ? "" : escapeJSONStrings(g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName)), m->specialWorkspaceID, m->activeWorkspaceID(), (!m->activeWorkspace ? "" : escapeJSONStrings(m->activeWorkspace->m_szName)), m->activeSpecialWorkspaceID() ,
escapeJSONStrings(getWorkspaceNameFromSpecialID(m->specialWorkspaceID)), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, escapeJSONStrings(m->activeSpecialWorkspace ? m->activeSpecialWorkspace->m_szName : ""), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y,
(int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "true" : "false"), (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "true" : "false"),
(m->dpmsStatus ? "true" : "false"), (m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED ? "true" : "false"), (m->dpmsStatus ? "true" : "false"), (m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED ? "true" : "false"),
m->tearingState.activelyTearing ? "true" : "false", formatToString(m->drmFormat), availableModesForOutput(m.get(), format)); m->tearingState.activelyTearing ? "true" : "false", formatToString(m->drmFormat), availableModesForOutput(m.get(), format));
@ -137,9 +128,9 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) {
"{} {} {}\n\tscale: {:.2f}\n\ttransform: " "{} {} {}\n\tscale: {:.2f}\n\ttransform: "
"{}\n\tfocused: {}\n\tdpmsStatus: {}\n\tvrr: {}\n\tactivelyTearing: {}\n\tcurrentFormat: {}\n\tavailableModes: {}\n\n", "{}\n\tfocused: {}\n\tdpmsStatus: {}\n\tvrr: {}\n\tactivelyTearing: {}\n\tcurrentFormat: {}\n\tavailableModes: {}\n\n",
m->szName, m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->szShortDescription, m->szName, m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->szShortDescription,
(m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""), (m->output->serial ? m->output->serial : ""), m->activeWorkspace, (m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""), (m->output->serial ? m->output->serial : ""), m->activeWorkspaceID(),
(m->activeWorkspace == -1 ? "" : g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName), m->specialWorkspaceID, (!m->activeWorkspace ? "" : m->activeWorkspace->m_szName), m->activeSpecialWorkspaceID(),
getWorkspaceNameFromSpecialID(m->specialWorkspaceID), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (m->activeSpecialWorkspace ? m->activeSpecialWorkspace->m_szName : ""), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x,
(int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus,
(int)(m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED), m->tearingState.activelyTearing, formatToString(m->drmFormat), (int)(m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED), m->tearingState.activelyTearing, formatToString(m->drmFormat),
availableModesForOutput(m.get(), format)); availableModesForOutput(m.get(), format));
@ -211,14 +202,12 @@ static std::string getWindowData(CWindow* w, eHyprCtlOutputFormat format) {
"focusHistoryID": {} "focusHistoryID": {}
}},)#", }},)#",
(uintptr_t)w, (w->m_bIsMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), (int)w->m_vRealPosition.goal().x, (int)w->m_vRealPosition.goal().y, (uintptr_t)w, (w->m_bIsMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), (int)w->m_vRealPosition.goal().x, (int)w->m_vRealPosition.goal().y,
(int)w->m_vRealSize.goal().x, (int)w->m_vRealSize.goal().y, w->m_iWorkspaceID, (int)w->m_vRealSize.goal().x, (int)w->m_vRealSize.goal().y, w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID,
escapeJSONStrings(w->m_iWorkspaceID == -1 ? "" : escapeJSONStrings(!w->m_pWorkspace ? "" : w->m_pWorkspace->m_szName),
g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName :
std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID))),
((int)w->m_bIsFloating == 1 ? "true" : "false"), (int64_t)w->m_iMonitorID, escapeJSONStrings(g_pXWaylandManager->getAppIDClass(w)), ((int)w->m_bIsFloating == 1 ? "true" : "false"), (int64_t)w->m_iMonitorID, escapeJSONStrings(g_pXWaylandManager->getAppIDClass(w)),
escapeJSONStrings(g_pXWaylandManager->getTitle(w)), escapeJSONStrings(w->m_szInitialClass), escapeJSONStrings(w->m_szInitialTitle), w->getPID(), escapeJSONStrings(g_pXWaylandManager->getTitle(w)), escapeJSONStrings(w->m_szInitialClass), escapeJSONStrings(w->m_szInitialTitle), w->getPID(),
((int)w->m_bIsX11 == 1 ? "true" : "false"), (w->m_bPinned ? "true" : "false"), (w->m_bIsFullscreen ? "true" : "false"), ((int)w->m_bIsX11 == 1 ? "true" : "false"), (w->m_bPinned ? "true" : "false"), (w->m_bIsFullscreen ? "true" : "false"),
(w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? (int)g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0), (w->m_bIsFullscreen ? (w->m_pWorkspace ? (int)w->m_pWorkspace->m_efFullscreenMode : 0) : 0),
w->m_bFakeFullscreenState ? "true" : "false", getGroupedData(w, format), (uintptr_t)w->m_pSwallowed, getFocusHistoryID(w)); w->m_bFakeFullscreenState ? "true" : "false", getGroupedData(w, format), (uintptr_t)w->m_pSwallowed, getFocusHistoryID(w));
} else { } else {
return std::format( return std::format(
@ -227,13 +216,11 @@ static std::string getWindowData(CWindow* w, eHyprCtlOutputFormat format) {
"{}\n\txwayland: {}\n\tpinned: " "{}\n\txwayland: {}\n\tpinned: "
"{}\n\tfullscreen: {}\n\tfullscreenmode: {}\n\tfakefullscreen: {}\n\tgrouped: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\n", "{}\n\tfullscreen: {}\n\tfullscreenmode: {}\n\tfakefullscreen: {}\n\tgrouped: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\n",
(uintptr_t)w, w->m_szTitle, (int)w->m_bIsMapped, (int)w->isHidden(), (int)w->m_vRealPosition.goal().x, (int)w->m_vRealPosition.goal().y, (int)w->m_vRealSize.goal().x, (uintptr_t)w, w->m_szTitle, (int)w->m_bIsMapped, (int)w->isHidden(), (int)w->m_vRealPosition.goal().x, (int)w->m_vRealPosition.goal().y, (int)w->m_vRealSize.goal().x,
(int)w->m_vRealSize.goal().y, w->m_iWorkspaceID, (int)w->m_vRealSize.goal().y, w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID,
(w->m_iWorkspaceID == -1 ? "" : (!w->m_pWorkspace ? "" : std::to_string(w->workspaceID())),
g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName :
std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID))),
(int)w->m_bIsFloating, (int64_t)w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w), g_pXWaylandManager->getTitle(w), w->m_szInitialClass, w->m_szInitialTitle, (int)w->m_bIsFloating, (int64_t)w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w), g_pXWaylandManager->getTitle(w), w->m_szInitialClass, w->m_szInitialTitle,
w->getPID(), (int)w->m_bIsX11, (int)w->m_bPinned, (int)w->m_bIsFullscreen, w->getPID(), (int)w->m_bIsX11, (int)w->m_bPinned, (int)w->m_bIsFullscreen,
(w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0), (w->m_bIsFullscreen ? (w->m_pWorkspace ? w->m_pWorkspace->m_efFullscreenMode : 0) : 0),
(int)w->m_bFakeFullscreenState, getGroupedData(w, format), (uintptr_t)w->m_pSwallowed, getFocusHistoryID(w)); (int)w->m_bFakeFullscreenState, getGroupedData(w, format), (uintptr_t)w->m_pSwallowed, getFocusHistoryID(w));
} }
} }
@ -264,7 +251,7 @@ std::string clientsRequest(eHyprCtlOutputFormat format, std::string request) {
return result; return result;
} }
static std::string getWorkspaceData(CWorkspace* w, eHyprCtlOutputFormat format) { static std::string getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat format) {
const auto PLASTW = w->getLastFocusedWindow(); const auto PLASTW = w->getLastFocusedWindow();
const auto PMONITOR = g_pCompositor->getMonitorFromID(w->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(w->m_iMonitorID);
if (format == eHyprCtlOutputFormat::FORMAT_JSON) { if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
@ -339,9 +326,9 @@ std::string activeWorkspaceRequest(eHyprCtlOutputFormat format, std::string requ
return "unsafe state"; return "unsafe state";
std::string result = ""; std::string result = "";
auto w = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); auto w = g_pCompositor->m_pLastMonitor->activeWorkspace;
if (!w) if (!valid(w))
return "internal error"; return "internal error";
return getWorkspaceData(w, format); return getWorkspaceData(w, format);
@ -353,7 +340,7 @@ std::string workspacesRequest(eHyprCtlOutputFormat format, std::string request)
if (format == eHyprCtlOutputFormat::FORMAT_JSON) { if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
result += "["; result += "[";
for (auto& w : g_pCompositor->m_vWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
result += getWorkspaceData(w.get(), format); result += getWorkspaceData(w, format);
result += ","; result += ",";
} }
@ -361,7 +348,7 @@ std::string workspacesRequest(eHyprCtlOutputFormat format, std::string request)
result += "]"; result += "]";
} else { } else {
for (auto& w : g_pCompositor->m_vWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
result += getWorkspaceData(w.get(), format); result += getWorkspaceData(w, format);
} }
} }

View file

@ -0,0 +1,6 @@
#pragma once
#include <memory>
class CWorkspace;
typedef std::shared_ptr<CWorkspace> PHLWORKSPACE;

View file

@ -4,6 +4,7 @@
#include "../render/decorations/CHyprGroupBarDecoration.hpp" #include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "../render/decorations/CHyprBorderDecoration.hpp" #include "../render/decorations/CHyprBorderDecoration.hpp"
#include "../config/ConfigValue.hpp" #include "../config/ConfigValue.hpp"
#include <any>
CWindow::CWindow() { CWindow::CWindow() {
m_vRealPosition.create(g_pConfigManager->getAnimationPropertyConfig("windowsIn"), this, AVARDAMAGE_ENTIRE); m_vRealPosition.create(g_pConfigManager->getAnimationPropertyConfig("windowsIn"), this, AVARDAMAGE_ENTIRE);
@ -377,45 +378,39 @@ void CWindow::updateSurfaceScaleTransformDetails() {
this); this);
} }
void CWindow::moveToWorkspace(int workspaceID) { void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
if (m_iWorkspaceID == workspaceID) if (m_pWorkspace == pWorkspace)
return; return;
static auto PCLOSEONLASTSPECIAL = CConfigValue<Hyprlang::INT>("misc:close_special_on_empty"); static auto PCLOSEONLASTSPECIAL = CConfigValue<Hyprlang::INT>("misc:close_special_on_empty");
const int OLDWORKSPACE = m_iWorkspaceID; const auto OLDWORKSPACE = m_pWorkspace;
m_iWorkspaceID = workspaceID; m_pWorkspace = pWorkspace;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
setAnimationsToMove(); setAnimationsToMove();
updateSpecialRenderData(); updateSpecialRenderData();
if (PWORKSPACE) { if (valid(pWorkspace)) {
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, PWORKSPACE->m_szName)}); g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_szName)});
g_pEventManager->postEvent(SHyprIPCEvent{"movewindowv2", std::format("{:x},{},{}", (uintptr_t)this, PWORKSPACE->m_iID, PWORKSPACE->m_szName)}); g_pEventManager->postEvent(SHyprIPCEvent{"movewindowv2", std::format("{:x},{},{}", (uintptr_t)this, pWorkspace->m_iID, pWorkspace->m_szName)});
EMIT_HOOK_EVENT("moveWindow", (std::vector<void*>{this, PWORKSPACE})); EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{this, pWorkspace}));
} }
if (m_pSwallowed) { if (m_pSwallowed) {
m_pSwallowed->moveToWorkspace(workspaceID); m_pSwallowed->moveToWorkspace(pWorkspace);
m_pSwallowed->m_iMonitorID = m_iMonitorID; m_pSwallowed->m_iMonitorID = m_iMonitorID;
} }
// update xwayland coords // update xwayland coords
g_pXWaylandManager->setWindowSize(this, m_vRealSize.value()); g_pXWaylandManager->setWindowSize(this, m_vRealSize.value());
if (g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE) && g_pCompositor->getWindowsOnWorkspace(OLDWORKSPACE) == 0 && *PCLOSEONLASTSPECIAL) { if (OLDWORKSPACE && g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE->m_iID) && g_pCompositor->getWindowsOnWorkspace(OLDWORKSPACE->m_iID) == 0 && *PCLOSEONLASTSPECIAL) {
const auto PWS = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); if (const auto PMONITOR = g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID); PMONITOR)
if (PWS) {
if (const auto PMONITOR = g_pCompositor->getMonitorFromID(PWS->m_iMonitorID); PMONITOR)
PMONITOR->setSpecialWorkspace(nullptr); PMONITOR->setSpecialWorkspace(nullptr);
} }
} }
}
CWindow* CWindow::X11TransientFor() { CWindow* CWindow::X11TransientFor() {
if (!m_bIsX11) if (!m_bIsX11)
@ -455,6 +450,8 @@ void CWindow::onUnmap() {
if (g_pCompositor->m_pLastWindow == this) if (g_pCompositor->m_pLastWindow == this)
g_pCompositor->m_pLastWindow = nullptr; g_pCompositor->m_pLastWindow = nullptr;
m_iLastWorkspace = onSpecialWorkspace();
m_vRealPosition.setCallbackOnEnd(unregisterVar); m_vRealPosition.setCallbackOnEnd(unregisterVar);
m_vRealSize.setCallbackOnEnd(unregisterVar); m_vRealSize.setCallbackOnEnd(unregisterVar);
m_fBorderFadeAnimationProgress.setCallbackOnEnd(unregisterVar); m_fBorderFadeAnimationProgress.setCallbackOnEnd(unregisterVar);
@ -470,9 +467,9 @@ void CWindow::onUnmap() {
hyprListener_unmapWindow.removeCallback(); hyprListener_unmapWindow.removeCallback();
if (*PCLOSEONLASTSPECIAL && g_pCompositor->getWindowsOnWorkspace(m_iWorkspaceID) == 0 && g_pCompositor->isWorkspaceSpecial(m_iWorkspaceID)) { if (*PCLOSEONLASTSPECIAL && g_pCompositor->getWindowsOnWorkspace(workspaceID()) == 0 && onSpecialWorkspace()) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
if (PMONITOR && PMONITOR->specialWorkspaceID == m_iWorkspaceID) if (PMONITOR && PMONITOR->activeSpecialWorkspace && PMONITOR->activeSpecialWorkspace == m_pWorkspace)
PMONITOR->setSpecialWorkspace(nullptr); PMONITOR->setSpecialWorkspace(nullptr);
} }
@ -481,13 +478,14 @@ void CWindow::onUnmap() {
if (PMONITOR && PMONITOR->solitaryClient == this) if (PMONITOR && PMONITOR->solitaryClient == this)
PMONITOR->solitaryClient = nullptr; PMONITOR->solitaryClient = nullptr;
g_pCompositor->updateWorkspaceWindows(m_iWorkspaceID); g_pCompositor->updateWorkspaceWindows(workspaceID());
if (m_bIsX11) if (m_bIsX11)
return; return;
m_pSubsurfaceHead.reset(); m_pSubsurfaceHead.reset();
m_pPopupHead.reset(); m_pPopupHead.reset();
m_pWorkspace.reset();
} }
void CWindow::onMap() { void CWindow::onMap() {
@ -943,7 +941,7 @@ void CWindow::setGroupCurrent(CWindow* pWindow) {
const auto PCURRENT = getGroupCurrent(); const auto PCURRENT = getGroupCurrent();
const bool FULLSCREEN = PCURRENT->m_bIsFullscreen; const bool FULLSCREEN = PCURRENT->m_bIsFullscreen;
const auto WORKSPACE = g_pCompositor->getWorkspaceByID(PCURRENT->m_iWorkspaceID); const auto WORKSPACE = PCURRENT->m_pWorkspace;
const auto PWINDOWSIZE = PCURRENT->m_vRealSize.goal(); const auto PWINDOWSIZE = PCURRENT->m_vRealSize.goal();
const auto PWINDOWPOS = PCURRENT->m_vRealPosition.goal(); const auto PWINDOWPOS = PCURRENT->m_vRealPosition.goal();
@ -1036,9 +1034,11 @@ void CWindow::updateGroupOutputs() {
CWindow* curr = m_sGroupData.pNextWindow; CWindow* curr = m_sGroupData.pNextWindow;
const auto WS = m_pWorkspace;
while (curr != this) { while (curr != this) {
curr->m_iMonitorID = m_iMonitorID; curr->m_iMonitorID = m_iMonitorID;
curr->moveToWorkspace(m_iWorkspaceID); curr->moveToWorkspace(WS);
curr->m_vRealPosition = m_vRealPosition.goal(); curr->m_vRealPosition = m_vRealPosition.goal();
curr->m_vRealSize = m_vRealSize.goal(); curr->m_vRealSize = m_vRealSize.goal();
@ -1058,7 +1058,7 @@ bool CWindow::opaque() {
if (m_vRealSize.goal().floor() != m_vReportedSize) if (m_vRealSize.goal().floor() != m_vReportedSize)
return false; return false;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); const auto PWORKSPACE = m_pWorkspace;
if (m_pWLSurface.small() && !m_pWLSurface.m_bFillIgnoreSmall) if (m_pWLSurface.small() && !m_pWLSurface.m_bFillIgnoreSmall)
return false; return false;
@ -1088,7 +1088,7 @@ float CWindow::rounding() {
} }
void CWindow::updateSpecialRenderData() { void CWindow::updateSpecialRenderData() {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); const auto PWORKSPACE = m_pWorkspace;
const auto WORKSPACERULES = PWORKSPACE ? g_pConfigManager->getWorkspaceRulesFor(PWORKSPACE) : std::vector<SWorkspaceRule>{}; const auto WORKSPACERULES = PWORKSPACE ? g_pConfigManager->getWorkspaceRulesFor(PWORKSPACE) : std::vector<SWorkspaceRule>{};
bool border = true; bool border = true;
@ -1137,7 +1137,7 @@ bool CWindow::canBeTorn() {
} }
bool CWindow::shouldSendFullscreenState() { bool CWindow::shouldSendFullscreenState() {
const auto MODE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID)->m_efFullscreenMode; const auto MODE = m_pWorkspace->m_efFullscreenMode;
return m_bDontSendFullscreen ? false : (m_bFakeFullscreenState || (m_bIsFullscreen && (MODE == FULLSCREEN_FULL))); return m_bDontSendFullscreen ? false : (m_bFakeFullscreenState || (m_bIsFullscreen && (MODE == FULLSCREEN_FULL)));
} }
@ -1173,7 +1173,7 @@ void CWindow::onWorkspaceAnimUpdate() {
} }
Vector2D offset; Vector2D offset;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); const auto PWORKSPACE = m_pWorkspace;
if (!PWORKSPACE) if (!PWORKSPACE)
return; return;
@ -1212,3 +1212,11 @@ int CWindow::popupsCount() {
m_uSurface.xdg, [](wlr_surface* s, int x, int y, void* data) { *(int*)data += 1; }, &no); m_uSurface.xdg, [](wlr_surface* s, int x, int y, void* data) { *(int*)data += 1; }, &no);
return no; return no;
} }
int CWindow::workspaceID() {
return m_pWorkspace ? m_pWorkspace->m_iID : m_iLastWorkspace;
}
bool CWindow::onSpecialWorkspace() {
return m_pWorkspace ? m_pWorkspace->m_bIsSpecialWorkspace : g_pCompositor->isWorkspaceSpecial(m_iLastWorkspace);
}

View file

@ -11,6 +11,7 @@
#include "Popup.hpp" #include "Popup.hpp"
#include "../macros.hpp" #include "../macros.hpp"
#include "../managers/XWaylandManager.hpp" #include "../managers/XWaylandManager.hpp"
#include "DesktopTypes.hpp"
enum eIdleInhibitMode { enum eIdleInhibitMode {
IDLEINHIBIT_NONE = 0, IDLEINHIBIT_NONE = 0,
@ -254,7 +255,7 @@ class CWindow {
std::string m_szTitle = ""; std::string m_szTitle = "";
std::string m_szInitialTitle = ""; std::string m_szInitialTitle = "";
std::string m_szInitialClass = ""; std::string m_szInitialClass = "";
int m_iWorkspaceID = -1; PHLWORKSPACE m_pWorkspace;
bool m_bIsMapped = false; bool m_bIsMapped = false;
@ -384,7 +385,7 @@ class CWindow {
void destroyToplevelHandle(); void destroyToplevelHandle();
void updateToplevel(); void updateToplevel();
void updateSurfaceScaleTransformDetails(); void updateSurfaceScaleTransformDetails();
void moveToWorkspace(int); void moveToWorkspace(PHLWORKSPACE);
CWindow* X11TransientFor(); CWindow* X11TransientFor();
void onUnmap(); void onUnmap();
void onMap(); void onMap();
@ -400,6 +401,8 @@ class CWindow {
bool shouldSendFullscreenState(); bool shouldSendFullscreenState();
void setSuspended(bool suspend); void setSuspended(bool suspend);
bool visibleOnMonitor(CMonitor* pMonitor); bool visibleOnMonitor(CMonitor* pMonitor);
int workspaceID();
bool onSpecialWorkspace();
int getRealBorderSize(); int getRealBorderSize();
void updateSpecialRenderData(); void updateSpecialRenderData();
@ -430,6 +433,7 @@ class CWindow {
// For hidden windows and stuff // For hidden windows and stuff
bool m_bHidden = false; bool m_bHidden = false;
bool m_bSuspended = false; bool m_bSuspended = false;
int m_iLastWorkspace = WORKSPACE_INVALID;
}; };
/** /**
@ -464,7 +468,7 @@ struct std::formatter<CWindow*, CharT> : std::formatter<CharT> {
std::format_to(out, "["); std::format_to(out, "[");
std::format_to(out, "Window {:x}: title: \"{}\"", (uintptr_t)w, w->m_szTitle); std::format_to(out, "Window {:x}: title: \"{}\"", (uintptr_t)w, w->m_szTitle);
if (formatWorkspace) if (formatWorkspace)
std::format_to(out, ", workspace: {}", w->m_iWorkspaceID); std::format_to(out, ", workspace: {}", w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID);
if (formatMonitor) if (formatMonitor)
std::format_to(out, ", monitor: {}", w->m_iMonitorID); std::format_to(out, ", monitor: {}", w->m_iMonitorID);
if (formatClass) if (formatClass)

View file

@ -2,6 +2,12 @@
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "../config/ConfigValue.hpp" #include "../config/ConfigValue.hpp"
PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special) {
PHLWORKSPACE workspace = std::make_shared<CWorkspace>(id, monitorID, name, special);
workspace->init(workspace);
return workspace;
}
CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) { CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
@ -14,17 +20,22 @@ CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
m_iID = id; m_iID = id;
m_szName = name; m_szName = name;
m_bIsSpecialWorkspace = special; m_bIsSpecialWorkspace = special;
}
m_vRenderOffset.create(special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), this, void CWorkspace::init(PHLWORKSPACE self) {
AVARDAMAGE_ENTIRE); m_pSelf = self;
m_fAlpha.create(AVARTYPE_FLOAT, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), this,
m_vRenderOffset.create(m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"),
self, AVARDAMAGE_ENTIRE);
m_fAlpha.create(AVARTYPE_FLOAT,
m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), self,
AVARDAMAGE_ENTIRE); AVARDAMAGE_ENTIRE);
m_fAlpha.setValueAndWarp(1.f); m_fAlpha.setValueAndWarp(1.f);
m_vRenderOffset.registerVar(); m_vRenderOffset.registerVar();
m_fAlpha.registerVar(); m_fAlpha.registerVar();
const auto RULESFORTHIS = g_pConfigManager->getWorkspaceRulesFor(this); const auto RULESFORTHIS = g_pConfigManager->getWorkspaceRulesFor(self);
for (auto& rule : RULESFORTHIS) { for (auto& rule : RULESFORTHIS) {
if (rule.defaultName.has_value()) if (rule.defaultName.has_value())
m_szName = rule.defaultName.value(); m_szName = rule.defaultName.value();
@ -37,6 +48,8 @@ CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
m_pLastFocusedWindow = nullptr; m_pLastFocusedWindow = nullptr;
}); });
m_bInert = false;
g_pEventManager->postEvent({"createworkspace", m_szName}); g_pEventManager->postEvent({"createworkspace", m_szName});
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)}); g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
EMIT_HOOK_EVENT("createWorkspace", this); EMIT_HOOK_EVENT("createWorkspace", this);
@ -61,7 +74,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
// set floating windows offset callbacks // set floating windows offset callbacks
m_vRenderOffset.setUpdateCallback([&](void*) { m_vRenderOffset.setUpdateCallback([&](void*) {
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(w.get()) || w->m_iWorkspaceID != m_iID) if (!g_pCompositor->windowValidMapped(w.get()) || w->workspaceID() != m_iID)
continue; continue;
w->onWorkspaceAnimUpdate(); w->onWorkspaceAnimUpdate();
@ -169,13 +182,13 @@ void CWorkspace::moveToMonitor(const int& id) {
} }
CWindow* CWorkspace::getLastFocusedWindow() { CWindow* CWorkspace::getLastFocusedWindow() {
if (!g_pCompositor->windowValidMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->m_iWorkspaceID != m_iID) if (!g_pCompositor->windowValidMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->workspaceID() != m_iID)
return nullptr; return nullptr;
return m_pLastFocusedWindow; return m_pLastFocusedWindow;
} }
void CWorkspace::rememberPrevWorkspace(const CWorkspace* prev) { void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
if (!prev) { if (!prev) {
m_sPrevWorkspace.iID = -1; m_sPrevWorkspace.iID = -1;
m_sPrevWorkspace.name = ""; m_sPrevWorkspace.name = "";
@ -405,3 +418,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
UNREACHABLE(); UNREACHABLE();
return false; return false;
} }
void CWorkspace::markInert() {
m_bInert = true;
m_iID = WORKSPACE_INVALID;
}
bool CWorkspace::inert() {
return m_bInert;
}

View file

@ -3,6 +3,7 @@
#include "../helpers/AnimatedVariable.hpp" #include "../helpers/AnimatedVariable.hpp"
#include <string> #include <string>
#include "../defines.hpp" #include "../defines.hpp"
#include "DesktopTypes.hpp"
enum eFullscreenMode : int8_t { enum eFullscreenMode : int8_t {
FULLSCREEN_INVALID = -1, FULLSCREEN_INVALID = -1,
@ -14,6 +15,8 @@ class CWindow;
class CWorkspace { class CWorkspace {
public: public:
static PHLWORKSPACE create(int id, int monitorID, std::string name, bool special = false);
// use create() don't use this
CWorkspace(int id, int monitorID, std::string name, bool special = false); CWorkspace(int id, int monitorID, std::string name, bool special = false);
~CWorkspace(); ~CWorkspace();
@ -55,18 +58,34 @@ class CWorkspace {
// Whether the user configured command for on-created-empty has been executed, if any // Whether the user configured command for on-created-empty has been executed, if any
bool m_bOnCreatedEmptyExecuted = false; bool m_bOnCreatedEmptyExecuted = false;
// Inert: destroyed and invalid. If this is true, release the ptr you have.
bool inert();
void startAnim(bool in, bool left, bool instant = false); void startAnim(bool in, bool left, bool instant = false);
void setActive(bool on); void setActive(bool on);
void moveToMonitor(const int&); void moveToMonitor(const int&);
CWindow* getLastFocusedWindow(); CWindow* getLastFocusedWindow();
void rememberPrevWorkspace(const CWorkspace* prevWorkspace); void rememberPrevWorkspace(const PHLWORKSPACE& prevWorkspace);
std::string getConfigName(); std::string getConfigName();
bool matchesStaticSelector(const std::string& selector); bool matchesStaticSelector(const std::string& selector);
void markInert();
private: private:
void init(PHLWORKSPACE self);
HOOK_CALLBACK_FN* m_pFocusedWindowHook = nullptr; HOOK_CALLBACK_FN* m_pFocusedWindowHook = nullptr;
bool m_bInert = true;
std::weak_ptr<CWorkspace> m_pSelf;
}; };
inline bool valid(const PHLWORKSPACE& ref) {
if (!ref)
return false;
return !ref->inert();
}

View file

@ -163,7 +163,7 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
CBox geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, CBox geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width,
layersurface->geometry.height}; layersurface->geometry.height};
g_pHyprRenderer->damageBox(&geomFixed); g_pHyprRenderer->damageBox(&geomFixed);
const auto WORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); const auto WORKSPACE = PMONITOR->activeWorkspace;
const bool FULLSCREEN = WORKSPACE->m_bHasFullscreenWindow && WORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL; const bool FULLSCREEN = WORKSPACE->m_bHasFullscreenWindow && WORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL;
layersurface->startAnimation(!(layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP && FULLSCREEN && !GRABSFOCUS)); layersurface->startAnimation(!(layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP && FULLSCREEN && !GRABSFOCUS));
@ -237,7 +237,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
&surfaceCoords, &pFoundLayerSurface); &surfaceCoords, &pFoundLayerSurface);
if (!foundSurface && g_pCompositor->m_pLastWindow && g_pCompositor->isWorkspaceVisible(g_pCompositor->m_pLastWindow->m_iWorkspaceID)) { if (!foundSurface && g_pCompositor->m_pLastWindow && g_pCompositor->isWorkspaceVisible(g_pCompositor->m_pLastWindow->workspaceID())) {
// if there isn't any, focus the last window // if there isn't any, focus the last window
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
g_pCompositor->focusWindow(nullptr); g_pCompositor->focusWindow(nullptr);

View file

@ -57,9 +57,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
g_pCompositor->setActiveMonitor(g_pCompositor->getMonitorFromVector({})); g_pCompositor->setActiveMonitor(g_pCompositor->getMonitorFromVector({}));
PMONITOR = g_pCompositor->m_pLastMonitor; PMONITOR = g_pCompositor->m_pLastMonitor;
} }
auto PWORKSPACE = PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); auto PWORKSPACE = PMONITOR->activeSpecialWorkspace ? PMONITOR->activeSpecialWorkspace : PMONITOR->activeWorkspace;
PWINDOW->m_iMonitorID = PMONITOR->ID; PWINDOW->m_iMonitorID = PMONITOR->ID;
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace; PWINDOW->m_pWorkspace = PWORKSPACE;
PWINDOW->m_bIsMapped = true; PWINDOW->m_bIsMapped = true;
PWINDOW->m_bReadyToDelete = false; PWINDOW->m_bReadyToDelete = false;
PWINDOW->m_bFadingOut = false; PWINDOW->m_bFadingOut = false;
@ -153,7 +153,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID)); g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID));
PMONITOR = PMONITORFROMID; PMONITOR = PMONITORFROMID;
} }
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace; PWINDOW->m_pWorkspace = PMONITOR->activeSpecialWorkspace ? PMONITOR->activeSpecialWorkspace : PMONITOR->activeWorkspace;
Debug::log(LOG, "Rule monitor, applying to {:mw}", PWINDOW); Debug::log(LOG, "Rule monitor, applying to {:mw}", PWINDOW);
} catch (std::exception& e) { Debug::log(ERR, "Rule monitor failed, rule: {} -> {} | err: {}", r.szRule, r.szValue, e.what()); } } catch (std::exception& e) { Debug::log(ERR, "Rule monitor failed, rule: {} -> {} | err: {}", r.szRule, r.szValue, e.what()); }
@ -287,16 +287,16 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWORKSPACE = pWorkspace; PWORKSPACE = pWorkspace;
PWINDOW->m_iWorkspaceID = pWorkspace->m_iID; PWINDOW->m_pWorkspace = pWorkspace;
PWINDOW->m_iMonitorID = pWorkspace->m_iMonitorID; PWINDOW->m_iMonitorID = pWorkspace->m_iMonitorID;
if (g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->specialWorkspaceID && !pWorkspace->m_bIsSpecialWorkspace) if (g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeSpecialWorkspace && !pWorkspace->m_bIsSpecialWorkspace)
workspaceSilent = true; workspaceSilent = true;
if (!workspaceSilent) { if (!workspaceSilent) {
if (pWorkspace->m_bIsSpecialWorkspace) if (pWorkspace->m_bIsSpecialWorkspace)
g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID)->setSpecialWorkspace(pWorkspace); g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID)->setSpecialWorkspace(pWorkspace);
else if (PMONITOR->activeWorkspace != REQUESTEDWORKSPACEID) else if (PMONITOR->activeWorkspaceID() != REQUESTEDWORKSPACEID)
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspaceName); g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspaceName);
PMONITOR = g_pCompositor->m_pLastMonitor; PMONITOR = g_pCompositor->m_pLastMonitor;
@ -632,7 +632,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
// fix some xwayland apps that don't behave nicely // fix some xwayland apps that don't behave nicely
PWINDOW->m_vReportedSize = PWINDOW->m_vPendingReportedSize; PWINDOW->m_vReportedSize = PWINDOW->m_vPendingReportedSize;
g_pCompositor->updateWorkspaceWindows(PWINDOW->m_iWorkspaceID); g_pCompositor->updateWorkspaceWindows(PWINDOW->workspaceID());
if (PMONITOR && PWINDOW->m_iX11Type == 2) if (PMONITOR && PWINDOW->m_iX11Type == 2)
PWINDOW->m_fX11SurfaceScaledBy = PMONITOR->scale; PWINDOW->m_fX11SurfaceScaledBy = PMONITOR->scale;
@ -704,7 +704,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
} }
// remove the fullscreen window status from workspace if we closed it // remove the fullscreen window status from workspace if we closed it
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); const auto PWORKSPACE = PWINDOW->m_pWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow && PWINDOW->m_bIsFullscreen) if (PWORKSPACE->m_bHasFullscreenWindow && PWINDOW->m_bIsFullscreen)
PWORKSPACE->m_bHasFullscreenWindow = false; PWORKSPACE->m_bHasFullscreenWindow = false;
@ -723,7 +723,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
if (PWINDOWCANDIDATE != g_pCompositor->m_pLastWindow && PWINDOWCANDIDATE) if (PWINDOWCANDIDATE != g_pCompositor->m_pLastWindow && PWINDOWCANDIDATE)
g_pCompositor->focusWindow(PWINDOWCANDIDATE); g_pCompositor->focusWindow(PWINDOWCANDIDATE);
if (!PWINDOWCANDIDATE && g_pCompositor->getWindowsOnWorkspace(PWINDOW->m_iWorkspaceID) == 0) if (!PWINDOWCANDIDATE && g_pCompositor->getWindowsOnWorkspace(PWINDOW->workspaceID()) == 0)
g_pInputManager->refocus(); g_pInputManager->refocus();
g_pInputManager->sendMotionEventsToFocused(); g_pInputManager->sendMotionEventsToFocused();
@ -758,7 +758,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
g_pInputManager->recheckIdleInhibitorStatus(); g_pInputManager->recheckIdleInhibitorStatus();
// force report all sizes (QT sometimes has an issue with this) // force report all sizes (QT sometimes has an issue with this)
g_pCompositor->forceReportSizesToWindowsOnWorkspace(PWINDOW->m_iWorkspaceID); g_pCompositor->forceReportSizesToWindowsOnWorkspace(PWINDOW->workspaceID());
// update lastwindow after focus // update lastwindow after focus
PWINDOW->onUnmap(); PWINDOW->onUnmap();
@ -934,7 +934,7 @@ void Events::listener_fullscreenWindow(void* owner, void* data) {
const auto REQUESTED = &PWINDOW->m_uSurface.xdg->toplevel->requested; const auto REQUESTED = &PWINDOW->m_uSurface.xdg->toplevel->requested;
if (REQUESTED->fullscreen && PWINDOW->m_bIsFullscreen) { if (REQUESTED->fullscreen && PWINDOW->m_bIsFullscreen) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); const auto PWORKSPACE = PWINDOW->m_pWorkspace;
if (PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) { if (PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) {
// Store that we were maximized // Store that we were maximized
PWINDOW->m_bWasMaximized = true; PWINDOW->m_bWasMaximized = true;
@ -1094,10 +1094,10 @@ void Events::listener_configureX11(void* owner, void* data) {
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();
if (!g_pCompositor->isWorkspaceVisible(PWINDOW->m_iWorkspaceID)) if (!g_pCompositor->isWorkspaceVisible(PWINDOW->workspaceID()))
return; // further things are only for visible windows return; // further things are only for visible windows
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.value() + PWINDOW->m_vRealSize.value() / 2.f)->activeWorkspace; PWINDOW->m_pWorkspace = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.value() + PWINDOW->m_vRealSize.value() / 2.f)->activeWorkspace;
g_pCompositor->changeWindowZOrder(PWINDOW, true); g_pCompositor->changeWindowZOrder(PWINDOW, true);
@ -1155,7 +1155,7 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goal(); PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goal();
PWINDOW->m_vSize = PWINDOW->m_vRealSize.goal(); PWINDOW->m_vSize = PWINDOW->m_vRealSize.goal();
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.value() + PWINDOW->m_vRealSize.value() / 2.f)->activeWorkspace; PWINDOW->m_pWorkspace = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.value() + PWINDOW->m_vRealSize.value() / 2.f)->activeWorkspace;
g_pCompositor->changeWindowZOrder(PWINDOW, true); g_pCompositor->changeWindowZOrder(PWINDOW, true);
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();

View file

@ -22,7 +22,7 @@ void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, SLayer
m_bDummy = false; m_bDummy = false;
} }
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, CWorkspace* pWorkspace, AVARDAMAGEPOLICY policy) { void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, AVARDAMAGEPOLICY policy) {
m_eDamagePolicy = policy; m_eDamagePolicy = policy;
m_pConfig = pAnimConfig; m_pConfig = pAnimConfig;
m_pWorkspace = pWorkspace; m_pWorkspace = pWorkspace;

View file

@ -8,6 +8,7 @@
#include "Color.hpp" #include "Color.hpp"
#include "../macros.hpp" #include "../macros.hpp"
#include "../debug/Log.hpp" #include "../debug/Log.hpp"
#include "../desktop/DesktopTypes.hpp"
enum ANIMATEDVARTYPE { enum ANIMATEDVARTYPE {
AVARTYPE_INVALID = -1, AVARTYPE_INVALID = -1,
@ -48,11 +49,11 @@ enum AVARDAMAGEPOLICY {
}; };
class CAnimationManager; class CAnimationManager;
class CWorkspace;
struct SLayerSurface; struct SLayerSurface;
struct SAnimationPropertyConfig; struct SAnimationPropertyConfig;
class CHyprRenderer; class CHyprRenderer;
class CWindow; class CWindow;
class CWorkspace;
// Utility to define a concept as a list of possible type // Utility to define a concept as a list of possible type
template <class T, class... U> template <class T, class... U>
@ -69,7 +70,7 @@ class CBaseAnimatedVariable {
CBaseAnimatedVariable(ANIMATEDVARTYPE type); CBaseAnimatedVariable(ANIMATEDVARTYPE type);
void create(SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy); void create(SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy);
void create(SAnimationPropertyConfig* pAnimConfig, SLayerSurface* pLayer, AVARDAMAGEPOLICY policy); void create(SAnimationPropertyConfig* pAnimConfig, SLayerSurface* pLayer, AVARDAMAGEPOLICY policy);
void create(SAnimationPropertyConfig* pAnimConfig, CWorkspace* pWorkspace, AVARDAMAGEPOLICY policy); void create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, AVARDAMAGEPOLICY policy);
void create(SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy); void create(SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy);
CBaseAnimatedVariable(const CBaseAnimatedVariable&) = delete; CBaseAnimatedVariable(const CBaseAnimatedVariable&) = delete;
@ -145,7 +146,7 @@ class CBaseAnimatedVariable {
protected: protected:
void* m_pWindow = nullptr; void* m_pWindow = nullptr;
void* m_pWorkspace = nullptr; std::weak_ptr<CWorkspace> m_pWorkspace;
void* m_pLayer = nullptr; void* m_pLayer = nullptr;
SAnimationPropertyConfig* m_pConfig = nullptr; SAnimationPropertyConfig* m_pConfig = nullptr;
@ -217,7 +218,7 @@ class CAnimatedVariable : public CBaseAnimatedVariable {
m_Value = value; m_Value = value;
m_Goal = value; m_Goal = value;
} }
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, CWorkspace* pWorkspace, AVARDAMAGEPOLICY policy) { void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, AVARDAMAGEPOLICY policy) {
create(pAnimConfig, pWorkspace, policy); create(pAnimConfig, pWorkspace, policy);
m_Value = value; m_Value = value;
m_Goal = value; m_Goal = value;

View file

@ -289,9 +289,9 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
if (!g_pCompositor->m_pLastMonitor) if (!g_pCompositor->m_pLastMonitor)
return WORKSPACE_INVALID; return WORKSPACE_INVALID;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
if (!PWORKSPACE) if (!valid(PWORKSPACE))
return WORKSPACE_INVALID; return WORKSPACE_INVALID;
const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PWORKSPACE->m_sPrevWorkspace.iID); const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PWORKSPACE->m_sPrevWorkspace.iID);
@ -347,7 +347,8 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
std::sort(namedWSes.begin(), namedWSes.end()); std::sort(namedWSes.begin(), namedWSes.end());
// Just take a blind guess at where we'll probably end up // Just take a blind guess at where we'll probably end up
int predictedWSID = g_pCompositor->m_pLastMonitor->activeWorkspace + remains; int activeWSID = g_pCompositor->m_pLastMonitor->activeWorkspace ? g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID : 1;
int predictedWSID = activeWSID + remains;
int remainingWSes = 0; int remainingWSes = 0;
char walkDir = in[1]; char walkDir = in[1];
@ -355,20 +356,20 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
predictedWSID = std::max(predictedWSID, 0); predictedWSID = std::max(predictedWSID, 0);
// Count how many invalidWSes are in between (how bad the prediction was) // Count how many invalidWSes are in between (how bad the prediction was)
int beginID = in[1] == '+' ? g_pCompositor->m_pLastMonitor->activeWorkspace + 1 : predictedWSID; int beginID = in[1] == '+' ? activeWSID + 1 : predictedWSID;
int endID = in[1] == '+' ? predictedWSID : g_pCompositor->m_pLastMonitor->activeWorkspace; int endID = in[1] == '+' ? predictedWSID : activeWSID;
auto begin = invalidWSes.upper_bound(beginID - 1); // upper_bound is >, we want >= auto begin = invalidWSes.upper_bound(beginID - 1); // upper_bound is >, we want >=
for (auto it = begin; *it <= endID && it != invalidWSes.end(); it++) { for (auto it = begin; *it <= endID && it != invalidWSes.end(); it++) {
remainingWSes++; remainingWSes++;
} }
// Handle named workspaces. They are treated like always before other workspaces // Handle named workspaces. They are treated like always before other workspaces
if (g_pCompositor->m_pLastMonitor->activeWorkspace < 0) { if (activeWSID < 0) {
// Behaviour similar to 'm' // Behaviour similar to 'm'
// Find current // Find current
int currentItem = -1; int currentItem = -1;
for (size_t i = 0; i < namedWSes.size(); i++) { for (size_t i = 0; i < namedWSes.size(); i++) {
if (namedWSes[i] == g_pCompositor->m_pLastMonitor->activeWorkspace) { if (namedWSes[i] == activeWSID) {
currentItem = i; currentItem = i;
break; break;
} }
@ -473,9 +474,10 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
remains = remains < 0 ? -((-remains) % validWSes.size()) : remains % validWSes.size(); remains = remains < 0 ? -((-remains) % validWSes.size()) : remains % validWSes.size();
// get the current item // get the current item
int activeWSID = g_pCompositor->m_pLastMonitor->activeWorkspace ? g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID : 1;
int currentItem = -1; int currentItem = -1;
for (size_t i = 0; i < validWSes.size(); i++) { for (size_t i = 0; i < validWSes.size(); i++) {
if (validWSes[i] == g_pCompositor->m_pLastMonitor->activeWorkspace) { if (validWSes[i] == activeWSID) {
currentItem = i; currentItem = i;
break; break;
} }
@ -496,7 +498,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
} else { } else {
if (in[0] == '+' || in[0] == '-') { if (in[0] == '+' || in[0] == '-') {
if (g_pCompositor->m_pLastMonitor) { if (g_pCompositor->m_pLastMonitor) {
const auto PLUSMINUSRESULT = getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PLUSMINUSRESULT = getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspaceID());
if (!PLUSMINUSRESULT.has_value()) if (!PLUSMINUSRESULT.has_value())
return WORKSPACE_INVALID; return WORKSPACE_INVALID;

View file

@ -170,7 +170,7 @@ void CMonitor::onConnect(bool noRule) {
for (auto& ws : g_pCompositor->m_vWorkspaces) { for (auto& ws : g_pCompositor->m_vWorkspaces) {
if (ws->m_szLastMonitor == szName || g_pCompositor->m_vMonitors.size() == 1 /* avoid lost workspaces on recover */) { if (ws->m_szLastMonitor == szName || g_pCompositor->m_vMonitors.size() == 1 /* avoid lost workspaces on recover */) {
g_pCompositor->moveWorkspaceToMonitor(ws.get(), this); g_pCompositor->moveWorkspaceToMonitor(ws, this);
ws->startAnim(true, true, true); ws->startAnim(true, true, true);
ws->m_szLastMonitor = ""; ws->m_szLastMonitor = "";
} }
@ -281,10 +281,10 @@ void CMonitor::onDisconnect(bool destroy) {
BACKUPMON->vecPosition.y + BACKUPMON->vecTransformedSize.y / 2.f); BACKUPMON->vecPosition.y + BACKUPMON->vecTransformedSize.y / 2.f);
// move workspaces // move workspaces
std::deque<CWorkspace*> wspToMove; std::deque<PHLWORKSPACE> wspToMove;
for (auto& w : g_pCompositor->m_vWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w->m_iMonitorID == ID || !g_pCompositor->getMonitorFromID(w->m_iMonitorID)) { if (w->m_iMonitorID == ID || !g_pCompositor->getMonitorFromID(w->m_iMonitorID)) {
wspToMove.push_back(w.get()); wspToMove.push_back(w);
} }
} }
@ -299,7 +299,7 @@ void CMonitor::onDisconnect(bool destroy) {
g_pCompositor->m_pLastMonitor = nullptr; g_pCompositor->m_pLastMonitor = nullptr;
} }
activeWorkspace = -1; activeWorkspace.reset();
if (!destroy) if (!destroy)
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output); wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
@ -403,17 +403,17 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
if (PNEWWORKSPACE) { if (PNEWWORKSPACE) {
// workspace exists, move it to the newly connected monitor // workspace exists, move it to the newly connected monitor
g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, this); g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, this);
activeWorkspace = PNEWWORKSPACE->m_iID; activeWorkspace = PNEWWORKSPACE;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
PNEWWORKSPACE->startAnim(true, true, true); PNEWWORKSPACE->startAnim(true, true, true);
} else { } else {
if (newDefaultWorkspaceName == "") if (newDefaultWorkspaceName == "")
newDefaultWorkspaceName = std::to_string(WORKSPACEID); newDefaultWorkspaceName = std::to_string(WORKSPACEID);
PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(WORKSPACEID, ID, newDefaultWorkspaceName)).get(); PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(CWorkspace::create(WORKSPACEID, ID, newDefaultWorkspaceName));
} }
activeWorkspace = PNEWWORKSPACE->m_iID; activeWorkspace = PNEWWORKSPACE;
PNEWWORKSPACE->setActive(true); PNEWWORKSPACE->setActive(true);
PNEWWORKSPACE->m_szLastMonitor = ""; PNEWWORKSPACE->m_szLastMonitor = "";
@ -481,10 +481,10 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
} }
// move all the WS // move all the WS
std::deque<CWorkspace*> wspToMove; std::deque<PHLWORKSPACE> wspToMove;
for (auto& w : g_pCompositor->m_vWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w->m_iMonitorID == ID) { if (w->m_iMonitorID == ID) {
wspToMove.push_back(w.get()); wspToMove.push_back(w);
} }
} }
@ -493,7 +493,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
w->startAnim(true, true, true); w->startAnim(true, true, true);
} }
activeWorkspace = -1; activeWorkspace.reset();
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output); wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
@ -532,24 +532,24 @@ float CMonitor::getDefaultScale() {
return 1; return 1;
} }
void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool noMouseMove, bool noFocus) { void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bool noMouseMove, bool noFocus) {
if (!pWorkspace) if (!pWorkspace)
return; return;
if (pWorkspace->m_bIsSpecialWorkspace) { if (pWorkspace->m_bIsSpecialWorkspace) {
if (specialWorkspaceID != pWorkspace->m_iID) { if (activeSpecialWorkspace != pWorkspace) {
Debug::log(LOG, "changeworkspace on special, togglespecialworkspace to id {}", pWorkspace->m_iID); Debug::log(LOG, "changeworkspace on special, togglespecialworkspace to id {}", pWorkspace->m_iID);
g_pKeybindManager->m_mDispatchers["togglespecialworkspace"](pWorkspace->m_szName == "special" ? "" : pWorkspace->m_szName); g_pKeybindManager->m_mDispatchers["togglespecialworkspace"](pWorkspace->m_szName == "special" ? "" : pWorkspace->m_szName);
} }
return; return;
} }
if (pWorkspace->m_iID == activeWorkspace) if (pWorkspace == activeWorkspace)
return; return;
const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(activeWorkspace); const auto POLDWORKSPACE = activeWorkspace;
activeWorkspace = pWorkspace->m_iID; activeWorkspace = pWorkspace;
if (!internal) { if (!internal) {
const auto ANIMTOLEFT = pWorkspace->m_iID > POLDWORKSPACE->m_iID; const auto ANIMTOLEFT = pWorkspace->m_iID > POLDWORKSPACE->m_iID;
@ -558,12 +558,11 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool
// move pinned windows // move pinned windows
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == POLDWORKSPACE->m_iID && w->m_bPinned) { if (w->m_pWorkspace == POLDWORKSPACE && w->m_bPinned)
w->m_iWorkspaceID = pWorkspace->m_iID; w->moveToWorkspace(pWorkspace);
}
} }
if (!noFocus && !g_pCompositor->m_pLastMonitor->specialWorkspaceID) { if (!noFocus && !g_pCompositor->m_pLastMonitor->activeSpecialWorkspace) {
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse"); static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
CWindow* pWindow = pWorkspace->getLastFocusedWindow(); CWindow* pWindow = pWorkspace->getLastFocusedWindow();
@ -599,37 +598,33 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool
g_pCompositor->updateSuspendedStates(); g_pCompositor->updateSuspendedStates();
if (specialWorkspaceID) { if (activeSpecialWorkspace)
const auto PSPECIALWS = g_pCompositor->getWorkspaceByID(specialWorkspaceID); g_pCompositor->updateFullscreenFadeOnWorkspace(activeSpecialWorkspace);
if (PSPECIALWS->m_bHasFullscreenWindow)
g_pCompositor->updateFullscreenFadeOnWorkspace(PSPECIALWS);
}
} }
void CMonitor::changeWorkspace(const int& id, bool internal, bool noMouseMove, bool noFocus) { void CMonitor::changeWorkspace(const int& id, bool internal, bool noMouseMove, bool noFocus) {
changeWorkspace(g_pCompositor->getWorkspaceByID(id), internal, noMouseMove, noFocus); changeWorkspace(g_pCompositor->getWorkspaceByID(id), internal, noMouseMove, noFocus);
} }
void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) { void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) {
g_pHyprRenderer->damageMonitor(this); g_pHyprRenderer->damageMonitor(this);
if (!pWorkspace) { if (!pWorkspace) {
// remove special if exists // remove special if exists
if (const auto EXISTINGSPECIAL = g_pCompositor->getWorkspaceByID(specialWorkspaceID); EXISTINGSPECIAL) { if (activeSpecialWorkspace) {
EXISTINGSPECIAL->startAnim(false, false); activeSpecialWorkspace->startAnim(false, false);
g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + szName}); g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + szName});
} }
specialWorkspaceID = 0; activeSpecialWorkspace.reset();
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(activeWorkspace); if (const auto PLAST = activeWorkspace->getLastFocusedWindow(); PLAST)
if (const auto PLAST = PWORKSPACE->getLastFocusedWindow(); PLAST)
g_pCompositor->focusWindow(PLAST); g_pCompositor->focusWindow(PLAST);
else else
g_pInputManager->refocus(); g_pInputManager->refocus();
g_pCompositor->updateFullscreenFadeOnWorkspace(PWORKSPACE); g_pCompositor->updateFullscreenFadeOnWorkspace(activeWorkspace);
g_pConfigManager->ensureVRR(this); g_pConfigManager->ensureVRR(this);
@ -638,20 +633,18 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
return; return;
} }
if (specialWorkspaceID) { if (activeSpecialWorkspace)
if (const auto EXISTINGSPECIAL = g_pCompositor->getWorkspaceByID(specialWorkspaceID); EXISTINGSPECIAL) activeSpecialWorkspace->startAnim(false, false);
EXISTINGSPECIAL->startAnim(false, false);
}
bool animate = true; bool animate = true;
//close if open elsewhere //close if open elsewhere
const auto PMONITORWORKSPACEOWNER = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); const auto PMONITORWORKSPACEOWNER = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
if (PMONITORWORKSPACEOWNER->specialWorkspaceID == pWorkspace->m_iID) { if (PMONITORWORKSPACEOWNER->activeSpecialWorkspace == pWorkspace) {
PMONITORWORKSPACEOWNER->specialWorkspaceID = 0; PMONITORWORKSPACEOWNER->activeSpecialWorkspace.reset();
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITORWORKSPACEOWNER->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITORWORKSPACEOWNER->ID);
g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMONITORWORKSPACEOWNER->szName}); g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMONITORWORKSPACEOWNER->szName});
const auto PACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITORWORKSPACEOWNER->activeWorkspace); const auto PACTIVEWORKSPACE = PMONITORWORKSPACEOWNER->activeWorkspace;
g_pCompositor->updateFullscreenFadeOnWorkspace(PACTIVEWORKSPACE); g_pCompositor->updateFullscreenFadeOnWorkspace(PACTIVEWORKSPACE);
animate = false; animate = false;
@ -659,12 +652,12 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
// open special // open special
pWorkspace->m_iMonitorID = ID; pWorkspace->m_iMonitorID = ID;
specialWorkspaceID = pWorkspace->m_iID; activeSpecialWorkspace = pWorkspace;
if (animate) if (animate)
pWorkspace->startAnim(true, true); pWorkspace->startAnim(true, true);
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == pWorkspace->m_iID) { if (w->m_pWorkspace == pWorkspace) {
w->m_iMonitorID = ID; w->m_iMonitorID = ID;
w->updateSurfaceScaleTransformDetails(); w->updateSurfaceScaleTransformDetails();
w->setAnimationsToMove(); w->setAnimationsToMove();
@ -729,6 +722,13 @@ void CMonitor::updateMatrix() {
} }
} }
int64_t CMonitor::activeWorkspaceID() {
return activeWorkspace ? activeWorkspace->m_iID : 0;
}
int64_t CMonitor::activeSpecialWorkspaceID() {
return activeSpecialWorkspace ? activeSpecialWorkspace->m_iID : 0;
}
CMonitorState::CMonitorState(CMonitor* owner) { CMonitorState::CMonitorState(CMonitor* owner) {
m_pOwner = owner; m_pOwner = owner;
wlr_output_state_init(&m_state); wlr_output_state_init(&m_state);

View file

@ -58,7 +58,8 @@ class CMonitor {
bool primary = false; bool primary = false;
uint64_t ID = -1; uint64_t ID = -1;
int activeWorkspace = -1; PHLWORKSPACE activeWorkspace = nullptr;
PHLWORKSPACE activeSpecialWorkspace = nullptr;
float setScale = 1; // scale set by cfg float setScale = 1; // scale set by cfg
float scale = 1; // real scale float scale = 1; // real scale
@ -119,9 +120,6 @@ class CMonitor {
bool frameScheduledWhileBusy = false; bool frameScheduledWhileBusy = false;
} tearingState; } tearingState;
// for the special workspace. 0 means not open.
int specialWorkspaceID = 0;
std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4> m_aLayerSurfaceLayers; std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4> m_aLayerSurfaceLayers;
DYNLISTENER(monitorFrame); DYNLISTENER(monitorFrame);
@ -142,13 +140,15 @@ class CMonitor {
bool isMirror(); bool isMirror();
bool matchesStaticSelector(const std::string& selector) const; bool matchesStaticSelector(const std::string& selector) const;
float getDefaultScale(); float getDefaultScale();
void changeWorkspace(CWorkspace* const pWorkspace, bool internal = false, bool noMouseMove = false, bool noFocus = false); void changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal = false, bool noMouseMove = false, bool noFocus = false);
void changeWorkspace(const int& id, bool internal = false, bool noMouseMove = false, bool noFocus = false); void changeWorkspace(const int& id, bool internal = false, bool noMouseMove = false, bool noFocus = false);
void setSpecialWorkspace(CWorkspace* const pWorkspace); void setSpecialWorkspace(const PHLWORKSPACE& pWorkspace);
void setSpecialWorkspace(const int& id); void setSpecialWorkspace(const int& id);
void moveTo(const Vector2D& pos); void moveTo(const Vector2D& pos);
Vector2D middle(); Vector2D middle();
void updateMatrix(); void updateMatrix();
int64_t activeWorkspaceID();
int64_t activeSpecialWorkspaceID();
bool m_bEnabled = false; bool m_bEnabled = false;
bool m_bRenderingInitPassed = false; bool m_bRenderingInitPassed = false;

View file

@ -280,7 +280,7 @@ struct SIdleInhibitor {
}; };
struct SSwipeGesture { struct SSwipeGesture {
CWorkspace* pWorkspaceBegin = nullptr; PHLWORKSPACE pWorkspaceBegin = nullptr;
double delta = 0; double delta = 0;

View file

@ -105,7 +105,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) { if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) {
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m->specialWorkspaceID == pNode->workspaceID) { if (m->activeSpecialWorkspaceID() == pNode->workspaceID) {
PMONITOR = m.get(); PMONITOR = m.get();
break; break;
} }
@ -162,10 +162,10 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
PWINDOW->m_vSize = nodeBox.size(); PWINDOW->m_vSize = nodeBox.size();
PWINDOW->m_vPosition = nodeBox.pos(); PWINDOW->m_vPosition = nodeBox.pos();
const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID); const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->workspaceID());
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && if (*PNOGAPSWHENONLY && !PWINDOW->onSpecialWorkspace() &&
(NODESONWORKSPACE == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) { (NODESONWORKSPACE == 1 || (PWINDOW->m_bIsFullscreen && PWINDOW->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
PWINDOW->m_sSpecialRenderData.rounding = false; PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.shadow = false; PWINDOW->m_sSpecialRenderData.shadow = false;
@ -229,7 +229,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
calcPos = calcPos + RESERVED.topLeft; calcPos = calcPos + RESERVED.topLeft;
calcSize = calcSize - (RESERVED.topLeft + RESERVED.bottomRight); calcSize = calcSize - (RESERVED.topLeft + RESERVED.bottomRight);
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && !PWINDOW->m_bIsFullscreen) { if (PWINDOW->onSpecialWorkspace() && !PWINDOW->m_bIsFullscreen) {
// if special, we adjust the coords a bit // if special, we adjust the coords a bit
static auto PSCALEFACTOR = CConfigValue<Hyprlang::FLOAT>("dwindle:special_scale_factor"); static auto PSCALEFACTOR = CConfigValue<Hyprlang::FLOAT>("dwindle:special_scale_factor");
@ -278,7 +278,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
overrideDirection = direction; overrideDirection = direction;
// Populate the node with our window's data // Populate the node with our window's data
PNODE->workspaceID = pWindow->m_iWorkspaceID; PNODE->workspaceID = pWindow->workspaceID();
PNODE->pWindow = pWindow; PNODE->pWindow = pWindow;
PNODE->isNode = false; PNODE->isNode = false;
PNODE->layout = this; PNODE->layout = this;
@ -289,7 +289,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromVector(MOUSECOORDS); const auto MONFROMCURSOR = g_pCompositor->getMonitorFromVector(MOUSECOORDS);
if (PMONITOR->ID == MONFROMCURSOR->ID && if (PMONITOR->ID == MONFROMCURSOR->ID &&
(PNODE->workspaceID == PMONITOR->activeWorkspace || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->specialWorkspaceID)) && !*PUSEACTIVE) { (PNODE->workspaceID == PMONITOR->activeWorkspaceID() || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->activeSpecialWorkspace)) && !*PUSEACTIVE) {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS)); OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS));
if (!OPENINGON && g_pCompositor->isPointOnReservedArea(MOUSECOORDS, PMONITOR)) if (!OPENINGON && g_pCompositor->isPointOnReservedArea(MOUSECOORDS, PMONITOR))
@ -297,7 +297,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
} else if (*PUSEACTIVE) { } else if (*PUSEACTIVE) {
if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow && if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow &&
g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) { g_pCompositor->m_pLastWindow->m_pWorkspace == pWindow->m_pWorkspace && g_pCompositor->m_pLastWindow->m_bIsMapped) {
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow); OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
} else { } else {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS)); OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS));
@ -307,7 +307,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
OPENINGON = getClosestNodeOnWorkspace(PNODE->workspaceID, MOUSECOORDS); OPENINGON = getClosestNodeOnWorkspace(PNODE->workspaceID, MOUSECOORDS);
} else } else
OPENINGON = getFirstNodeOnWorkspace(pWindow->m_iWorkspaceID); OPENINGON = getFirstNodeOnWorkspace(pWindow->workspaceID());
Debug::log(LOG, "OPENINGON: {}, Monitor: {}", OPENINGON, PMONITOR->ID); Debug::log(LOG, "OPENINGON: {}, Monitor: {}", OPENINGON, PMONITOR->ID);
@ -551,40 +551,35 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
void CHyprDwindleLayout::recalculateMonitor(const int& monid) { void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid); const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
if (!PMONITOR) if (!PMONITOR || !PMONITOR->activeWorkspace)
return; // ??? return; // ???
g_pHyprRenderer->damageMonitor(PMONITOR); g_pHyprRenderer->damageMonitor(PMONITOR);
if (PMONITOR->specialWorkspaceID) if (PMONITOR->activeSpecialWorkspace)
calculateWorkspace(PMONITOR->specialWorkspaceID); calculateWorkspace(PMONITOR->activeSpecialWorkspace);
calculateWorkspace(PMONITOR->activeWorkspace); calculateWorkspace(PMONITOR->activeWorkspace);
} }
void CHyprDwindleLayout::calculateWorkspace(const int& ws) { void CHyprDwindleLayout::calculateWorkspace(const PHLWORKSPACE& pWorkspace) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
if (!PWORKSPACE)
return;
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
if (!PMONITOR) if (!PMONITOR)
return; return;
if (PWORKSPACE->m_bHasFullscreenWindow) { if (pWorkspace->m_bHasFullscreenWindow) {
// massive hack from the fullscreen func // massive hack from the fullscreen func
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(pWorkspace->m_iID);
if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { if (pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL) {
PFULLWINDOW->m_vRealPosition = PMONITOR->vecPosition; PFULLWINDOW->m_vRealPosition = PMONITOR->vecPosition;
PFULLWINDOW->m_vRealSize = PMONITOR->vecSize; PFULLWINDOW->m_vRealSize = PMONITOR->vecSize;
} else if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) { } else if (pWorkspace->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
SDwindleNodeData fakeNode; SDwindleNodeData fakeNode;
fakeNode.pWindow = PFULLWINDOW; fakeNode.pWindow = PFULLWINDOW;
fakeNode.box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight}; fakeNode.box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
fakeNode.workspaceID = PWORKSPACE->m_iID; fakeNode.workspaceID = pWorkspace->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.box.pos(); PFULLWINDOW->m_vPosition = fakeNode.box.pos();
PFULLWINDOW->m_vSize = fakeNode.box.size(); PFULLWINDOW->m_vSize = fakeNode.box.size();
fakeNode.ignoreFullscreenChecks = true; fakeNode.ignoreFullscreenChecks = true;
@ -596,7 +591,7 @@ void CHyprDwindleLayout::calculateWorkspace(const int& ws) {
return; return;
} }
const auto TOPNODE = getMasterNodeOnWorkspace(ws); const auto TOPNODE = getMasterNodeOnWorkspace(pWorkspace->m_iID);
if (TOPNODE) { if (TOPNODE) {
TOPNODE->box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight}; TOPNODE->box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
@ -813,7 +808,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
return; // ignore return; // ignore
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow && on) { if (PWORKSPACE->m_bHasFullscreenWindow && on) {
// if the window wants to be fullscreen but there already is one, // if the window wants to be fullscreen but there already is one,
@ -868,7 +863,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
SDwindleNodeData fakeNode; SDwindleNodeData fakeNode;
fakeNode.pWindow = pWindow; fakeNode.pWindow = pWindow;
fakeNode.box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight}; fakeNode.box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
fakeNode.workspaceID = pWindow->m_iWorkspaceID; fakeNode.workspaceID = pWindow->workspaceID();
pWindow->m_vPosition = fakeNode.box.pos(); pWindow->m_vPosition = fakeNode.box.pos();
pWindow->m_vSize = fakeNode.box.size(); pWindow->m_vSize = fakeNode.box.size();
fakeNode.ignoreFullscreenChecks = true; fakeNode.ignoreFullscreenChecks = true;
@ -981,7 +976,7 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
if (PNODE->workspaceID != PNODE2->workspaceID) { if (PNODE->workspaceID != PNODE2->workspaceID) {
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID); std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID); std::swap(pWindow2->m_pWorkspace, pWindow->m_pWorkspace);
} }
pWindow->setAnimationsToMove(); pWindow->setAnimationsToMove();
@ -1137,7 +1132,7 @@ Vector2D CHyprDwindleLayout::predictSizeForNewWindowTiled() {
CWindow* candidate = g_pCompositor->m_pLastWindow; CWindow* candidate = g_pCompositor->m_pLastWindow;
if (!candidate) if (!candidate)
candidate = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace); candidate = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID);
// create a fake node // create a fake node
SDwindleNodeData node; SDwindleNodeData node;

View file

@ -78,7 +78,7 @@ class CHyprDwindleLayout : public IHyprLayout {
int getNodesOnWorkspace(const int&); int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false); void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
void calculateWorkspace(const int& ws); void calculateWorkspace(const PHLWORKSPACE& pWorkspace);
SDwindleNodeData* getNodeFromWindow(CWindow*); SDwindleNodeData* getNodeFromWindow(CWindow*);
SDwindleNodeData* getFirstNodeOnWorkspace(const int&); SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
SDwindleNodeData* getClosestNodeOnWorkspace(const int&, const Vector2D&); SDwindleNodeData* getClosestNodeOnWorkspace(const int&, const Vector2D&);

View file

@ -189,7 +189,7 @@ void IHyprLayout::onBeginDragWindow() {
g_pCompositor->setWindowFullscreen(DRAGGINGWINDOW, false, FULLSCREEN_FULL); g_pCompositor->setWindowFullscreen(DRAGGINGWINDOW, false, FULLSCREEN_FULL);
} }
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(DRAGGINGWINDOW->m_iWorkspaceID); const auto PWORKSPACE = DRAGGINGWINDOW->m_pWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow && (!DRAGGINGWINDOW->m_bCreatedOverFullscreen || !DRAGGINGWINDOW->m_bIsFloating)) { if (PWORKSPACE->m_bHasFullscreenWindow && (!DRAGGINGWINDOW->m_bCreatedOverFullscreen || !DRAGGINGWINDOW->m_bIsFloating)) {
Debug::log(LOG, "Rejecting drag on a fullscreen workspace. (window under fullscreen)"); Debug::log(LOG, "Rejecting drag on a fullscreen workspace. (window under fullscreen)");
@ -329,7 +329,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
static auto TIMER = std::chrono::high_resolution_clock::now(), MSTIMER = TIMER; static auto TIMER = std::chrono::high_resolution_clock::now(), MSTIMER = TIMER;
const auto SPECIAL = g_pCompositor->isWorkspaceSpecial(DRAGGINGWINDOW->m_iWorkspaceID); const auto SPECIAL = DRAGGINGWINDOW->onSpecialWorkspace();
const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y); const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y); const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y);
@ -479,10 +479,10 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
if (!TILED) { if (!TILED) {
const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.value() + pWindow->m_vRealSize.value() / 2.f); const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.value() + pWindow->m_vRealSize.value() / 2.f);
pWindow->m_iMonitorID = PNEWMON->ID; pWindow->m_iMonitorID = PNEWMON->ID;
pWindow->moveToWorkspace(PNEWMON->specialWorkspaceID != 0 ? PNEWMON->specialWorkspaceID : PNEWMON->activeWorkspace); pWindow->moveToWorkspace(PNEWMON->activeSpecialWorkspace ? PNEWMON->activeSpecialWorkspace : PNEWMON->activeWorkspace);
pWindow->updateGroupOutputs(); pWindow->updateGroupOutputs();
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNEWMON->specialWorkspaceID != 0 ? PNEWMON->specialWorkspaceID : PNEWMON->activeWorkspace); const auto PWORKSPACE = PNEWMON->activeSpecialWorkspace ? PNEWMON->activeSpecialWorkspace : PNEWMON->activeWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow) if (PWORKSPACE->m_bHasFullscreenWindow)
g_pCompositor->setWindowFullscreen(g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID), false); g_pCompositor->setWindowFullscreen(g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID), false);
@ -569,17 +569,17 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
if (!pWindow) if (!pWindow)
return nullptr; return nullptr;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
// first of all, if this is a fullscreen workspace, // first of all, if this is a fullscreen workspace,
if (PWORKSPACE->m_bHasFullscreenWindow) if (PWORKSPACE->m_bHasFullscreenWindow)
return g_pCompositor->getFullscreenWindowOnWorkspace(pWindow->m_iWorkspaceID); return g_pCompositor->getFullscreenWindowOnWorkspace(pWindow->workspaceID());
if (pWindow->m_bIsFloating) { if (pWindow->m_bIsFloating) {
// find whether there is a floating window below this one // find whether there is a floating window below this one
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_pWorkspace == pWindow->m_pWorkspace && !w->m_bX11ShouldntFocus &&
!w->m_sAdditionalConfigData.noFocus && w.get() != pWindow) { !w->m_sAdditionalConfigData.noFocus && w.get() != pWindow) {
if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x, if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x,
w->m_vPosition.y + w->m_vSize.y)) { w->m_vPosition.y + w->m_vSize.y)) {
@ -589,7 +589,7 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
} }
// let's try the last tiled window. // let's try the last tiled window.
if (m_pLastTiledWindow && m_pLastTiledWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID) if (m_pLastTiledWindow && m_pLastTiledWindow->m_pWorkspace == pWindow->m_pWorkspace)
return m_pLastTiledWindow; return m_pLastTiledWindow;
// if we don't, let's try to find any window that is in the middle // if we don't, let's try to find any window that is in the middle
@ -599,7 +599,7 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
// if not, floating window // if not, floating window
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_pWorkspace == pWindow->m_pWorkspace && !w->m_bX11ShouldntFocus &&
!w->m_sAdditionalConfigData.noFocus && w.get() != pWindow) !w->m_sAdditionalConfigData.noFocus && w.get() != pWindow)
return w.get(); return w.get();
} }
@ -612,10 +612,10 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
auto pWindowCandidate = g_pCompositor->vectorToWindowUnified(pWindow->middle(), RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING); auto pWindowCandidate = g_pCompositor->vectorToWindowUnified(pWindow->middle(), RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING);
if (!pWindowCandidate) if (!pWindowCandidate)
pWindowCandidate = g_pCompositor->getTopLeftWindowOnWorkspace(pWindow->m_iWorkspaceID); pWindowCandidate = g_pCompositor->getTopLeftWindowOnWorkspace(pWindow->workspaceID());
if (!pWindowCandidate) if (!pWindowCandidate)
pWindowCandidate = g_pCompositor->getFirstWindowOnWorkspace(pWindow->m_iWorkspaceID); pWindowCandidate = g_pCompositor->getFirstWindowOnWorkspace(pWindow->workspaceID());
if (!pWindowCandidate || pWindow == pWindowCandidate || !pWindowCandidate->m_bIsMapped || pWindowCandidate->isHidden() || pWindowCandidate->m_bX11ShouldntFocus || if (!pWindowCandidate || pWindow == pWindowCandidate || !pWindowCandidate->m_bIsMapped || pWindowCandidate->isHidden() || pWindowCandidate->m_bX11ShouldntFocus ||
pWindowCandidate->m_iX11Type == 2 || pWindowCandidate->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID) pWindowCandidate->m_iX11Type == 2 || pWindowCandidate->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)

View file

@ -90,7 +90,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back(); const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();
PNODE->workspaceID = pWindow->m_iWorkspaceID; PNODE->workspaceID = pWindow->workspaceID();
PNODE->pWindow = pWindow; PNODE->pWindow = pWindow;
static auto PNEWISMASTER = CConfigValue<Hyprlang::INT>("master:new_is_master"); static auto PNEWISMASTER = CConfigValue<Hyprlang::INT>("master:new_is_master");
@ -99,9 +99,9 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
static auto PMFACT = CConfigValue<Hyprlang::FLOAT>("master:mfact"); static auto PMFACT = CConfigValue<Hyprlang::FLOAT>("master:mfact");
float lastSplitPercent = *PMFACT; float lastSplitPercent = *PMFACT;
auto OPENINGON = isWindowTiled(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID ? auto OPENINGON = isWindowTiled(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_pWorkspace == pWindow->m_pWorkspace ?
getNodeFromWindow(g_pCompositor->m_pLastWindow) : getNodeFromWindow(g_pCompositor->m_pLastWindow) :
getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID); getMasterNodeOnWorkspace(pWindow->workspaceID());
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
@ -133,7 +133,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
pWindow->applyGroupRules(); pWindow->applyGroupRules();
static auto PDROPATCURSOR = CConfigValue<Hyprlang::INT>("master:drop_at_cursor"); static auto PDROPATCURSOR = CConfigValue<Hyprlang::INT>("master:drop_at_cursor");
const auto PWORKSPACEDATA = getMasterWorkspaceData(pWindow->m_iWorkspaceID); const auto PWORKSPACEDATA = getMasterWorkspaceData(pWindow->workspaceID());
eOrientation orientation = PWORKSPACEDATA->orientation; eOrientation orientation = PWORKSPACEDATA->orientation;
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE); const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
@ -142,7 +142,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
if (*PDROPATCURSOR && g_pInputManager->dragMode == MBIND_MOVE) { if (*PDROPATCURSOR && g_pInputManager->dragMode == MBIND_MOVE) {
if (WINDOWSONWORKSPACE > 2) { if (WINDOWSONWORKSPACE > 2) {
for (auto it = m_lMasterNodesData.begin(); it != m_lMasterNodesData.end(); ++it) { for (auto it = m_lMasterNodesData.begin(); it != m_lMasterNodesData.end(); ++it) {
if (it->workspaceID != pWindow->m_iWorkspaceID) if (it->workspaceID != pWindow->workspaceID())
continue; continue;
const CBox box = it->pWindow->getWindowIdealBoundingBoxIgnoreReserved(); const CBox box = it->pWindow->getWindowIdealBoundingBoxIgnoreReserved();
if (box.containsPoint(MOUSECOORDS)) { if (box.containsPoint(MOUSECOORDS)) {
@ -286,41 +286,36 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
void CHyprMasterLayout::recalculateMonitor(const int& monid) { void CHyprMasterLayout::recalculateMonitor(const int& monid) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid); const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
if (!PMONITOR) if (!PMONITOR || !PMONITOR->activeWorkspace)
return; return;
g_pHyprRenderer->damageMonitor(PMONITOR); g_pHyprRenderer->damageMonitor(PMONITOR);
if (PMONITOR->specialWorkspaceID) if (PMONITOR->activeSpecialWorkspace)
calculateWorkspace(PMONITOR->specialWorkspaceID); calculateWorkspace(PMONITOR->activeSpecialWorkspace);
calculateWorkspace(PMONITOR->activeWorkspace); calculateWorkspace(PMONITOR->activeWorkspace);
} }
void CHyprMasterLayout::calculateWorkspace(const int& ws) { void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
if (!PWORKSPACE)
return;
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
if (!PMONITOR) if (!PMONITOR)
return; return;
if (PWORKSPACE->m_bHasFullscreenWindow) { if (pWorkspace->m_bHasFullscreenWindow) {
// massive hack from the fullscreen func // massive hack from the fullscreen func
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(pWorkspace->m_iID);
if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { if (pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL) {
PFULLWINDOW->m_vRealPosition = PMONITOR->vecPosition; PFULLWINDOW->m_vRealPosition = PMONITOR->vecPosition;
PFULLWINDOW->m_vRealSize = PMONITOR->vecSize; PFULLWINDOW->m_vRealSize = PMONITOR->vecSize;
} else if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) { } else if (pWorkspace->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
SMasterNodeData fakeNode; SMasterNodeData fakeNode;
fakeNode.pWindow = PFULLWINDOW; fakeNode.pWindow = PFULLWINDOW;
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight; fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = PWORKSPACE->m_iID; fakeNode.workspaceID = pWorkspace->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.position; PFULLWINDOW->m_vPosition = fakeNode.position;
PFULLWINDOW->m_vSize = fakeNode.size; PFULLWINDOW->m_vSize = fakeNode.size;
fakeNode.ignoreFullscreenChecks = true; fakeNode.ignoreFullscreenChecks = true;
@ -332,14 +327,14 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
return; return;
} }
const auto PWORKSPACEDATA = getMasterWorkspaceData(ws); const auto PWORKSPACEDATA = getMasterWorkspaceData(pWorkspace->m_iID);
const auto PMASTERNODE = getMasterNodeOnWorkspace(PWORKSPACE->m_iID); const auto PMASTERNODE = getMasterNodeOnWorkspace(pWorkspace->m_iID);
if (!PMASTERNODE) if (!PMASTERNODE)
return; return;
// dynamic workspace rules // dynamic workspace rules
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(g_pCompositor->getWorkspaceByID(ws)); const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(pWorkspace);
std::string orientationForWs; std::string orientationForWs;
for (auto& wsRule : WORKSPACERULES) { for (auto& wsRule : WORKSPACERULES) {
@ -363,8 +358,8 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master"); static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing"); static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");
const auto MASTERS = getMastersOnWorkspace(PWORKSPACE->m_iID); const auto MASTERS = getMastersOnWorkspace(pWorkspace->m_iID);
const auto WINDOWS = getNodesOnWorkspace(PWORKSPACE->m_iID); const auto WINDOWS = getNodesOnWorkspace(pWorkspace->m_iID);
const auto STACKWINDOWS = WINDOWS - MASTERS; const auto STACKWINDOWS = WINDOWS - MASTERS;
const auto WSSIZE = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight; const auto WSSIZE = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
const auto WSPOS = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; const auto WSPOS = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
@ -387,7 +382,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
// check the total width and height so that later // check the total width and height so that later
// if larger/smaller than screen size them down/up // if larger/smaller than screen size them down/up
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID == PWORKSPACE->m_iID) { if (nd.workspaceID == pWorkspace->m_iID) {
if (nd.isMaster) if (nd.isMaster)
masterAccumulatedSize += totalSize / MASTERS * nd.percSize; masterAccumulatedSize += totalSize / MASTERS * nd.percSize;
else else
@ -414,7 +409,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
nextY = WSSIZE.y - HEIGHT; nextY = WSSIZE.y - HEIGHT;
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || !nd.isMaster) if (nd.workspaceID != pWorkspace->m_iID || !nd.isMaster)
continue; continue;
float WIDTH = mastersLeft > 1 ? widthLeft / mastersLeft * nd.percSize : widthLeft; float WIDTH = mastersLeft > 1 ? widthLeft / mastersLeft * nd.percSize : widthLeft;
@ -451,7 +446,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
} }
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || !nd.isMaster) if (nd.workspaceID != pWorkspace->m_iID || !nd.isMaster)
continue; continue;
float HEIGHT = mastersLeft > 1 ? heightLeft / mastersLeft * nd.percSize : heightLeft; float HEIGHT = mastersLeft > 1 ? heightLeft / mastersLeft * nd.percSize : heightLeft;
@ -488,7 +483,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
nextY = PMASTERNODE->size.y; nextY = PMASTERNODE->size.y;
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster) if (nd.workspaceID != pWorkspace->m_iID || nd.isMaster)
continue; continue;
float WIDTH = slavesLeft > 1 ? widthLeft / slavesLeft * nd.percSize : widthLeft; float WIDTH = slavesLeft > 1 ? widthLeft / slavesLeft * nd.percSize : widthLeft;
@ -518,7 +513,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
nextX = PMASTERNODE->size.x; nextX = PMASTERNODE->size.x;
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster) if (nd.workspaceID != pWorkspace->m_iID || nd.isMaster)
continue; continue;
float HEIGHT = slavesLeft > 1 ? heightLeft / slavesLeft * nd.percSize : heightLeft; float HEIGHT = slavesLeft > 1 ? heightLeft / slavesLeft * nd.percSize : heightLeft;
@ -558,7 +553,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
float slaveAccumulatedHeightR = 0; float slaveAccumulatedHeightR = 0;
if (*PSMARTRESIZING) { if (*PSMARTRESIZING) {
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster) if (nd.workspaceID != pWorkspace->m_iID || nd.isMaster)
continue; continue;
if (onRight) { if (onRight) {
@ -572,7 +567,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
} }
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster) if (nd.workspaceID != pWorkspace->m_iID || nd.isMaster)
continue; continue;
if (onRight) { if (onRight) {
@ -625,7 +620,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) { if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) {
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m->specialWorkspaceID == pNode->workspaceID) { if (m->activeSpecialWorkspaceID() == pNode->workspaceID) {
PMONITOR = m.get(); PMONITOR = m.get();
break; break;
} }
@ -648,7 +643,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
const auto PWINDOW = pNode->pWindow; const auto PWINDOW = pNode->pWindow;
// get specific gaps and rules for this workspace, // get specific gaps and rules for this workspace,
// if user specified them in config // if user specified them in config
const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)); const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(PWINDOW->m_pWorkspace);
if (PWINDOW->m_bIsFullscreen && !pNode->ignoreFullscreenChecks) if (PWINDOW->m_bIsFullscreen && !pNode->ignoreFullscreenChecks)
return; return;
@ -679,9 +674,9 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
PWINDOW->m_vSize = pNode->size; PWINDOW->m_vSize = pNode->size;
PWINDOW->m_vPosition = pNode->position; PWINDOW->m_vPosition = pNode->position;
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && if (*PNOGAPSWHENONLY && !PWINDOW->onSpecialWorkspace() &&
(getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 || (getNodesOnWorkspace(PWINDOW->workspaceID()) == 1 ||
(PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) { (PWINDOW->m_bIsFullscreen && PWINDOW->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
PWINDOW->m_sSpecialRenderData.rounding = false; PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.shadow = false; PWINDOW->m_sSpecialRenderData.shadow = false;
@ -721,7 +716,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
calcPos = calcPos + RESERVED.topLeft; calcPos = calcPos + RESERVED.topLeft;
calcSize = calcSize - (RESERVED.topLeft + RESERVED.bottomRight); calcSize = calcSize - (RESERVED.topLeft + RESERVED.bottomRight);
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && !PWINDOW->m_bIsFullscreen) { if (PWINDOW->onSpecialWorkspace() && !PWINDOW->m_bIsFullscreen) {
static auto PSCALEFACTOR = CConfigValue<Hyprlang::FLOAT>("master:special_scale_factor"); static auto PSCALEFACTOR = CConfigValue<Hyprlang::FLOAT>("master:special_scale_factor");
CBox wb = {calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f, calcSize * *PSCALEFACTOR}; CBox wb = {calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f, calcSize * *PSCALEFACTOR};
@ -772,7 +767,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
} }
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->m_iWorkspaceID); const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->workspaceID());
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master"); static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing"); static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");
@ -793,7 +788,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
const auto WINDOWS = getNodesOnWorkspace(PNODE->workspaceID); const auto WINDOWS = getNodesOnWorkspace(PNODE->workspaceID);
const auto STACKWINDOWS = WINDOWS - MASTERS; const auto STACKWINDOWS = WINDOWS - MASTERS;
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 && !centered) if (getNodesOnWorkspace(PWINDOW->workspaceID()) == 1 && !centered)
return; return;
m_bForceWarps = true; m_bForceWarps = true;
@ -815,7 +810,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
default: UNREACHABLE(); default: UNREACHABLE();
} }
const auto workspaceIdForResizing = PMONITOR->specialWorkspaceID == 0 ? PMONITOR->activeWorkspace : PMONITOR->specialWorkspaceID; const auto workspaceIdForResizing = PMONITOR->activeSpecialWorkspace ? PMONITOR->activeWorkspaceID() : PMONITOR->activeSpecialWorkspaceID();
for (auto& n : m_lMasterNodesData) { for (auto& n : m_lMasterNodesData) {
if (n.isMaster && n.workspaceID == workspaceIdForResizing) if (n.isMaster && n.workspaceID == workspaceIdForResizing)
n.percMaster = std::clamp(n.percMaster + delta, 0.05, 0.95); n.percMaster = std::clamp(n.percMaster + delta, 0.05, 0.95);
@ -908,7 +903,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
return; // ignore return; // ignore
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow && on) { if (PWORKSPACE->m_bHasFullscreenWindow && on) {
// if the window wants to be fullscreen but there already is one, // if the window wants to be fullscreen but there already is one,
@ -964,7 +959,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
fakeNode.pWindow = pWindow; fakeNode.pWindow = pWindow;
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight; fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = pWindow->m_iWorkspaceID; fakeNode.workspaceID = pWindow->workspaceID();
pWindow->m_vPosition = fakeNode.position; pWindow->m_vPosition = fakeNode.position;
pWindow->m_vSize = fakeNode.size; pWindow->m_vSize = fakeNode.size;
fakeNode.ignoreFullscreenChecks = true; fakeNode.ignoreFullscreenChecks = true;
@ -1007,10 +1002,10 @@ void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir) {
pWindow->setAnimationsToMove(); pWindow->setAnimationsToMove();
if (pWindow->m_iWorkspaceID != PWINDOW2->m_iWorkspaceID) { if (pWindow->m_pWorkspace != PWINDOW2->m_pWorkspace) {
// if different monitors, send to monitor // if different monitors, send to monitor
onWindowRemovedTiling(pWindow); onWindowRemovedTiling(pWindow);
pWindow->moveToWorkspace(PWINDOW2->m_iWorkspaceID); pWindow->moveToWorkspace(PWINDOW2->m_pWorkspace);
pWindow->m_iMonitorID = PWINDOW2->m_iMonitorID; pWindow->m_iMonitorID = PWINDOW2->m_iMonitorID;
const auto pMonitor = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); const auto pMonitor = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
g_pCompositor->setActiveMonitor(pMonitor); g_pCompositor->setActiveMonitor(pMonitor);
@ -1032,7 +1027,7 @@ void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
if (PNODE->workspaceID != PNODE2->workspaceID) { if (PNODE->workspaceID != PNODE2->workspaceID) {
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID); std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID); std::swap(pWindow2->m_pWorkspace, pWindow->m_pWorkspace);
} }
// massive hack: just swap window pointers, lol // massive hack: just swap window pointers, lol
@ -1058,7 +1053,7 @@ void CHyprMasterLayout::alterSplitRatio(CWindow* pWindow, float ratio, bool exac
if (!PNODE) if (!PNODE)
return; return;
const auto PMASTER = getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID); const auto PMASTER = getMasterNodeOnWorkspace(pWindow->workspaceID());
float newRatio = exact ? ratio : PMASTER->percMaster + ratio; float newRatio = exact ? ratio : PMASTER->percMaster + ratio;
PMASTER->percMaster = std::clamp(newRatio, 0.05f, 0.95f); PMASTER->percMaster = std::clamp(newRatio, 0.05f, 0.95f);
@ -1094,7 +1089,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
return; return;
if (header.pWindow->m_bIsFullscreen) { if (header.pWindow->m_bIsFullscreen) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(header.pWindow->m_iWorkspaceID); const auto PWORKSPACE = header.pWindow->m_pWorkspace;
const auto FSMODE = PWORKSPACE->m_efFullscreenMode; const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
static auto INHERITFULLSCREEN = CConfigValue<Hyprlang::INT>("master:inherit_fullscreen"); static auto INHERITFULLSCREEN = CConfigValue<Hyprlang::INT>("master:inherit_fullscreen");
g_pCompositor->setWindowFullscreen(header.pWindow, false, FULLSCREEN_FULL); g_pCompositor->setWindowFullscreen(header.pWindow, false, FULLSCREEN_FULL);
@ -1134,7 +1129,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (!isWindowTiled(PWINDOW)) if (!isWindowTiled(PWINDOW))
return 0; return 0;
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID); const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->workspaceID());
if (!PMASTER) if (!PMASTER)
return 0; return 0;
@ -1172,7 +1167,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (!PWINDOW) if (!PWINDOW)
return 0; return 0;
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID); const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->workspaceID());
if (!PMASTER) if (!PMASTER)
return 0; return 0;
@ -1249,8 +1244,8 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
const auto PNODE = getNodeFromWindow(header.pWindow); const auto PNODE = getNodeFromWindow(header.pWindow);
const auto WINDOWS = getNodesOnWorkspace(header.pWindow->m_iWorkspaceID); const auto WINDOWS = getNodesOnWorkspace(header.pWindow->workspaceID());
const auto MASTERS = getMastersOnWorkspace(header.pWindow->m_iWorkspaceID); const auto MASTERS = getMastersOnWorkspace(header.pWindow->workspaceID());
static auto SMALLSPLIT = CConfigValue<Hyprlang::INT>("master:allow_small_split"); static auto SMALLSPLIT = CConfigValue<Hyprlang::INT>("master:allow_small_split");
if (MASTERS + 2 > WINDOWS && *SMALLSPLIT == 0) if (MASTERS + 2 > WINDOWS && *SMALLSPLIT == 0)
@ -1260,7 +1255,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (!PNODE || PNODE->isMaster) { if (!PNODE || PNODE->isMaster) {
// first non-master node // first non-master node
for (auto& n : m_lMasterNodesData) { for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == header.pWindow->m_iWorkspaceID && !n.isMaster) { if (n.workspaceID == header.pWindow->workspaceID() && !n.isMaster) {
n.isMaster = true; n.isMaster = true;
break; break;
} }
@ -1281,8 +1276,8 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
const auto PNODE = getNodeFromWindow(header.pWindow); const auto PNODE = getNodeFromWindow(header.pWindow);
const auto WINDOWS = getNodesOnWorkspace(header.pWindow->m_iWorkspaceID); const auto WINDOWS = getNodesOnWorkspace(header.pWindow->workspaceID());
const auto MASTERS = getMastersOnWorkspace(header.pWindow->m_iWorkspaceID); const auto MASTERS = getMastersOnWorkspace(header.pWindow->workspaceID());
if (WINDOWS < 2 || MASTERS < 2) if (WINDOWS < 2 || MASTERS < 2)
return 0; return 0;
@ -1292,7 +1287,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (!PNODE || !PNODE->isMaster) { if (!PNODE || !PNODE->isMaster) {
// first non-master node // first non-master node
for (auto& nd : m_lMasterNodesData | std::views::reverse) { for (auto& nd : m_lMasterNodesData | std::views::reverse) {
if (nd.workspaceID == header.pWindow->m_iWorkspaceID && nd.isMaster) { if (nd.workspaceID == header.pWindow->workspaceID() && nd.isMaster) {
nd.isMaster = false; nd.isMaster = false;
break; break;
} }
@ -1310,7 +1305,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL); g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL);
const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->m_iWorkspaceID); const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->workspaceID());
if (command == "orientationleft") if (command == "orientationleft")
PWORKSPACEDATA->orientation = ORIENTATION_LEFT; PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
@ -1418,7 +1413,7 @@ void CHyprMasterLayout::runOrientationCycle(SLayoutMessageHeader& header, CVarLi
g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL); g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL);
const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->m_iWorkspaceID); const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->workspaceID());
int nextOrPrev = 0; int nextOrPrev = 0;
for (size_t i = 0; i < cycle.size(); ++i) { for (size_t i = 0; i < cycle.size(); ++i) {
@ -1476,19 +1471,19 @@ Vector2D CHyprMasterLayout::predictSizeForNewWindowTiled() {
if (!g_pCompositor->m_pLastMonitor) if (!g_pCompositor->m_pLastMonitor)
return {}; return {};
const int NODES = getNodesOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace); const int NODES = getNodesOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID);
if (NODES <= 0) if (NODES <= 0)
return g_pCompositor->m_pLastMonitor->vecSize; return g_pCompositor->m_pLastMonitor->vecSize;
const auto MASTER = getMasterNodeOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto MASTER = getMasterNodeOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID);
if (!MASTER) // wtf if (!MASTER) // wtf
return {}; return {};
if (*PNEWISMASTER) { if (*PNEWISMASTER) {
return MASTER->size; return MASTER->size;
} else { } else {
const auto SLAVES = NODES - getMastersOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto SLAVES = NODES - getMastersOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID);
// TODO: make this better // TODO: make this better
return {g_pCompositor->m_pLastMonitor->vecSize.x - MASTER->size.x, g_pCompositor->m_pLastMonitor->vecSize.y / (SLAVES + 1)}; return {g_pCompositor->m_pLastMonitor->vecSize.x - MASTER->size.x, g_pCompositor->m_pLastMonitor->vecSize.y / (SLAVES + 1)};

View file

@ -84,7 +84,7 @@ class CHyprMasterLayout : public IHyprLayout {
SMasterNodeData* getNodeFromWindow(CWindow*); SMasterNodeData* getNodeFromWindow(CWindow*);
SMasterNodeData* getMasterNodeOnWorkspace(const int&); SMasterNodeData* getMasterNodeOnWorkspace(const int&);
SMasterWorkspaceData* getMasterWorkspaceData(const int&); SMasterWorkspaceData* getMasterWorkspaceData(const int&);
void calculateWorkspace(const int&); void calculateWorkspace(PHLWORKSPACE);
CWindow* getNextWindow(CWindow*, bool); CWindow* getNextWindow(CWindow*, bool);
int getMastersOnWorkspace(const int&); int getMastersOnWorkspace(const int&);

View file

@ -80,7 +80,7 @@ void CAnimationManager::tick() {
// window stuff // window stuff
const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWINDOW = (CWindow*)av->m_pWindow;
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; PHLWORKSPACE PWORKSPACE = av->m_pWorkspace.lock();
const auto PLAYER = (SLayerSurface*)av->m_pLayer; const auto PLAYER = (SLayerSurface*)av->m_pLayer;
CMonitor* PMONITOR = nullptr; CMonitor* PMONITOR = nullptr;
bool animationsDisabled = animGlobalDisabled; bool animationsDisabled = animGlobalDisabled;
@ -111,7 +111,7 @@ void CAnimationManager::tick() {
// TODO: just make this into a damn callback already vax... // TODO: just make this into a damn callback already vax...
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->isHidden() || w->m_iWorkspaceID != PWORKSPACE->m_iID) if (!w->m_bIsMapped || w->isHidden() || w->m_pWorkspace != PWORKSPACE)
continue; continue;
if (w->m_bIsFloating && !w->m_bPinned) { if (w->m_bIsFloating && !w->m_bPinned) {
@ -129,7 +129,7 @@ void CAnimationManager::tick() {
// damage any workspace window that is on any monitor // damage any workspace window that is on any monitor
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(w.get()) || w->m_iWorkspaceID != PWORKSPACE->m_iID || w->m_bPinned) if (!g_pCompositor->windowValidMapped(w.get()) || w->m_pWorkspace != PWORKSPACE || w->m_bPinned)
continue; continue;
g_pHyprRenderer->damageWindow(w.get()); g_pHyprRenderer->damageWindow(w.get());
@ -146,7 +146,7 @@ void CAnimationManager::tick() {
animationsDisabled = animationsDisabled || PLAYER->noAnimations; animationsDisabled = animationsDisabled || PLAYER->noAnimations;
} }
const bool VISIBLE = PWINDOW ? g_pCompositor->isWorkspaceVisible(PWINDOW->m_iWorkspaceID) : true; const bool VISIBLE = PWINDOW && PWINDOW->m_pWorkspace ? g_pCompositor->isWorkspaceVisible(PWINDOW->workspaceID()) : true;
// beziers are with a switch unforto // beziers are with a switch unforto
// TODO: maybe do something cleaner // TODO: maybe do something cleaner
@ -212,7 +212,7 @@ void CAnimationManager::tick() {
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
} else if (PWORKSPACE) { } else if (PWORKSPACE) {
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(w.get()) || w->m_iWorkspaceID != PWORKSPACE->m_iID) if (!g_pCompositor->windowValidMapped(w.get()) || w->m_pWorkspace != PWORKSPACE)
continue; continue;
w->updateWindowDecos(); w->updateWindowDecos();

View file

@ -225,13 +225,13 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
return false; return false;
} }
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
const auto PNEWMAINWORKSPACE = g_pCompositor->getWorkspaceByID(monitor->activeWorkspace); const auto PNEWMAINWORKSPACE = monitor->activeWorkspace;
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
PNEWMAINWORKSPACE->rememberPrevWorkspace(PWORKSPACE); PNEWMAINWORKSPACE->rememberPrevWorkspace(PWORKSPACE);
const auto PNEWWORKSPACE = monitor->specialWorkspaceID != 0 ? g_pCompositor->getWorkspaceByID(monitor->specialWorkspaceID) : PNEWMAINWORKSPACE; const auto PNEWWORKSPACE = monitor->activeSpecialWorkspace ? monitor->activeSpecialWorkspace : PNEWMAINWORKSPACE;
const auto PNEWWINDOW = PNEWWORKSPACE->getLastFocusedWindow(); const auto PNEWWINDOW = PNEWWORKSPACE->getLastFocusedWindow();
if (PNEWWINDOW) { if (PNEWWINDOW) {
@ -259,8 +259,8 @@ void CKeybindManager::switchToWindow(CWindow* PWINDOWTOCHANGETO) {
// remove constraints // remove constraints
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
if (PLASTWINDOW && PLASTWINDOW->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && PLASTWINDOW->m_bIsFullscreen) { if (PLASTWINDOW && PLASTWINDOW->m_pWorkspace == PWINDOWTOCHANGETO->m_pWorkspace && PLASTWINDOW->m_bIsFullscreen) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PLASTWINDOW->m_iWorkspaceID); const auto PWORKSPACE = PLASTWINDOW->m_pWorkspace;
const auto FSMODE = PWORKSPACE->m_efFullscreenMode; const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
if (!PWINDOWTOCHANGETO->m_bPinned) if (!PWINDOWTOCHANGETO->m_bPinned)
@ -874,11 +874,11 @@ void toggleActiveFloatingCore(std::string args, std::optional<bool> floatState)
curr = curr->m_sGroupData.pNextWindow; curr = curr->m_sGroupData.pNextWindow;
} }
g_pCompositor->updateWorkspaceWindows(PWINDOW->m_iWorkspaceID); g_pCompositor->updateWorkspaceWindows(PWINDOW->workspaceID());
} else { } else {
PWINDOW->m_bIsFloating = !PWINDOW->m_bIsFloating; PWINDOW->m_bIsFloating = !PWINDOW->m_bIsFloating;
g_pCompositor->updateWorkspaceWindows(PWINDOW->m_iWorkspaceID); g_pCompositor->updateWorkspaceWindows(PWINDOW->workspaceID());
g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PWINDOW); g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PWINDOW);
} }
@ -927,7 +927,7 @@ void CKeybindManager::changeworkspace(std::string args) {
if (!PMONITOR) if (!PMONITOR)
return; return;
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); const auto PCURRENTWORKSPACE = PMONITOR->activeWorkspace;
const bool EXPLICITPREVIOUS = args.starts_with("previous"); const bool EXPLICITPREVIOUS = args.starts_with("previous");
if (args.starts_with("previous")) { if (args.starts_with("previous")) {
@ -1044,14 +1044,14 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
return; return;
} }
if (WORKSPACEID == PWINDOW->m_iWorkspaceID) { if (WORKSPACEID == PWINDOW->workspaceID()) {
Debug::log(LOG, "Not moving to workspace because it didn't change."); Debug::log(LOG, "Not moving to workspace because it didn't change.");
return; return;
} }
auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID); auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID);
CMonitor* pMonitor = nullptr; CMonitor* pMonitor = nullptr;
const auto POLDWS = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); const auto POLDWS = PWINDOW->m_pWorkspace;
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles"); static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
@ -1106,7 +1106,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
return; return;
} }
if (WORKSPACEID == PWINDOW->m_iWorkspaceID) if (WORKSPACEID == PWINDOW->workspaceID())
return; return;
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
@ -1220,7 +1220,7 @@ void CKeybindManager::moveActiveTo(std::string args) {
if (!PNEWMONITOR) if (!PNEWMONITOR)
return; return;
moveActiveToWorkspace(std::to_string(PNEWMONITOR->activeWorkspace)); moveActiveToWorkspace(PNEWMONITOR->activeWorkspace->getConfigName());
return; return;
} }
@ -1265,7 +1265,7 @@ void CKeybindManager::moveActiveTo(std::string args) {
if (!PMONITORTOCHANGETO) if (!PMONITORTOCHANGETO)
return; return;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITORTOCHANGETO->activeWorkspace); const auto PWORKSPACE = PMONITORTOCHANGETO->activeWorkspace;
moveActiveToWorkspace(PWORKSPACE->getConfigName()); moveActiveToWorkspace(PWORKSPACE->getConfigName());
} }
@ -1324,7 +1324,7 @@ void CKeybindManager::toggleSplit(std::string args) {
if (!header.pWindow) if (!header.pWindow)
return; return;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(header.pWindow->m_iWorkspaceID); const auto PWORKSPACE = header.pWindow->m_pWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow) if (PWORKSPACE->m_bHasFullscreenWindow)
return; return;
@ -1339,7 +1339,7 @@ void CKeybindManager::swapSplit(std::string args) {
if (!header.pWindow) if (!header.pWindow)
return; return;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(header.pWindow->m_iWorkspaceID); const auto PWORKSPACE = header.pWindow->m_pWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow) if (PWORKSPACE->m_bHasFullscreenWindow)
return; return;
@ -1447,7 +1447,7 @@ void CKeybindManager::moveCursor(std::string args) {
void CKeybindManager::workspaceOpt(std::string args) { void CKeybindManager::workspaceOpt(std::string args) {
// current workspace // current workspace
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
if (!PWORKSPACE) if (!PWORKSPACE)
return; // ???? return; // ????
@ -1457,7 +1457,7 @@ void CKeybindManager::workspaceOpt(std::string args) {
// apply // apply
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID) if (!w->m_bIsMapped || w->m_pWorkspace != PWORKSPACE)
continue; continue;
w->m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo; w->m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo;
@ -1472,7 +1472,7 @@ void CKeybindManager::workspaceOpt(std::string args) {
ptrs.push_back(w.get()); ptrs.push_back(w.get());
for (auto& w : ptrs) { for (auto& w : ptrs) {
if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID || w->isHidden()) if (!w->m_bIsMapped || w->m_pWorkspace != PWORKSPACE || w->isHidden())
continue; continue;
if (!w->m_bRequestsFloat && w->m_bIsFloating != PWORKSPACE->m_bDefaultFloating) { if (!w->m_bRequestsFloat && w->m_bIsFloating != PWORKSPACE->m_bDefaultFloating) {
@ -1526,7 +1526,7 @@ void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) {
} }
// get the current workspace // get the current workspace
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PCURRENTWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
if (!PCURRENTWORKSPACE) { if (!PCURRENTWORKSPACE) {
Debug::log(ERR, "moveCurrentWorkspaceToMonitor invalid workspace!"); Debug::log(ERR, "moveCurrentWorkspaceToMonitor invalid workspace!");
@ -1595,7 +1595,7 @@ void CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args) {
static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth"); static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
if (*PBACKANDFORTH && PCURRMONITOR->activeWorkspace == workspaceID && pWorkspace->m_sPrevWorkspace.iID != -1) { if (*PBACKANDFORTH && PCURRMONITOR->activeWorkspaceID() == workspaceID && pWorkspace->m_sPrevWorkspace.iID != -1) {
const int PREVWORKSPACEID = pWorkspace->m_sPrevWorkspace.iID; const int PREVWORKSPACEID = pWorkspace->m_sPrevWorkspace.iID;
const auto PREVWORKSPACENAME = pWorkspace->m_sPrevWorkspace.name; const auto PREVWORKSPACENAME = pWorkspace->m_sPrevWorkspace.name;
// Workspace to focus is previous workspace // Workspace to focus is previous workspace
@ -1612,7 +1612,7 @@ void CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args) {
Debug::log(ERR, "focusWorkspaceOnCurrentMonitor old monitor doesn't exist!"); Debug::log(ERR, "focusWorkspaceOnCurrentMonitor old monitor doesn't exist!");
return; return;
} }
if (POLDMONITOR->activeWorkspace == workspaceID) { if (POLDMONITOR->activeWorkspaceID() == workspaceID) {
g_pCompositor->swapActiveWorkspaces(POLDMONITOR, PCURRMONITOR); g_pCompositor->swapActiveWorkspaces(POLDMONITOR, PCURRMONITOR);
return; return;
} else { } else {
@ -1634,10 +1634,10 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
bool requestedWorkspaceIsAlreadyOpen = false; bool requestedWorkspaceIsAlreadyOpen = false;
const auto PMONITOR = g_pCompositor->m_pLastMonitor; const auto PMONITOR = g_pCompositor->m_pLastMonitor;
int specialOpenOnMonitor = PMONITOR->specialWorkspaceID; int specialOpenOnMonitor = PMONITOR->activeSpecialWorkspaceID();
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m->specialWorkspaceID == workspaceID) { if (m->activeSpecialWorkspaceID() == workspaceID) {
requestedWorkspaceIsAlreadyOpen = true; requestedWorkspaceIsAlreadyOpen = true;
break; break;
} }
@ -1750,8 +1750,8 @@ void CKeybindManager::circleNext(std::string arg) {
if (!g_pCompositor->m_pLastWindow) { if (!g_pCompositor->m_pLastWindow) {
// if we have a clear focus, find the first window and get the next focusable. // if we have a clear focus, find the first window and get the next focusable.
if (g_pCompositor->getWindowsOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace) > 0) { if (g_pCompositor->getWindowsOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID()) > 0) {
const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID());
switchToWindow(PWINDOW); switchToWindow(PWINDOW);
} }
@ -1781,13 +1781,13 @@ void CKeybindManager::focusWindow(std::string regexp) {
Debug::log(LOG, "Focusing to window name: {}", PWINDOW->m_szTitle); Debug::log(LOG, "Focusing to window name: {}", PWINDOW->m_szTitle);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); const auto PWORKSPACE = PWINDOW->m_pWorkspace;
if (!PWORKSPACE) { if (!PWORKSPACE) {
Debug::log(ERR, "BUG THIS: null workspace in focusWindow"); Debug::log(ERR, "BUG THIS: null workspace in focusWindow");
return; return;
} }
if (g_pCompositor->m_pLastMonitor->activeWorkspace != PWINDOW->m_iWorkspaceID) { if (g_pCompositor->m_pLastMonitor->activeWorkspace != PWINDOW->m_pWorkspace) {
Debug::log(LOG, "Fake executing workspace to move focus"); Debug::log(LOG, "Fake executing workspace to move focus");
changeworkspace(PWORKSPACE->getConfigName()); changeworkspace(PWORKSPACE->getConfigName());
} }
@ -1975,7 +1975,7 @@ void CKeybindManager::swapnext(std::string arg) {
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) && const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) &&
g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_iWorkspaceID == PLASTWINDOW->m_iWorkspaceID ? g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_pWorkspace == PLASTWINDOW->m_pWorkspace ?
g_pCompositor->m_pLastWindow->m_pLastCycledWindow : g_pCompositor->m_pLastWindow->m_pLastCycledWindow :
nullptr; nullptr;
@ -2030,12 +2030,12 @@ void CKeybindManager::pinActive(std::string args) {
return; return;
PWINDOW->m_bPinned = !PWINDOW->m_bPinned; PWINDOW->m_bPinned = !PWINDOW->m_bPinned;
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace; PWINDOW->m_pWorkspace = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace;
PWINDOW->updateDynamicRules(); PWINDOW->updateDynamicRules();
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW); g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); const auto PWORKSPACE = PWINDOW->m_pWorkspace;
PWORKSPACE->m_pLastFocusedWindow = g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS); PWORKSPACE->m_pLastFocusedWindow = g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS);

View file

@ -74,7 +74,7 @@ void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
} }
if (!pWindow->m_bPinned) if (!pWindow->m_bPinned)
g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID)->m_pLastFocusedWindow = pWindow; pWindow->m_pWorkspace->m_pLastFocusedWindow = pWindow;
} }
void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, CBox* pbox) { void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, CBox* pbox) {

View file

@ -65,7 +65,7 @@ void CInputManager::recheckIdleInhibitorStatus() {
return; return;
} }
if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID)) { if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->workspaceID())) {
g_pCompositor->setIdleActivityInhibit(false); g_pCompositor->setIdleActivityInhibit(false);
return; return;
} }

View file

@ -230,7 +230,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface); foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface);
// then, we check if the workspace doesnt have a fullscreen window // then, we check if the workspace doesnt have a fullscreen window
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); const auto PWORKSPACE = PMONITOR->activeWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
@ -244,7 +244,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (PWINDOWIDEAL && if (PWINDOWIDEAL &&
((PWINDOWIDEAL->m_bIsFloating && PWINDOWIDEAL->m_bCreatedOverFullscreen) /* floating over fullscreen */ ((PWINDOWIDEAL->m_bIsFloating && PWINDOWIDEAL->m_bCreatedOverFullscreen) /* floating over fullscreen */
|| (PMONITOR->specialWorkspaceID == PWINDOWIDEAL->m_iWorkspaceID) /* on an open special workspace */)) || (PMONITOR->activeSpecialWorkspace == PWINDOWIDEAL->m_pWorkspace) /* on an open special workspace */))
pFoundWindow = PWINDOWIDEAL; pFoundWindow = PWINDOWIDEAL;
if (!pFoundWindow->m_bIsX11) { if (!pFoundWindow->m_bIsX11) {
@ -260,10 +260,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!foundSurface) { if (!foundSurface) {
if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) { if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
if (PMONITOR->specialWorkspaceID) { if (PMONITOR->activeSpecialWorkspace) {
pFoundWindow = g_pCompositor->vectorToWindowUnified(mouseCoords, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING); pFoundWindow = g_pCompositor->vectorToWindowUnified(mouseCoords, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING);
if (pFoundWindow && !g_pCompositor->isWorkspaceSpecial(pFoundWindow->m_iWorkspaceID)) { if (pFoundWindow && !pFoundWindow->onSpecialWorkspace()) {
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
} }
} else { } else {

View file

@ -24,7 +24,7 @@ void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
} }
void CInputManager::beginWorkspaceSwipe() { void CInputManager::beginWorkspaceSwipe() {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
Debug::log(LOG, "Starting a swipe from {}", PWORKSPACE->m_szName); Debug::log(LOG, "Starting a swipe from {}", PWORKSPACE->m_szName);
@ -87,7 +87,7 @@ void CInputManager::endWorkspaceSwipe() {
const auto XDISTANCE = m_sActiveSwipe.pMonitor->vecSize.x + *PWORKSPACEGAP; const auto XDISTANCE = m_sActiveSwipe.pMonitor->vecSize.x + *PWORKSPACEGAP;
const auto YDISTANCE = m_sActiveSwipe.pMonitor->vecSize.y + *PWORKSPACEGAP; const auto YDISTANCE = m_sActiveSwipe.pMonitor->vecSize.y + *PWORKSPACEGAP;
CWorkspace* pSwitchedTo = nullptr; PHLWORKSPACE pSwitchedTo = nullptr;
if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) ||
abs(m_sActiveSwipe.delta) < 2) { abs(m_sActiveSwipe.delta) < 2) {

View file

@ -37,7 +37,7 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
return; return;
// TODO: Don't swipe if you touched a floating window. // TODO: Don't swipe if you touched a floating window.
} else if (*PSWIPETOUCH && (!m_pFoundLSToFocus || m_pFoundLSToFocus->layer <= ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)) { } else if (*PSWIPETOUCH && (!m_pFoundLSToFocus || m_pFoundLSToFocus->layer <= ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); const auto PWORKSPACE = PMONITOR->activeWorkspace;
const bool VERTANIMS = PWORKSPACE->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert" || const bool VERTANIMS = PWORKSPACE->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert" ||
PWORKSPACE->m_vRenderOffset.getConfig()->pValues->internalStyle.starts_with("slidefadevert"); PWORKSPACE->m_vRenderOffset.getConfig()->pValues->internalStyle.starts_with("slidefadevert");
// TODO: support no_gaps_when_only? // TODO: support no_gaps_when_only?

View file

@ -224,7 +224,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
if (w->popupsCount() > 0 && *PBLURPOPUPS) if (w->popupsCount() > 0 && *PBLURPOPUPS)
return true; return true;
if (!w->m_bIsFloating && *POPTIM && !g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (!w->m_bIsFloating && *POPTIM && !w->onSpecialWorkspace())
continue; continue;
if (w->m_sAdditionalConfigData.forceNoBlur.toUnderlying() == true || w->m_sAdditionalConfigData.xray.toUnderlying() == true) if (w->m_sAdditionalConfigData.forceNoBlur.toUnderlying() == true || w->m_sAdditionalConfigData.xray.toUnderlying() == true)
@ -1342,7 +1342,7 @@ void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) {
const auto PSURFACE = pWindow->m_pWLSurface.wlr(); const auto PSURFACE = pWindow->m_pWLSurface.wlr();
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
const float A = pWindow->m_fAlpha.value() * pWindow->m_fActiveInactiveAlpha.value() * PWORKSPACE->m_fAlpha.value(); const float A = pWindow->m_fAlpha.value() * pWindow->m_fActiveInactiveAlpha.value() * PWORKSPACE->m_fAlpha.value();
if (A >= 1.f) { if (A >= 1.f) {
@ -1364,7 +1364,7 @@ void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) {
bool hasWindows = false; bool hasWindows = false;
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == pMonitor->activeWorkspace && !w->isHidden() && w->m_bIsMapped && (!w->m_bIsFloating || *PBLURXRAY)) { if (w->m_pWorkspace == pMonitor->activeWorkspace && !w->isHidden() && w->m_bIsMapped && (!w->m_bIsFloating || *PBLURXRAY)) {
// check if window is valid // check if window is valid
if (!windowShouldBeBlurred(w.get())) if (!windowShouldBeBlurred(w.get()))
@ -1456,7 +1456,7 @@ bool CHyprOpenGLImpl::shouldUseNewBlurOptimizations(SLayerSurface* pLayer, CWind
if (pLayer && pLayer->xray == 0) if (pLayer && pLayer->xray == 0)
return false; return false;
if ((*PBLURNEWOPTIMIZE && pWindow && !pWindow->m_bIsFloating && !g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID)) || *PBLURXRAY) if ((*PBLURNEWOPTIMIZE && pWindow && !pWindow->m_bIsFloating && !pWindow->onSpecialWorkspace()) || *PBLURXRAY)
return true; return true;
if ((pLayer && pLayer->xray == 1) || (pWindow && pWindow->m_sAdditionalConfigData.xray.toUnderlying() == 1)) if ((pLayer && pLayer->xray == 1) || (pWindow && pWindow->m_sAdditionalConfigData.xray.toUnderlying() == 1))

View file

@ -91,7 +91,7 @@ struct SMonitorRenderData {
struct SCurrentRenderData { struct SCurrentRenderData {
CMonitor* pMonitor = nullptr; CMonitor* pMonitor = nullptr;
CWorkspace* pWorkspace = nullptr; PHLWORKSPACE pWorkspace = nullptr;
float projection[9]; float projection[9];
float savedProjection[9]; float savedProjection[9];

View file

@ -217,13 +217,13 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, geometry.pWlr())) if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, geometry.pWlr()))
return false; return false;
if (pWindow->m_iWorkspaceID == -1) if (!pWindow->m_pWorkspace && !pWindow->m_bFadingOut)
return false; return false;
if (pWindow->m_bPinned) if (pWindow->m_bPinned)
return true; return true;
const auto PWINDOWWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWINDOWWORKSPACE = pWindow->m_pWorkspace;
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_iMonitorID == pMonitor->ID) { if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_iMonitorID == pMonitor->ID) {
if (PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWINDOWWORKSPACE->m_fAlpha.isBeingAnimated() || PWINDOWWORKSPACE->m_bForceRendering) if (PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWINDOWWORKSPACE->m_fAlpha.isBeingAnimated() || PWINDOWWORKSPACE->m_bForceRendering)
return true; return true;
@ -233,21 +233,21 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
pWindow->m_fAlpha.value() == 0) pWindow->m_fAlpha.value() == 0)
return false; return false;
if (!PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !PWINDOWWORKSPACE->m_fAlpha.isBeingAnimated() && !g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID)) if (!PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !PWINDOWWORKSPACE->m_fAlpha.isBeingAnimated() && !g_pCompositor->isWorkspaceVisible(pWindow->workspaceID()))
return false; return false;
} }
if (pWindow->m_iMonitorID == pMonitor->ID) if (pWindow->m_iMonitorID == pMonitor->ID)
return true; return true;
if (!g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) && pWindow->m_iMonitorID != pMonitor->ID) if (!g_pCompositor->isWorkspaceVisible(pWindow->workspaceID()) && pWindow->m_iMonitorID != pMonitor->ID)
return false; return false;
// if not, check if it maybe is active on a different monitor. // if not, check if it maybe is active on a different monitor.
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) && pWindow->m_bIsFloating /* tiled windows can't be multi-ws */) if (g_pCompositor->isWorkspaceVisible(pWindow->workspaceID()) && pWindow->m_bIsFloating /* tiled windows can't be multi-ws */)
return !pWindow->m_bIsFullscreen; // Do not draw fullscreen windows on other monitors return !pWindow->m_bIsFullscreen; // Do not draw fullscreen windows on other monitors
if (pMonitor->specialWorkspaceID == pWindow->m_iWorkspaceID) if (pMonitor->activeSpecialWorkspace == pWindow->m_pWorkspace)
return true; return true;
// if window is tiled and it's flying in, don't render on other mons (for slide) // if window is tiled and it's flying in, don't render on other mons (for slide)
@ -277,29 +277,29 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
if (!g_pCompositor->windowValidMapped(pWindow)) if (!g_pCompositor->windowValidMapped(pWindow))
return false; return false;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
if (pWindow->m_iWorkspaceID == -1) if (!pWindow->m_pWorkspace)
return false; return false;
if (pWindow->m_bPinned || PWORKSPACE->m_bForceRendering) if (pWindow->m_bPinned || PWORKSPACE->m_bForceRendering)
return true; return true;
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID)) if (g_pCompositor->isWorkspaceVisible(pWindow->workspaceID()))
return true; return true;
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (PWORKSPACE && PWORKSPACE->m_iMonitorID == m->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())) if (PWORKSPACE && PWORKSPACE->m_iMonitorID == m->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()))
return true; return true;
if (m->specialWorkspaceID && g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID)) if (m->activeSpecialWorkspace && pWindow->onSpecialWorkspace())
return true; return true;
} }
return false; return false;
} }
void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) { void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time) {
CWindow* pWorkspaceWindow = nullptr; CWindow* pWorkspaceWindow = nullptr;
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS); EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
@ -315,7 +315,7 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorksp
if (w->m_bIsFullscreen || w->m_bIsFloating) if (w->m_bIsFullscreen || w->m_bIsFloating)
continue; continue;
if (pWorkspace->m_bIsSpecialWorkspace != g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())
continue; continue;
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
@ -332,7 +332,7 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorksp
if (w->m_bIsFullscreen || !w->m_bIsFloating) if (w->m_bIsFullscreen || !w->m_bIsFloating)
continue; continue;
if (w->m_iMonitorID == pWorkspace->m_iMonitorID && pWorkspace->m_bIsSpecialWorkspace != g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (w->m_iMonitorID == pWorkspace->m_iMonitorID && pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())
continue; continue;
if (pWorkspace->m_bIsSpecialWorkspace && w->m_iMonitorID != pWorkspace->m_iMonitorID) if (pWorkspace->m_bIsSpecialWorkspace && w->m_iMonitorID != pWorkspace->m_iMonitorID)
@ -343,9 +343,9 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorksp
// TODO: this pass sucks // TODO: this pass sucks
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID); const auto PWORKSPACE = w->m_pWorkspace;
if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen) { if (w->m_pWorkspace != pWorkspace || !w->m_bIsFullscreen) {
if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering))) if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering)))
continue; continue;
@ -356,13 +356,13 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorksp
if (!w->m_bIsFullscreen) if (!w->m_bIsFullscreen)
continue; continue;
if (w->m_iMonitorID == pWorkspace->m_iMonitorID && pWorkspace->m_bIsSpecialWorkspace != g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (w->m_iMonitorID == pWorkspace->m_iMonitorID && pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())
continue; continue;
if (shouldRenderWindow(w.get(), pMonitor)) if (shouldRenderWindow(w.get(), pMonitor))
renderWindow(w.get(), pMonitor, time, pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL, RENDER_PASS_ALL); renderWindow(w.get(), pMonitor, time, pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL, RENDER_PASS_ALL);
if (w->m_iWorkspaceID != pWorkspace->m_iID) if (w->m_pWorkspace != pWorkspace)
continue; continue;
pWorkspaceWindow = w.get(); pWorkspaceWindow = w.get();
@ -376,10 +376,10 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorksp
// then render windows over fullscreen. // then render windows over fullscreen.
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID != pWorkspaceWindow->m_iWorkspaceID || (!w->m_bCreatedOverFullscreen && !w->m_bPinned) || (!w->m_bIsMapped && !w->m_bFadingOut) || w->m_bIsFullscreen) if (w->m_pWorkspace != pWorkspaceWindow->m_pWorkspace || (!w->m_bCreatedOverFullscreen && !w->m_bPinned) || (!w->m_bIsMapped && !w->m_bFadingOut) || w->m_bIsFullscreen)
continue; continue;
if (w->m_iMonitorID == pWorkspace->m_iMonitorID && pWorkspace->m_bIsSpecialWorkspace != g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (w->m_iMonitorID == pWorkspace->m_iMonitorID && pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())
continue; continue;
if (pWorkspace->m_bIsSpecialWorkspace && w->m_iMonitorID != pWorkspace->m_iMonitorID) if (pWorkspace->m_bIsSpecialWorkspace && w->m_iMonitorID != pWorkspace->m_iMonitorID)
@ -389,7 +389,7 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorksp
} }
} }
void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) { void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time) {
CWindow* lastWindow = nullptr; CWindow* lastWindow = nullptr;
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS); EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
@ -405,7 +405,7 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWork
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor))
continue; continue;
if (pWorkspace->m_bIsSpecialWorkspace != g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())
continue; continue;
// render active window after all others of this pass // render active window after all others of this pass
@ -429,7 +429,7 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWork
if (w->m_bIsFloating) if (w->m_bIsFloating)
continue; // floating are in the second pass continue; // floating are in the second pass
if (pWorkspace->m_bIsSpecialWorkspace != g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())
continue; continue;
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor))
@ -450,7 +450,7 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWork
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor))
continue; continue;
if (pWorkspace->m_bIsSpecialWorkspace != g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) if (pWorkspace->m_bIsSpecialWorkspace != w->onSpecialWorkspace())
continue; continue;
if (pWorkspace->m_bIsSpecialWorkspace && w->m_iMonitorID != pWorkspace->m_iMonitorID) if (pWorkspace->m_bIsSpecialWorkspace && w->m_iMonitorID != pWorkspace->m_iMonitorID)
@ -476,7 +476,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
TRACY_GPU_ZONE("RenderWindow"); TRACY_GPU_ZONE("RenderWindow");
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = pWindow->m_pWorkspace;
const auto REALPOS = pWindow->m_vRealPosition.value() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.value()); const auto REALPOS = pWindow->m_vRealPosition.value() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.value());
static auto PDIMAROUND = CConfigValue<Hyprlang::FLOAT>("decoration:dim_around"); static auto PDIMAROUND = CConfigValue<Hyprlang::FLOAT>("decoration:dim_around");
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled"); static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
@ -732,7 +732,7 @@ void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, CMon
wlr_surface_for_each_surface(pSurface->pWlrLockSurface->surface, renderSurface, &renderdata); wlr_surface_for_each_surface(pSurface->pWlrLockSurface->surface, renderSurface, &renderdata);
} }
void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time, const Vector2D& translate, const float& scale) { void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time, const Vector2D& translate, const float& scale) {
static auto PDIMSPECIAL = CConfigValue<Hyprlang::FLOAT>("decoration:dim_special"); static auto PDIMSPECIAL = CConfigValue<Hyprlang::FLOAT>("decoration:dim_special");
static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special"); static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special");
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled"); static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
@ -810,7 +810,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace*
for (auto& ws : g_pCompositor->m_vWorkspaces) { for (auto& ws : g_pCompositor->m_vWorkspaces) {
if (ws->m_iMonitorID == pMonitor->ID && ws->m_fAlpha.value() > 0.f && ws->m_bIsSpecialWorkspace) { if (ws->m_iMonitorID == pMonitor->ID && ws->m_fAlpha.value() > 0.f && ws->m_bIsSpecialWorkspace) {
const auto SPECIALANIMPROGRS = ws->m_vRenderOffset.isBeingAnimated() ? ws->m_vRenderOffset.getCurveValue() : ws->m_fAlpha.getCurveValue(); const auto SPECIALANIMPROGRS = ws->m_vRenderOffset.isBeingAnimated() ? ws->m_vRenderOffset.getCurveValue() : ws->m_fAlpha.getCurveValue();
const bool ANIMOUT = !pMonitor->specialWorkspaceID; const bool ANIMOUT = !pMonitor->activeSpecialWorkspace;
if (*PDIMSPECIAL != 0.f) { if (*PDIMSPECIAL != 0.f) {
CBox monbox = {translate.x, translate.y, pMonitor->vecTransformedSize.x * scale, pMonitor->vecTransformedSize.y * scale}; CBox monbox = {translate.x, translate.y, pMonitor->vecTransformedSize.x * scale, pMonitor->vecTransformedSize.y * scale};
@ -830,9 +830,9 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace*
for (auto& ws : g_pCompositor->m_vWorkspaces) { for (auto& ws : g_pCompositor->m_vWorkspaces) {
if (ws->m_fAlpha.value() > 0.f && ws->m_bIsSpecialWorkspace) { if (ws->m_fAlpha.value() > 0.f && ws->m_bIsSpecialWorkspace) {
if (ws->m_bHasFullscreenWindow) if (ws->m_bHasFullscreenWindow)
renderWorkspaceWindowsFullscreen(pMonitor, ws.get(), time); renderWorkspaceWindowsFullscreen(pMonitor, ws, time);
else else
renderWorkspaceWindows(pMonitor, ws.get(), time); renderWorkspaceWindows(pMonitor, ws, time);
} }
} }
@ -1273,7 +1273,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
renderCursor = false; renderCursor = false;
} else { } else {
CBox renderBox = {0, 0, (int)pMonitor->vecPixelSize.x, (int)pMonitor->vecPixelSize.y}; CBox renderBox = {0, 0, (int)pMonitor->vecPixelSize.x, (int)pMonitor->vecPixelSize.y};
renderWorkspace(pMonitor, g_pCompositor->getWorkspaceByID(pMonitor->activeWorkspace), &now, renderBox); renderWorkspace(pMonitor, pMonitor->activeWorkspace, &now, renderBox);
renderLockscreen(pMonitor, &now, renderBox); renderLockscreen(pMonitor, &now, renderBox);
@ -1379,7 +1379,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
} }
} }
void CHyprRenderer::renderWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const CBox& geometry) { void CHyprRenderer::renderWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry) {
Vector2D translate = {geometry.x, geometry.y}; Vector2D translate = {geometry.x, geometry.y};
float scale = (float)geometry.width / pMonitor->vecPixelSize.x; float scale = (float)geometry.width / pMonitor->vecPixelSize.x;
@ -1727,7 +1727,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow, bool forceFull) {
return; return;
CBox windowBox = pWindow->getFullWindowBoundingBox(); CBox windowBox = pWindow->getFullWindowBoundingBox();
const auto PWINDOWWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWINDOWWORKSPACE = pWindow->m_pWorkspace;
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !pWindow->m_bPinned) if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !pWindow->m_bPinned)
windowBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value()); windowBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value());
windowBox.translate(pWindow->m_vFloatingOffset); windowBox.translate(pWindow->m_vFloatingOffset);
@ -2402,16 +2402,16 @@ void CHyprRenderer::initiateManualCrash() {
**PDT = 0; **PDT = 0;
} }
void CHyprRenderer::setOccludedForMainWorkspace(CRegion& region, CWorkspace* pWorkspace) { void CHyprRenderer::setOccludedForMainWorkspace(CRegion& region, PHLWORKSPACE pWorkspace) {
CRegion rg; CRegion rg;
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
if (!PMONITOR->specialWorkspaceID) if (!PMONITOR->activeSpecialWorkspace)
return; return;
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->isHidden() || w->m_iWorkspaceID != PMONITOR->specialWorkspaceID) if (!w->m_bIsMapped || w->isHidden() || w->m_pWorkspace != PMONITOR->activeSpecialWorkspace)
continue; continue;
if (!w->opaque()) if (!w->opaque())
@ -2431,13 +2431,13 @@ void CHyprRenderer::setOccludedForMainWorkspace(CRegion& region, CWorkspace* pWo
region.subtract(rg); region.subtract(rg);
} }
void CHyprRenderer::setOccludedForBackLayers(CRegion& region, CWorkspace* pWorkspace) { void CHyprRenderer::setOccludedForBackLayers(CRegion& region, PHLWORKSPACE pWorkspace) {
CRegion rg; CRegion rg;
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->isHidden() || w->m_iWorkspaceID != pWorkspace->m_iID) if (!w->m_bIsMapped || w->isHidden() || w->m_pWorkspace != pWorkspace)
continue; continue;
if (!w->opaque()) if (!w->opaque())
@ -2489,9 +2489,9 @@ void CHyprRenderer::recheckSolitaryForMonitor(CMonitor* pMonitor) {
if (g_pHyprNotificationOverlay->hasAny()) if (g_pHyprNotificationOverlay->hasAny())
return; return;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pMonitor->activeWorkspace); const auto PWORKSPACE = pMonitor->activeWorkspace;
if (!PWORKSPACE || !PWORKSPACE->m_bHasFullscreenWindow || g_pInputManager->m_sDrag.drag || g_pCompositor->m_sSeat.exclusiveClient || pMonitor->specialWorkspaceID || if (!PWORKSPACE || !PWORKSPACE->m_bHasFullscreenWindow || g_pInputManager->m_sDrag.drag || g_pCompositor->m_sSeat.exclusiveClient || pMonitor->activeSpecialWorkspace ||
PWORKSPACE->m_fAlpha.value() != 1.f || PWORKSPACE->m_vRenderOffset.value() != Vector2D{}) PWORKSPACE->m_fAlpha.value() != 1.f || PWORKSPACE->m_vRenderOffset.value() != Vector2D{})
return; return;
@ -2519,11 +2519,11 @@ void CHyprRenderer::recheckSolitaryForMonitor(CMonitor* pMonitor) {
if (w.get() == PCANDIDATE || (!w->m_bIsMapped && !w->m_bFadingOut) || w->isHidden()) if (w.get() == PCANDIDATE || (!w->m_bIsMapped && !w->m_bFadingOut) || w->isHidden())
continue; continue;
if (w->m_iWorkspaceID == PCANDIDATE->m_iWorkspaceID && w->m_bIsFloating && w->m_bCreatedOverFullscreen && w->visibleOnMonitor(pMonitor)) if (w->m_pWorkspace == PCANDIDATE->m_pWorkspace && w->m_bIsFloating && w->m_bCreatedOverFullscreen && w->visibleOnMonitor(pMonitor))
return; return;
} }
if (pMonitor->specialWorkspaceID != 0) if (pMonitor->activeSpecialWorkspace)
return; return;
// check if it did not open any subsurfaces or shit // check if it did not open any subsurfaces or shit

View file

@ -61,8 +61,8 @@ class CHyprRenderer {
void calculateUVForSurface(CWindow*, wlr_surface*, bool main = false, const Vector2D& projSize = {}, bool fixMisalignedFSV1 = false); void calculateUVForSurface(CWindow*, wlr_surface*, bool main = false, const Vector2D& projSize = {}, bool fixMisalignedFSV1 = false);
std::tuple<float, float, float> getRenderTimes(CMonitor* pMonitor); // avg max min std::tuple<float, float, float> getRenderTimes(CMonitor* pMonitor); // avg max min
void renderLockscreen(CMonitor* pMonitor, timespec* now, const CBox& geometry); void renderLockscreen(CMonitor* pMonitor, timespec* now, const CBox& geometry);
void setOccludedForBackLayers(CRegion& region, CWorkspace* pWorkspace); void setOccludedForBackLayers(CRegion& region, PHLWORKSPACE pWorkspace);
void setOccludedForMainWorkspace(CRegion& region, CWorkspace* pWorkspace); // TODO: merge occlusion methods void setOccludedForMainWorkspace(CRegion& region, PHLWORKSPACE pWorkspace); // TODO: merge occlusion methods
bool canSkipBackBufferClear(CMonitor* pMonitor); bool canSkipBackBufferClear(CMonitor* pMonitor);
void recheckSolitaryForMonitor(CMonitor* pMonitor); void recheckSolitaryForMonitor(CMonitor* pMonitor);
void setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY, bool force = false); void setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY, bool force = false);
@ -111,15 +111,15 @@ class CHyprRenderer {
private: private:
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, CBox*); void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, CBox*);
void renderWorkspaceWindowsFullscreen(CMonitor*, CWorkspace*, timespec*); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special) void renderWorkspaceWindowsFullscreen(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special)
void renderWorkspaceWindows(CMonitor*, CWorkspace*, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special) void renderWorkspaceWindows(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special)
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false); void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
void renderLayer(SLayerSurface*, CMonitor*, timespec*, bool popups = false); void renderLayer(SLayerSurface*, CMonitor*, timespec*, bool popups = false);
void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*); void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*);
void renderDragIcon(CMonitor*, timespec*); void renderDragIcon(CMonitor*, timespec*);
void renderIMEPopup(CInputPopup*, CMonitor*, timespec*); void renderIMEPopup(CInputPopup*, CMonitor*, timespec*);
void renderWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const CBox& geometry); void renderWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry);
void renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f); void renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f);
bool m_bCursorHidden = false; bool m_bCursorHidden = false;
bool m_bCursorHasSurface = false; bool m_bCursorHasSurface = false;

View file

@ -36,7 +36,7 @@ CBox CHyprBorderDecoration::assignedBoxGlobal() {
CBox box = m_bAssignedGeometry; CBox box = m_bAssignedGeometry;
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_pWindow)); box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_pWindow));
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); const auto PWORKSPACE = m_pWindow->m_pWorkspace;
if (!PWORKSPACE) if (!PWORKSPACE)
return box; return box;
@ -95,7 +95,7 @@ void CHyprBorderDecoration::damageEntire() {
const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 2; const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 2;
const auto BORDERSIZE = m_pWindow->getRealBorderSize() + 1; const auto BORDERSIZE = m_pWindow->getRealBorderSize() + 1;
const auto PWINDOWWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); const auto PWINDOWWORKSPACE = m_pWindow->m_pWorkspace;
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned) if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
surfaceBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value()); surfaceBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value());
surfaceBox.translate(m_pWindow->m_vFloatingOffset); surfaceBox.translate(m_pWindow->m_vFloatingOffset);

View file

@ -45,7 +45,7 @@ void CHyprDropShadowDecoration::damageEntire() {
m_pWindow->m_vRealSize.value().x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x, m_pWindow->m_vRealSize.value().x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
m_pWindow->m_vRealSize.value().y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y}; m_pWindow->m_vRealSize.value().y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y};
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); const auto PWORKSPACE = m_pWindow->m_pWorkspace;
if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned) if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
shadowBox.translate(PWORKSPACE->m_vRenderOffset.value()); shadowBox.translate(PWORKSPACE->m_vRenderOffset.value());
shadowBox.translate(m_pWindow->m_vFloatingOffset); shadowBox.translate(m_pWindow->m_vFloatingOffset);
@ -110,7 +110,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
const auto ROUNDINGBASE = m_pWindow->rounding(); const auto ROUNDINGBASE = m_pWindow->rounding();
const auto ROUNDING = ROUNDINGBASE > 0 ? ROUNDINGBASE + m_pWindow->getRealBorderSize() : 0; const auto ROUNDING = ROUNDINGBASE > 0 ? ROUNDINGBASE + m_pWindow->getRealBorderSize() : 0;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); const auto PWORKSPACE = m_pWindow->m_pWorkspace;
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D(); const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
// draw the shadow // draw the shadow

View file

@ -423,7 +423,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, CWindow
} }
bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_pointer_button_event* e) { bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_pointer_button_event* e) {
if (m_pWindow->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_FULL) if (m_pWindow->m_bIsFullscreen && m_pWindow->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL)
return true; return true;
const float BARRELATIVEX = pos.x - assignedBoxGlobal().x; const float BARRELATIVEX = pos.x - assignedBoxGlobal().x;
@ -506,7 +506,7 @@ CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
CBox box = m_bAssignedBox; CBox box = m_bAssignedBox;
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow)); box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow));
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); const auto PWORKSPACE = m_pWindow->m_pWorkspace;
if (PWORKSPACE && !m_pWindow->m_bPinned) if (PWORKSPACE && !m_pWindow->m_bPinned)
box.translate(PWORKSPACE->m_vRenderOffset.value()); box.translate(PWORKSPACE->m_vRenderOffset.value());