Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't simulate mouse movement on focus change in follow_mouse = 2/3 if no_warps is false #7015

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
vaxerski marked this conversation as resolved.
Show resolved Hide resolved
const auto PNEWMAINWORKSPACE = monitor->activeWorkspace;

g_pInputManager->unconstrainMouse();
PNEWMAINWORKSPACE->rememberPrevWorkspace(PWORKSPACE);
Expand All @@ -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());
Expand All @@ -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;
Expand All @@ -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
Expand Down
Loading