Commit 08a65dfd authored by Marco Trevisan's avatar Marco Trevisan 🎺

compositor: make it a GObject

Bump glib_req version as per g_clear_handle_id usage.
parent 0c074246
......@@ -9,7 +9,7 @@ mutter_plugin_api_version = '3'
libmutter_api_version = '4'
# generic version requirements
glib_req = '>= 2.53.2'
glib_req = '>= 2.56'
gi_req = '>= 0.9.5'
gtk3_req = '>= 3.19.8'
gdk_pixbuf_req = '>= 2.0'
......
......@@ -13,6 +13,8 @@
struct _MetaCompositor
{
GObject parent;
MetaDisplay *display;
guint pre_paint_func_id;
......
......@@ -86,6 +86,8 @@
#include "wayland/meta-wayland-private.h"
#endif
G_DEFINE_TYPE (MetaCompositor, meta_compositor, G_TYPE_OBJECT)
static void
on_presented (ClutterStage *stage,
CoglFrameEvent event,
......@@ -131,11 +133,8 @@ meta_switch_workspace_completed (MetaCompositor *compositor)
void
meta_compositor_destroy (MetaCompositor *compositor)
{
clutter_threads_remove_repaint_func (compositor->pre_paint_func_id);
clutter_threads_remove_repaint_func (compositor->post_paint_func_id);
if (compositor->have_x11_sync_object)
meta_sync_ring_destroy ();
g_object_run_dispose (G_OBJECT (compositor));
g_object_unref (compositor);
}
static void
......@@ -1274,12 +1273,20 @@ on_shadow_factory_changed (MetaShadowFactory *factory,
MetaCompositor *
meta_compositor_new (MetaDisplay *display)
{
MetaBackend *backend = meta_get_backend ();
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
MetaCompositor *compositor;
compositor = g_new0 (MetaCompositor, 1);
compositor = g_object_new (META_TYPE_COMPOSITOR, NULL);
compositor->display = display;
return compositor;
}
static void
meta_compositor_init (MetaCompositor *compositor)
{
MetaBackend *backend = meta_get_backend ();
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
compositor->context = clutter_backend->cogl_context;
g_signal_connect (meta_shadow_factory_get_default (),
......@@ -1297,7 +1304,33 @@ meta_compositor_new (MetaDisplay *display)
meta_post_paint_func,
compositor,
NULL);
return compositor;
}
static void
meta_compositor_dispose (GObject *gobject)
{
MetaCompositor *compositor = META_COMPOSITOR (gobject);
g_clear_handle_id (&compositor->pre_paint_func_id,
clutter_threads_remove_repaint_func);
g_clear_handle_id (&compositor->post_paint_func_id,
clutter_threads_remove_repaint_func);
if (compositor->have_x11_sync_object)
{
meta_sync_ring_destroy ();
compositor->have_x11_sync_object = FALSE;
}
G_OBJECT_CLASS (meta_compositor_parent_class)->dispose (gobject);
}
static void
meta_compositor_class_init (MetaCompositorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = meta_compositor_dispose;
}
/**
......
......@@ -28,6 +28,11 @@
#include <meta/window.h>
#include <meta/workspace.h>
#define META_TYPE_COMPOSITOR (meta_compositor_get_type ())
META_EXPORT
G_DECLARE_FINAL_TYPE (MetaCompositor, meta_compositor, META, COMPOSITOR, GObject)
/**
* MetaCompEffect:
* @META_COMP_EFFECT_CREATE: The window is newly created
......
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