[PATCH 18/19] tablet-shell: add sleep event in tablet_client protocol

ning.tang at intel.com ning.tang at intel.com
Mon Sep 24 19:40:03 PDT 2012


From: Ning Tang <ning.tang at intel.com>

 Send an event to client to inform it that it will not
 be drawn and need it to release resources. The client
 task have a client resource to communicate.
 
 Signed-off-by: Ning Tang <ning.tang at intel.com>
---
 protocol/tablet-shell.xml |  1 +
 src/tablet-shell.c        | 42 ++++++++++++++++++++++++------------------
 2 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/protocol/tablet-shell.xml b/protocol/tablet-shell.xml
index 40188ec..8c3a1e2 100644
--- a/protocol/tablet-shell.xml
+++ b/protocol/tablet-shell.xml
@@ -33,6 +33,7 @@
     <request name="activate"/>
 
     <event name="set_fullscreen"/>
+    <event name="go_sleep"/>
   </interface>
 
 </protocol>
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 7ab37a6..906a6aa 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -49,6 +49,7 @@ struct client_task {
 	struct wl_client *client;
 	struct wl_list shsurf_list;
 	struct wl_list link;
+	struct wl_resource *resource;
 };
 
 struct task_manager {
@@ -58,7 +59,7 @@ struct task_manager {
 
 struct tablet_shell {
 	struct wl_resource resource;
-	struct wl_resource client_resource;
+	struct wl_resource *client_resource;
 
 	struct wl_listener unlock_listener;
 	struct wl_listener destroy_listener;
@@ -178,10 +179,9 @@ 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->client_task->resource->client) {
+		wl_resource_destroy(shsurf->client_task->resource);
+		shsurf->client_task->resource->client = NULL;
 	}
 	if (shsurf->resource.client) {
 		wl_resource_destroy(&shsurf->resource);
@@ -242,10 +242,9 @@ 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->client_task->resource->client) {
+		wl_resource_destroy(shsurf->client_task->resource);
+		shsurf->client_task->resource->client = NULL;
 	}
 	if (shsurf->resource.client) {
 		wl_resource_destroy(&shsurf->resource);
@@ -371,11 +370,16 @@ shell_surface_create_client(struct shell_surface *shsurf,
 			    struct wl_client *client)
 {
 	struct client_task *task;
+	struct tablet_shell *shell = shsurf->shell;
 	task = calloc(1, sizeof *task);
 	task->client = client;
 	wl_list_init(&task->link);
 	wl_list_init(&task->shsurf_list);
 	shsurf->client_task = task;
+	if (shell->client_resource != NULL) {
+		shsurf->client_task->resource = shell->client_resource;
+		shell->client_resource = NULL;
+	}
 }
 
 static void
@@ -635,9 +639,9 @@ shell_surface_configure(struct weston_surface *surface,
 				 link)
 			weston_surface_activate(surface, seat);
 		weston_compositor_schedule_repaint(surface->compositor);
-		if (shell->client_resource.client) {
+		if (shsurf->client_task->resource->client) {
 			tablet_client_send_set_fullscreen(
-					&shell->client_resource);
+					shsurf->client_task->resource);
 		}
 	}
 	if (sx != 0 || sy != 0 ||
@@ -1063,6 +1067,7 @@ hang_client(struct tablet_shell *shell, int home)
 	}
 	wl_list_insert(shell->task_manager.task_list.prev,
 		       &task->link);
+	tablet_client_send_go_sleep(task->resource);
 }
 
 static void
@@ -1118,15 +1123,16 @@ 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 =
+	shell->client_resource = calloc(1, sizeof *(shell->client_resource));
+	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;
+	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);
+	wl_client_add_resource(client, shell->client_resource);
 }
 
 static void
-- 
1.7.12.1



More information about the wayland-devel mailing list