mirror of
https://codeberg.org/dwl/dwl.git
synced 2024-12-27 03:36:31 +00:00
use l
instead of layersurface
`layer_surface` instead of `wlr_layer_surface` and `scene_layer` whenever a wlr_scene_tree is related to layer surfaces
This commit is contained in:
parent
b100b446b8
commit
2e4fdc1664
1 changed files with 68 additions and 78 deletions
146
dwl.c
146
dwl.c
|
@ -469,21 +469,20 @@ arrange(Monitor *m)
|
||||||
void
|
void
|
||||||
arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive)
|
arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive)
|
||||||
{
|
{
|
||||||
LayerSurface *layersurface;
|
LayerSurface *l;
|
||||||
struct wlr_box full_area = m->m;
|
struct wlr_box full_area = m->m;
|
||||||
|
|
||||||
wl_list_for_each(layersurface, list, link) {
|
wl_list_for_each(l, list, link) {
|
||||||
struct wlr_layer_surface_v1 *wlr_layer_surface = layersurface->layer_surface;
|
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
||||||
struct wlr_layer_surface_v1_state *state = &wlr_layer_surface->current;
|
struct wlr_layer_surface_v1_state *state = &layer_surface->current;
|
||||||
|
|
||||||
if (exclusive != (state->exclusive_zone > 0))
|
if (exclusive != (state->exclusive_zone > 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
wlr_scene_layer_surface_v1_configure(layersurface->scene_layer, &full_area, usable_area);
|
wlr_scene_layer_surface_v1_configure(l->scene_layer, &full_area, usable_area);
|
||||||
wlr_scene_node_set_position(&layersurface->popups->node,
|
wlr_scene_node_set_position(&l->popups->node, l->scene->node.x, l->scene->node.y);
|
||||||
layersurface->scene->node.x, layersurface->scene->node.y);
|
l->geom.x = l->scene->node.x;
|
||||||
layersurface->geom.x = layersurface->scene->node.x;
|
l->geom.y = l->scene->node.y;
|
||||||
layersurface->geom.y = layersurface->scene->node.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,11 +491,11 @@ arrangelayers(Monitor *m)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct wlr_box usable_area = m->m;
|
struct wlr_box usable_area = m->m;
|
||||||
|
LayerSurface *l;
|
||||||
uint32_t layers_above_shell[] = {
|
uint32_t layers_above_shell[] = {
|
||||||
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
|
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
|
||||||
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
|
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
|
||||||
};
|
};
|
||||||
LayerSurface *layersurface;
|
|
||||||
if (!m->wlr_output->enabled)
|
if (!m->wlr_output->enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -515,14 +514,12 @@ arrangelayers(Monitor *m)
|
||||||
|
|
||||||
/* Find topmost keyboard interactive layer, if such a layer exists */
|
/* Find topmost keyboard interactive layer, if such a layer exists */
|
||||||
for (i = 0; i < LENGTH(layers_above_shell); i++) {
|
for (i = 0; i < LENGTH(layers_above_shell); i++) {
|
||||||
wl_list_for_each_reverse(layersurface,
|
wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) {
|
||||||
&m->layers[layers_above_shell[i]], link) {
|
if (!locked && l->layer_surface->current.keyboard_interactive && l->mapped) {
|
||||||
if (!locked && layersurface->layer_surface->current.keyboard_interactive
|
|
||||||
&& layersurface->mapped) {
|
|
||||||
/* Deactivate the focused client. */
|
/* Deactivate the focused client. */
|
||||||
focusclient(NULL, 0);
|
focusclient(NULL, 0);
|
||||||
exclusive_focus = layersurface;
|
exclusive_focus = l;
|
||||||
client_notify_enter(layersurface->layer_surface->surface, wlr_seat_get_keyboard(seat));
|
client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -708,25 +705,24 @@ closemon(Monitor *m)
|
||||||
void
|
void
|
||||||
commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
LayerSurface *layersurface = wl_container_of(listener, layersurface, surface_commit);
|
LayerSurface *l = wl_container_of(listener, l, surface_commit);
|
||||||
struct wlr_layer_surface_v1 *wlr_layer_surface = layersurface->layer_surface;
|
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
||||||
struct wlr_scene_tree *layer = layers[layermap[wlr_layer_surface->current.layer]];
|
struct wlr_scene_tree *scene_layer = layers[layermap[layer_surface->current.layer]];
|
||||||
|
|
||||||
if (wlr_layer_surface->current.committed == 0
|
|
||||||
&& layersurface->mapped == wlr_layer_surface->surface->mapped)
|
if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped)
|
||||||
return;
|
return;
|
||||||
layersurface->mapped = wlr_layer_surface->surface->mapped;
|
l->mapped = layer_surface->surface->mapped;
|
||||||
|
|
||||||
if (layer != layersurface->scene->node.parent) {
|
if (scene_layer != l->scene->node.parent) {
|
||||||
wlr_scene_node_reparent(&layersurface->scene->node, layer);
|
wlr_scene_node_reparent(&l->scene->node, scene_layer);
|
||||||
wl_list_remove(&layersurface->link);
|
wl_list_remove(&l->link);
|
||||||
wl_list_insert(&layersurface->mon->layers[wlr_layer_surface->current.layer],
|
wl_list_insert(&l->mon->layers[layer_surface->current.layer], &l->link);
|
||||||
&layersurface->link);
|
wlr_scene_node_reparent(&l->popups->node, (layer_surface->current.layer
|
||||||
wlr_scene_node_reparent(&layersurface->popups->node, (wlr_layer_surface->current.layer
|
< ZWLR_LAYER_SHELL_V1_LAYER_TOP ? layers[LyrTop] : scene_layer));
|
||||||
< ZWLR_LAYER_SHELL_V1_LAYER_TOP ? layers[LyrTop] : layer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arrangelayers(layersurface->mon);
|
arrangelayers(l->mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -795,48 +791,44 @@ createkeyboard(struct wlr_keyboard *keyboard)
|
||||||
void
|
void
|
||||||
createlayersurface(struct wl_listener *listener, void *data)
|
createlayersurface(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct wlr_layer_surface_v1 *wlr_layer_surface = data;
|
struct wlr_layer_surface_v1 *layer_surface = data;
|
||||||
LayerSurface *layersurface;
|
LayerSurface *l;
|
||||||
|
struct wlr_surface *surface = layer_surface->surface;
|
||||||
|
struct wlr_scene_tree *scene_layer = layers[layermap[layer_surface->pending.layer]];
|
||||||
struct wlr_layer_surface_v1_state old_state;
|
struct wlr_layer_surface_v1_state old_state;
|
||||||
struct wlr_scene_tree *l = layers[layermap[wlr_layer_surface->pending.layer]];
|
|
||||||
|
|
||||||
if (!wlr_layer_surface->output
|
if (!layer_surface->output
|
||||||
&& !(wlr_layer_surface->output = selmon ? selmon->wlr_output : NULL)) {
|
&& !(layer_surface->output = selmon ? selmon->wlr_output : NULL)) {
|
||||||
wlr_layer_surface_v1_destroy(wlr_layer_surface);
|
wlr_layer_surface_v1_destroy(layer_surface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
layersurface = wlr_layer_surface->data = ecalloc(1, sizeof(*layersurface));
|
l = layer_surface->data = ecalloc(1, sizeof(*l));
|
||||||
layersurface->type = LayerShell;
|
l->type = LayerShell;
|
||||||
LISTEN(&wlr_layer_surface->surface->events.commit,
|
LISTEN(&surface->events.commit, &l->surface_commit, commitlayersurfacenotify);
|
||||||
&layersurface->surface_commit, commitlayersurfacenotify);
|
LISTEN(&surface->events.map, &l->map, maplayersurfacenotify);
|
||||||
LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy,
|
LISTEN(&surface->events.unmap, &l->unmap, unmaplayersurfacenotify);
|
||||||
destroylayersurfacenotify);
|
LISTEN(&layer_surface->events.destroy, &l->destroy, destroylayersurfacenotify);
|
||||||
LISTEN(&wlr_layer_surface->surface->events.map, &layersurface->map,
|
|
||||||
maplayersurfacenotify);
|
|
||||||
LISTEN(&wlr_layer_surface->surface->events.unmap, &layersurface->unmap,
|
|
||||||
unmaplayersurfacenotify);
|
|
||||||
|
|
||||||
layersurface->layer_surface = wlr_layer_surface;
|
l->layer_surface = layer_surface;
|
||||||
layersurface->mon = wlr_layer_surface->output->data;
|
l->mon = layer_surface->output->data;
|
||||||
layersurface->scene_layer = wlr_scene_layer_surface_v1_create(l, wlr_layer_surface);
|
l->scene_layer = wlr_scene_layer_surface_v1_create(scene_layer, layer_surface);
|
||||||
layersurface->scene = layersurface->scene_layer->tree;
|
l->scene = l->scene_layer->tree;
|
||||||
layersurface->popups = wlr_layer_surface->surface->data = wlr_scene_tree_create(l);
|
l->popups = surface->data = wlr_scene_tree_create(scene_layer);
|
||||||
|
l->scene->node.data = l;
|
||||||
|
|
||||||
layersurface->scene->node.data = layersurface;
|
|
||||||
|
|
||||||
wl_list_insert(&layersurface->mon->layers[wlr_layer_surface->pending.layer],
|
wl_list_insert(&l->mon->layers[layer_surface->pending.layer],&l->link);
|
||||||
&layersurface->link);
|
wlr_surface_send_enter(surface, layer_surface->output);
|
||||||
wlr_surface_send_enter(wlr_layer_surface->surface, wlr_layer_surface->output);
|
|
||||||
|
|
||||||
/* Temporarily set the layer's current state to pending
|
/* Temporarily set the layer's current state to pending
|
||||||
* so that we can easily arrange it
|
* so that we can easily arrange it
|
||||||
*/
|
*/
|
||||||
old_state = wlr_layer_surface->current;
|
old_state = layer_surface->current;
|
||||||
wlr_layer_surface->current = wlr_layer_surface->pending;
|
layer_surface->current = layer_surface->pending;
|
||||||
layersurface->mapped = 1;
|
l->mapped = 1;
|
||||||
arrangelayers(layersurface->mon);
|
arrangelayers(l->mon);
|
||||||
wlr_layer_surface->current = old_state;
|
layer_surface->current = old_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1054,16 +1046,16 @@ destroyidleinhibitor(struct wl_listener *listener, void *data)
|
||||||
void
|
void
|
||||||
destroylayersurfacenotify(struct wl_listener *listener, void *data)
|
destroylayersurfacenotify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
LayerSurface *layersurface = wl_container_of(listener, layersurface, destroy);
|
LayerSurface *l = wl_container_of(listener, l, destroy);
|
||||||
|
|
||||||
wl_list_remove(&layersurface->link);
|
wl_list_remove(&l->link);
|
||||||
wl_list_remove(&layersurface->destroy.link);
|
wl_list_remove(&l->destroy.link);
|
||||||
wl_list_remove(&layersurface->map.link);
|
wl_list_remove(&l->map.link);
|
||||||
wl_list_remove(&layersurface->unmap.link);
|
wl_list_remove(&l->unmap.link);
|
||||||
wl_list_remove(&layersurface->surface_commit.link);
|
wl_list_remove(&l->surface_commit.link);
|
||||||
wlr_scene_node_destroy(&layersurface->scene->node);
|
wlr_scene_node_destroy(&l->scene->node);
|
||||||
wlr_scene_node_destroy(&layersurface->popups->node);
|
wlr_scene_node_destroy(&l->popups->node);
|
||||||
free(layersurface);
|
free(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2490,17 +2482,15 @@ unlocksession(struct wl_listener *listener, void *data)
|
||||||
void
|
void
|
||||||
unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
LayerSurface *layersurface = wl_container_of(listener, layersurface, unmap);
|
LayerSurface *l = wl_container_of(listener, l, unmap);
|
||||||
|
|
||||||
layersurface->mapped = 0;
|
l->mapped = 0;
|
||||||
wlr_scene_node_set_enabled(&layersurface->scene->node, 0);
|
wlr_scene_node_set_enabled(&l->scene->node, 0);
|
||||||
if (layersurface == exclusive_focus)
|
if (l == exclusive_focus)
|
||||||
exclusive_focus = NULL;
|
exclusive_focus = NULL;
|
||||||
if (layersurface->layer_surface->output
|
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
||||||
&& (layersurface->mon = layersurface->layer_surface->output->data))
|
arrangelayers(l->mon);
|
||||||
arrangelayers(layersurface->mon);
|
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||||
if (layersurface->layer_surface->surface ==
|
|
||||||
seat->keyboard_state.focused_surface)
|
|
||||||
focusclient(focustop(selmon), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
motionnotify(0);
|
motionnotify(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue