Skip to content
Snippets Groups Projects

kiosk-shell: Separate (keyboard) input focus from xdg-shell toplevel window activation

Merged Marius Vlad requested to merge mvlad/weston:fix-desktop-shell-top-level-activation into main
1 file
+ 44
21
Compare changes
  • Side-by-side
  • Inline
+ 44
21
@@ -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);
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)) {
Loading