From: Ning Tang <ning.t...@intel.com> Send kill signal to client in order to exit. After the client ends, the surface below it would get focus.
Signed-off-by: Ning Tang <tecto...@gmail.com> --- src/tablet-shell.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/tablet-shell.c b/src/tablet-shell.c index d7ce01f..695f7d3 100644 --- a/src/tablet-shell.c +++ b/src/tablet-shell.c @@ -924,6 +924,70 @@ 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; + struct shell_surface * shsurf; + focus = (struct weston_surface *) seat->pointer->focus; + + shsurf = get_shell_surface(focus); + + if (shsurf) + weston_surface_activate(shsurf->surface, seat); + +} + +static void +force_kill_binding(struct wl_seat *seat, uint32_t time, uint32_t key, + void *data) +{ + struct tablet_shell *shell = data; + struct wl_client *client; + struct weston_surface * focus; + struct shell_surface * shsurf; + pid_t pid; + uid_t uid; + gid_t gid; + int client_cnt; + + if (!seat->keyboard->focus) + return; + client = seat->keyboard->focus->resource.client; + shsurf = get_shell_surface(seat->keyboard->focus); + if (!shsurf) + return; + + wl_client_get_credentials(client, &pid, &uid, &gid); + client_cnt = wl_list_length(&shell->application_layer.surface_list); + if (client_cnt > 2) { + wl_list_for_each(focus, &shell->application_layer.surface_list, + layer_link) { + client_cnt--; + if (client_cnt < 2) { + weston_surface_activate(focus, seat); + break; + } + } + } + else + focus = NULL; + kill(pid, SIGKILL); + tablet_shell_set_state(shell, STATE_HOME); + if (focus == NULL) + weston_surface_activate(shell->home_surface, seat); + weston_compositor_schedule_repaint(shell->compositor); +} + +static void destroy_tablet_shell(struct wl_resource *resource) { } @@ -1031,6 +1095,15 @@ 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_ESC, 0, + force_kill_binding, shell); weston_layer_init(&shell->homescreen_layer, &compositor->cursor_layer.link); weston_layer_init(&shell->application_layer, -- 1.7.11.5 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel