diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 412702ef29..e0345ada38 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4583,6 +4583,13 @@ void wxWindowGTK::SetFocus() if (gs_currentFocus != this) gs_pendingFocus = this; + // Toplevel must be active for child to actually receive focus. + // But avoid activating if tlw is not yet shown, as that will + // cause it to be immediately shown. + GtkWidget* tlw = gtk_widget_get_ancestor(m_widget, GTK_TYPE_WINDOW); + if (tlw && gtk_widget_get_visible(tlw) && !gtk_window_is_active(GTK_WINDOW(tlw))) + gtk_window_present(GTK_WINDOW(tlw)); + GtkWidget *widget = m_wxwindow ? m_wxwindow : m_focusWidget; if ( GTK_IS_CONTAINER(widget) &&