[mutter] wayland: Make MetaWaylandCompositor a GObject
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland: Make MetaWaylandCompositor a GObject
- Date: Tue, 27 Nov 2018 14:56:19 +0000 (UTC)
commit bc5e76c76f7cb427cd00b54f98617409fe290d09
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Aug 23 15:49:17 2018 +0200
wayland: Make MetaWaylandCompositor a GObject
This makes it possible to use GObject features such as data attachments.
https://gitlab.gnome.org/GNOME/mutter/issues/276
src/wayland/meta-wayland-private.h | 6 ++++++
src/wayland/meta-wayland.c | 33 ++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index c5db43922..07a71f82b 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -61,6 +61,8 @@ typedef struct
struct _MetaWaylandCompositor
{
+ GObject parent;
+
struct wl_display *wayland_display;
char *display_name;
GHashTable *outputs;
@@ -74,4 +76,8 @@ struct _MetaWaylandCompositor
GHashTable *scheduled_surface_associations;
};
+#define META_TYPE_WAYLAND_COMPOSITOR (meta_wayland_compositor_get_type ())
+G_DECLARE_FINAL_TYPE (MetaWaylandCompositor, meta_wayland_compositor,
+ META, WAYLAND_COMPOSITOR, GObject)
+
#endif /* META_WAYLAND_PRIVATE_H */
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 25b49918f..a06d2d7d8 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -48,13 +48,17 @@
#include "wayland/meta-xwayland-private.h"
#include "wayland/meta-xwayland.h"
-static MetaWaylandCompositor _meta_wayland_compositor;
+static MetaWaylandCompositor *_meta_wayland_compositor = NULL;
static char *_display_name_override;
+G_DEFINE_TYPE (MetaWaylandCompositor, meta_wayland_compositor, G_TYPE_OBJECT)
+
MetaWaylandCompositor *
meta_wayland_compositor_get_default (void)
{
- return &_meta_wayland_compositor;
+ g_assert (_meta_wayland_compositor);
+
+ return _meta_wayland_compositor;
}
typedef struct
@@ -305,26 +309,33 @@ meta_wayland_log_func (const char *fmt,
static void
meta_wayland_compositor_init (MetaWaylandCompositor *compositor)
{
- memset (compositor, 0, sizeof (MetaWaylandCompositor));
wl_list_init (&compositor->frame_callbacks);
compositor->scheduled_surface_associations = g_hash_table_new (NULL, NULL);
-}
-
-void
-meta_wayland_pre_clutter_init (void)
-{
- MetaWaylandCompositor *compositor = &_meta_wayland_compositor;
-
- meta_wayland_compositor_init (compositor);
wl_log_set_handler_server (meta_wayland_log_func);
compositor->wayland_display = wl_display_create ();
if (compositor->wayland_display == NULL)
g_error ("Failed to create the global wl_display");
+}
+
+static void
+meta_wayland_compositor_class_init (MetaWaylandCompositorClass *klass)
+{
+}
+
+void
+meta_wayland_pre_clutter_init (void)
+{
+ MetaWaylandCompositor *compositor;
+ g_assert (!_meta_wayland_compositor);
+
+ compositor = g_object_new (META_TYPE_WAYLAND_COMPOSITOR, NULL);
clutter_wayland_set_compositor_display (compositor->wayland_display);
+
+ _meta_wayland_compositor = compositor;
}
static bool
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]