From 334a0f03ee2f80118418c16cc06005a1fe8cfd60 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 10 Feb 2024 00:47:00 +0100 Subject: [PATCH 1/2] keybinds: Fix focus not moving along when moving workspace (#4660) --------- Signed-off-by: Sefa Eyeoglu --- src/Compositor.cpp | 3 ++- src/helpers/Monitor.cpp | 4 ++-- src/helpers/Monitor.hpp | 2 +- src/managers/KeybindManager.cpp | 8 ++++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 69812482..0d336506 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2156,7 +2156,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni } Debug::log(LOG, "moveWorkspaceToMonitor: Plugging gap with existing {}", nextWorkspaceOnMonitorID); - POLDMON->changeWorkspace(nextWorkspaceOnMonitorID); + POLDMON->changeWorkspace(nextWorkspaceOnMonitorID, false, true, true); } // move the workspace @@ -2197,6 +2197,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni if (const auto PWORKSPACE = getWorkspaceByID(pMonitor->activeWorkspace); PWORKSPACE) getWorkspaceByID(pMonitor->activeWorkspace)->startAnim(false, false); + setActiveMonitor(pMonitor); pMonitor->activeWorkspace = pWorkspace->m_iID; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitor->ID); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index f084d3c0..cb69318f 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -571,8 +571,8 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool g_pCompositor->updateSuspendedStates(); } -void CMonitor::changeWorkspace(const int& id, bool internal) { - changeWorkspace(g_pCompositor->getWorkspaceByID(id), internal); +void CMonitor::changeWorkspace(const int& id, bool internal, bool noMouseMove, bool noFocus) { + changeWorkspace(g_pCompositor->getWorkspaceByID(id), internal, noMouseMove, noFocus); } void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) { diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 43de8d12..d5aba751 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -142,7 +142,7 @@ class CMonitor { bool isMirror(); float getDefaultScale(); void changeWorkspace(CWorkspace* const pWorkspace, bool internal = false, bool noMouseMove = false, bool noFocus = false); - void changeWorkspace(const int& id, bool internal = false); + void changeWorkspace(const int& id, bool internal = false, bool noMouseMove = false, bool noFocus = false); void setSpecialWorkspace(CWorkspace* const pWorkspace); void setSpecialWorkspace(const int& id); void moveTo(const Vector2D& pos); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index a5419e67..db6bbbbc 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1459,14 +1459,18 @@ void CKeybindManager::exitHyprland(std::string argz) { void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) { CMonitor* PMONITOR = g_pCompositor->getMonitorFromString(args); - if (!PMONITOR) + if (!PMONITOR) { + Debug::log(ERR, "Ignoring moveCurrentWorkspaceToMonitor: monitor doesnt exist"); return; + } // get the current workspace const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); - if (!PCURRENTWORKSPACE) + if (!PCURRENTWORKSPACE) { + Debug::log(ERR, "moveCurrentWorkspaceToMonitor invalid workspace!"); return; + } g_pCompositor->moveWorkspaceToMonitor(PCURRENTWORKSPACE, PMONITOR); } From 658f718fa3b2e08653493a00aeaa670a41d19c8d Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 10 Feb 2024 17:05:28 +0000 Subject: [PATCH 2/2] input: partially revert #4514 issues with refocus in #4649 --- src/managers/input/InputManager.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d0bc402c..44bbaf28 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -601,12 +601,8 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) { const auto mouseCoords = g_pInputManager->getMouseCoordsInternal(); const auto w = g_pCompositor->vectorToWindowUnified(mouseCoords, ALLOW_FLOATING | RESERVED_EXTENTS | INPUT_EXTENTS); - if (w && !m_bLastFocusOnLS) { - if (g_pCompositor->m_pLastWindow != w && *PFOLLOWMOUSE != 3) - g_pCompositor->focusWindow(w); - if (w->checkInputOnDecos(INPUT_TYPE_BUTTON, mouseCoords, e)) - return; - } + if (w && !m_bLastFocusOnLS && w->checkInputOnDecos(INPUT_TYPE_BUTTON, mouseCoords, e)) + return; // clicking on border triggers resize // TODO detect click on LS properly