diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 79e9360c..0c6fbc60 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -657,24 +657,6 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { 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(); @@ -690,48 +672,69 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { } } - // 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) { - 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) + 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 continue; - if (box.containsPoint({m_sWLRCursor->x, m_sWLRCursor->y})) { + 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; - 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 (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(); } - return w.get(); + if (!w->m_bIsX11) { + if (w->hasPopupAt(pos)) + return w.get(); + } } + } - if (!w->m_bIsX11) { - if (w->hasPopupAt(pos)) + // 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) { + if ((w)->hasPopupAt(pos)) return w.get(); } } - } + for (auto& w : m_vWindows) { + if (special != isWorkspaceSpecial(w->m_iWorkspaceID)) + continue; - // 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)) + 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) 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; + return nullptr; + }; + + // special workspace + if (PMONITOR->specialWorkspaceID) + return windowForWorkspace(true); + + return windowForWorkspace(false); } CWindow* CCompositor::windowFromCursor() { @@ -2521,6 +2524,8 @@ 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 aa35e3fd..c3a5efe1 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -735,11 +735,10 @@ 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; @@ -747,9 +746,6 @@ 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 bf668004..b78ddccd 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -253,9 +253,6 @@ 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; @@ -280,9 +277,6 @@ 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; @@ -298,9 +292,6 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWork if (!w->m_bIsFloating || w->m_bPinned) continue; - if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) - continue; - if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace)) continue; @@ -316,9 +307,6 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWork if (!w->m_bPinned || !w->m_bIsFloating) continue; - if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)) - continue; - if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace)) continue; @@ -420,8 +408,11 @@ 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()) - g_pHyprOpenGL->m_RenderData.clipBox = pWindow->getFullWindowBoundingBox().translate(-pMonitor->vecPosition); + if (!ignorePosition && pWindow->m_bIsFloating && !pWindow->m_bIsFullscreen && PWORKSPACE->m_vRenderOffset.isBeingAnimated()) { + 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(); + } // render window decorations first, if not fullscreen full if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) { @@ -681,18 +672,10 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* } } - 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); + // 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); } EMIT_HOOK_EVENT("render", RENDER_POST_WINDOWS);