for_each_surface: only iterate mapped surfaces

These functions are used mostly for rendering, where including unmapped
surfaces is undesired.

This is a breaking change. However, few to no usages will have to be
updated.
master
tiosgz 3 years ago committed by Simon Ser
parent dc3d1530bf
commit 893434b2d4

@ -143,7 +143,10 @@ bool wlr_surface_is_layer_surface(struct wlr_surface *surface);
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_wlr_surface(
struct wlr_surface *surface);
/* Calls the iterator function for each sub-surface and popup of this surface */
/**
* Calls the iterator function for each mapped sub-surface and popup of this
* surface (whether or not this surface is mapped).
*/
void wlr_layer_surface_v1_for_each_surface(struct wlr_layer_surface_v1 *surface,
wlr_surface_iterator_func_t iterator, void *user_data);

@ -264,9 +264,9 @@ void wlr_surface_get_extends(struct wlr_surface *surface, struct wlr_box *box);
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource);
/**
* Call `iterator` on each surface in the surface tree, with the surface's
* position relative to the root surface. The function is called from root to
* leaves (in rendering order).
* Call `iterator` on each mapped surface in the surface tree (whether or not
* this surface is mapped), with the surface's position relative to the root
* surface. The function is called from root to leaves (in rendering order).
*/
void wlr_surface_for_each_surface(struct wlr_surface *surface,
wlr_surface_iterator_func_t iterator, void *user_data);

@ -413,17 +413,19 @@ void wlr_xdg_surface_get_geometry(struct wlr_xdg_surface *surface,
struct wlr_box *box);
/**
* Call `iterator` on each surface and popup in the xdg-surface tree, with the
* surface's position relative to the root xdg-surface. The function is called
* from root to leaves (in rendering order).
* Call `iterator` on each mapped surface and popup in the xdg-surface tree
* (whether or not this xdg-surface is mapped), with the surface's position
* relative to the root xdg-surface. The function is called from root to leaves
* (in rendering order).
*/
void wlr_xdg_surface_for_each_surface(struct wlr_xdg_surface *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Call `iterator` on each popup's surface and popup's subsurface in the
* xdg-surface tree, with the surfaces's position relative to the root
* xdg-surface. The function is called from root to leaves (in rendering order).
* Call `iterator` on each mapped popup's surface and popup's subsurface in the
* xdg-surface tree (whether or not this xdg-surface is mapped), with the
* surfaces's position relative to the root xdg-surface. The function is called
* from root to leaves (in rendering order).
*/
void wlr_xdg_surface_for_each_popup_surface(struct wlr_xdg_surface *surface,
wlr_surface_iterator_func_t iterator, void *user_data);

@ -506,7 +506,7 @@ void wlr_layer_surface_v1_for_each_popup_surface(struct wlr_layer_surface_v1 *su
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) {
if (!popup->configured || !popup->mapped) {
continue;
}

@ -1331,6 +1331,10 @@ static void surface_for_each_surface(struct wlr_surface *surface, int x, int y,
wlr_surface_iterator_func_t iterator, void *user_data) {
struct wlr_subsurface *subsurface;
wl_list_for_each(subsurface, &surface->current.subsurfaces_below, current.link) {
if (!subsurface->mapped) {
continue;
}
struct wlr_subsurface_parent_state *state = &subsurface->current;
int sx = state->x;
int sy = state->y;
@ -1342,6 +1346,10 @@ static void surface_for_each_surface(struct wlr_surface *surface, int x, int y,
iterator(surface, x, y, user_data);
wl_list_for_each(subsurface, &surface->current.subsurfaces_above, current.link) {
if (!subsurface->mapped) {
continue;
}
struct wlr_subsurface_parent_state *state = &subsurface->current;
int sx = state->x;
int sy = state->y;

@ -583,7 +583,7 @@ static void xdg_surface_for_each_popup_surface(struct wlr_xdg_surface *surface,
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) {
if (!popup->configured || !popup->mapped) {
continue;
}

Loading…
Cancel
Save