Skip to content
Snippets Groups Projects
Commit f7b9c926 authored by Marius Vlad's avatar Marius Vlad
Browse files

kiosk-shell: Embed keyboard focus activation code


Just like desktop-shell, we shouldn't be dependent on having a keyboard
to be present in order to activate a window/surface.

Signed-off-by: default avatarMarius Vlad <marius.vlad@collabora.com>
parent 77d882d7
No related branches found
No related tags found
Loading
This commit is part of merge request !570. Comments created here will be created in the context of that merge request.
......@@ -94,6 +94,20 @@ transform_handler(struct wl_listener *listener, void *data)
api->send_position(surface, x, y);
}
static void
kiosk_shell_surface_deactivate(struct kiosk_shell_surface *shsurf)
{
if (--shsurf->focus_count == 0)
weston_desktop_surface_set_activated(shsurf->desktop_surface, false);
}
static void
kiosk_shell_surface_activate(struct kiosk_shell_surface *shsurf)
{
if (shsurf->focus_count++ == 0)
weston_desktop_surface_set_activated(shsurf->desktop_surface, true);
}
/*
* kiosk_shell_surface
*/
......@@ -350,26 +364,8 @@ kiosk_shell_surface_create(struct kiosk_shell *shell,
static void
kiosk_shell_seat_handle_keyboard_focus(struct wl_listener *listener, void *data)
{
struct weston_keyboard *keyboard = data;
struct kiosk_shell_seat *shseat = get_kiosk_shell_seat(keyboard->seat);
if (shseat->focused_surface) {
struct kiosk_shell_surface *shsurf =
get_kiosk_shell_surface(shseat->focused_surface);
if (shsurf && --shsurf->focus_count == 0)
weston_desktop_surface_set_activated(shsurf->desktop_surface,
false);
}
shseat->focused_surface = weston_surface_get_main_surface(keyboard->focus);
if (shseat->focused_surface) {
struct kiosk_shell_surface *shsurf =
get_kiosk_shell_surface(shseat->focused_surface);
if (shsurf && shsurf->focus_count++ == 0)
weston_desktop_surface_set_activated(shsurf->desktop_surface,
true);
}
/* kept for future usage, handle_keyboard_focus() is trigged from
* weston_keyboard_set_focus() */
}
static void
......@@ -662,9 +658,18 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
if (focus_view) {
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
struct kiosk_shell_seat *kiosk_seat =
get_kiosk_shell_seat(seat);
struct weston_keyboard *keyboard = seat->keyboard_state;
struct kiosk_shell_surface *focus_shsurf =
get_kiosk_shell_surface(focus_view->surface);
if (keyboard && keyboard->focus == surface)
weston_view_activate(focus_view, seat, 0);
kiosk_shell_surface_deactivate(shsurf);
  • Owner

    Should this be here? It seems like we should unconditionally deactivate the view, even if we don't have a successor.

  • Marius Vlad @mvlad

    changed this line in version 5 of the diff

    ·

    changed this line in version 5 of the diff

    Toggle commit list
  • Author Maintainer

    Moved outside of the check.

  • Please register or sign in to reply
kiosk_seat->focused_surface = focus_view->surface;
kiosk_shell_surface_activate(focus_shsurf);
}
}
......@@ -718,8 +723,26 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
shsurf->view->is_mapped = true;
surface->is_mapped = true;
wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link)
wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
struct kiosk_shell_seat *kiosk_seat = get_kiosk_shell_seat(seat);
weston_view_activate(shsurf->view, seat, 0);
if (kiosk_seat->focused_surface) {
struct kiosk_shell_surface *current_focus =
get_kiosk_shell_surface(kiosk_seat->focused_surface);
if (current_focus)
kiosk_shell_surface_deactivate(current_focus);
}
kiosk_seat->focused_surface = surface;
if (kiosk_seat->focused_surface) {
if (shsurf)
kiosk_shell_surface_activate(shsurf);
}
}
}
if (!is_fullscreen && (sx != 0 || sy != 0)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment