summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorAnton Lazarev <22821309+antonok-edm@users.noreply.github.com>2024-07-24 15:16:47 -0700
committerGitHub <noreply@github.com>2024-07-25 00:16:47 +0200
commit391f1ae838e936e909d0f3de8a5bf0387d22f80d (patch)
tree1899bf1b22e97e57c86b5b06af0d934926226f99 /src/managers/KeybindManager.cpp
parent381cb2d8330d09f8994ca01591fb3e3737e6a67a (diff)
input: don't simulate mouse movement on focus change in follow_mouse = 2/3 if no_warps is false (#7015)
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 4232ea64..44826fff 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -281,13 +281,18 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
return false;
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor.get();
+ if (!LASTMONITOR)
+ return false;
if (LASTMONITOR == monitor) {
Debug::log(LOG, "Tried to move to active monitor");
return false;
}
- const auto PWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
- const auto PNEWMAINWORKSPACE = monitor->activeWorkspace;
+ static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
+ static auto PNOWARPS = CConfigValue<Hyprlang::INT>("cursor:no_warps");
+
+ const auto PWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
+ const auto PNEWMAINWORKSPACE = monitor->activeWorkspace;
g_pInputManager->unconstrainMouse();
PNEWMAINWORKSPACE->rememberPrevWorkspace(PWORKSPACE);
@@ -300,9 +305,11 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
g_pCompositor->focusWindow(PNEWWINDOW);
PNEWWINDOW->warpCursor();
- g_pInputManager->m_pForcedFocus = PNEWWINDOW;
- g_pInputManager->simulateMouseMovement();
- g_pInputManager->m_pForcedFocus.reset();
+ if (*PNOWARPS == 0 || *PFOLLOWMOUSE < 2) {
+ g_pInputManager->m_pForcedFocus = PNEWWINDOW;
+ g_pInputManager->simulateMouseMovement();
+ g_pInputManager->m_pForcedFocus.reset();
+ }
} else {
g_pCompositor->focusWindow(nullptr);
g_pCompositor->warpCursorTo(monitor->middle());
@@ -313,7 +320,10 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
}
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
- const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
+ static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
+ static auto PNOWARPS = CConfigValue<Hyprlang::INT>("cursor:no_warps");
+
+ const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
if (PWINDOWTOCHANGETO == PLASTWINDOW || !PWINDOWTOCHANGETO)
return;
@@ -337,9 +347,12 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
PWINDOWTOCHANGETO->warpCursor();
- g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO;
- g_pInputManager->simulateMouseMovement();
- g_pInputManager->m_pForcedFocus.reset();
+ // Move mouse focus to the new window if required by current follow_mouse and warp modes
+ if (*PNOWARPS == 0 || *PFOLLOWMOUSE < 2) {
+ g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO;
+ g_pInputManager->simulateMouseMovement();
+ g_pInputManager->m_pForcedFocus.reset();
+ }
if (PLASTWINDOW && PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID) {
// event