From a4e473206e9cba1455c6ff4d3bee559728f91f56 Mon Sep 17 00:00:00 2001 From: Kaley Fischer Date: Thu, 23 Nov 2023 05:54:48 +0100 Subject: [PATCH] fix: removed floating mode in special workspace --- src/Compositor.cpp | 98 +++++++++---------- src/managers/KeybindManager.cpp | 8 +- src/render/Renderer.cpp | 32 ++++-- .../decorations/CHyprDropShadowDecoration.cpp | 1 - 4 files changed, 75 insertions(+), 64 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 1b27a0f4..081700ed 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -657,6 +657,24 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos, CWindow* pIgnoreW static auto* const PBORDERGRABEXTEND = &g_pConfigManager->getConfigValuePtr("general:extend_border_grab_area")->intValue; const auto BORDER_GRAB_AREA = *PRESIZEONBORDER ? *PBORDERSIZE + *PBORDERGRABEXTEND : 0; + // special workspace + if (PMONITOR->specialWorkspaceID) { + for (auto& w : m_vWindows | std::views::reverse) { + const auto BB = w->getWindowInputBox(); + 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_iWorkspaceID == PMONITOR->specialWorkspaceID && w->m_bIsMapped && box.containsPoint(pos) && !w->isHidden() && !w->m_bX11ShouldntFocus && + !w->m_bNoFocus) + return w.get(); + } + + for (auto& w : m_vWindows) { + CBox box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y}; + if (!w->m_bIsFloating && w->m_iWorkspaceID == PMONITOR->specialWorkspaceID && w->m_bIsMapped && box.containsPoint(pos) && !w->isHidden() && !w->m_bX11ShouldntFocus && + !w->m_bNoFocus) + return w.get(); + } + } + // pinned windows on top of floating regardless for (auto& w : m_vWindows | std::views::reverse) { const auto BB = w->getWindowInputBox(); @@ -671,72 +689,48 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos, CWindow* pIgnoreW } } } - - auto windowForWorkspace = [&](bool special) -> CWindow* { // first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter. - for (auto& w : m_vWindows | std::views::reverse) { - - if (special && !isWorkspaceSpecial(w->m_iWorkspaceID)) // because special floating may creep up into regular + for (auto& w : m_vWindows | std::views::reverse) { + const auto BB = w->getWindowInputBox(); + 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_bNoFocus) { + // OR windows should add focus to parent + if (w->m_bX11ShouldntFocus && w->m_iX11Type != 2) continue; - const auto BB = w->getWindowInputBox(); - 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_bNoFocus && w.get() != pIgnoreWindow) { - // OR windows should add focus to parent - if (w->m_bX11ShouldntFocus && w->m_iX11Type != 2) - continue; + if (box.containsPoint({m_sWLRCursor->x, m_sWLRCursor->y})) { - if (box.containsPoint({m_sWLRCursor->x, m_sWLRCursor->y})) { - - if (w->m_bIsX11 && w->m_iX11Type == 2 && !wlr_xwayland_or_surface_wants_focus(w->m_uSurface.xwayland)) { - // Override Redirect - return g_pCompositor->m_pLastWindow; // we kinda trick everything here. - // TODO: this is wrong, we should focus the parent, but idk how to get it considering it's nullptr in most cases. - } - - return w.get(); + if (w->m_bIsX11 && w->m_iX11Type == 2 && !wlr_xwayland_or_surface_wants_focus(w->m_uSurface.xwayland)) { + // Override Redirect + return g_pCompositor->m_pLastWindow; // we kinda trick everything here. + // TODO: this is wrong, we should focus the parent, but idk how to get it considering it's nullptr in most cases. } - if (!w->m_bIsX11) { - if (w->hasPopupAt(pos)) - return w.get(); - } + return w.get(); } - } - // for windows, we need to check their extensions too, first. - for (auto& w : m_vWindows) { - if (special != isWorkspaceSpecial(w->m_iWorkspaceID)) - continue; - - const int64_t WORKSPACEID = special ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace; - - if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus && !w->m_bNoFocus && - w.get() != pIgnoreWindow) { - if ((w)->hasPopupAt(pos)) + if (!w->m_bIsX11) { + if (w->hasPopupAt(pos)) return w.get(); } } - for (auto& w : m_vWindows) { - if (special != isWorkspaceSpecial(w->m_iWorkspaceID)) - continue; + } - const int64_t WORKSPACEID = special ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace; - - CBox box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y}; - if (!w->m_bIsFloating && w->m_bIsMapped && box.containsPoint(pos) && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus && !w->m_bNoFocus && - w.get() != pIgnoreWindow) + // for windows, we need to check their extensions too, first. + for (auto& w : m_vWindows) { + if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->isHidden() && !w->m_bX11ShouldntFocus && !w->m_bNoFocus) { + if ((w)->hasPopupAt(pos)) return w.get(); } + } + for (auto& w : m_vWindows) { + CBox box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y}; + if (!w->m_bIsFloating && w->m_bIsMapped && box.containsPoint(pos) && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->isHidden() && !w->m_bX11ShouldntFocus && + !w->m_bNoFocus) + return w.get(); + } - return nullptr; - }; - - // special workspace - if (PMONITOR->specialWorkspaceID) - return windowForWorkspace(true); - - return windowForWorkspace(false); + return nullptr; } CWindow* CCompositor::windowFromCursor() { @@ -2526,8 +2520,6 @@ CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, con PWORKSPACE->m_iID = id; PWORKSPACE->m_iMonitorID = monID; - PWORKSPACE->m_fAlpha.setValueAndWarp(0); - return PWORKSPACE; } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c3a5efe1..aa35e3fd 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -735,10 +735,11 @@ void CKeybindManager::clearKeybinds() { void CKeybindManager::toggleActiveFloating(std::string args) { CWindow* PWINDOW = nullptr; - if (args != "" && args != "active" && args.length() > 1) + if (args != "" && args != "active" && args.length() > 1) { PWINDOW = g_pCompositor->getWindowByRegex(args); - else + } else { PWINDOW = g_pCompositor->m_pLastWindow; + } if (!PWINDOW) return; @@ -746,6 +747,9 @@ void CKeybindManager::toggleActiveFloating(std::string args) { // remove drag status g_pInputManager->currentlyDraggedWindow = nullptr; + if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) + return; + if (PWINDOW->m_sGroupData.pNextWindow && PWINDOW->m_sGroupData.pNextWindow != PWINDOW) { const auto PCURRENT = PWINDOW->getGroupCurrent(); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 43616868..92432370 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -252,13 +252,13 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWork if (w->m_bIsFloating) continue; // floating are in the second pass + // + if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) + continue; // special are in the third pass if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace)) continue; - if (pWorkspace->m_bIsSpecialWorkspace && w->m_iWorkspaceID != pWorkspace->m_iID) - continue; - // render active window after all others of this pass if (w.get() == g_pCompositor->m_pLastWindow && w->m_iWorkspaceID == pWorkspace->m_iID) { lastWindow = w.get(); @@ -279,6 +279,9 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWork if (w->m_bIsFloating) continue; // floating are in the second pass + + if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) + continue; // special are in the third pass if (pWorkspace->m_bIsSpecialWorkspace && w->m_iWorkspaceID != pWorkspace->m_iID) continue; @@ -403,7 +406,8 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* // if window is floating and we have a slide animation, clip it to its full bb if (!ignorePosition && pWindow->m_bIsFloating && !pWindow->m_bIsFullscreen && PWORKSPACE->m_vRenderOffset.isBeingAnimated()) { - CRegion rg = pWindow->getFullWindowBoundingBox().translate(-pMonitor->vecPosition + PWORKSPACE->m_vRenderOffset.vec()).scale(pMonitor->scale); + CRegion rg = pWindow->getFullWindowBoundingBox().translate(-pMonitor->vecPosition); + rg.add(CBox{0, 0, pMonitor->vecSize.x, pMonitor->vecSize.y}); g_pHyprOpenGL->m_RenderData.clipBox = rg.getExtents(); } @@ -665,10 +669,19 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* } } - // special - for (auto& ws : g_pCompositor->m_vWorkspaces) { - if (ws->m_iMonitorID == pMonitor->ID && ws->m_fAlpha.fl() > 0.f && ws->m_bIsSpecialWorkspace) - renderWorkspaceWindows(pMonitor, ws.get(), time); + + for (auto& w : g_pCompositor->m_vWindows) { + if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut) + continue; + + if (!g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) + continue; + + if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace)) + continue; + + // render the bad boy + renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); } // pinned always above @@ -679,6 +692,9 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* if (!w->m_bPinned || !w->m_bIsFloating) continue; + if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) + continue; + if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace)) continue; diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index bbf6def4..d8972376 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -92,7 +92,6 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D // scale the box in relation to the center of the box fullBox.scaleFromCenter(SHADOWSCALE).translate(*PSHADOWOFFSET); - m_vLastWindowPos += WORKSPACEOFFSET; m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2}, {fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2, fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}};