diff options
author | Neil Roberts <neil@linux.intel.com> | 2011-12-23 14:14:23 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2011-12-23 14:14:23 +0000 |
commit | 9855f063f2c122bbc215212733c7867be60542e9 (patch) | |
tree | bfa4faf08be94382373b8296a8aed3c04ead0db6 | |
parent | ea9e96b62eeb5c4e21b7af752cdde7f29523fab3 (diff) | |
download | clutter-9855f063f2c122bbc215212733c7867be60542e9.tar.gz |
test-wayland-surface: Update to the latest Wayland shell interface
This is based on similar changes to the Cogland example in Cogl:
http://git.gnome.org/browse/cogl/commit/?id=d6b03ab45d3047835d8
-rw-r--r-- | tests/interactive/test-wayland-surface.c | 128 |
1 files changed, 101 insertions, 27 deletions
diff --git a/tests/interactive/test-wayland-surface.c b/tests/interactive/test-wayland-surface.c index 0e24af953..6e6131632 100644 --- a/tests/interactive/test-wayland-surface.c +++ b/tests/interactive/test-wayland-surface.c @@ -34,10 +34,19 @@ typedef struct int y; TWSBuffer *buffer; ClutterActor *actor; + + gboolean has_shell_surface; } TWSSurface; typedef struct { + TWSSurface *surface; + struct wl_resource resource; + struct wl_listener surface_destroy_listener; +} TWSShellSurface; + +typedef struct +{ guint32 flags; int width; int height; @@ -465,54 +474,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_surface_resize (struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *input_device, + uint32_t time, + uint32_t edges) { } 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_set_toplevel (struct wl_client *client, + struct wl_resource *resource) { } static void -shell_set_toplevel (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource) +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_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_fullscreen (struct wl_client *client, + struct wl_resource *resource) { } +static const struct wl_shell_surface_interface tws_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) +{ + TWSShellSurface *shell_surface = container_of (listener, + TWSShellSurface, + surface_destroy_listener); + + shell_surface->surface->has_shell_surface = FALSE; + shell_surface->surface = NULL; + wl_resource_destroy (&shell_surface->resource, time); +} + static void -shell_set_fullscreen (struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *surface_resource) +destroy_shell_surface (struct wl_resource *resource) { + TWSShellSurface *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) +{ + TWSSurface *surface = surface_resource->data; + TWSShellSurface *shell_surface = g_new0 (TWSShellSurface, 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)) &tws_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 tws_shell_interface = { - shell_move, - shell_resize, - shell_set_toplevel, - shell_set_transient, - shell_set_fullscreen + get_shell_surface }; static void |