From 6f8509f8eb4de57d7fd49e8f32df3e042a6b74c6 Mon Sep 17 00:00:00 2001 From: ali kettab Date: Thu, 9 Jul 2020 16:29:16 +0100 Subject: [PATCH 1/4] Revert 06ffd1d This reverts commit 06ffd1dbabcb0de47ea7ceecbbee7e3af697bf99. --- src/gtk/window.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 052c4bb984..b8f0fd9f0f 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4583,13 +4583,9 @@ void wxWindowGTK::SetFocus() if (gs_currentFocus != this) gs_pendingFocus = this; - // We can't do this under GTK 2 as it breaks the GUI tests suite, but GTK 3 - // tests are robust enough to pass even if we do this. -#ifdef __WXGTK3__ wxWindow* tlw = wxGetTopLevelParent(static_cast(this)); if (tlw && tlw->m_widget && !gtk_window_is_active(GTK_WINDOW(tlw->m_widget))) tlw->Raise(); -#endif // __WXGTK3__ GtkWidget *widget = m_wxwindow ? m_wxwindow : m_focusWidget; From bca8bc13b446074b3ed409e8c7c9c72a9a3f0f8d Mon Sep 17 00:00:00 2001 From: ali kettab Date: Fri, 10 Jul 2020 21:47:05 +0100 Subject: [PATCH 2/4] fix typo --- src/unix/uiactionx11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/uiactionx11.cpp b/src/unix/uiactionx11.cpp index aaee4eaf56..61b2c89141 100644 --- a/src/unix/uiactionx11.cpp +++ b/src/unix/uiactionx11.cpp @@ -178,7 +178,7 @@ protected: wxUnusedVar(win); #endif // platform - wxLogTrace("focus", "SetInputFocusToXWindow on Window 0x%ul.", focus); + wxLogTrace("focus", "SetInputFocusToXWindow on Window 0x%lu.", focus); XSetInputFocus(m_display, focus, RevertToPointerRoot, CurrentTime); } From 8fd09b9382da01dcd97f93b551f24613e14103d4 Mon Sep 17 00:00:00 2001 From: ali kettab Date: Fri, 10 Jul 2020 22:29:23 +0100 Subject: [PATCH 3/4] SetInputFocusToXWindow() fixup --- src/unix/uiactionx11.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/unix/uiactionx11.cpp b/src/unix/uiactionx11.cpp index 61b2c89141..6bc7df4c39 100644 --- a/src/unix/uiactionx11.cpp +++ b/src/unix/uiactionx11.cpp @@ -130,27 +130,19 @@ protected: wxYield(); wxMilliSleep(50); + #ifndef __WXGTK3__ SetInputFocusToXWindow(); + #endif } - // This helper function tries to set the input focus to the active (top level) - // window, i.e.: the window to which keyboard events will be reported. + // Workaround a focus problem happening with GTK2 when running under Xvfb, + // 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. - // But for some reasons, the input focus is set to PointerRoot under Xvfb, - // 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. + // This helper function tries to set the input focus to the active (top level) + // window, i.e.: the window to which keyboard events will be delivered. void SetInputFocusToXWindow() { - Window focus; - int revert_to; // dummy - - XGetInputFocus(m_display, &focus, &revert_to); - - if ( focus != PointerRoot && focus != None ) - return; - + Window focus = None; wxWindow* win = wxGetActiveWindow(); #if defined(__WXGTK20__) @@ -180,7 +172,8 @@ protected: wxLogTrace("focus", "SetInputFocusToXWindow on Window 0x%lu.", focus); - XSetInputFocus(m_display, focus, RevertToPointerRoot, CurrentTime); + if ( focus != None ) + XSetInputFocus(m_display, focus, RevertToPointerRoot, CurrentTime); } wxX11Display m_display; From a33a38c1ad206f8a0a8e6560be132c8dbefdbade Mon Sep 17 00:00:00 2001 From: ali kettab Date: Fri, 10 Jul 2020 22:31:00 +0100 Subject: [PATCH 4/4] Remove unneeded workarounds --- tests/menu/menu.cpp | 4 ---- tests/validators/valnum.cpp | 10 ---------- 2 files changed, 14 deletions(-) diff --git a/tests/menu/menu.cpp b/tests/menu/menu.cpp index d9026f4aae..ef957e4f18 100644 --- a/tests/menu/menu.cpp +++ b/tests/menu/menu.cpp @@ -584,10 +584,6 @@ void MenuTestCase::Events() // Invoke the accelerator. m_frame->Show(); m_frame->SetFocus(); -#ifdef __WXGTK__ - // Without this, test fails when run with other tests under Xvfb. - m_frame->Raise(); -#endif wxYield(); wxUIActionSimulator sim; diff --git a/tests/validators/valnum.cpp b/tests/validators/valnum.cpp index 0d4e579c68..400011a232 100644 --- a/tests/validators/valnum.cpp +++ b/tests/validators/valnum.cpp @@ -211,16 +211,6 @@ void NumValidatorTestCase::Interactive() return; #endif // __WXMSW__ -#ifdef __WXGTK20__ - // Travis CI fails without this! - if ( IsAutomaticTest() ) - { - wxFrame* frame = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame); - frame->SetFocus(); - frame->Raise(); - } -#endif // __WXGTK20__ - // Set a locale using comma as thousands separator character. wxLocale loc(wxLANGUAGE_ENGLISH_UK, wxLOCALE_DONT_LOAD_DEFAULT);