From 3fc40e1939631632ffc2870eae43b7e120efe332 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 3 May 2003 13:50:06 +0000 Subject: [PATCH] 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. --- lib/platform/CMSWindowsSecondaryScreen.cpp | 18 +++++++++------- lib/platform/CMSWindowsSecondaryScreen.h | 2 +- lib/platform/CXWindowsSecondaryScreen.cpp | 25 +++++++++++++--------- lib/platform/CXWindowsSecondaryScreen.h | 2 +- lib/synergy/CSecondaryScreen.cpp | 6 ++++-- lib/synergy/CSecondaryScreen.h | 6 +++--- 6 files changed, 34 insertions(+), 25 deletions(-) diff --git a/lib/platform/CMSWindowsSecondaryScreen.cpp b/lib/platform/CMSWindowsSecondaryScreen.cpp index e7bd4e481a..f4be6dea24 100644 --- a/lib/platform/CMSWindowsSecondaryScreen.cpp +++ b/lib/platform/CMSWindowsSecondaryScreen.cpp @@ -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 diff --git a/lib/platform/CMSWindowsSecondaryScreen.h b/lib/platform/CMSWindowsSecondaryScreen.h index 3bb9140b42..3acff2522d 100644 --- a/lib/platform/CMSWindowsSecondaryScreen.h +++ b/lib/platform/CMSWindowsSecondaryScreen.h @@ -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(); diff --git a/lib/platform/CXWindowsSecondaryScreen.cpp b/lib/platform/CXWindowsSecondaryScreen.cpp index 598cc4ed8b..3f7ed99611 100644 --- a/lib/platform/CXWindowsSecondaryScreen.cpp +++ b/lib/platform/CXWindowsSecondaryScreen.cpp @@ -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 diff --git a/lib/platform/CXWindowsSecondaryScreen.h b/lib/platform/CXWindowsSecondaryScreen.h index ae0655d723..fd535c8c87 100644 --- a/lib/platform/CXWindowsSecondaryScreen.h +++ b/lib/platform/CXWindowsSecondaryScreen.h @@ -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(); diff --git a/lib/synergy/CSecondaryScreen.cpp b/lib/synergy/CSecondaryScreen.cpp index 0f8bdbc2f2..24a9146f0b 100644 --- a/lib/synergy/CSecondaryScreen.cpp +++ b/lib/synergy/CSecondaryScreen.cpp @@ -173,8 +173,10 @@ CSecondaryScreen::leave() // restore toggle key state setToggleState(m_toggleKeys); - // hide mouse - showWindow(); + // warp and hide mouse + SInt32 x, y; + getScreen()->getCursorCenter(x, y); + showWindow(x, y); // subclass hook onPostLeave(); diff --git a/lib/synergy/CSecondaryScreen.h b/lib/synergy/CSecondaryScreen.h index 239caf3415..e4dd8a9fc2 100644 --- a/lib/synergy/CSecondaryScreen.h +++ b/lib/synergy/CSecondaryScreen.h @@ -323,10 +323,10 @@ protected: //! Show window /*! Called when the user navigates off this secondary screen. It needn't - actually show the window created by createWindow() but it must hide - the cursor and clean up event synthesis. + actually show the window created by createWindow() but it must move + the cursor to x,y, hide it, and clean up event synthesis. */ - virtual void showWindow() = 0; + virtual void showWindow(SInt32 x, SInt32 y) = 0; //! Hide window /*!