summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2021-01-29 17:42:23 +0100
committerraveit65 <[email protected]>2021-03-01 13:55:09 +0100
commitbc5c7f0bc2db56fbc8475eab9b651b8a77effe91 (patch)
tree9f212308a42ecb5230a409364795cd4f598d80d0
parent5b6170f917cdb1cbd3752c963a6ad4d2a58b35d8 (diff)
downloadmarco-bc5c7f0bc2db56fbc8475eab9b651b8a77effe91.tar.bz2
marco-bc5c7f0bc2db56fbc8475eab9b651b8a77effe91.tar.xz
window: turn into a GObject
-rw-r--r--src/core/window-private.h8
-rw-r--r--src/core/window.c70
-rw-r--r--src/include/window.h8
3 files changed, 62 insertions, 24 deletions
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 <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
+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)
+{
+}
diff --git a/src/include/window.h b/src/include/window.h
index 0aa208e4..6dece7d3 100644
--- a/src/include/window.h
+++ b/src/include/window.h
@@ -23,12 +23,18 @@
#define META_WINDOW_H
#include <glib.h>
+#include <glib-object.h>
#include <cairo.h>
#include <X11/Xlib.h>
#include "boxes.h"
#include "types.h"
+G_BEGIN_DECLS
+
+#define META_TYPE_WINDOW meta_window_get_type ()
+G_DECLARE_FINAL_TYPE (MetaWindow, meta_window, META, WINDOW, GObject)
+
MetaFrame *meta_window_get_frame (MetaWindow *window);
gboolean meta_window_has_focus (MetaWindow *window);
gboolean meta_window_is_shaded (MetaWindow *window);
@@ -40,4 +46,6 @@ MetaWindow *meta_window_get_transient_for (MetaWindow *window);
gboolean meta_window_is_maximized (MetaWindow *window);
cairo_region_t *meta_window_get_frame_bounds (MetaWindow *window);
+G_END_DECLS
+
#endif