desktop-shell: Add surface_keyboard_focus_lost helper
Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
+22
-25
@@ -1423,6 +1423,26 @@ workspace_has_only(struct workspace *ws, struct weston_surface *surface)
|
|||||||
return container_of(e, struct weston_view, layer_link.link)->surface == surface;
|
return container_of(e, struct weston_view, layer_link.link)->surface == surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
surface_keyboard_focus_lost(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) {
|
||||||
|
struct weston_keyboard *keyboard =
|
||||||
|
weston_seat_get_keyboard(seat);
|
||||||
|
|
||||||
|
if (!keyboard)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
focus = weston_surface_get_main_surface(keyboard->focus);
|
||||||
|
if (focus == surface)
|
||||||
|
weston_keyboard_set_focus(keyboard, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
move_surface_to_workspace(struct desktop_shell *shell,
|
move_surface_to_workspace(struct desktop_shell *shell,
|
||||||
struct shell_surface *shsurf,
|
struct shell_surface *shsurf,
|
||||||
@@ -1430,8 +1450,6 @@ move_surface_to_workspace(struct desktop_shell *shell,
|
|||||||
{
|
{
|
||||||
struct workspace *from;
|
struct workspace *from;
|
||||||
struct workspace *to;
|
struct workspace *to;
|
||||||
struct weston_seat *seat;
|
|
||||||
struct weston_surface *focus;
|
|
||||||
struct weston_view *view;
|
struct weston_view *view;
|
||||||
|
|
||||||
if (workspace == shell->workspaces.current)
|
if (workspace == shell->workspaces.current)
|
||||||
@@ -1455,17 +1473,7 @@ move_surface_to_workspace(struct desktop_shell *shell,
|
|||||||
shell_surface_update_child_surface_layers(shsurf);
|
shell_surface_update_child_surface_layers(shsurf);
|
||||||
|
|
||||||
drop_focus_state(shell, from, view->surface);
|
drop_focus_state(shell, from, view->surface);
|
||||||
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
|
surface_keyboard_focus_lost(view->surface);
|
||||||
struct weston_keyboard *keyboard =
|
|
||||||
weston_seat_get_keyboard(seat);
|
|
||||||
|
|
||||||
if (!keyboard)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
focus = weston_surface_get_main_surface(keyboard->focus);
|
|
||||||
if (focus == view->surface)
|
|
||||||
weston_keyboard_set_focus(keyboard, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
weston_view_damage_below(view);
|
weston_view_damage_below(view);
|
||||||
}
|
}
|
||||||
@@ -2705,8 +2713,6 @@ set_minimized(struct weston_surface *surface)
|
|||||||
{
|
{
|
||||||
struct shell_surface *shsurf;
|
struct shell_surface *shsurf;
|
||||||
struct workspace *current_ws;
|
struct workspace *current_ws;
|
||||||
struct weston_seat *seat;
|
|
||||||
struct weston_surface *focus;
|
|
||||||
struct weston_view *view;
|
struct weston_view *view;
|
||||||
|
|
||||||
view = get_default_view(surface);
|
view = get_default_view(surface);
|
||||||
@@ -2722,16 +2728,7 @@ set_minimized(struct weston_surface *surface)
|
|||||||
weston_layer_entry_insert(&shsurf->shell->minimized_layer.view_list, &view->layer_link);
|
weston_layer_entry_insert(&shsurf->shell->minimized_layer.view_list, &view->layer_link);
|
||||||
|
|
||||||
drop_focus_state(shsurf->shell, current_ws, view->surface);
|
drop_focus_state(shsurf->shell, current_ws, view->surface);
|
||||||
wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
|
surface_keyboard_focus_lost(surface);
|
||||||
struct weston_keyboard *keyboard =
|
|
||||||
weston_seat_get_keyboard(seat);
|
|
||||||
|
|
||||||
if (!keyboard)
|
|
||||||
continue;
|
|
||||||
focus = weston_surface_get_main_surface(keyboard->focus);
|
|
||||||
if (focus == view->surface)
|
|
||||||
weston_keyboard_set_focus(keyboard, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
shell_surface_update_child_surface_layers(shsurf);
|
shell_surface_update_child_surface_layers(shsurf);
|
||||||
weston_view_damage_below(view);
|
weston_view_damage_below(view);
|
||||||
|
|||||||
Reference in New Issue
Block a user