From bf3e2001696cde5969d3acf90eb564dc180b2140 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Wed, 24 Mar 2021 12:47:07 +0200 Subject: [PATCH] kiosk-shell: Add transform_handler to correctly position xwayland surfaces When using xwayland surfaces and multiple outputs we need to notify xwayland surface that the surface position has changed, otherwise we're going to end up with pop-ups being displayed on other outputs rather than the one were the main surface resides. Stolen from desktop-shell. Signed-off-by: Marius Vlad Suggested-by: Alexandros Frantzis --- kiosk-shell/kiosk-shell.c | 35 +++++++++++++++++++++++++++++++++++ kiosk-shell/kiosk-shell.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index c2868706..d08167e2 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -35,6 +35,8 @@ #include "shared/helpers.h" #include "util.h" +#include + static struct kiosk_shell_surface * get_kiosk_shell_surface(struct weston_surface *surface) { @@ -63,6 +65,35 @@ get_kiosk_shell_seat(struct weston_seat *seat) struct kiosk_shell_seat, seat_destroy_listener); } +static void +transform_handler(struct wl_listener *listener, void *data) +{ + struct weston_surface *surface = data; + struct kiosk_shell_surface *shsurf = get_kiosk_shell_surface(surface); + const struct weston_xwayland_surface_api *api; + int x, y; + + if (!shsurf) + return; + + api = shsurf->shell->xwayland_surface_api; + if (!api) { + api = weston_xwayland_surface_get_api(shsurf->shell->compositor); + shsurf->shell->xwayland_surface_api = api; + } + + if (!api || !api->is_xwayland_surface(surface)) + return; + + if (!weston_view_is_mapped(shsurf->view)) + return; + + x = shsurf->view->geometry.x; + y = shsurf->view->geometry.y; + + api->send_position(surface, x, y); +} + /* * kiosk_shell_surface */ @@ -1015,6 +1046,7 @@ kiosk_shell_destroy(struct wl_listener *listener, void *data) wl_list_remove(&shell->output_resized_listener.link); wl_list_remove(&shell->output_moved_listener.link); wl_list_remove(&shell->seat_created_listener.link); + wl_list_remove(&shell->transform_listener.link); wl_list_for_each_safe(shoutput, tmp, &shell->output_list, link) { kiosk_shell_output_destroy(shoutput); @@ -1050,6 +1082,9 @@ wet_shell_init(struct weston_compositor *ec, return 0; } + shell->transform_listener.notify = transform_handler; + wl_signal_add(&ec->transform_signal, &shell->transform_listener); + weston_layer_init(&shell->background_layer, ec); weston_layer_init(&shell->normal_layer, ec); diff --git a/kiosk-shell/kiosk-shell.h b/kiosk-shell/kiosk-shell.h index 2018fcb2..79c85f4f 100644 --- a/kiosk-shell/kiosk-shell.h +++ b/kiosk-shell/kiosk-shell.h @@ -36,12 +36,15 @@ struct kiosk_shell { struct wl_listener output_resized_listener; struct wl_listener output_moved_listener; struct wl_listener seat_created_listener; + struct wl_listener transform_listener; struct weston_layer background_layer; struct weston_layer normal_layer; struct wl_list output_list; struct wl_list seat_list; + + const struct weston_xwayland_surface_api *xwayland_surface_api; }; struct kiosk_shell_surface {