diff options
-rw-r--r-- | include/wlr/types/wlr_layer_shell.h | 4 | ||||
-rw-r--r-- | rootston/output.c | 2 | ||||
-rw-r--r-- | types/wlr_layer_shell.c | 46 |
3 files changed, 52 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_layer_shell.h b/include/wlr/types/wlr_layer_shell.h index 4b3e4e1c..6040478d 100644 --- a/include/wlr/types/wlr_layer_shell.h +++ b/include/wlr/types/wlr_layer_shell.h @@ -109,4 +109,8 @@ bool wlr_surface_is_layer_surface(struct wlr_surface *surface); struct wlr_layer_surface *wlr_layer_surface_from_wlr_surface( struct wlr_surface *surface); +/* Calls the iterator function for each sub-surface and popup of this surface */ +void wlr_layer_surface_for_each_surface(struct wlr_layer_surface *surface, + wlr_surface_iterator_func_t iterator, void *user_data); + #endif diff --git a/rootston/output.c b/rootston/output.c index 791b2819..48b20466 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -366,6 +366,8 @@ static void render_layer(struct roots_output *output, roots_surface->geo.x + output_layout_box->x, roots_surface->geo.y + output_layout_box->y, 0, &data->layout, render_surface, data); + + wlr_layer_surface_for_each_surface(layer, render_surface, data); } } diff --git a/types/wlr_layer_shell.c b/types/wlr_layer_shell.c index 29e44827..9121b1d2 100644 --- a/types/wlr_layer_shell.c +++ b/types/wlr_layer_shell.c @@ -452,3 +452,49 @@ void wlr_layer_shell_destroy(struct wlr_layer_shell *layer_shell) { wl_global_destroy(layer_shell->wl_global); free(layer_shell); } + +struct layer_surface_iterator_data { + wlr_surface_iterator_func_t user_iterator; + void *user_data; + int x, y; +}; + +static void layer_surface_iterator(struct wlr_surface *surface, + int sx, int sy, void *data) { + struct layer_surface_iterator_data *iter_data = data; + iter_data->user_iterator(surface, iter_data->x + sx, iter_data->y + sy, + iter_data->user_data); +} + +static void layer_surface_for_each_surface(struct wlr_layer_surface *surface, + int x, int y, wlr_surface_iterator_func_t iterator, void *user_data) { + struct layer_surface_iterator_data data = { + .user_iterator = iterator, + .user_data = user_data, + .x = x, .y = y, + }; + wlr_surface_for_each_surface(surface->surface, + layer_surface_iterator, &data); + + struct wlr_xdg_popup *popup_state; + wl_list_for_each(popup_state, &surface->popups, link) { + struct wlr_xdg_surface *popup = popup_state->base; + if (!popup->configured) { + continue; + } + + double popup_sx, popup_sy; + popup_sx = popup->geometry.x; + popup_sy = popup->geometry.y; + + iterator(popup->surface, data.x + popup_sx, + data.y + popup_sy, user_data); + + wlr_xdg_surface_for_each_surface(popup, layer_surface_iterator, &data); + } +} + +void wlr_layer_surface_for_each_surface(struct wlr_layer_surface *surface, + wlr_surface_iterator_func_t iterator, void *user_data) { + layer_surface_for_each_surface(surface, 0, 0, iterator, user_data); +} |