Now restoring input focus when entering the screen to the window
that had the focus when the screen was left.
This commit is contained in:
parent
455d0210b2
commit
242050d0f2
|
@ -114,6 +114,8 @@ CXWindowsScreen::CXWindowsScreen(bool isPrimary) :
|
|||
m_xCenter(0), m_yCenter(0),
|
||||
m_xCursor(0), m_yCursor(0),
|
||||
m_keyState(NULL),
|
||||
m_lastFocus(None),
|
||||
m_lastFocusRevert(RevertToNone),
|
||||
m_im(NULL),
|
||||
m_ic(NULL),
|
||||
m_lastKeycode(0),
|
||||
|
@ -257,6 +259,13 @@ CXWindowsScreen::enter()
|
|||
// keyboard if they're grabbed.
|
||||
XUnmapWindow(m_display, m_window);
|
||||
|
||||
// set the input focus to what it had been when we took it
|
||||
if (m_lastFocus != None) {
|
||||
// the window may not exist anymore so ignore errors
|
||||
CXWindowsUtil::CErrorLock lock(m_display);
|
||||
XSetInputFocus(m_display, m_lastFocus, m_lastFocusRevert, CurrentTime);
|
||||
}
|
||||
|
||||
/* maybe call this if entering for the screensaver
|
||||
// set keyboard focus to root window. the screensaver should then
|
||||
// pick up key events for when the user enters a password to unlock.
|
||||
|
@ -305,6 +314,9 @@ CXWindowsScreen::leave()
|
|||
return false;
|
||||
}
|
||||
|
||||
// save current focus
|
||||
XGetInputFocus(m_display, &m_lastFocus, &m_lastFocusRevert);
|
||||
|
||||
// take focus
|
||||
XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime);
|
||||
|
||||
|
|
|
@ -156,6 +156,10 @@ private:
|
|||
// keyboard stuff
|
||||
CXWindowsKeyState* m_keyState;
|
||||
|
||||
// input focus stuff
|
||||
Window m_lastFocus;
|
||||
int m_lastFocusRevert;
|
||||
|
||||
// input method stuff
|
||||
XIM m_im;
|
||||
XIC m_ic;
|
||||
|
|
Loading…
Reference in New Issue