SetInputFocusToXWindow() fixup
This commit is contained in:
@@ -130,27 +130,19 @@ protected:
|
|||||||
wxYield();
|
wxYield();
|
||||||
wxMilliSleep(50);
|
wxMilliSleep(50);
|
||||||
|
|
||||||
|
#ifndef __WXGTK3__
|
||||||
SetInputFocusToXWindow();
|
SetInputFocusToXWindow();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// This helper function tries to set the input focus to the active (top level)
|
// Workaround a focus problem happening with GTK2 when running under Xvfb,
|
||||||
// window, i.e.: the window to which keyboard events will be reported.
|
// i.e. keyboard and mouse events not delivered to the right window.
|
||||||
//
|
//
|
||||||
// Normally we would expect the input focus to be correctly set by the WM.
|
// This helper function tries to set the input focus to the active (top level)
|
||||||
// But for some reasons, the input focus is set to PointerRoot under Xvfb,
|
// window, i.e.: the window to which keyboard events will be delivered.
|
||||||
// which means: all keyboard events are forewarded to whatever is underneath
|
|
||||||
// mouse pointer. and consequently, our fake events could be simply lost and
|
|
||||||
// do not reach the subject window at all.
|
|
||||||
void SetInputFocusToXWindow()
|
void SetInputFocusToXWindow()
|
||||||
{
|
{
|
||||||
Window focus;
|
Window focus = None;
|
||||||
int revert_to; // dummy
|
|
||||||
|
|
||||||
XGetInputFocus(m_display, &focus, &revert_to);
|
|
||||||
|
|
||||||
if ( focus != PointerRoot && focus != None )
|
|
||||||
return;
|
|
||||||
|
|
||||||
wxWindow* win = wxGetActiveWindow();
|
wxWindow* win = wxGetActiveWindow();
|
||||||
|
|
||||||
#if defined(__WXGTK20__)
|
#if defined(__WXGTK20__)
|
||||||
@@ -180,6 +172,7 @@ protected:
|
|||||||
|
|
||||||
wxLogTrace("focus", "SetInputFocusToXWindow on Window 0x%lu.", focus);
|
wxLogTrace("focus", "SetInputFocusToXWindow on Window 0x%lu.", focus);
|
||||||
|
|
||||||
|
if ( focus != None )
|
||||||
XSetInputFocus(m_display, focus, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(m_display, focus, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user