From bc5c7f0bc2db56fbc8475eab9b651b8a77effe91 Mon Sep 17 00:00:00 2001 From: rbuj Date: Fri, 29 Jan 2021 17:42:23 +0100 Subject: window: turn into a GObject --- src/core/window-private.h | 8 +++++- src/core/window.c | 70 +++++++++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 24 deletions(-) (limited to 'src/core') diff --git a/src/core/window-private.h b/src/core/window-private.h index 6b57c4b2..02b7df42 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -45,6 +45,8 @@ #include #include +G_BEGIN_DECLS + typedef struct _MetaGroup MetaGroup; typedef struct _MetaWindowQueue MetaWindowQueue; @@ -97,6 +99,8 @@ typedef enum { struct _MetaWindow { + GObject parent; + MetaDisplay *display; MetaScreen *screen; MetaWorkspace *workspace; @@ -700,4 +704,6 @@ void meta_window_update_net_wm_type (MetaWindow *window); gboolean meta_window_can_tile (MetaWindow *window); -#endif +G_END_DECLS + +#endif /* META_WINDOW_PRIVATE_H */ diff --git a/src/core/window.c b/src/core/window.c index 5f75e901..e377d7df 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -139,6 +139,8 @@ 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) + #ifdef WITH_VERBOSE_MODE static const char* wm_state_to_string (int state) @@ -386,7 +388,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; @@ -1209,28 +1211,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)); - - if (window->frame_bounds) - cairo_region_destroy (window->frame_bounds); - - 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->gtk_theme_variant); - g_free (window); + g_object_unref (window); } static void @@ -8889,3 +8870,46 @@ meta_window_get_frame_bounds (MetaWindow *window) return window->frame_bounds; } + +static void +meta_window_finalize (GObject *object) +{ + MetaWindow *window; + + window = META_WINDOW (object); + + g_clear_object (&window->icon); + g_clear_object (&window->mini_icon); + + g_clear_pointer (&window->frame_bounds, cairo_region_destroy); + + meta_icon_cache_free (&window->icon_cache); + + g_clear_pointer (&window->sm_client_id, g_free); + g_clear_pointer (&window->wm_client_machine, g_free); + g_clear_pointer (&window->startup_id, g_free); + g_clear_pointer (&window->role, g_free); + g_clear_pointer (&window->res_class, g_free); + g_clear_pointer (&window->res_name, g_free); + g_clear_pointer (&window->title, g_free); + g_clear_pointer (&window->icon_name, g_free); + g_clear_pointer (&window->desc, g_free); + g_clear_pointer (&window->gtk_theme_variant, g_free); + + G_OBJECT_CLASS (meta_window_parent_class)->finalize (object); +} + +static void +meta_window_class_init (MetaWindowClass *window_class) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (window_class); + + object_class->finalize = meta_window_finalize; +} + +static void +meta_window_init (MetaWindow *window) +{ +} -- cgit v1.2.1