Make sure toplevel is active in SetFocus(), episode 2

Toplevel must be active for child to actually receive focus
See #18783
This commit is contained in:
Paul Cornett
2020-07-21 08:44:57 -07:00
parent 1ebf8daa2a
commit 44a75afe93

View File

@@ -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) &&