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 <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2024-05-22 13:47:00 +03:00 committed by Marius Vlad
parent 5b2f010c03
commit 4c100ca1d7
2 changed files with 35 additions and 0 deletions

View File

@ -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);

View File

@ -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;