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.
This commit is contained in:
Dan Winship 2009-02-02 15:16:05 -05:00
parent f6a3ba26f9
commit 0fdb644454
4 changed files with 25 additions and 17 deletions

View File

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

View File

@ -360,7 +360,7 @@ struct _MetaWindow
MetaGroup *group;
#ifdef HAVE_COMPOSITE_EXTENSIONS
void *compositor_private;
GObject *compositor_private;
#endif
};

View File

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

View File

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