summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-19 13:51:57 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-19 13:51:57 (EDT)
commitf428f40570d7cc582a079abc242b795a85ea0cbb (patch)
tree067a04899258f73c1ae67a025ba7f855a71e1146
parent875ad970b6c1ea132cf4d7434afd8030cde3077d (diff)
downloadmarquee-f428f40570d7cc582a079abc242b795a85ea0cbb.zip
marquee-f428f40570d7cc582a079abc242b795a85ea0cbb.tar.gz
marquee-f428f40570d7cc582a079abc242b795a85ea0cbb.tar.bz2
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.
-rw-r--r--src/tab-body.c1
1 files changed, 1 insertions, 0 deletions
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;
}