From 4c100ca1d7a0afc299c2a26f44debc28ed74e8c2 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Wed, 22 May 2024 13:47:00 +0300 Subject: [PATCH] desktop-shell: Add session listener And use it to perform keyboard activation on the currently focused window. Similar to what kiosk-shell does, with the note that we go over all seats in the system rather than picking the first one available. Signed-off-by: Marius Vlad --- desktop-shell/shell.c | 34 ++++++++++++++++++++++++++++++++++ desktop-shell/shell.h | 1 + 2 files changed, 35 insertions(+) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 32fae2e1..8aca5597 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -4778,6 +4778,7 @@ shell_destroy(struct wl_listener *listener, void *data) wl_list_remove(&shell->output_create_listener.link); wl_list_remove(&shell->output_move_listener.link); wl_list_remove(&shell->resized_listener.link); + wl_list_remove(&shell->session_listener.link); wl_list_for_each_safe(shseat, shseat_next, &shell->seat_list, link) desktop_shell_destroy_seat(shseat); @@ -4872,6 +4873,37 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell) weston_install_debug_key_binding(ec, mod); } +static void +desktop_shell_notify_session(struct wl_listener *listener, void *data) +{ + struct desktop_shell *shell = + container_of(listener, struct desktop_shell, session_listener); + struct weston_compositor *compositor = data; + struct weston_seat *seat; + + if (!compositor->session_active) + return; + + wl_list_for_each(seat, &shell->seat_list, link) { + struct shell_seat *shseat = get_shell_seat(seat); + + if (!shseat) + continue; + + if (shseat->focused_surface) { + struct shell_surface *current_focus = + get_shell_surface(shseat->focused_surface); + + if (!current_focus) + continue; + + weston_view_activate_input(current_focus->view, + shseat->seat, + WESTON_ACTIVATE_FLAG_NONE); + } + } +} + static void handle_seat_created(struct wl_listener *listener, void *data) { @@ -4972,6 +5004,8 @@ wet_shell_init(struct weston_compositor *ec, shell->resized_listener.notify = handle_output_resized; wl_signal_add(&ec->output_resized_signal, &shell->resized_listener); + shell->session_listener.notify = desktop_shell_notify_session; + wl_signal_add(&ec->session_signal, &shell->session_listener); screenshooter_create(ec); shell_add_bindings(ec, shell); diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h index debb3652..fc34eb45 100644 --- a/desktop-shell/shell.h +++ b/desktop-shell/shell.h @@ -90,6 +90,7 @@ struct desktop_shell { struct wl_listener show_input_panel_listener; struct wl_listener hide_input_panel_listener; struct wl_listener update_input_panel_listener; + struct wl_listener session_listener; struct weston_layer fullscreen_layer; struct weston_layer panel_layer;