From f428f40570d7cc582a079abc242b795a85ea0cbb Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 19 Sep 2017 13:51:57 -0400 Subject: mq_tab_body_new(): Assign focus to Web view This fixes the following assertion in GTK+ versions before 3.15.3: Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion 'GTK_IS_WIDGET (widget)' failed This assertion occurs when: 1. No widget has been given input focus, 2. A popover (e.g. the tab label context menu) is shown, and 3. The window regains focus. This is because of the following code in window_focus_in() in gtk/gtkpopover.c (from 3.14.x): focus = gtk_window_get_focus (GTK_WINDOW (widget)); if (!gtk_widget_is_ancestor (focus, GTK_WIDGET (popover))) gtk_widget_grab_focus (GTK_WIDGET (popover)); When no widget has focus, the first argument to gtk_widget_is_ancestor() (which is checked with a GTK_IS_WIDGET() assertion) is NULL. So, some widget needs to have focus before a popover is shown and the window regains focus. Arguably, this is a bug in GTK+, and it has been fixed in GTK+ 3.15.3: https://git.gnome.org/browse/gtk+/commit/gtk/gtkpopover.c?id=e26fddc With that change, the above lines from window_focus_in() now read: focus = gtk_window_get_focus (GTK_WINDOW (widget)); if (focus == NULL || !gtk_widget_is_ancestor (focus, GTK_WIDGET (popover))) gtk_widget_grab_focus (GTK_WIDGET (popover)); That is, if focus is NULL, don't check if popover is an ancestor of it. Instead just give focus to popover. --- (limited to 'src/tab-body.c') diff --git a/src/tab-body.c b/src/tab-body.c index d195f6d..44c4451 100644 --- a/src/tab-body.c +++ b/src/tab-body.c @@ -38,6 +38,7 @@ mq_tab_body_new(gchar *uri) body->container = GTK_WIDGET(body->web_view); gtk_widget_set_vexpand(body->container, TRUE); + gtk_widget_grab_focus(body->container); return body; } -- cgit v0.9.1