[PATCH 14/19] tablet-shell: remove lock surface in tablet-shell.

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


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

It is no requirement to use lockscreen. So remove it totally but
remaining unlock listener to unlock from sleep status.
---
 clients/tablet-shell.c    | 94 -----------------------------------------------
 protocol/tablet-shell.xml |  5 ---
 src/tablet-shell.c        | 79 +++------------------------------------
 3 files changed, 6 insertions(+), 172 deletions(-)

diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index a19effa..7c579c4 100644
--- a/clients/tablet-shell.c
+++ b/clients/tablet-shell.c
@@ -41,7 +41,6 @@ struct tablet {
 	struct window *switcher;
 
 	struct homescreen *homescreen;
-	struct lockscreen *lockscreen;
 };
 
 struct homescreen {
@@ -51,11 +50,6 @@ struct homescreen {
 	struct input *input;
 };
 
-struct lockscreen {
-	struct window *window;
-	struct widget *widget;
-};
-
 /* container of launchers on background */
 struct layout {
 	struct widget *widget;
@@ -99,8 +93,6 @@ struct launcher {
 	struct wl_data_source *data_source;
 };
 
-static char *key_lockscreen_icon;
-static char *key_lockscreen_background;
 static char *key_homescreen_background;
 static char *key_launcher_icon;
 static char *key_launcher_path;
@@ -120,8 +112,6 @@ static cairo_surface_t *trash_surface = NULL;
 struct rectangle *trash_allocation = NULL;
 
 static const struct config_key shell_config_keys[] = {
-	{ "lockscreen-icon", CONFIG_KEY_STRING, &key_lockscreen_icon },
-	{ "lockscreen", CONFIG_KEY_STRING, &key_lockscreen_background },
 	{ "homescreen", CONFIG_KEY_STRING, &key_homescreen_background },
 	{ "trash-image", CONFIG_KEY_STRING, &key_trash_image },
 	{ "terminal", CONFIG_KEY_STRING, &key_terminal },
@@ -305,55 +295,6 @@ static const struct wl_data_source_listener data_source_listener = {
 	NULL,
 };
 
-static void
-lockscreen_draw(struct widget *widget, void *data)
-{
-	struct lockscreen *lockscreen = data;
-	cairo_surface_t *surface;
-	cairo_surface_t *icon;
-	struct rectangle allocation;
-	cairo_t *cr;
-	int width, height;
-
-	surface = window_get_surface(lockscreen->window);
-	cr = cairo_create(surface);
-
-	widget_get_allocation(widget, &allocation);
-	paint_background(cr, key_lockscreen_background, &allocation);
-
-	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-	icon = load_cairo_surface(key_lockscreen_icon);
-	if (icon) {
-		width = cairo_image_surface_get_width(icon);
-		height = cairo_image_surface_get_height(icon);
-		cairo_set_source_surface(cr, icon,
-			allocation.x + (allocation.width - width) / 2,
-			allocation.y + (allocation.height - height) / 2);
-	} else {
-		fprintf(stderr, "couldn't load lockscreen icon: %s\n",
-				 key_lockscreen_icon);
-		cairo_set_source_rgb(cr, 0.2, 0, 0);
-	}
-	cairo_paint(cr);
-	cairo_destroy(cr);
-	cairo_surface_destroy(icon);
-	cairo_surface_destroy(surface);
-}
-
-static void
-lockscreen_button_handler(struct widget *widget,
-			  struct input *input, uint32_t time,
-			  uint32_t button,
-			  enum wl_pointer_button_state state, void *data)
-{
-	struct lockscreen *lockscreen = data;
-
-	if (state == WL_POINTER_BUTTON_STATE_PRESSED && lockscreen->window) {
-		window_destroy(lockscreen->window);
-		lockscreen->window = NULL;
-	}
-}
-
 static cairo_surface_t *
 create_drag_cursor(struct launcher *launcher,
 		   int32_t x, int32_t y, double opacity)
@@ -638,40 +579,6 @@ static void trash_set_allocation(struct rectangle allocation)
 	}
 }
 
-static struct lockscreen *
-lockscreen_create(struct tablet *tablet)
-{
-	struct lockscreen *lockscreen;
-
-	lockscreen = malloc (sizeof *lockscreen);
-	memset(lockscreen, 0, sizeof *lockscreen);
-
-	lockscreen->window = window_create_custom(tablet->display);
-	lockscreen->widget =
-		window_add_widget(lockscreen->window, lockscreen);
-	window_set_user_data(lockscreen->window, lockscreen);
-	window_set_title(lockscreen->window, "lockscreen");
-	widget_set_redraw_handler(lockscreen->widget, lockscreen_draw);
-	widget_set_button_handler(lockscreen->widget,
-				  lockscreen_button_handler);
-
-	return lockscreen;
-}
-
-static void
-show_lockscreen(void *data, struct tablet_shell *tablet_shell)
-{
-	struct tablet *tablet = data;
-
-	tablet->lockscreen = lockscreen_create(tablet);
-	tablet_shell_set_lockscreen(tablet->tablet_shell,
-			window_get_wl_surface(tablet->lockscreen->window));
-
-	widget_schedule_resize(tablet->lockscreen->widget,
-			       tablet->allocation.width,
-			       tablet->allocation.height);
-}
-
 static void
 show_switcher(void *data, struct tablet_shell *tablet_shell)
 {
@@ -709,7 +616,6 @@ launch_terminal(void *data, struct tablet_shell *tablet_shell)
 }
 
 static const struct tablet_shell_listener tablet_shell_listener = {
-	show_lockscreen,
 	show_switcher,
 	hide_switcher,
 	launch_terminal
diff --git a/protocol/tablet-shell.xml b/protocol/tablet-shell.xml
index 24ca2fd..40188ec 100644
--- a/protocol/tablet-shell.xml
+++ b/protocol/tablet-shell.xml
@@ -1,10 +1,6 @@
 <protocol name="tablet">
 
   <interface name="tablet_shell" version="1">
-    <request name="set_lockscreen">
-      <arg name="surface" type="object" interface="wl_surface"/>
-    </request>
-
     <request name="set_switcher">
       <arg name="surface" type="object" interface="wl_surface"/>
     </request>
@@ -27,7 +23,6 @@
       <arg name="fd" type="fd"/>
     </request>
 
-    <event name="show_lockscreen"/>
     <event name="show_switcher"/>
     <event name="hide_switcher"/>
     <event name="launch_terminal"/>
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 0bd0120..27d0486 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -37,7 +37,6 @@
 
 enum {
 	STATE_STARTING,
-	STATE_LOCKED,
 	STATE_HOME,
 	STATE_SWITCHER,
 	STATE_TASK
@@ -47,7 +46,6 @@ struct tablet_shell {
 	struct wl_resource resource;
 	struct wl_resource client_resource;
 
-	struct wl_listener lock_listener;
 	struct wl_listener unlock_listener;
 	struct wl_listener destroy_listener;
 
@@ -57,10 +55,6 @@ struct tablet_shell {
 
 	struct weston_surface *surface;
 
-	struct weston_surface *lockscreen_surface;
-	struct wl_listener lockscreen_listener;
-	struct weston_layer lockscreen_layer;
-
 	struct weston_layer application_layer;
 
 	struct weston_surface *home_surface;
@@ -166,6 +160,7 @@ shell_handle_surface_destroy(struct wl_listener *listener, void *data)
 		destroy_shell_surface(shsurf);
 	}
 }
+
 static void
 shell_surface_pong(struct wl_client *client, struct wl_resource *resource,
 		uint32_t serial)
@@ -412,7 +407,7 @@ static void
 tablet_shell_set_state(struct tablet_shell *shell, int state)
 {
 	static const char *states[] = {
-		"STARTING", "LOCKED", "HOME", "SWITCHER", "TASK"
+		"STARTING", "HOME", "SWITCHER", "TASK"
 	};
 
 	weston_log("switching to state %s (from %s)\n",
@@ -436,10 +431,7 @@ tablet_shell_surface_configure(struct weston_surface *surface,
 
 	weston_surface_configure(surface, 0, 0, width, height);
 
-	if (surface == shell->lockscreen_surface) {
-			wl_list_insert(&shell->lockscreen_layer.surface_list,
-					&surface->layer_link);
-	} else if (surface == shell->switcher_surface) {
+	if (surface == shell->switcher_surface) {
 		/* */
 	} else if (surface == shell->home_surface) {
 		if (shell->state == STATE_STARTING) {
@@ -447,9 +439,7 @@ tablet_shell_surface_configure(struct weston_surface *surface,
 			wl_list_insert(&shell->homescreen_layer.surface_list,
 					&surface->layer_link);
 
-			tablet_shell_set_state(shell, STATE_LOCKED);
-			shell->previous_state = STATE_HOME;
-			tablet_shell_send_show_lockscreen(&shell->resource);
+			shell->state = STATE_HOME;
 		}
 	} else if (shell->current_client &&
 		   shell->current_client->surface != surface &&
@@ -465,33 +455,6 @@ tablet_shell_surface_configure(struct weston_surface *surface,
 }
 
 static void
-handle_lockscreen_surface_destroy(struct wl_listener *listener, void *data)
-{
-	struct tablet_shell *shell =
-		container_of(listener,
-			     struct tablet_shell, lockscreen_listener);
-
-	shell->lockscreen_surface = NULL;
-	tablet_shell_set_state(shell, shell->previous_state);
-}
-
-static void
-tablet_shell_set_lockscreen(struct wl_client *client,
-			    struct wl_resource *resource,
-			    struct wl_resource *surface_resource)
-{
-	struct tablet_shell *shell = resource->data;
-	struct weston_surface *es = surface_resource->data;
-
-	weston_surface_set_position(es, 0, 0);
-	shell->lockscreen_surface = es;
-	shell->lockscreen_surface->configure = tablet_shell_surface_configure;
-	shell->lockscreen_listener.notify = handle_lockscreen_surface_destroy;
-	wl_signal_add(&es->surface.resource.destroy_signal,
-		      &shell->lockscreen_listener);
-}
-
-static void
 center_on_output(struct weston_surface *surface, struct weston_output *output)
 {
 	struct weston_mode *mode = output->current;
@@ -625,8 +588,7 @@ handle_switcher_surface_destroy(struct wl_listener *listener, void *data)
 			     struct tablet_shell, switcher_listener);
 
 	shell->switcher_surface = NULL;
-	if (shell->state != STATE_LOCKED)
-		tablet_shell_set_state(shell, shell->previous_state);
+	tablet_shell_set_state(shell, shell->previous_state);
 }
 
 static void
@@ -795,7 +757,6 @@ tablet_shell_create_client(struct wl_client *client,
 }
 
 static const struct tablet_shell_interface tablet_shell_implementation = {
-	tablet_shell_set_lockscreen,
 	tablet_shell_set_switcher,
 	tablet_shell_set_homescreen,
 	tablet_shell_show_grid,
@@ -828,25 +789,10 @@ toggle_switcher(struct tablet_shell *shell)
 }
 
 static void
-tablet_shell_lock(struct wl_listener *listener, void *data)
-{
-	struct tablet_shell *shell =
-		container_of(listener, struct tablet_shell, lock_listener);
-
-	if (shell->state == STATE_LOCKED)
-		return;
-	if (shell->state == STATE_SWITCHER)
-		tablet_shell_send_hide_switcher(&shell->resource);
-
-	tablet_shell_send_show_lockscreen(&shell->resource);
-	tablet_shell_set_state(shell, STATE_LOCKED);
-}
-
-static void
 tablet_shell_unlock(struct wl_listener *listener, void *data)
 {
 	struct tablet_shell *shell =
-		container_of(listener, struct tablet_shell, lock_listener);
+		container_of(listener, struct tablet_shell, unlock_listener);
 
 	weston_compositor_wake(shell->compositor);
 }
@@ -878,9 +824,6 @@ menu_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data)
 {
 	struct tablet_shell *shell = data;
 
-	if (shell->state == STATE_LOCKED)
-		return;
-
 	toggle_switcher(shell);
 }
 
@@ -889,9 +832,6 @@ home_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data)
 {
 	struct tablet_shell *shell = data;
 
-	if (shell->state == STATE_LOCKED)
-		return;
-
 	if (1) {
 		wl_event_source_timer_update(shell->long_press_source, 500);
 		shell->long_press_active = 1;
@@ -1037,9 +977,6 @@ tablet_shell_destroy(struct wl_listener *listener, void *data)
 	if (shell->home_surface)
 		shell->home_surface->configure = NULL;
 
-	if (shell->lockscreen_surface)
-		shell->lockscreen_surface->configure = NULL;
-
 	wl_event_source_remove(shell->long_press_source);
 	free(shell);
 }
@@ -1059,8 +996,6 @@ module_init(struct weston_compositor *compositor)
 
 	shell->destroy_listener.notify = tablet_shell_destroy;
 	wl_signal_add(&compositor->destroy_signal, &shell->destroy_listener);
-	shell->lock_listener.notify = tablet_shell_lock;
-	wl_signal_add(&compositor->lock_signal, &shell->lock_listener);
 	shell->unlock_listener.notify = tablet_shell_unlock;
 	wl_signal_add(&compositor->unlock_signal, &shell->unlock_listener);
 
@@ -1107,8 +1042,6 @@ module_init(struct weston_compositor *compositor)
 			  &compositor->cursor_layer.link);
 	weston_layer_init(&shell->application_layer,
 			  &compositor->cursor_layer.link);
-	weston_layer_init(&shell->lockscreen_layer,
-			  &compositor->cursor_layer.link);
 	launch_ux_daemon(shell);
 
 	tablet_shell_set_state(shell, STATE_STARTING);
-- 
1.7.12.1



More information about the wayland-devel mailing list