aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-04-14 20:36:01 -0400
committerGuido Günther <agx@sigxcpu.org>2018-04-23 11:24:06 +0200
commit278aa846195ceb8ea85c181aba21e0befbcce5de (patch)
tree8a27634d02ed833e189d65f852ce8b732f9f7e46
parentd3cdb00208f119e1e2a2fc1f1733e6eff6d47da5 (diff)
Basic layer popup rendering
-rw-r--r--include/wlr/types/wlr_layer_shell.h4
-rw-r--r--rootston/output.c2
-rw-r--r--types/wlr_layer_shell.c46
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);
+}