mirror of
https://github.com/hyprwm/Hyprland
synced 2025-02-17 03:42:08 +01:00
input: don't simulate mouse movement on focus change in follow_mouse = 2/3 if no_warps is false (#7015)
This commit is contained in:
parent
381cb2d833
commit
391f1ae838
1 changed files with 22 additions and 9 deletions
|
@ -281,11 +281,16 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor.get();
|
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor.get();
|
||||||
|
if (!LASTMONITOR)
|
||||||
|
return false;
|
||||||
if (LASTMONITOR == monitor) {
|
if (LASTMONITOR == monitor) {
|
||||||
Debug::log(LOG, "Tried to move to active monitor");
|
Debug::log(LOG, "Tried to move to active monitor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 PWORKSPACE = g_pCompositor->m_pLastMonitor->activeWorkspace;
|
||||||
const auto PNEWMAINWORKSPACE = monitor->activeWorkspace;
|
const auto PNEWMAINWORKSPACE = monitor->activeWorkspace;
|
||||||
|
|
||||||
|
@ -300,9 +305,11 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
|
||||||
g_pCompositor->focusWindow(PNEWWINDOW);
|
g_pCompositor->focusWindow(PNEWWINDOW);
|
||||||
PNEWWINDOW->warpCursor();
|
PNEWWINDOW->warpCursor();
|
||||||
|
|
||||||
|
if (*PNOWARPS == 0 || *PFOLLOWMOUSE < 2) {
|
||||||
g_pInputManager->m_pForcedFocus = PNEWWINDOW;
|
g_pInputManager->m_pForcedFocus = PNEWWINDOW;
|
||||||
g_pInputManager->simulateMouseMovement();
|
g_pInputManager->simulateMouseMovement();
|
||||||
g_pInputManager->m_pForcedFocus.reset();
|
g_pInputManager->m_pForcedFocus.reset();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
g_pCompositor->focusWindow(nullptr);
|
g_pCompositor->focusWindow(nullptr);
|
||||||
g_pCompositor->warpCursorTo(monitor->middle());
|
g_pCompositor->warpCursorTo(monitor->middle());
|
||||||
|
@ -313,6 +320,9 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
|
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
|
||||||
|
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();
|
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
|
||||||
|
|
||||||
if (PWINDOWTOCHANGETO == PLASTWINDOW || !PWINDOWTOCHANGETO)
|
if (PWINDOWTOCHANGETO == PLASTWINDOW || !PWINDOWTOCHANGETO)
|
||||||
|
@ -337,9 +347,12 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
|
||||||
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
||||||
PWINDOWTOCHANGETO->warpCursor();
|
PWINDOWTOCHANGETO->warpCursor();
|
||||||
|
|
||||||
|
// 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->m_pForcedFocus = PWINDOWTOCHANGETO;
|
||||||
g_pInputManager->simulateMouseMovement();
|
g_pInputManager->simulateMouseMovement();
|
||||||
g_pInputManager->m_pForcedFocus.reset();
|
g_pInputManager->m_pForcedFocus.reset();
|
||||||
|
}
|
||||||
|
|
||||||
if (PLASTWINDOW && PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID) {
|
if (PLASTWINDOW && PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID) {
|
||||||
// event
|
// event
|
||||||
|
|
Loading…
Add table
Reference in a new issue