[gtk/kill-register-surface: 2/2] gtk: Use gdk_surface_set/get_widget



commit 7cdf27e6361e7a94bc99eea93126dd8914790647
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 23 18:44:40 2019 -0500

    gtk: Use gdk_surface_set/get_widget
    
    The last two places where use the surface api
    are in gtkroot.c and gtkwidget.c. Make them
    use the private api.

 gtk/gtkroot.c   |  9 +++++----
 gtk/gtkwidget.c | 20 +++++---------------
 2 files changed, 10 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtkroot.c b/gtk/gtkroot.c
index 0a32288ba9..103502dbc6 100644
--- a/gtk/gtkroot.c
+++ b/gtk/gtkroot.c
@@ -20,6 +20,7 @@
 #include "config.h"
 
 #include "gtkrootprivate.h"
+#include "gdk/gdk-private.h"
 
 /**
  * SECTION:root
@@ -114,12 +115,12 @@ gtk_root_get_surface_transform (GtkRoot *self,
 GtkWidget *
 gtk_root_get_for_surface (GdkSurface *surface)
 {
-  gpointer user_data;
+  GtkWidget *widget;
 
-  gdk_surface_get_user_data (surface, &user_data);
+  widget = (GtkWidget *)gdk_surface_get_widget (surface);
 
-  if (user_data && GTK_IS_ROOT (user_data))
-    return GTK_WIDGET (user_data);
+  if (widget && GTK_IS_ROOT (widget))
+    return widget;
 
   return NULL;
 }
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 531fb3da29..a5f84c9137 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8598,13 +8598,10 @@ static gboolean
 is_my_surface (GtkWidget *widget,
               GdkSurface *surface)
 {
-  gpointer user_data;
-
   if (!surface)
     return FALSE;
 
-  gdk_surface_get_user_data (surface, &user_data);
-  return (user_data == widget);
+  return gdk_surface_get_widget (surface) == widget;
 }
 
 /*
@@ -11446,15 +11443,11 @@ void
 gtk_widget_register_surface (GtkWidget    *widget,
                             GdkSurface    *surface)
 {
-  gpointer user_data;
-
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (GDK_IS_SURFACE (surface));
 
-  gdk_surface_get_user_data (surface, &user_data);
-  g_assert (user_data == NULL);
-
-  gdk_surface_set_user_data (surface, widget);
+  g_assert (gdk_surface_get_widget (surface) == NULL);
+  gdk_surface_set_widget (surface, widget);
 
   g_signal_connect (surface, "render", G_CALLBACK (surface_expose), widget);
   g_signal_connect (surface, "event", G_CALLBACK (surface_event), widget);
@@ -11473,14 +11466,11 @@ void
 gtk_widget_unregister_surface (GtkWidget    *widget,
                               GdkSurface    *surface)
 {
-  gpointer user_data;
-
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (GDK_IS_SURFACE (surface));
 
-  gdk_surface_get_user_data (surface, &user_data);
-  g_assert (user_data == widget);
-  gdk_surface_set_user_data (surface, NULL);
+  g_assert (gdk_surface_get_widget (surface) == widget);
+  gdk_surface_set_widget (surface, NULL);
 
   g_signal_handlers_disconnect_by_func (surface, surface_expose, widget);
   g_signal_handlers_disconnect_by_func (surface, surface_event, widget);


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