[cogl/wip/runtime-egl-platform: 8/12] cogland: Update to the new shell interface
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/runtime-egl-platform: 8/12] cogland: Update to the new shell interface
- Date: Tue, 13 Dec 2011 12:26:27 +0000 (UTC)
commit 9f93ffdbd35c1c9e60a5f1d2eb39f13222b4c9d9
Author: Neil Roberts <neil linux intel com>
Date: Mon Dec 12 19:31:01 2011 +0000
cogland: Update to the new shell interface
Wayland has changed so that the shell interface now only has one
function which returns a shell surface for the surface. This patch
makes it create a dummy service in the same way that the wayland demo
compositor does. The implementation of the shell_surface_interface for
that dummy service is all no-ops.
examples/cogland.c | 128 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 101 insertions(+), 27 deletions(-)
---
diff --git a/examples/cogland.c b/examples/cogland.c
index 7f28204..6774792 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -25,10 +25,19 @@ typedef struct
int x;
int y;
CoglandBuffer *buffer;
+
+ gboolean has_shell_surface;
} CoglandSurface;
typedef struct
{
+ CoglandSurface *surface;
+ struct wl_resource resource;
+ struct wl_listener surface_destroy_listener;
+} CoglandShellSurface;
+
+typedef struct
+{
guint32 flags;
int width;
int height;
@@ -551,54 +560,119 @@ compositor_bind (struct wl_client *client,
}
static void
-shell_move(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *surface_resource,
- struct wl_resource *input_resource,
- guint32 time)
+shell_surface_move (struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *input_device,
+ uint32_t time)
{
}
static void
-shell_resize (struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *surface_resource,
- struct wl_resource *input_resource,
- guint32 time,
- guint32 edges)
+shell_surface_resize (struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *input_device,
+ uint32_t time,
+ uint32_t edges)
{
}
static void
-shell_set_toplevel (struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *surface_resource)
+shell_surface_set_toplevel (struct wl_client *client,
+ struct wl_resource *resource)
{
}
static void
-shell_set_transient (struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *surface_resource,
- struct wl_resource *parent_resource,
- int x, int y, uint32_t flags)
+shell_surface_set_transient (struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *parent,
+ int32_t x,
+ int32_t y,
+ uint32_t flags)
{
}
static void
-shell_set_fullscreen (struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *surface_resource)
+shell_surface_set_fullscreen (struct wl_client *client,
+ struct wl_resource *resource)
{
}
+static const struct wl_shell_surface_interface cogl_shell_surface_interface =
+{
+ shell_surface_move,
+ shell_surface_resize,
+ shell_surface_set_toplevel,
+ shell_surface_set_transient,
+ shell_surface_set_fullscreen
+};
+
+static void
+shell_handle_surface_destroy (struct wl_listener *listener,
+ struct wl_resource *resource,
+ uint32_t time)
+{
+ CoglandShellSurface *shell_surface = container_of (listener,
+ CoglandShellSurface,
+ surface_destroy_listener);
+
+ shell_surface->surface->has_shell_surface = FALSE;
+ shell_surface->surface = NULL;
+ wl_resource_destroy (&shell_surface->resource, time);
+}
+
+static void
+destroy_shell_surface (struct wl_resource *resource)
+{
+ CoglandShellSurface *shell_surface = resource->data;
+
+ /* In case cleaning up a dead client destroys shell_surface first */
+ if (shell_surface->surface)
+ {
+ wl_list_remove (&shell_surface->surface_destroy_listener.link);
+ shell_surface->surface->has_shell_surface = FALSE;
+ }
+
+ g_free (shell_surface);
+}
+
+static void
+get_shell_surface (struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct wl_resource *surface_resource)
+{
+ CoglandSurface *surface = surface_resource->data;
+ CoglandShellSurface *shell_surface = g_new0 (CoglandShellSurface, 1);
+
+ if (surface->has_shell_surface)
+ {
+ wl_resource_post_error (surface_resource,
+ WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "wl_shell::get_shell_surface already requested");
+ return;
+ }
+
+ shell_surface->resource.destroy = destroy_shell_surface;
+ shell_surface->resource.object.id = id;
+ shell_surface->resource.object.interface = &wl_shell_surface_interface;
+ shell_surface->resource.object.implementation =
+ (void (**) (void)) &cogl_shell_surface_interface;
+ shell_surface->resource.data = shell_surface;
+
+ shell_surface->surface = surface;
+ shell_surface->surface_destroy_listener.func = shell_handle_surface_destroy;
+ wl_list_insert (surface->wayland_surface.resource.destroy_listener_list.prev,
+ &shell_surface->surface_destroy_listener.link);
+
+ surface->has_shell_surface = TRUE;
+
+ wl_client_add_resource (client, &shell_surface->resource);
+}
+
static const struct wl_shell_interface cogland_shell_interface =
{
- shell_move,
- shell_resize,
- shell_set_toplevel,
- shell_set_transient,
- shell_set_fullscreen
+ get_shell_surface
};
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]