mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-26 22:03:24 +08:00
Now warping mouse to center of screen when leaving client screens.
Some users requested this. Also, the hider window is mapped before warping the mouse so the active window shouldn't change if the focus policy is point-to-focus. Showing the window first can also reduce the likelihood of seeing the cursor briefly in its hidden position.
This commit is contained in:
@@ -367,7 +367,9 @@ CMSWindowsSecondaryScreen::postCreateWindow(HWND window)
|
||||
|
||||
// hide cursor if this screen isn't active
|
||||
if (!isActive()) {
|
||||
showWindow();
|
||||
SInt32 x, y;
|
||||
getScreen()->getCursorCenter(x, y);
|
||||
showWindow(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,16 +425,16 @@ CMSWindowsSecondaryScreen::destroyWindow()
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsSecondaryScreen::showWindow()
|
||||
CMSWindowsSecondaryScreen::showWindow(SInt32 x, SInt32 y)
|
||||
{
|
||||
// move hider window under the mouse (rather than moving the mouse
|
||||
// somewhere else on the screen)
|
||||
SInt32 x, y;
|
||||
getCursorPos(x, y);
|
||||
// move hider window under the given position
|
||||
MoveWindow(m_window, x, y, 1, 1, FALSE);
|
||||
|
||||
// raise and show the hider window. take activation.
|
||||
ShowWindow(m_window, SW_SHOWNORMAL);
|
||||
// raise and show the hider window
|
||||
ShowWindow(m_window, SW_SHOWNA);
|
||||
|
||||
// now warp the mouse
|
||||
warpCursor(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -68,7 +68,7 @@ protected:
|
||||
virtual void onPreLeave();
|
||||
virtual void createWindow();
|
||||
virtual void destroyWindow();
|
||||
virtual void showWindow();
|
||||
virtual void showWindow(SInt32 x, SInt32 y);
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void updateKeys();
|
||||
|
||||
@@ -488,18 +488,23 @@ CXWindowsSecondaryScreen::destroyWindow()
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::showWindow()
|
||||
CXWindowsSecondaryScreen::showWindow(SInt32 x, SInt32 y)
|
||||
{
|
||||
// move hider window under the mouse (rather than moving the mouse
|
||||
// somewhere else on the screen)
|
||||
SInt32 x, y;
|
||||
getCursorPos(x, y);
|
||||
CDisplayLock display(m_screen);
|
||||
XMoveWindow(display, m_window, x, y);
|
||||
{
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// raise and show the hider window. take activation.
|
||||
// FIXME -- take focus?
|
||||
XMapRaised(display, m_window);
|
||||
// move hider window under the given position
|
||||
XMoveWindow(display, m_window, x, y);
|
||||
|
||||
// raise and show the hider window. take activation.
|
||||
// FIXME -- take focus?
|
||||
XMapRaised(display, m_window);
|
||||
}
|
||||
|
||||
// now warp the mouse. we warp after showing the window so we're
|
||||
// guaranteed to get the mouse leave event and to prevent the
|
||||
// keyboard focus from changing under point-to-focus policies.
|
||||
warpCursor(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -66,7 +66,7 @@ protected:
|
||||
virtual void onPreLeave();
|
||||
virtual void createWindow();
|
||||
virtual void destroyWindow();
|
||||
virtual void showWindow();
|
||||
virtual void showWindow(SInt32 x, SInt32 y);
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void updateKeys();
|
||||
|
||||
Reference in New Issue
Block a user