From 33f034d0d7fe91533aeb506b02f4ab2b3558ba28 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 Apr 2019 20:54:05 -0400 Subject: [PATCH 1/4] a11y: Stop using gtk_widget_get_parent_surface We can just use the surface of the parent. --- gtk/a11y/gtkwidgetaccessible.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c index d2c2471be9..c79b23f574 100644 --- a/gtk/a11y/gtkwidgetaccessible.c +++ b/gtk/a11y/gtkwidgetaccessible.c @@ -557,7 +557,7 @@ gtk_widget_accessible_get_extents (AtkComponent *component, { *x = allocation.x; *y = allocation.y; - surface = gtk_widget_get_parent_surface (widget); + surface = gtk_widget_get_surface (gtk_widget_get_parent (widget)); } else { From fe3b5ba545d513dffca68ab683628e62895589e3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 Apr 2019 20:56:43 -0400 Subject: [PATCH 2/4] tests: Stop using gtk_widget_get_parent_surface We can just use the surface of the parent. --- tests/testfullscreen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testfullscreen.c b/tests/testfullscreen.c index acdbd15bb0..0ed79b91c2 100644 --- a/tests/testfullscreen.c +++ b/tests/testfullscreen.c @@ -25,7 +25,7 @@ set_fullscreen_monitor_cb (GtkWidget *widget, gpointer user_data) GdkFullscreenMode mode = (GdkFullscreenMode) GPOINTER_TO_INT (user_data); GdkSurface *window; - window = gtk_widget_get_parent_surface (widget); + window = gtk_widget_get_surface (gtk_widget_get_parent (widget)); gdk_surface_set_fullscreen_mode (window, mode); gdk_surface_fullscreen (window); } @@ -35,7 +35,7 @@ remove_fullscreen_cb (GtkWidget *widget, gpointer user_data) { GdkSurface *window; - window = gtk_widget_get_parent_surface (widget); + window = gtk_widget_get_surface (gtk_widget_get_parent (widget)); gdk_surface_unfullscreen (window); } From 52d4bcf1be1e280636167e26206233f8cf380a9d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 Apr 2019 20:54:25 -0400 Subject: [PATCH 3/4] popover: Stop using gtk_widget_get_parent_surface We can just use the surface of the parent. --- gtk/gtkpopover.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 58cd6473bd..b22ffd453c 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -564,7 +564,7 @@ gtk_popover_realize (GtkWidget *widget) gtk_widget_get_surface_allocation (widget, &allocation); - surface = gdk_surface_new_child (gtk_widget_get_parent_surface (widget), &allocation); + surface = gdk_surface_new_child (gtk_widget_get_surface (gtk_widget_get_parent (widget)), &allocation); gtk_widget_set_surface (widget, surface); gtk_widget_register_surface (widget, surface); From b9770fa75275ad8bc948987f71e3a295fcc204ec Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 Apr 2019 20:54:56 -0400 Subject: [PATCH 4/4] widget: Drop gtk_widget_set_parent_surface And the getter, too. Widgets no longer have extra surfaces that could serve as parent surfaces. --- docs/reference/gtk/gtk4-sections.txt | 2 - gtk/gtkwidget.c | 72 +--------------------------- gtk/gtkwidget.h | 6 --- 3 files changed, 1 insertion(+), 79 deletions(-) diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 2331283531..33f5984760 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4438,8 +4438,6 @@ gtk_widget_set_name gtk_widget_get_name gtk_widget_set_sensitive gtk_widget_set_parent -gtk_widget_set_parent_surface -gtk_widget_get_parent_surface gtk_widget_get_toplevel gtk_widget_get_root gtk_widget_get_ancestor diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ab33790cb2..579633722c 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -725,7 +725,6 @@ GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR; static GQuark quark_accel_path = 0; static GQuark quark_accel_closures = 0; -static GQuark quark_parent_surface = 0; static GQuark quark_input_shape_info = 0; static GQuark quark_pango_context = 0; static GQuark quark_mnemonic_labels = 0; @@ -876,7 +875,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_accel_path = g_quark_from_static_string ("gtk-accel-path"); quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures"); - quark_parent_surface = g_quark_from_static_string ("gtk-parent-surface"); quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info"); quark_pango_context = g_quark_from_static_string ("gtk-pango-context"); quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels"); @@ -3046,13 +3044,6 @@ gtk_widget_unparent (GtkWidget *widget) if (old_parent->priv->layout_manager) gtk_layout_manager_remove_layout_child (old_parent->priv->layout_manager, widget); - /* Now that the parent pointer is nullified and the unroot vfunc already - * called, go ahead and unset the parent window, if we are unparenting - * an embedded GtkWindow the window will become toplevel again and root - * will fire for the new hierarchy. - */ - gtk_widget_set_parent_surface (widget, NULL); - g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_PARENT]); g_object_thaw_notify (G_OBJECT (widget)); @@ -7353,67 +7344,6 @@ gtk_widget_create_pango_layout (GtkWidget *widget, return layout; } -/** - * gtk_widget_set_parent_surface: - * @widget: a #GtkWidget. - * @parent_surface: the new parent window. - * - * Sets a non default parent window for @widget. - * - * For #GtkWindow classes, setting a @parent_surface effects whether - * the window is a toplevel window or can be embedded into other - * widgets. - * - * For #GtkWindow classes, this needs to be called before the - * window is realized. - */ -void -gtk_widget_set_parent_surface (GtkWidget *widget, - GdkSurface *parent_surface) -{ - GdkSurface *old_parent_surface; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (!GTK_IS_WINDOW (widget)); - - old_parent_surface = g_object_get_qdata (G_OBJECT (widget), - quark_parent_surface); - - if (parent_surface != old_parent_surface) - { - g_object_set_qdata (G_OBJECT (widget), quark_parent_surface, - parent_surface); - if (old_parent_surface) - g_object_unref (old_parent_surface); - if (parent_surface) - g_object_ref (parent_surface); - } -} - -/** - * gtk_widget_get_parent_surface: - * @widget: a #GtkWidget. - * - * Gets @widget’s parent window, or %NULL if it does not have one. - * - * Returns: (transfer none) (nullable): the parent window of @widget, or %NULL - * if it does not have a parent window. - **/ -GdkSurface * -gtk_widget_get_parent_surface (GtkWidget *widget) -{ - GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - GdkSurface *parent_surface; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - parent_surface = g_object_get_qdata (G_OBJECT (widget), quark_parent_surface); - - return (parent_surface != NULL) ? parent_surface : - (priv->parent != NULL) ? priv->parent->priv->surface : NULL; -} - - /** * gtk_widget_set_child_visible: * @widget: a #GtkWidget @@ -8531,7 +8461,7 @@ gtk_widget_real_realize (GtkWidget *widget) else { g_assert (priv->parent); - priv->surface = gtk_widget_get_parent_surface (widget); + priv->surface = priv->parent->priv->surface; g_object_ref (priv->surface); } diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 30741b9499..9b17b56845 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -556,12 +556,6 @@ GtkWidget * gtk_widget_get_parent (GtkWidget *widget); GDK_AVAILABLE_IN_ALL GtkRoot * gtk_widget_get_root (GtkWidget *widget); -GDK_AVAILABLE_IN_ALL -void gtk_widget_set_parent_surface (GtkWidget *widget, - GdkSurface *parent_surface); -GDK_AVAILABLE_IN_ALL -GdkSurface * gtk_widget_get_parent_surface (GtkWidget *widget); - GDK_AVAILABLE_IN_ALL void gtk_widget_set_child_visible (GtkWidget *widget, gboolean child_visible);