From c4d12bf5d9500093edbca3f3fb42987d7b476434 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sat, 4 May 2024 23:10:45 +0200 Subject: [PATCH] xwayland: prevent shaded views from getting mouse events Fixes: #1753 --- include/view.h | 1 + src/view.c | 4 ++++ src/xwayland.c | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/include/view.h b/include/view.h index b688f104..5ab5d002 100644 --- a/include/view.h +++ b/include/view.h @@ -127,6 +127,7 @@ struct view_impl { void (*minimize)(struct view *view, bool minimize); void (*move_to_front)(struct view *view); void (*move_to_back)(struct view *view); + void (*shade)(struct view *view, bool shaded); struct view *(*get_root)(struct view *self); void (*append_children)(struct view *self, struct wl_array *children); struct view_size_hints (*get_size_hints)(struct view *self); diff --git a/src/view.c b/src/view.c index 19b5a33a..14052354 100644 --- a/src/view.c +++ b/src/view.c @@ -2207,6 +2207,10 @@ view_set_shade(struct view *view, bool shaded) view->shaded = shaded; ssd_enable_shade(view->ssd, view->shaded); wlr_scene_node_set_enabled(view->scene_node, !view->shaded); + + if (view->impl->shade) { + view->impl->shade(view, shaded); + } } void diff --git a/src/xwayland.c b/src/xwayland.c index 3a936456..d59e0fb7 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -744,6 +744,15 @@ static void xwayland_view_move_to_front(struct view *view) { view_impl_move_to_front(view); + + if (view->shaded) { + /* + * Ensure that we don't raise a shaded window + * to the front which then steals mouse events. + */ + return; + } + /* * Update XWayland stacking order. * @@ -754,6 +763,7 @@ xwayland_view_move_to_front(struct view *view) */ wlr_xwayland_surface_restack(xwayland_surface_from_view(view), NULL, XCB_STACK_MODE_ABOVE); + /* Restack unmanaged surfaces on top */ struct wl_list *list = &view->server->unmanaged_surfaces; struct xwayland_unmanaged *u; @@ -851,6 +861,20 @@ xwayland_view_get_pid(struct view *view) return xwayland_surface->pid; } +static void +xwayland_view_shade(struct view *view, bool shaded) +{ + assert(view); + + /* Ensure that clicks on some xwayland surface don't end up on the shaded one */ + if (shaded) { + wlr_xwayland_surface_restack(xwayland_surface_from_view(view), + NULL, XCB_STACK_MODE_BELOW); + } else { + xwayland_adjust_stacking_order(view->server); + } +} + static const struct view_impl xwayland_view_impl = { .configure = xwayland_view_configure, .close = xwayland_view_close, @@ -863,6 +887,7 @@ static const struct view_impl xwayland_view_impl = { .minimize = xwayland_view_minimize, .move_to_front = xwayland_view_move_to_front, .move_to_back = xwayland_view_move_to_back, + .shade = xwayland_view_shade, .get_root = xwayland_view_get_root, .append_children = xwayland_view_append_children, .get_size_hints = xwayland_view_get_size_hints,