From 0fdb644454471a86b2ebb1516b739768e25e7389 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 2 Feb 2009 15:16:05 -0500 Subject: [PATCH] Make compositor private a GObject than a void pointer Requiring the compositor private object to be a GObject allows the return value of meta_window_get_compositor_private() to be used via gobject-introspection, since the type and memory management can be determined. This allows a reverse mapping from MetaWindow to MutterWindow. - Change meta_window_get/set_compositor_private to use GObject rather than void * - Adapt code in compositor-mutter.c to match. --- src/compositor/mutter/compositor-mutter.c | 24 +++++++++++------------ src/core/window-private.h | 2 +- src/core/window.c | 12 ++++++++++-- src/include/window.h | 4 ++-- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/compositor/mutter/compositor-mutter.c b/src/compositor/mutter/compositor-mutter.c index 0e61a4d11..823b9e37b 100644 --- a/src/compositor/mutter/compositor-mutter.c +++ b/src/compositor/mutter/compositor-mutter.c @@ -1217,7 +1217,7 @@ add_win (MetaWindow *window) meta_verbose ("added 0x%x (%p) type:", (guint)top_window, cw); /* Hang our compositor window state off the MetaWindow for fast retrieval */ - meta_window_set_compositor_private (window, cw); + meta_window_set_compositor_private (window, G_OBJECT (cw)); /* * Add this to the list at the top of the stack before it is mapped so that @@ -1742,7 +1742,7 @@ clutter_cmp_remove_window (MetaCompositor *compositor, MutterWindow *cw = NULL; DEBUG_TRACE ("clutter_cmp_remove_window\n"); - cw = meta_window_get_compositor_private (window); + cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); if (!cw) return; @@ -1876,7 +1876,7 @@ static void clutter_cmp_map_window (MetaCompositor *compositor, MetaWindow *window) { #ifdef HAVE_COMPOSITE_EXTENSIONS - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); DEBUG_TRACE ("clutter_cmp_map_window\n"); if (!cw) return; @@ -1889,7 +1889,7 @@ static void clutter_cmp_unmap_window (MetaCompositor *compositor, MetaWindow *window) { #ifdef HAVE_COMPOSITE_EXTENSIONS - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); DEBUG_TRACE ("clutter_cmp_unmap_window\n"); if (!cw) return; @@ -1905,7 +1905,7 @@ clutter_cmp_minimize_window (MetaCompositor *compositor, MetaRectangle *icon_rect) { #ifdef HAVE_COMPOSITE_EXTENSIONS - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -1941,7 +1941,7 @@ clutter_cmp_unminimize_window (MetaCompositor *compositor, { #ifdef HAVE_COMPOSITE_EXTENSIONS #if 0 - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -1965,7 +1965,7 @@ clutter_cmp_unminimize_window (MetaCompositor *compositor, cw->priv->minimize_in_progress--; } #else - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); DEBUG_TRACE ("clutter_cmp_unminimize_window\n"); if (!cw) return; @@ -1982,7 +1982,7 @@ clutter_cmp_maximize_window (MetaCompositor *compositor, MetaRectangle *rect) { #ifdef HAVE_COMPOSITE_EXTENSIONS - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -2012,7 +2012,7 @@ clutter_cmp_unmaximize_window (MetaCompositor *compositor, MetaRectangle *rect) { #ifdef HAVE_COMPOSITE_EXTENSIONS - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); @@ -2171,7 +2171,7 @@ clutter_cmp_sync_stack (MetaCompositor *compositor, for (tmp = stack; tmp != NULL; tmp = tmp->next) { MetaWindow *window = tmp->data; - MutterWindow *cw = window->compositor_private; + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); if (!cw) { @@ -2193,7 +2193,7 @@ clutter_cmp_set_window_hidden (MetaCompositor *compositor, MetaWindow *window, gboolean hidden) { - MutterWindow *cw = window->compositor_private; + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaCompScreen *info = meta_screen_get_compositor_data (screen); DEBUG_TRACE ("clutter_cmp_set_window_hidden\n"); @@ -2221,7 +2221,7 @@ clutter_cmp_sync_window_geometry (MetaCompositor *compositor, MetaWindow *window) { #ifdef HAVE_COMPOSITE_EXTENSIONS - MutterWindow *cw = meta_window_get_compositor_private (window); + MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window)); MetaScreen *screen = meta_window_get_screen (window); MetaCompScreen *info = meta_screen_get_compositor_data (screen); diff --git a/src/core/window-private.h b/src/core/window-private.h index efdb3476e..5255b774b 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -360,7 +360,7 @@ struct _MetaWindow MetaGroup *group; #ifdef HAVE_COMPOSITE_EXTENSIONS - void *compositor_private; + GObject *compositor_private; #endif }; diff --git a/src/core/window.c b/src/core/window.c index e4d51cc62..a9a0d9099 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -8707,7 +8707,15 @@ meta_window_get_description (MetaWindow *window) return window->desc; } -void * +/** + * meta_window_get_compositor_private: + * @window: a #MetaWindow + * + * Gets the compositor's wrapper object for @window. + * + * Return value: (transfer none): the wrapper object. + **/ +GObject * meta_window_get_compositor_private (MetaWindow *window) { if (!window) @@ -8716,7 +8724,7 @@ meta_window_get_compositor_private (MetaWindow *window) } void -meta_window_set_compositor_private (MetaWindow *window, void *priv) +meta_window_set_compositor_private (MetaWindow *window, GObject *priv) { if (!window) return; diff --git a/src/include/window.h b/src/include/window.h index b99816dca..1ee2af647 100644 --- a/src/include/window.h +++ b/src/include/window.h @@ -92,8 +92,8 @@ void meta_window_change_workspace_by_index (MetaWindow *window, gint space_index, gboolean append, guint32 timestamp); -void *meta_window_get_compositor_private (MetaWindow *window); -void meta_window_set_compositor_private (MetaWindow *window, void *priv); +GObject *meta_window_get_compositor_private (MetaWindow *window); +void meta_window_set_compositor_private (MetaWindow *window, GObject *priv); void meta_window_configure_notify (MetaWindow *window, XConfigureEvent *event); const char *meta_window_get_role (MetaWindow *window);