wayland: Replace buffer destroy wl_signal with a GObject signal
Don't use the libwayland-* utilities when we have our own that do the same thing. https://bugzilla.gnome.org/show_bug.cgi?id=762828
This commit is contained in:
parent
623eb6eacc
commit
aa7bc501d5
@ -30,6 +30,15 @@
|
|||||||
#include <cogl/cogl-wayland-server.h>
|
#include <cogl/cogl-wayland-server.h>
|
||||||
#include <meta/util.h>
|
#include <meta/util.h>
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RESOURCE_DESTROYED,
|
||||||
|
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
guint signals[LAST_SIGNAL];
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaWaylandBuffer, meta_wayland_buffer, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (MetaWaylandBuffer, meta_wayland_buffer, G_TYPE_OBJECT);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -40,7 +49,7 @@ meta_wayland_buffer_destroy_handler (struct wl_listener *listener,
|
|||||||
wl_container_of (listener, buffer, destroy_listener);
|
wl_container_of (listener, buffer, destroy_listener);
|
||||||
|
|
||||||
buffer->resource = NULL;
|
buffer->resource = NULL;
|
||||||
wl_signal_emit (&buffer->destroy_signal, buffer);
|
g_signal_emit (buffer, signals[RESOURCE_DESTROYED], 0);
|
||||||
g_object_unref (buffer);
|
g_object_unref (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +91,6 @@ meta_wayland_buffer_from_resource (struct wl_resource *resource)
|
|||||||
buffer = g_object_new (META_TYPE_WAYLAND_BUFFER, NULL);
|
buffer = g_object_new (META_TYPE_WAYLAND_BUFFER, NULL);
|
||||||
|
|
||||||
buffer->resource = resource;
|
buffer->resource = resource;
|
||||||
wl_signal_init (&buffer->destroy_signal);
|
|
||||||
buffer->destroy_listener.notify = meta_wayland_buffer_destroy_handler;
|
buffer->destroy_listener.notify = meta_wayland_buffer_destroy_handler;
|
||||||
wl_resource_add_destroy_listener (resource, &buffer->destroy_listener);
|
wl_resource_add_destroy_listener (resource, &buffer->destroy_listener);
|
||||||
}
|
}
|
||||||
@ -181,4 +189,11 @@ meta_wayland_buffer_class_init (MetaWaylandBufferClass *klass)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = meta_wayland_buffer_finalize;
|
object_class->finalize = meta_wayland_buffer_finalize;
|
||||||
|
|
||||||
|
signals[RESOURCE_DESTROYED] = g_signal_new ("resource-destroyed",
|
||||||
|
G_TYPE_FROM_CLASS (object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ struct _MetaWaylandBuffer
|
|||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wl_signal destroy_signal;
|
|
||||||
struct wl_listener destroy_listener;
|
struct wl_listener destroy_listener;
|
||||||
|
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
|
@ -432,11 +432,11 @@ toplevel_surface_commit (MetaWaylandSurfaceRole *surface_role,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
surface_handle_pending_buffer_destroy (struct wl_listener *listener, void *data)
|
pending_buffer_resource_destroyed (MetaWaylandBuffer *buffer,
|
||||||
|
MetaWaylandPendingState *pending)
|
||||||
{
|
{
|
||||||
MetaWaylandPendingState *state = wl_container_of (listener, state, buffer_destroy_listener);
|
g_signal_handler_disconnect (buffer, pending->buffer_destroy_handler_id);
|
||||||
|
pending->buffer = NULL;
|
||||||
state->buffer = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -454,7 +454,6 @@ pending_state_init (MetaWaylandPendingState *state)
|
|||||||
state->opaque_region_set = FALSE;
|
state->opaque_region_set = FALSE;
|
||||||
|
|
||||||
state->damage = cairo_region_create ();
|
state->damage = cairo_region_create ();
|
||||||
state->buffer_destroy_listener.notify = surface_handle_pending_buffer_destroy;
|
|
||||||
wl_list_init (&state->frame_callback_list);
|
wl_list_init (&state->frame_callback_list);
|
||||||
|
|
||||||
state->has_new_geometry = FALSE;
|
state->has_new_geometry = FALSE;
|
||||||
@ -470,7 +469,8 @@ pending_state_destroy (MetaWaylandPendingState *state)
|
|||||||
g_clear_pointer (&state->opaque_region, cairo_region_destroy);
|
g_clear_pointer (&state->opaque_region, cairo_region_destroy);
|
||||||
|
|
||||||
if (state->buffer)
|
if (state->buffer)
|
||||||
wl_list_remove (&state->buffer_destroy_listener.link);
|
g_signal_handler_disconnect (state->buffer,
|
||||||
|
state->buffer_destroy_handler_id);
|
||||||
wl_list_for_each_safe (cb, next, &state->frame_callback_list, link)
|
wl_list_for_each_safe (cb, next, &state->frame_callback_list, link)
|
||||||
wl_resource_destroy (cb->resource);
|
wl_resource_destroy (cb->resource);
|
||||||
}
|
}
|
||||||
@ -487,7 +487,7 @@ move_pending_state (MetaWaylandPendingState *from,
|
|||||||
MetaWaylandPendingState *to)
|
MetaWaylandPendingState *to)
|
||||||
{
|
{
|
||||||
if (from->buffer)
|
if (from->buffer)
|
||||||
wl_list_remove (&from->buffer_destroy_listener.link);
|
g_signal_handler_disconnect (from->buffer, from->buffer_destroy_handler_id);
|
||||||
|
|
||||||
to->newly_attached = from->newly_attached;
|
to->newly_attached = from->newly_attached;
|
||||||
to->buffer = from->buffer;
|
to->buffer = from->buffer;
|
||||||
@ -506,7 +506,12 @@ move_pending_state (MetaWaylandPendingState *from,
|
|||||||
wl_list_insert_list (&to->frame_callback_list, &from->frame_callback_list);
|
wl_list_insert_list (&to->frame_callback_list, &from->frame_callback_list);
|
||||||
|
|
||||||
if (to->buffer)
|
if (to->buffer)
|
||||||
wl_signal_add (&to->buffer->destroy_signal, &to->buffer_destroy_listener);
|
{
|
||||||
|
to->buffer_destroy_handler_id =
|
||||||
|
g_signal_connect (to->buffer, "resource-destroyed",
|
||||||
|
G_CALLBACK (pending_buffer_resource_destroyed),
|
||||||
|
to);
|
||||||
|
}
|
||||||
|
|
||||||
pending_state_init (from);
|
pending_state_init (from);
|
||||||
}
|
}
|
||||||
@ -779,7 +784,10 @@ wl_surface_attach (struct wl_client *client,
|
|||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
|
|
||||||
if (surface->pending->buffer)
|
if (surface->pending->buffer)
|
||||||
wl_list_remove (&surface->pending->buffer_destroy_listener.link);
|
{
|
||||||
|
g_signal_handler_disconnect (surface->pending->buffer,
|
||||||
|
surface->pending->buffer_destroy_handler_id);
|
||||||
|
}
|
||||||
|
|
||||||
surface->pending->newly_attached = TRUE;
|
surface->pending->newly_attached = TRUE;
|
||||||
surface->pending->buffer = buffer;
|
surface->pending->buffer = buffer;
|
||||||
@ -787,8 +795,12 @@ wl_surface_attach (struct wl_client *client,
|
|||||||
surface->pending->dy = dy;
|
surface->pending->dy = dy;
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
wl_signal_add (&buffer->destroy_signal,
|
{
|
||||||
&surface->pending->buffer_destroy_listener);
|
surface->pending->buffer_destroy_handler_id =
|
||||||
|
g_signal_connect (buffer, "resource-destroyed",
|
||||||
|
G_CALLBACK (pending_buffer_resource_destroyed),
|
||||||
|
surface->pending);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -104,7 +104,7 @@ struct _MetaWaylandPendingState
|
|||||||
/* wl_surface.attach */
|
/* wl_surface.attach */
|
||||||
gboolean newly_attached;
|
gboolean newly_attached;
|
||||||
MetaWaylandBuffer *buffer;
|
MetaWaylandBuffer *buffer;
|
||||||
struct wl_listener buffer_destroy_listener;
|
gulong buffer_destroy_handler_id;
|
||||||
int32_t dx;
|
int32_t dx;
|
||||||
int32_t dy;
|
int32_t dy;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user