summaryrefslogtreecommitdiff
path: root/kiosk-shell
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2021-03-24 12:47:07 +0200
committerMarius Vlad <marius.vlad@collabora.com>2021-04-04 18:45:33 +0300
commitbf3e2001696cde5969d3acf90eb564dc180b2140 (patch)
treea7305f9f9abbd7939e8a969141ff548ab9ec6b64 /kiosk-shell
parent15363291c113ddd51d953541716f4549f3c9d153 (diff)
downloadweston-bf3e2001696cde5969d3acf90eb564dc180b2140.tar.gz
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 <marius.vlad@collabora.com> Suggested-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Diffstat (limited to 'kiosk-shell')
-rw-r--r--kiosk-shell/kiosk-shell.c35
-rw-r--r--kiosk-shell/kiosk-shell.h3
2 files changed, 38 insertions, 0 deletions
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 <libweston/xwayland-api.h>
+
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 {