[weston,04/17] desktop-shell: Add unset_keyboard_focus_for_surface helper

Submitted by Jonas Ådahl on Dec. 2, 2014, 1:49 p.m.

Details

Message ID 1417528165-9319-5-git-send-email-jadahl@gmail.com
State Superseded
Delegated to: Daniel Stone
Headers show

Not browsing as part of any series.

Commit Message

Jonas Ådahl Dec. 2, 2014, 1:49 p.m.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
---
 desktop-shell/shell.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

Patch hide | download patch | download mbox

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index b03dbaf..2e416e9 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1356,14 +1356,28 @@  workspace_has_only(struct workspace *ws, struct weston_surface *surface)
 }
 
 static void
+unset_keyboard_focus_for_surface(struct weston_surface *surface)
+{
+	struct weston_compositor *compositor = surface->compositor;
+	struct weston_seat *seat;
+	struct weston_surface *focus;
+
+	wl_list_for_each(seat, &compositor->seat_list, link) {
+		if (!seat->keyboard)
+			continue;
+		focus = weston_surface_get_main_surface(seat->keyboard->focus);
+		if (focus == surface)
+			weston_keyboard_set_focus(seat->keyboard, NULL);
+	}
+}
+
+static void
 move_surface_to_workspace(struct desktop_shell *shell,
                           struct shell_surface *shsurf,
                           uint32_t workspace)
 {
 	struct workspace *from;
 	struct workspace *to;
-	struct weston_seat *seat;
-	struct weston_surface *focus;
 	struct weston_view *view;
 
 	if (workspace == shell->workspaces.current)
@@ -1387,14 +1401,7 @@  move_surface_to_workspace(struct desktop_shell *shell,
 	shell_surface_update_child_surface_layers(shsurf);
 
 	drop_focus_state(shell, from, view->surface);
-	wl_list_for_each(seat, &shell->compositor->seat_list, link) {
-		if (!seat->keyboard)
-			continue;
-
-		focus = weston_surface_get_main_surface(seat->keyboard->focus);
-		if (focus == view->surface)
-			weston_keyboard_set_focus(seat->keyboard, NULL);
-	}
+	unset_keyboard_focus_for_surface(view->surface);
 
 	weston_view_damage_below(view);
 }
@@ -2610,7 +2617,6 @@  set_minimized(struct weston_surface *surface, uint32_t is_true)
 	struct shell_surface *shsurf;
 	struct workspace *current_ws;
 	struct weston_seat *seat;
-	struct weston_surface *focus;
 	struct weston_view *view;
 
 	view = get_default_view(surface);
@@ -2628,13 +2634,7 @@  set_minimized(struct weston_surface *surface, uint32_t is_true)
 		weston_layer_entry_insert(&shsurf->shell->minimized_layer.view_list, &view->layer_link);
 
 		drop_focus_state(shsurf->shell, current_ws, view->surface);
-		wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
-			if (!seat->keyboard)
-				continue;
-			focus = weston_surface_get_main_surface(seat->keyboard->focus);
-			if (focus == view->surface)
-				weston_keyboard_set_focus(seat->keyboard, NULL);
-		}
+		unset_keyboard_focus_for_surface(view->surface);
 	}
 	else {
 		weston_layer_entry_insert(&current_ws->layer.view_list, &view->layer_link);