From e377822c64151c8ba1fcfb2e3ccdd62768fcd1d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 31 Jul 2012 17:29:30 -0400 Subject: [PATCH] shell: Give keyboard focus to top surface when current keyboard focus goes away --- src/shell.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/shell.c b/src/shell.c index bfb2978..6821836 100644 --- a/src/shell.c +++ b/src/shell.c @@ -385,9 +385,25 @@ focus_state_surface_destroy(struct wl_listener *listener, void *data) struct focus_state *state = container_of(listener, struct focus_state, surface_destroy_listener); + struct desktop_shell *shell; + struct weston_surface *surface, *next; - wl_list_remove(&state->link); - focus_state_destroy(state); + next = NULL; + wl_list_for_each(surface, &state->ws->layer.surface_list, layer_link) { + if (surface == state->keyboard_focus) + continue; + + next = surface; + break; + } + + if (next) { + shell = state->seat->compositor->shell_interface.shell; + activate(shell, next, state->seat); + } else { + wl_list_remove(&state->link); + focus_state_destroy(state); + } } static struct focus_state * -- 2.7.4