mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
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.
This commit is contained in:
parent
09fea73a40
commit
cc216c9e84
@ -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
|
||||
|
@ -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__ */
|
||||
|
@ -145,7 +145,7 @@ struct _GdkSurface
|
||||
GdkSurface *parent;
|
||||
GdkSurface *transient_for;
|
||||
|
||||
gpointer user_data;
|
||||
gpointer widget;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user