MetaWaylandSurface: Make it a GObject

This way we can add signals and weak references without relying on
wl_signal, wl_listener etc.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
This commit is contained in:
Jonas Ådahl 2015-07-08 11:21:23 +08:00
parent b01f95cfdd
commit cd1ce2cb0a
2 changed files with 24 additions and 2 deletions

View File

@ -68,6 +68,10 @@ typedef struct
struct wl_listener sibling_destroy_listener; struct wl_listener sibling_destroy_listener;
} MetaWaylandSubsurfacePlacementOp; } MetaWaylandSubsurfacePlacementOp;
GType meta_wayland_surface_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (MetaWaylandSurface, meta_wayland_surface, G_TYPE_OBJECT);
int int
meta_wayland_surface_set_role (MetaWaylandSurface *surface, meta_wayland_surface_set_role (MetaWaylandSurface *surface,
MetaWaylandSurfaceRole role, MetaWaylandSurfaceRole role,
@ -968,7 +972,7 @@ wl_surface_destructor (struct wl_resource *resource)
if (surface->gtk_surface) if (surface->gtk_surface)
wl_resource_destroy (surface->gtk_surface); wl_resource_destroy (surface->gtk_surface);
g_slice_free (MetaWaylandSurface, surface); g_object_unref (surface);
meta_wayland_compositor_repick (compositor); meta_wayland_compositor_repick (compositor);
} }
@ -979,7 +983,7 @@ meta_wayland_surface_create (MetaWaylandCompositor *compositor,
struct wl_resource *compositor_resource, struct wl_resource *compositor_resource,
guint32 id) guint32 id)
{ {
MetaWaylandSurface *surface = g_slice_new0 (MetaWaylandSurface); MetaWaylandSurface *surface = g_object_new (META_TYPE_WAYLAND_SURFACE, NULL);
surface->compositor = compositor; surface->compositor = compositor;
surface->scale = 1; surface->scale = 1;
@ -2290,3 +2294,13 @@ meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface)
return NULL; return NULL;
} }
static void
meta_wayland_surface_init (MetaWaylandSurface *surface)
{
}
static void
meta_wayland_surface_class_init (MetaWaylandSurfaceClass *klass)
{
}

View File

@ -31,6 +31,12 @@
#include "meta-wayland-types.h" #include "meta-wayland-types.h"
#include "meta-surface-actor.h" #include "meta-surface-actor.h"
#define META_TYPE_WAYLAND_SURFACE (meta_wayland_surface_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandSurface,
meta_wayland_surface,
META, WAYLAND_SURFACE,
GObject);
struct _MetaWaylandSerial { struct _MetaWaylandSerial {
gboolean set; gboolean set;
uint32_t value; uint32_t value;
@ -89,6 +95,8 @@ struct _MetaWaylandDragDestFuncs
struct _MetaWaylandSurface struct _MetaWaylandSurface
{ {
GObject parent;
/* Generic stuff */ /* Generic stuff */
struct wl_resource *resource; struct wl_resource *resource;
MetaWaylandCompositor *compositor; MetaWaylandCompositor *compositor;