diff options
| author | memchr <118117622+memchr@users.noreply.github.com> | 2023-08-21 18:54:02 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-21 20:54:02 +0200 |
| commit | cb59763d32b5ac9824ed921d225c376cd1f98df6 (patch) | |
| tree | a3082b700b3bd8ffab208fc453b206a57d89f06d /src/helpers/Monitor.cpp | |
| parent | 9977a8bfd4f5fcf932880b72f1271546c401f783 (diff) | |
fix: improved focus behaviour on workspace switching for follow_mouse!=1 (#3041)
* fix: improved focus behaviour on workspace switching for follow_mouse!=1
When the 'input:follow_mouse' is not set to 1 and the target workspace
for switching does not currently have the previously focused window,
Hyprland will prioritize focusing on the top-left-most window.
* fix: #2451 call simulateMouseMovement.
* unify logic
* multimon fix
---------
Co-authored-by: vaxerski <43317083+vaxerski@users.noreply.github.com>
Diffstat (limited to 'src/helpers/Monitor.cpp')
| -rw-r--r-- | src/helpers/Monitor.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 3839115a..d82005e3 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -551,13 +551,27 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) { } } + static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + if (const auto PLASTWINDOW = pWorkspace->getLastFocusedWindow(); PLASTWINDOW) g_pCompositor->focusWindow(PLASTWINDOW); else { - g_pCompositor->focusWindow(nullptr); - g_pInputManager->simulateMouseMovement(); + CWindow* pWindow = nullptr; + + if (*PFOLLOWMOUSE == 1) + pWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal()); + + if (!pWindow) + pWindow = g_pCompositor->getTopLeftWindowOnWorkspace(pWorkspace->m_iID); + + if (!pWindow) + pWindow = g_pCompositor->getFirstWindowOnWorkspace(pWorkspace->m_iID); + + g_pCompositor->focusWindow(pWindow); } + g_pInputManager->simulateMouseMovement(); + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); // set some flags and fire event |
