From af24f0bd0fd406fa8710e0ccd22d245841ff9c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 14 Mar 2008 01:14:56 +0000 Subject: [PATCH] make sure FindFocus returns newly focused window immediately after SetFocus on 2.8 branch too git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52476 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a6d22d1d8c..150bdd00f7 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3254,6 +3254,20 @@ void wxWindowGTK::SetFocus() return; } + // Setting "physical" focus is not immediate in GTK+ and while + // gtk_widget_is_focus ("determines if the widget is the focus widget + // within its toplevel", i.e. returns true for one widget per TLW, not + // globally) returns true immediately after grabbing focus, + // GTK_WIDGET_HAS_FOCUS (which returns true only for the one widget that + // has focus at the moment) takes affect only after the window is shown + // (if it was hidden at the moment of the call) or at the next event loop + // iteration. + // + // Because we want to FindFocus() call immediately following + // foo->SetFocus() to return foo, we have to keep track of "pending" focus + // ourselves. + g_focusWindow = this; + if (m_wxwindow) { if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow))