[PATCH 11/19] tablet-shell: add event in tablet-client protocol.

ning.tang at intel.com ning.tang at intel.com
Mon Sep 24 19:39:56 PDT 2012


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 <ning.tang at intel.com>
---
 protocol/tablet-shell.xml |  2 ++
 src/tablet-shell.c        | 74 +++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 74 insertions(+), 2 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 172ec79..080cd4b 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;
@@ -152,6 +153,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 {
@@ -210,6 +216,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 {
@@ -545,6 +556,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)
 {
@@ -560,9 +589,31 @@ shell_surface_configure(struct weston_surface *surface,
 		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)
+		wl_list_for_each(seat,
+				 &surface->compositor->seat_list,
+				 link)
 			weston_surface_activate(surface, seat);
-		weston_compositor_schedule_repaint(shell->compositor);
+		weston_compositor_schedule_repaint(surface->compositor);
+		if (shell->client_resource.client) {
+			tablet_client_send_set_fullscreen(
+					&shell->client_resource);
+		}
+	}
+	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);
 	}
 }
 
@@ -889,6 +940,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 =
@@ -924,6 +991,9 @@ module_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.12.1



More information about the wayland-devel mailing list