From ab22734159e12e3828152e4c29395f5b59f1e45b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 8 Oct 2017 14:03:19 -0400 Subject: [PATCH] Fix application window snapshot differently As Timm Baedert pointed out, the previous fix made the menubar go on top of popovers, which is just wrong. Instead, make gtk_window_snapshot handle all direct children of the window, taking care to stack popovers correctly. --- gtk/gtkapplicationwindow.c | 13 ------------- gtk/gtkwindow.c | 14 +++++++++----- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c index 8eda444ea5..9c028a2459 100644 --- a/gtk/gtkapplicationwindow.c +++ b/gtk/gtkapplicationwindow.c @@ -798,18 +798,6 @@ gtk_application_window_init (GtkApplicationWindow *window) G_CALLBACK (g_action_group_action_removed), window); } -static void -gtk_application_window_snapshot (GtkWidget *widget, - GtkSnapshot *snapshot) -{ - GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget); - - GTK_WIDGET_CLASS (gtk_application_window_parent_class)->snapshot (widget, snapshot); - - if (window->priv->menubar) - gtk_widget_snapshot_child (widget, window->priv->menubar, snapshot); -} - static void gtk_application_window_class_init (GtkApplicationWindowClass *class) { @@ -825,7 +813,6 @@ gtk_application_window_class_init (GtkApplicationWindowClass *class) widget_class->unrealize = gtk_application_window_real_unrealize; widget_class->map = gtk_application_window_real_map; widget_class->unmap = gtk_application_window_real_unmap; - widget_class->snapshot = gtk_application_window_snapshot; object_class->get_property = gtk_application_window_get_property; object_class->set_property = gtk_application_window_set_property; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 91b637a401..4995e3867d 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -9152,6 +9152,7 @@ gtk_window_snapshot (GtkWidget *widget, gint title_height; GList *l; int width, height; + GtkWidget *child; context = gtk_widget_get_style_context (widget); @@ -9219,11 +9220,14 @@ gtk_window_snapshot (GtkWidget *widget, height - (window_border.top + window_border.bottom + title_height)); - if (priv->title_box != NULL) - gtk_widget_snapshot_child (widget, priv->title_box, snapshot); - - if (gtk_bin_get_child (GTK_BIN (widget))) - gtk_widget_snapshot_child (widget, gtk_bin_get_child (GTK_BIN (widget)), snapshot); + for (child = _gtk_widget_get_first_child (widget); + child != NULL; + child = _gtk_widget_get_next_sibling (child)) + { + /* Handle popovers separately until their stacking order is fixed */ + if (!GTK_IS_POPOVER (child)) + gtk_widget_snapshot_child (widget, child, snapshot); + } for (l = priv->popovers.head; l; l = l->next) {