layersurface: create a dedicated scene tree for popups

this tree should be always above the top layer

Fixes: https://github.com/djpohly/dwl/issues/328
This commit is contained in:
Leonardo Hernández Hernández 2022-10-31 20:42:17 -06:00
parent 3cc22de712
commit 8bd3442575
No known key found for this signature in database
GPG key ID: E538897EE11B9624

19
dwl.c
View file

@ -152,6 +152,7 @@ typedef struct {
struct wlr_box geom;
Monitor *mon;
struct wlr_scene_node *scene;
struct wlr_scene_node *popups;
struct wl_list link;
int mapped;
struct wlr_layer_surface_v1 *layer_surface;
@ -583,6 +584,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int
state->margin.top, state->margin.right,
state->margin.bottom, state->margin.left);
wlr_scene_node_set_position(layersurface->scene, box.x, box.y);
wlr_scene_node_set_position(layersurface->popups, box.x, box.y);
wlr_layer_surface_v1_configure(wlr_layer_surface, box.width, box.height);
}
}
@ -823,10 +825,14 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
if (layers[wlr_layer_surface->current.layer] != layersurface->scene->parent) {
wlr_scene_node_reparent(layersurface->scene,
layers[wlr_layer_surface->current.layer]);
wlr_scene_node_reparent(layersurface->popups,
layers[wlr_layer_surface->current.layer]);
wl_list_remove(&layersurface->link);
wl_list_insert(&layersurface->mon->layers[wlr_layer_surface->current.layer],
&layersurface->link);
}
if (wlr_layer_surface->current.layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
wlr_scene_node_reparent(layersurface->popups, layers[LyrTop]);
if (wlr_layer_surface->current.committed == 0
&& layersurface->mapped == wlr_layer_surface->mapped)
@ -920,10 +926,11 @@ createlayersurface(struct wl_listener *listener, void *data)
layersurface->mon = wlr_layer_surface->output->data;
wlr_layer_surface->data = layersurface;
layersurface->scene = wlr_layer_surface->surface->data =
wlr_scene_subsurface_tree_create(layers[wlr_layer_surface->pending.layer],
wlr_layer_surface->surface);
layersurface->scene = wlr_scene_subsurface_tree_create(
layers[wlr_layer_surface->pending.layer], wlr_layer_surface->surface);
layersurface->scene->data = layersurface;
layersurface->popups = wlr_layer_surface->surface->data =
&wlr_scene_tree_create(layers[wlr_layer_surface->pending.layer])->node;
wl_list_insert(&layersurface->mon->layers[wlr_layer_surface->pending.layer],
&layersurface->link);
@ -1011,12 +1018,6 @@ createnotify(struct wl_listener *listener, void *data)
LayerSurface *l = toplevel_from_popup(xdg_surface->popup);
xdg_surface->surface->data = wlr_scene_xdg_surface_create(
xdg_surface->popup->parent->data, xdg_surface);
/* Raise to top layer if the inmediate parent of the popup is on
* bottom/background layer, which will cause popups appear below the
* x{dg,wayland} clients */
if (wlr_surface_is_layer_surface(xdg_surface->popup->parent) && l
&& l->layer_surface->current.layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
wlr_scene_node_reparent(xdg_surface->surface->data, layers[LyrTop]);
/* Probably the check of `l` is useless, the only thing that can be NULL
* is its monitor */
if (!l || !l->mon)