[RFC PATCH 07/12] tablet-shell: add key binding for kill and activate surface

juan.j.zhao at linux.intel.com juan.j.zhao at linux.intel.com
Fri Aug 3 04:21:49 PDT 2012


From: Juan Zhao <juan.j.zhao at intel.com>

Signed-off-by: Juan Zhao <juan.j.zhao at linux.intel.com>
---
 clients/tablet-shell.c |  5 +++--
 src/tablet-shell.c     | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index 651aa67..37c0a48 100644
--- a/clients/tablet-shell.c
+++ b/clients/tablet-shell.c
@@ -106,7 +106,7 @@ static char *key_trash_image;
 /* launcher drag */
 struct launcher *gl_launcher_drag = NULL;
 /* launcher size */
-static int launcher_size = 146;
+static int launcher_size = 64;
 /* trash parameters */
 static cairo_surface_t *trash_surface = NULL;
 static int trash_x, trash_y;
@@ -177,7 +177,8 @@ paint_background(cairo_t *cr, const char *path, struct rectangle *allocation)
 }
 
 /*simple draw trash function*/
-static void homescreen_draw_trash(void *data, int x, int y){
+static void
+homescreen_draw_trash(void *data, int x, int y){
 	int w, h;
 	cairo_t *cr;
 	cairo_surface_t *surface;
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index b2db2b7..b4dfe55 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -847,6 +847,44 @@ home_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data)
 }
 
 static void
+terminate_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
+				  void *data)
+{
+	struct weston_compositor *compositor = data;
+			wl_display_terminate(compositor->wl_display);
+}
+
+static void
+click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
+			  void *data)
+{
+	struct weston_surface * focus;
+	focus = (struct weston_surface *) seat->pointer->focus;
+	weston_surface_activate(focus, seat);
+}
+
+	static void
+force_kill_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
+		void *data)
+{
+	struct wl_client *client;
+	pid_t pid;
+	uid_t uid;
+	gid_t gid;
+
+	client = seat->keyboard->focus->resource.client;
+	wl_client_get_credentials(client, &pid, &uid, &gid);
+
+	kill(pid, SIGKILL);
+<<<<<<< HEAD
+=======
+	tablet_shell_set_state(shell, STATE_HOME);
+	weston_surface_damage(shell->home_surface);
+	weston_compositor_schedule_repaint(shell->compositor);
+>>>>>>> 6bc1b22... update for repaint after kill an client
+}
+
+static void
 destroy_tablet_shell(struct wl_resource *resource)
 {
 }
@@ -957,6 +995,16 @@ shell_init(struct weston_compositor *compositor)
 	weston_compositor_add_key_binding(compositor, KEY_COMPOSE, 0,
 					  menu_key_binding, shell);
 
+	/* Use keyboard to simulate events */
+	weston_compositor_add_key_binding(compositor, KEY_BACKSPACE,
+					  MODIFIER_CTRL | MODIFIER_ALT,
+					  terminate_binding, compositor);
+	weston_compositor_add_button_binding(compositor, BTN_LEFT, 0,
+					     click_to_activate_binding,
+					     shell);
+	weston_compositor_add_key_binding(compositor, KEY_K, MODIFIER_ALT,
+					  force_kill_binding, shell);
+
 	weston_layer_init(&shell->homescreen_layer,
 			  &compositor->cursor_layer.link);
 	weston_layer_init(&shell->application_layer,
-- 
1.7.11



More information about the wayland-devel mailing list