Add gtk_root_get_for_surface

This is a replacement for gdk_surface_get_user_data.
This commit is contained in:
Matthias Clasen 2019-02-23 16:27:21 -05:00
parent 69b1a348c6
commit a13d8501d4
2 changed files with 23 additions and 0 deletions

View File

@ -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;
}

View File

@ -53,6 +53,8 @@ struct _GtkRootInterface
int *y);
};
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_root_get_for_surface (GdkSurface *surface);
G_END_DECLS