Commit 9a1be032 authored by Owen Taylor's avatar Owen Taylor
Browse files

Make MetaWindow a GObject

Make MetaWindow into a GObject so that it is accessible to
gobject-introspection (also allows for signals to be added.)

Renames:

 meta_window_free() => meta_window_unmanage()
 meta_window_get_type() => meta_window_get_window_type()
 meta_window_get_type_atom() => meta_window_get_window_type_atom()
parent 026008a7
......@@ -241,10 +241,11 @@ mutter_window_class_init (MutterWindowClass *klass)
object_class->get_property = mutter_window_get_property;
object_class->constructed = mutter_window_constructed;
pspec = g_param_spec_pointer ("meta-window",
"MetaWindow",
"MetaWindow",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
pspec = g_param_spec_object ("meta-window",
"MetaWindow",
"The displayed MetaWindow",
META_TYPE_WINDOW,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class,
PROP_MCW_META_WINDOW,
......@@ -416,7 +417,7 @@ mutter_window_set_property (GObject *object,
switch (prop_id)
{
case PROP_MCW_META_WINDOW:
priv->window = g_value_get_pointer (value);
priv->window = g_value_get_object (value);
break;
case PROP_MCW_META_SCREEN:
priv->screen = g_value_get_pointer (value);
......@@ -444,7 +445,7 @@ mutter_window_get_property (GObject *object,
switch (prop_id)
{
case PROP_MCW_META_WINDOW:
g_value_set_pointer (value, priv->window);
g_value_set_object (value, priv->window);
break;
case PROP_MCW_META_SCREEN:
g_value_set_pointer (value, priv->screen);
......@@ -533,9 +534,9 @@ mutter_window_query_window_type (MutterWindow *self)
* If the window is managed by the WM, get the type from the WM,
* otherwise do it the hard way.
*/
if (priv->window && meta_window_get_type_atom (priv->window) != None)
if (priv->window && meta_window_get_window_type_atom (priv->window) != None)
{
priv->type = (MetaCompWindowType) meta_window_get_type (priv->window);
priv->type = (MetaCompWindowType) meta_window_get_window_type (priv->window);
return;
}
......
......@@ -903,7 +903,7 @@ meta_display_close (MetaDisplay *display,
}
#endif
/* Must be after all calls to meta_window_free() since they
/* Must be after all calls to meta_window_unmanage() since they
* unregister windows
*/
g_hash_table_destroy (display->window_ids);
......@@ -1992,7 +1992,7 @@ event_callback (XEvent *event,
else
{
/* Unmanage destroyed window */
meta_window_free (window, timestamp);
meta_window_unmanage (window, timestamp);
window = NULL;
}
}
......@@ -2024,7 +2024,7 @@ event_callback (XEvent *event,
/* Unmanage withdrawn window */
window->withdrawn = TRUE;
meta_window_free (window, timestamp);
meta_window_unmanage (window, timestamp);
window = NULL;
}
else
......@@ -4814,7 +4814,7 @@ meta_display_unmanage_windows_for_screen (MetaDisplay *display,
tmp = winlist;
while (tmp != NULL)
{
meta_window_free (tmp->data, timestamp);
meta_window_unmanage (tmp->data, timestamp);
tmp = tmp->next;
}
......
......@@ -66,6 +66,8 @@ typedef enum {
struct _MetaWindow
{
GObject parent_instance;
MetaDisplay *display;
MetaScreen *screen;
MetaWorkspace *workspace;
......@@ -233,7 +235,7 @@ struct _MetaWindow
/* Has this window not ever been shown yet? */
guint showing_for_first_time : 1;
/* Are we in meta_window_free()? */
/* Are we in meta_window_unmanage()? */
guint unmanaging : 1;
/* Are we in meta_window_new()? */
......@@ -354,6 +356,11 @@ struct _MetaWindow
#endif
};
struct _MetaWindowClass
{
GObjectClass parent_class;
};
/* These differ from window->has_foo_func in that they consider
* the dynamic window state such as "maximized", not just the
* window's type
......@@ -377,7 +384,7 @@ MetaWindow* meta_window_new_with_attrs (MetaDisplay *display,
Window xwindow,
gboolean must_be_viewable,
XWindowAttributes *attrs);
void meta_window_free (MetaWindow *window,
void meta_window_unmanage (MetaWindow *window,
guint32 timestamp);
void meta_window_calc_showing (MetaWindow *window);
void meta_window_queue (MetaWindow *window,
......
......@@ -128,6 +128,45 @@ static gboolean idle_calc_showing (gpointer data);
static gboolean idle_move_resize (gpointer data);
static gboolean idle_update_icon (gpointer data);
G_DEFINE_TYPE (MetaWindow, meta_window, G_TYPE_OBJECT);
static void
meta_window_finalize (GObject *object)
{
MetaWindow *window = META_WINDOW (object);
if (window->icon)
g_object_unref (G_OBJECT (window->icon));
if (window->mini_icon)
g_object_unref (G_OBJECT (window->mini_icon));
meta_icon_cache_free (&window->icon_cache);
g_free (window->sm_client_id);
g_free (window->wm_client_machine);
g_free (window->startup_id);
g_free (window->role);
g_free (window->res_class);
g_free (window->res_name);
g_free (window->title);
g_free (window->icon_name);
g_free (window->desc);
}
static void
meta_window_class_init (MetaWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_window_finalize;
}
static void
meta_window_init (MetaWindow *self)
{
}
#ifdef WITH_VERBOSE_MODE
static const char*
wm_state_to_string (int state)
......@@ -386,7 +425,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
g_assert (!attrs->override_redirect);
window = g_new (MetaWindow, 1);
window = g_object_new (META_TYPE_WINDOW, NULL);
window->constructing = TRUE;
......@@ -980,8 +1019,8 @@ meta_window_apply_session_info (MetaWindow *window,
}
void
meta_window_free (MetaWindow *window,
guint32 timestamp)
meta_window_unmanage (MetaWindow *window,
guint32 timestamp)
{
GList *tmp;
......@@ -1194,24 +1233,7 @@ meta_window_free (MetaWindow *window,
meta_error_trap_pop (window->display, FALSE);
if (window->icon)
g_object_unref (G_OBJECT (window->icon));
if (window->mini_icon)
g_object_unref (G_OBJECT (window->mini_icon));
meta_icon_cache_free (&window->icon_cache);
g_free (window->sm_client_id);
g_free (window->wm_client_machine);
g_free (window->startup_id);
g_free (window->role);
g_free (window->res_class);
g_free (window->res_name);
g_free (window->title);
g_free (window->icon_name);
g_free (window->desc);
g_free (window);
g_object_unref (window);
}
static void
......@@ -8300,13 +8322,13 @@ meta_window_get_xwindow (MetaWindow *window)
}
MetaWindowType
meta_window_get_type (MetaWindow *window)
meta_window_get_window_type (MetaWindow *window)
{
return window->type;
}
Atom
meta_window_get_type_atom (MetaWindow *window)
meta_window_get_window_type_atom (MetaWindow *window)
{
return window->type_atom;
}
......
......@@ -22,7 +22,7 @@
#ifndef META_WINDOW_H
#define META_WINDOW_H
#include <glib.h>
#include <glib-object.h>
#include <X11/Xlib.h>
#include "boxes.h"
......@@ -47,6 +47,17 @@ typedef enum
META_MAXIMIZE_VERTICAL = 1 << 1
} MetaMaximizeFlags;
#define META_TYPE_WINDOW (meta_window_get_type ())
#define META_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_WINDOW, MetaWindow))
#define META_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_WINDOW, MetaWindowClass))
#define META_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_WINDOW_TYPE))
#define META_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_WINDOW))
#define META_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_WINDOW, MetaWindowClass))
typedef struct _MetaWindowClass MetaWindowClass;
GType meta_window_get_type (void);
MetaFrame *meta_window_get_frame (MetaWindow *window);
gboolean meta_window_has_focus (MetaWindow *window);
gboolean meta_window_is_shaded (MetaWindow *window);
......@@ -54,8 +65,8 @@ MetaRectangle *meta_window_get_rect (MetaWindow *window);
MetaScreen *meta_window_get_screen (MetaWindow *window);
MetaDisplay *meta_window_get_display (MetaWindow *window);
Window meta_window_get_xwindow (MetaWindow *window);
MetaWindowType meta_window_get_type (MetaWindow *window);
Atom meta_window_get_type_atom (MetaWindow *window);
MetaWindowType meta_window_get_window_type (MetaWindow *window);
Atom meta_window_get_window_type_atom (MetaWindow *window);
MetaWorkspace *meta_window_get_workspace (MetaWindow *window);
gboolean meta_window_is_on_all_workspaces (MetaWindow *window);
gboolean meta_window_is_hidden (MetaWindow *window);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment