aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar David96 <david@hameipe.de>2019-12-03 16:03:38 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2020-04-10 10:45:47 +0200
commit8c6227820754f2bb09ebda3676dcf7a43722ff64 (patch)
tree63e68c2e9f78d44287f7a451e57c93d1872a5551
parentoutput: remove damage listeners in damage destroy (diff)
downloadsway-8c6227820754f2bb09ebda3676dcf7a43722ff64.tar.gz
sway-8c6227820754f2bb09ebda3676dcf7a43722ff64.tar.zst
sway-8c6227820754f2bb09ebda3676dcf7a43722ff64.zip
Render layer shell popups over the top layer
-rw-r--r--include/sway/output.h8
-rw-r--r--sway/desktop/output.c55
-rw-r--r--sway/desktop/render.c31
3 files changed, 88 insertions, 6 deletions
diff --git a/include/sway/output.h b/include/sway/output.h
index 4771b14f..cabb4b55 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -125,6 +125,14 @@ void output_layer_for_each_surface(struct sway_output *output,
125 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, 125 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
126 void *user_data); 126 void *user_data);
127 127
128void output_layer_for_each_surface_toplevel(struct sway_output *output,
129 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
130 void *user_data);
131
132void output_layer_for_each_surface_popup(struct sway_output *output,
133 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
134 void *user_data);
135
128#if HAVE_XWAYLAND 136#if HAVE_XWAYLAND
129void output_unmanaged_for_each_surface(struct sway_output *output, 137void output_unmanaged_for_each_surface(struct sway_output *output,
130 struct wl_list *unmanaged, sway_surface_iterator_func_t iterator, 138 struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 367be2d0..a86622e1 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -243,6 +243,61 @@ void output_layer_for_each_surface(struct sway_output *output,
243 } 243 }
244} 244}
245 245
246void output_layer_for_each_surface_toplevel(struct sway_output *output,
247 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
248 void *user_data) {
249 struct sway_layer_surface *layer_surface;
250 wl_list_for_each(layer_surface, layer_surfaces, link) {
251 struct wlr_layer_surface_v1 *wlr_layer_surface_v1 =
252 layer_surface->layer_surface;
253 output_surface_for_each_surface(output, wlr_layer_surface_v1->surface,
254 layer_surface->geo.x, layer_surface->geo.y, iterator,
255 user_data);
256 }
257}
258
259
260void output_layer_for_each_surface_popup(struct sway_output *output,
261 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
262 void *user_data) {
263 struct sway_layer_surface *layer_surface;
264 wl_list_for_each(layer_surface, layer_surfaces, link) {
265 struct wlr_layer_surface_v1 *wlr_layer_surface_v1 =
266 layer_surface->layer_surface;
267
268 struct wlr_xdg_popup *state;
269 wl_list_for_each(state, &wlr_layer_surface_v1->popups, link) {
270 struct wlr_xdg_surface *popup = state->base;
271 if (!popup->configured) {
272 continue;
273 }
274
275 double popup_sx, popup_sy;
276 popup_sx = layer_surface->geo.x +
277 popup->popup->geometry.x - popup->geometry.x;
278 popup_sy = layer_surface->geo.y +
279 popup->popup->geometry.y - popup->geometry.y;
280
281 struct wlr_surface *surface = popup->surface;
282
283 struct surface_iterator_data data = {
284 .user_iterator = iterator,
285 .user_data = user_data,
286 .output = output,
287 .view = NULL,
288 .ox = popup_sx,
289 .oy = popup_sy,
290 .width = surface->current.width,
291 .height = surface->current.height,
292 .rotation = 0,
293 };
294
295 wlr_xdg_surface_for_each_surface(
296 popup, output_for_each_surface_iterator, &data);
297 }
298 }
299}
300
246#if HAVE_XWAYLAND 301#if HAVE_XWAYLAND
247void output_unmanaged_for_each_surface(struct sway_output *output, 302void output_unmanaged_for_each_surface(struct sway_output *output,
248 struct wl_list *unmanaged, sway_surface_iterator_func_t iterator, 303 struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 477034fc..14753df2 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -156,13 +156,23 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view
156 wlr_output); 156 wlr_output);
157} 157}
158 158
159static void render_layer(struct sway_output *output, 159static void render_layer_toplevel(struct sway_output *output,
160 pixman_region32_t *damage, struct wl_list *layer_surfaces) { 160 pixman_region32_t *damage, struct wl_list *layer_surfaces) {
161 struct render_data data = { 161 struct render_data data = {
162 .damage = damage, 162 .damage = damage,
163 .alpha = 1.0f, 163 .alpha = 1.0f,
164 }; 164 };
165 output_layer_for_each_surface(output, layer_surfaces, 165 output_layer_for_each_surface_toplevel(output, layer_surfaces,
166 render_surface_iterator, &data);
167}
168
169static void render_layer_popups(struct sway_output *output,
170 pixman_region32_t *damage, struct wl_list *layer_surfaces) {
171 struct render_data data = {
172 .damage = damage,
173 .alpha = 1.0f,
174 };
175 output_layer_for_each_surface_popup(output, layer_surfaces,
166 render_surface_iterator, &data); 176 render_surface_iterator, &data);
167} 177}
168 178
@@ -1041,9 +1051,9 @@ void output_render(struct sway_output *output, struct timespec *when,
1041 wlr_renderer_clear(renderer, clear_color); 1051 wlr_renderer_clear(renderer, clear_color);
1042 } 1052 }
1043 1053
1044 render_layer(output, damage, 1054 render_layer_toplevel(output, damage,
1045 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); 1055 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
1046 render_layer(output, damage, 1056 render_layer_toplevel(output, damage,
1047 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); 1057 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
1048 1058
1049 render_workspace(output, damage, workspace, workspace->current.focused); 1059 render_workspace(output, damage, workspace, workspace->current.focused);
@@ -1051,7 +1061,14 @@ void output_render(struct sway_output *output, struct timespec *when,
1051#if HAVE_XWAYLAND 1061#if HAVE_XWAYLAND
1052 render_unmanaged(output, damage, &root->xwayland_unmanaged); 1062 render_unmanaged(output, damage, &root->xwayland_unmanaged);
1053#endif 1063#endif
1054 render_layer(output, damage, 1064 render_layer_toplevel(output, damage,
1065 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
1066
1067 render_layer_popups(output, damage,
1068 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
1069 render_layer_popups(output, damage,
1070 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
1071 render_layer_popups(output, damage,
1055 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); 1072 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
1056 } 1073 }
1057 1074
@@ -1064,7 +1081,9 @@ void output_render(struct sway_output *output, struct timespec *when,
1064 } 1081 }
1065 1082
1066render_overlay: 1083render_overlay:
1067 render_layer(output, damage, 1084 render_layer_toplevel(output, damage,
1085 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
1086 render_layer_popups(output, damage,
1068 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); 1087 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
1069 render_drag_icons(output, damage, &root->drag_icons); 1088 render_drag_icons(output, damage, &root->drag_icons);
1070 1089