xwayland: prevent shaded views from getting mouse events

Fixes: #1753
This commit is contained in:
Consolatis 2024-05-04 23:10:45 +02:00 committed by Johan Malm
parent 95dc4ac4b5
commit c4d12bf5d9
3 changed files with 30 additions and 0 deletions

View file

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

View file

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

View file

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