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:
crs 2003-05-03 13:50:06 +00:00
parent af110dbce2
commit 3fc40e1939
6 changed files with 34 additions and 25 deletions

View File

@ -367,7 +367,9 @@ CMSWindowsSecondaryScreen::postCreateWindow(HWND window)
// hide cursor if this screen isn't active // hide cursor if this screen isn't active
if (!isActive()) { if (!isActive()) {
showWindow(); SInt32 x, y;
getScreen()->getCursorCenter(x, y);
showWindow(x, y);
} }
} }
@ -423,16 +425,16 @@ CMSWindowsSecondaryScreen::destroyWindow()
} }
void void
CMSWindowsSecondaryScreen::showWindow() CMSWindowsSecondaryScreen::showWindow(SInt32 x, SInt32 y)
{ {
// move hider window under the mouse (rather than moving the mouse // move hider window under the given position
// somewhere else on the screen)
SInt32 x, y;
getCursorPos(x, y);
MoveWindow(m_window, x, y, 1, 1, FALSE); MoveWindow(m_window, x, y, 1, 1, FALSE);
// raise and show the hider window. take activation. // raise and show the hider window
ShowWindow(m_window, SW_SHOWNORMAL); ShowWindow(m_window, SW_SHOWNA);
// now warp the mouse
warpCursor(x, y);
} }
void void

View File

@ -68,7 +68,7 @@ protected:
virtual void onPreLeave(); virtual void onPreLeave();
virtual void createWindow(); virtual void createWindow();
virtual void destroyWindow(); virtual void destroyWindow();
virtual void showWindow(); virtual void showWindow(SInt32 x, SInt32 y);
virtual void hideWindow(); virtual void hideWindow();
virtual void warpCursor(SInt32 x, SInt32 y); virtual void warpCursor(SInt32 x, SInt32 y);
virtual void updateKeys(); virtual void updateKeys();

View File

@ -488,13 +488,12 @@ CXWindowsSecondaryScreen::destroyWindow()
} }
void 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); CDisplayLock display(m_screen);
// move hider window under the given position
XMoveWindow(display, m_window, x, y); XMoveWindow(display, m_window, x, y);
// raise and show the hider window. take activation. // raise and show the hider window. take activation.
@ -502,6 +501,12 @@ CXWindowsSecondaryScreen::showWindow()
XMapRaised(display, m_window); 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 void
CXWindowsSecondaryScreen::hideWindow() CXWindowsSecondaryScreen::hideWindow()
{ {

View File

@ -66,7 +66,7 @@ protected:
virtual void onPreLeave(); virtual void onPreLeave();
virtual void createWindow(); virtual void createWindow();
virtual void destroyWindow(); virtual void destroyWindow();
virtual void showWindow(); virtual void showWindow(SInt32 x, SInt32 y);
virtual void hideWindow(); virtual void hideWindow();
virtual void warpCursor(SInt32 x, SInt32 y); virtual void warpCursor(SInt32 x, SInt32 y);
virtual void updateKeys(); virtual void updateKeys();

View File

@ -173,8 +173,10 @@ CSecondaryScreen::leave()
// restore toggle key state // restore toggle key state
setToggleState(m_toggleKeys); setToggleState(m_toggleKeys);
// hide mouse // warp and hide mouse
showWindow(); SInt32 x, y;
getScreen()->getCursorCenter(x, y);
showWindow(x, y);
// subclass hook // subclass hook
onPostLeave(); onPostLeave();

View File

@ -323,10 +323,10 @@ protected:
//! Show window //! Show window
/*! /*!
Called when the user navigates off this secondary screen. It needn't Called when the user navigates off this secondary screen. It needn't
actually show the window created by createWindow() but it must hide actually show the window created by createWindow() but it must move
the cursor and clean up event synthesis. 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 //! Hide window
/*! /*!