Basic layer popup rendering

This commit is contained in:
Drew DeVault 2018-04-14 20:36:01 -04:00 committed by Guido Günther
parent d3cdb00208
commit 278aa84619
3 changed files with 52 additions and 0 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}