Skip to content

Commit dd0c776

Browse files
author
徐扬斌
committed
Fix keyboard focus problem when embedd CEF window.
When wxGTKWindow::SetFocus, we will bring up the toplevel window to the user before we set the focus to the child widget. And now, we no longer need to consider whether gtk_window_is_active(tlw). Because of these two reasons: 1. if the gtk_window_is_active(tlw), gtk_window_preset() don't harm anyway; 2. when foreign XWindow embedded(not via GtkPlug), maybe use XWindow controlled by GDK as their parent, for example, a CEF browser window(which is now an XWindow) take ours as parent, our tlw active state maybe altered(when CEF window take the keyboard focus) and unknown to us. i.e. gtk_window_is_active(tlw) may still true while the focus is already taken by the CEF window. we need to force to bring up our tlw to the user at this moment.
1 parent b968c7c commit dd0c776

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/gtk/window.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4866,7 +4866,15 @@ void wxWindowGTK::SetFocus()
48664866
// But avoid activating if tlw is not yet shown, as that will
48674867
// cause it to be immediately shown.
48684868
GtkWidget* tlw = gtk_widget_get_ancestor(m_widget, GTK_TYPE_WINDOW);
4869-
if (tlw && gtk_widget_get_visible(tlw) && !gtk_window_is_active(GTK_WINDOW(tlw)))
4869+
if (tlw && gtk_widget_get_visible(tlw))
4870+
// we don't need to consider whether the tlw is active or not,
4871+
// for these two reasons:
4872+
// 1. if the gtk_window_is_active(tlw), gtk_window_preset() don't harm anyway;
4873+
// 2. when foreign XWindow embedded(not via GtkPlug), maybe use XWindow controlled by GDK as their parent,
4874+
// for example, a CEF browser window(which is now an XWindow) take ours as parent,
4875+
// our tlw active state maybe altered(when CEF window take the keyboard focus) and unknown to us.
4876+
// i.e. gtk_window_is_active(tlw) may still true while the focus is already taken by the CEF window.
4877+
// we need to force to bring up our tlw to the user at this moment.
48704878
gtk_window_present(GTK_WINDOW(tlw));
48714879

48724880
GtkWidget *widget = m_wxwindow ? m_wxwindow : m_focusWidget;

0 commit comments

Comments
 (0)