[gtk/kill-register-surface: 1/10] Add gtk_root_get_for_surface



commit ff634726be7a90cd510a393701ef2af69c4c98cd
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 23 16:27:21 2019 -0500

    Add gtk_root_get_for_surface
    
    This is a replacement for gdk_surface_get_user_data.

 gtk/gtkroot.c | 21 +++++++++++++++++++++
 gtk/gtkroot.h |  2 ++
 2 files changed, 23 insertions(+)
---
diff --git a/gtk/gtkroot.c b/gtk/gtkroot.c
index 1907786e95..0a32288ba9 100644
--- a/gtk/gtkroot.c
+++ b/gtk/gtkroot.c
@@ -102,3 +102,24 @@ gtk_root_get_surface_transform (GtkRoot *self,
   iface = GTK_ROOT_GET_IFACE (self);
   return iface->get_surface_transform (self, x, y);
 }
+
+/**
+ * gtk_root_get_for_surface:
+ * @surface: a #GdkSurface
+ *
+ * Finds the GtkRoot associated with the surface.
+ * 
+ * Returns: (transfer none): the #GtkRoot that is associated with @surface
+ */
+GtkWidget *
+gtk_root_get_for_surface (GdkSurface *surface)
+{
+  gpointer user_data;
+
+  gdk_surface_get_user_data (surface, &user_data);
+
+  if (user_data && GTK_IS_ROOT (user_data))
+    return GTK_WIDGET (user_data);
+
+  return NULL;
+}
diff --git a/gtk/gtkroot.h b/gtk/gtkroot.h
index e3494fcc7a..45e777ba68 100644
--- a/gtk/gtkroot.h
+++ b/gtk/gtkroot.h
@@ -53,6 +53,8 @@ struct _GtkRootInterface
                                                          int                    *y);
 };
 
+GDK_AVAILABLE_IN_ALL
+GtkWidget * gtk_root_get_for_surface (GdkSurface *surface);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]