scene: add knob to turn off Xwayland surface restacking

This is useful in these cases:

- The same surface is added to two different scene-graphs. wlroots
  can't figure out on its own which scene-graph should drive the
  Xwayland stacking.
- A compositor uses multiple Xwayland servers (e.g. one per app).
  wlroots will try to restack surfaces from different Xwayland
  instances and this will not go well.
This commit is contained in:
Simon Ser 2025-07-08 15:00:57 +02:00 committed by Isaac Freund
parent b094f8aeb3
commit 2c64b30a67
2 changed files with 12 additions and 2 deletions

View file

@ -105,6 +105,8 @@ struct wlr_scene {
struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
struct wlr_color_manager_v1 *color_manager_v1;
bool restack_xwayland_surfaces;
struct {
struct wl_listener linux_dmabuf_v1_destroy;
struct wl_listener gamma_control_manager_v1_destroy;

View file

@ -185,6 +185,8 @@ struct wlr_scene *wlr_scene_create(void) {
wl_list_init(&scene->gamma_control_manager_v1_destroy.link);
wl_list_init(&scene->gamma_control_manager_v1_set_gamma.link);
scene->restack_xwayland_surfaces = true;
const char *debug_damage_options[] = {
"none",
"rerender",
@ -293,6 +295,7 @@ struct scene_update_data {
struct wlr_box update_box;
struct wl_list *outputs;
bool calculate_visibility;
bool restack_xwayland_surfaces;
#if WLR_HAS_XWAYLAND
struct wlr_xwayland_surface *restack_above;
@ -609,7 +612,9 @@ static bool scene_node_update_iterator(struct wlr_scene_node *node,
update_node_update_outputs(node, data->outputs, NULL, NULL);
#if WLR_HAS_XWAYLAND
restack_xwayland_surface(node, &box, data);
if (data->restack_xwayland_surfaces) {
restack_xwayland_surface(node, &box, data);
}
#endif
return false;
@ -671,6 +676,7 @@ static void scene_update_region(struct wlr_scene *scene,
},
.outputs = &scene->outputs,
.calculate_visibility = scene->calculate_visibility,
.restack_xwayland_surfaces = scene->restack_xwayland_surfaces,
};
// update node visibility and output enter/leave events
@ -686,7 +692,9 @@ static void scene_node_update(struct wlr_scene_node *node,
int x, y;
if (!wlr_scene_node_coords(node, &x, &y)) {
#if WLR_HAS_XWAYLAND
restack_xwayland_surface_below(node);
if (scene->restack_xwayland_surfaces) {
restack_xwayland_surface_below(node);
}
#endif
if (damage) {
scene_update_region(scene, damage);