[gtk/kill-register-surface] Remove gdk_surface_set_user_data
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/kill-register-surface] Remove gdk_surface_set_user_data
- Date: Sun, 24 Feb 2019 00:48:34 +0000 (UTC)
commit 17fc194fcd83ebd922dd9b60f1e3702a57eb0ad6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 23 18:56:02 2019 -0500
Remove gdk_surface_set_user_data
Change gdk_surface_get/set_user_data to private
API and rename them to get/set_widget.
Also remove an unused associated function.
The last two places where the surface API is used
are in gtkroot.c and gtkwidget.c. Make them
use the private api.
docs/reference/gdk/gdk4-sections.txt | 3 --
gdk/gdk-private.h | 4 ++
gdk/gdkinternals.h | 2 +-
gdk/gdksurface.c | 81 +++---------------------------------
gdk/gdksurface.h | 9 ----
gtk/gtkroot.c | 9 ++--
gtk/gtkwidget.c | 20 +++------
7 files changed, 21 insertions(+), 107 deletions(-)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index 80fa982dcd..75824dfef8 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -240,7 +240,6 @@ gdk_surface_thaw_updates
gdk_surface_get_frame_clock
<SUBSECTION>
-gdk_surface_set_user_data
gdk_surface_set_accept_focus
gdk_surface_get_accept_focus
gdk_surface_set_focus_on_map
@@ -252,7 +251,6 @@ gdk_surface_set_title
GDK_PARENT_RELATIVE
gdk_surface_set_cursor
gdk_surface_get_cursor
-gdk_surface_get_user_data
gdk_surface_get_geometry
gdk_surface_set_geometry_hints
gdk_surface_get_width
@@ -278,7 +276,6 @@ GdkModifierIntent
gdk_surface_get_parent
gdk_surface_get_toplevel
gdk_surface_get_children
-gdk_surface_get_children_with_user_data
gdk_surface_peek_children
gdk_surface_set_icon_name
gdk_surface_set_transient_for
diff --git a/gdk/gdk-private.h b/gdk/gdk-private.h
index 551ecac9aa..9344ac2e49 100644
--- a/gdk/gdk-private.h
+++ b/gdk/gdk-private.h
@@ -40,4 +40,8 @@ PangoDirection gdk_unichar_direction (gunichar ch);
PangoDirection gdk_find_base_dir (const char *text,
int len);
+void gdk_surface_set_widget (GdkSurface *surface,
+ gpointer widget);
+gpointer gdk_surface_get_widget (GdkSurface *surface);
+
#endif /* __GDK__PRIVATE_H__ */
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 30429e931a..c6ed927826 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -145,7 +145,7 @@ struct _GdkSurface
GdkSurface *parent;
GdkSurface *transient_for;
- gpointer user_data;
+ gpointer widget;
gint x;
gint y;
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 7f9af6fa8f..06513a4b94 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1042,43 +1042,17 @@ gdk_surface_destroy (GdkSurface *surface)
g_object_unref (surface);
}
-/**
- * gdk_surface_set_user_data:
- * @surface: a #GdkSurface
- * @user_data: (allow-none) (type GObject.Object): user data
- *
- * For most purposes this function is deprecated in favor of
- * g_object_set_data(). However, for historical reasons GTK+ stores
- * the #GtkWidget that owns a #GdkSurface as user data on the
- * #GdkSurface. So, custom widget implementations should use
- * this function for that. If GTK+ receives an event for a #GdkSurface,
- * and the user data for the surface is non-%NULL, GTK+ will assume the
- * user data is a #GtkWidget, and forward the event to that widget.
- *
- **/
void
-gdk_surface_set_user_data (GdkSurface *surface,
- gpointer user_data)
+gdk_surface_set_widget (GdkSurface *surface,
+ gpointer widget)
{
- g_return_if_fail (GDK_IS_SURFACE (surface));
-
- surface->user_data = user_data;
+ surface->widget = widget;
}
-/**
- * gdk_surface_get_user_data:
- * @surface: a #GdkSurface
- * @data: (out): return location for user data
- *
- * Retrieves the user data for @surface, which is normally the widget
- * that @surface belongs to. See gdk_surface_set_user_data().
- *
- **/
-void
-gdk_surface_get_user_data (GdkSurface *surface,
- gpointer *data)
+gpointer
+gdk_surface_get_widget (GdkSurface *surface)
{
- *data = surface->user_data;
+ return surface->widget;
}
/**
@@ -1265,49 +1239,6 @@ gdk_surface_peek_children (GdkSurface *surface)
return surface->children;
}
-
-/**
- * gdk_surface_get_children_with_user_data:
- * @surface: a #GdkSurface
- * @user_data: user data to look for
- *
- * Gets the list of children of @surface known to GDK with a
- * particular @user_data set on it.
- *
- * The returned list must be freed, but the elements in the
- * list need not be.
- *
- * The list is returned in (relative) stacking order, i.e. the
- * lowest surface is first.
- *
- * Returns: (transfer container) (element-type GdkSurface):
- * list of child surfaces inside @surface
- **/
-GList *
-gdk_surface_get_children_with_user_data (GdkSurface *surface,
- gpointer user_data)
-{
- GdkSurface *child;
- GList *res, *l;
-
- g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
-
- if (GDK_SURFACE_DESTROYED (surface))
- return NULL;
-
- res = NULL;
- for (l = surface->children; l != NULL; l = l->next)
- {
- child = l->data;
-
- if (child->user_data == user_data)
- res = g_list_prepend (res, child);
- }
-
- return res;
-}
-
-
/**
* gdk_surface_is_visible:
* @surface: a #GdkSurface
diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h
index 972c8a5fc9..9a87ab0bc4 100644
--- a/gdk/gdksurface.h
+++ b/gdk/gdksurface.h
@@ -491,9 +491,6 @@ GDK_AVAILABLE_IN_ALL
void gdk_surface_focus (GdkSurface *surface,
guint32 timestamp);
GDK_AVAILABLE_IN_ALL
-void gdk_surface_set_user_data (GdkSurface *surface,
- gpointer user_data);
-GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_get_accept_focus (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_accept_focus (GdkSurface *surface,
@@ -595,9 +592,6 @@ GDK_AVAILABLE_IN_ALL
GdkCursor *gdk_surface_get_device_cursor (GdkSurface *surface,
GdkDevice *device);
GDK_AVAILABLE_IN_ALL
-void gdk_surface_get_user_data (GdkSurface *surface,
- gpointer *data);
-GDK_AVAILABLE_IN_ALL
void gdk_surface_get_geometry (GdkSurface *surface,
gint *x,
gint *y,
@@ -666,9 +660,6 @@ GDK_AVAILABLE_IN_ALL
GList * gdk_surface_get_children (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GList * gdk_surface_peek_children (GdkSurface *surface);
-GDK_AVAILABLE_IN_ALL
-GList * gdk_surface_get_children_with_user_data (GdkSurface *surface,
- gpointer user_data);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_icon_list (GdkSurface *surface,
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]