From 9f9129e53647f61ffa70287ae0cc83d70d4c9bf6 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 29 Sep 2022 16:53:31 +0100 Subject: [PATCH 1/4] focusable checks in nextWindow calls --- src/Compositor.cpp | 12 ++++++------ src/Compositor.hpp | 4 ++-- src/managers/KeybindManager.cpp | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index e3392483..c61c2582 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1154,7 +1154,7 @@ void CCompositor::deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclud } } -CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) { +CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) { bool gotToWindow = false; for (auto& w : m_vWindows) { if (w.get() != pWindow && !gotToWindow) @@ -1165,19 +1165,19 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) { continue; } - if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden) + if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden && (!focusableOnly || !w->m_bNoFocus)) return w.get(); } for (auto& w : m_vWindows) { - if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden) + if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden && (!focusableOnly || !w->m_bNoFocus)) return w.get(); } return nullptr; } -CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow) { +CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) { bool gotToWindow = false; for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) { if (it->get() != pWindow && !gotToWindow) @@ -1188,12 +1188,12 @@ CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow) { continue; } - if ((*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden) + if ((*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden && (!focusableOnly || !(*it)->m_bNoFocus)) return it->get(); } for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) { - if (it->get() != pWindow && (*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden) + if (it->get() != pWindow && (*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->m_bHidden && (!focusableOnly || !(*it)->m_bNoFocus)) return it->get(); } diff --git a/src/Compositor.hpp b/src/Compositor.hpp index fcec0fb5..aa4cd878 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -138,8 +138,8 @@ public: void cleanupFadingOut(const int& monid); CWindow* getWindowInDirection(CWindow*, char); void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr); - CWindow* getNextWindowOnWorkspace(CWindow*); - CWindow* getPrevWindowOnWorkspace(CWindow*); + CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false); + CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false); int getNextAvailableNamedWorkspace(); bool isPointOnAnyMonitor(const Vector2D&); CWindow* getConstraintWindow(SMouse*); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9aebe7c4..50a12a80 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1003,7 +1003,7 @@ void CKeybindManager::moveFocusTo(std::string args) { if (PWINDOWTOCHANGETO) { switchToWindow(PWINDOWTOCHANGETO); } else { - const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW); + const auto PWINDOWNEXT = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true); if (PWINDOWNEXT) { switchToWindow(PWINDOWNEXT); } @@ -1415,9 +1415,9 @@ void CKeybindManager::circleNext(std::string arg) { }; if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") - switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow)); + switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow, true)); else - switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow)); + switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow, true)); } void CKeybindManager::focusWindow(std::string regexp) { @@ -1577,16 +1577,16 @@ void CKeybindManager::swapnext(std::string arg) { 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 : nullptr; if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") - toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW); + toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true); else - toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW); + toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true); // sometimes we may come back to ourselves. if (toSwap == PLASTWINDOW) { if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") - toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW); + toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW), true; else - toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW); + toSwap = g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true); } g_pLayoutManager->getCurrentLayout()->switchWindows(PLASTWINDOW, toSwap); From ff4c22ca905441c1f1b916c22057bc0fbd003990 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 29 Sep 2022 19:30:49 +0100 Subject: [PATCH 2/4] add fullscreen info to clients request --- src/debug/HyprCtl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 30dc3c61..0795beaa 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -86,7 +86,9 @@ R"#({ "title": "%s", "pid": %i, "xwayland": %s, - "pinned": %s + "pinned": %s, + "fullscreen": %s, + "fullscreenMode": %i },)#", w.get(), (int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y, @@ -98,7 +100,9 @@ R"#({ escapeJSONStrings(g_pXWaylandManager->getTitle(w.get())).c_str(), w->getPID(), ((int)w->m_bIsX11 == 1 ? "true" : "false"), - (w->m_bPinned ? "true" : "false") + (w->m_bPinned ? "true" : "false"), + (w->m_bIsFullscreen ? "true" : "false"), + (w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0) ); } } @@ -111,8 +115,8 @@ R"#({ } else { for (auto& w : g_pCompositor->m_vWindows) { if (w->m_bIsMapped) { - result += getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\txwayland: %i\n\tpinned: %i\n\n", - w.get(), w->m_szTitle.c_str(), (int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y, (int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w.get()).c_str(), g_pXWaylandManager->getTitle(w.get()).c_str(), w->getPID(), (int)w->m_bIsX11, (int)w->m_bPinned); + result += getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\txwayland: %i\n\tpinned: %i\n\tfullscreen: %i\n\tfullscreenmode: %i\n\n", + w.get(), w->m_szTitle.c_str(), (int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y, (int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w.get()).c_str(), g_pXWaylandManager->getTitle(w.get()).c_str(), 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)); } } From bdd9680adf6c764ace88ccc6102e9b6f682c2b4b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 29 Sep 2022 19:33:43 +0100 Subject: [PATCH 3/4] fix ipc event missing on silent movetoworkspace --- src/managers/KeybindManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 50a12a80..ae0dff0f 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -948,6 +948,9 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) { g_pEventManager->m_bIgnoreEvents = false; + // manually post event cuz it got ignored above + g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", PWINDOW, PWORKSPACE->m_szName.c_str())}); + g_pInputManager->refocus(); } From caeb0636fa09d3681ac61cc22d8db5a7ddece242 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 29 Sep 2022 19:41:49 +0100 Subject: [PATCH 4/4] fix crash on dwindle splitratio alter on single group --- src/layout/DwindleLayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 3661c7a3..9ded8f95 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -1129,7 +1129,7 @@ void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) { const auto PNODE = getNodeFromWindow(pWindow); - if (!PNODE || !PNODE->pParent) + if (!PNODE || !PNODE->pParent || (PNODE->isGroupMember() && PNODE->getGroupMemberCount() == g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID))) return; PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f);