[PATCH 10/14] tablet-shell: add event in tablet-client protocol.
Philipp Brüschweiler
blei42 at gmail.com
Tue Aug 21 09:14:26 PDT 2012
On Tue, Aug 21, 2012 at 1:49 PM, <tecton69 at gmail.com> wrote:
> From: Ning Tang <ning.tang at intel.com>
>
> When a client is binded, the server side will send an event to let the
> client set fullscreen.
> If the client don't response, it will remain centered.
>
> Signed-off-by: Ning Tang <tecton69 at gmail.com>
>
> ---
> protocol/tablet-shell.xml | 2 ++
> src/tablet-shell.c | 90 ++++++++++++++++++++++++++++++++++++++++++++---
> 2 files changed, 87 insertions(+), 5 deletions(-)
>
> diff --git a/protocol/tablet-shell.xml b/protocol/tablet-shell.xml
> index 10f1756..f226c01 100644
> --- a/protocol/tablet-shell.xml
> +++ b/protocol/tablet-shell.xml
> @@ -35,6 +35,8 @@
> <interface name="tablet_client" version="1">
> <request name="destroy" type="destructor"/>
> <request name="activate"/>
> +
> + <event name="set_fullscreen"/>
> </interface>
>
> </protocol>
> diff --git a/src/tablet-shell.c b/src/tablet-shell.c
> index 89f84bf..d7ce01f 100644
> --- a/src/tablet-shell.c
> +++ b/src/tablet-shell.c
> @@ -45,6 +45,7 @@ enum {
>
> struct tablet_shell {
> struct wl_resource resource;
> + struct wl_resource client_resource;
>
> struct wl_listener lock_listener;
> struct wl_listener unlock_listener;
> @@ -153,6 +154,11 @@ shell_handle_surface_destroy(struct wl_listener *listener, void *data)
> struct shell_surface *shsurf =
> container_of(listener, struct shell_surface,
> surface_destroy_listener);
> + struct tablet_shell *shell = shsurf->shell;
> + if (shell->client_resource.client) {
> + wl_resource_destroy(&shell->client_resource);
> + shell->client_resource.client = NULL;
> + }
> if (shsurf->resource.client) {
> wl_resource_destroy(&shsurf->resource);
> } else {
> @@ -211,6 +217,11 @@ shell_surface_set_transient(struct wl_client *client,
> int x, int y, uint32_t flags)
> {
> struct shell_surface *shsurf = resource->data;
> + struct tablet_shell *shell = shsurf->shell;
> + if (shell->client_resource.client) {
> + wl_resource_destroy(&shell->client_resource);
> + shell->client_resource.client = NULL;
> + }
> if (shsurf->resource.client) {
> wl_resource_destroy(&shsurf->resource);
> } else {
> @@ -546,6 +557,24 @@ shell_stack_fullscreen(struct shell_surface *shsurf)
> }
>
> static void
> +configure(struct tablet_shell *shell, struct weston_surface *surface,
> + GLfloat x, GLfloat y, int32_t width, int32_t height)
> +{
> + struct shell_surface *shsurf;
> +
> + shsurf = get_shell_surface(surface);
> + surface->geometry.x = x;
> + surface->geometry.y = y;
> + surface->geometry.width = width;
> + surface->geometry.height = height;
> + surface->geometry.dirty = 1;
> +
> + shell_stack_fullscreen(shsurf);
> + center_on_output(surface, surface->output);
> + weston_surface_assign_output(surface);
> +}
> +
> +static void
> shell_surface_configure(struct weston_surface *surface,
> int32_t sx, int32_t sy)
> {
> @@ -558,12 +587,44 @@ shell_surface_configure(struct weston_surface *surface,
>
> wl_list_insert(&shell->application_layer.surface_list,
> &surface->layer_link);
> - weston_surface_assign_output(surface);
> - center_on_output(surface, surface->output);
> - shell_stack_fullscreen(shsurf);
> - wl_list_for_each(seat, &surface->compositor->seat_list, link)
> + if (shell->client_resource.client) {
> + weston_surface_assign_output(surface);
> + center_on_output(surface, surface->output);
> + shell_stack_fullscreen(shsurf);
> + wl_list_for_each(seat,
> + &surface->compositor->seat_list,
> + link)
> weston_surface_activate(surface, seat);
Please indent this line.
> - weston_compositor_schedule_repaint(shell->compositor);
> + weston_compositor_schedule_repaint(surface->compositor);
> + tablet_client_send_set_fullscreen(
> + &shell->client_resource);
> +
> + return;
> + } else {
> + weston_surface_assign_output(surface);
> + center_on_output(surface, surface->output);
> + shell_stack_fullscreen(shsurf);
> + wl_list_for_each(seat, &surface->compositor->seat_list,
> + link)
> + weston_surface_activate(surface, seat);
> + weston_compositor_schedule_repaint(shell->compositor);
This else branch is exactly the same as the beginning of the if
branch. Why not move this code outside of the if?
> + }
> + }
> + if (sx != 0 || sy != 0 ||
> + surface->geometry.width != surface->buffer->width ||
> + surface->geometry.height != surface->buffer->height) {
> + GLfloat from_x, from_y;
> + GLfloat to_x, to_y;
> +
> + weston_surface_to_global_float(surface, 0, 0,
> + &from_x, &from_y);
> + weston_surface_to_global_float(surface, sx, sy,
> + &to_x, &to_y);
> + configure(shell, surface,
> + surface->geometry.x + to_x - from_x,
> + surface->geometry.y + to_y - from_y,
> + surface->buffer->width,
> + surface->buffer->height);
> }
> }
>
> @@ -890,6 +951,22 @@ bind_tablet_shell(struct wl_client *client, void *data, uint32_t version,
> }
>
> static void
> +bind_tablet_client(struct wl_client *client, void *data, uint32_t version,
> + uint32_t id)
> +{
> + struct tablet_shell *shell = data;
> + shell->client_resource.object.id = id;
> + shell->client_resource.object.interface = &tablet_client_interface;
> + shell->client_resource.object.implementation =
> + (void (**)(void)) &tablet_client_implementation;
> + shell->client_resource.client = client;
> + shell->client_resource.data = shell;
> + shell->client_resource.destroy = destroy_tablet_shell;
> +
> + wl_client_add_resource(client, &shell->client_resource);
> +}
> +
> +static void
> tablet_shell_destroy(struct wl_listener *listener, void *data)
> {
> struct tablet_shell *shell =
> @@ -928,6 +1005,9 @@ shell_init(struct weston_compositor *compositor)
> shell->unlock_listener.notify = tablet_shell_unlock;
> wl_signal_add(&compositor->unlock_signal, &shell->unlock_listener);
>
> + wl_display_add_global(compositor->wl_display, &tablet_client_interface,
> + shell, bind_tablet_client);
> +
> /* FIXME: This will make the object available to all clients. */
> wl_display_add_global(compositor->wl_display, &tablet_shell_interface,
> shell, bind_tablet_shell);
> --
> 1.7.11.5
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list