aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Kenny Levinsen <kl@kl.wtf>2020-05-31 01:37:43 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2020-06-03 16:41:17 +0200
commitfcd0ab8f331a6e74fde113d665d4aed21bccdfc5 (patch)
treec2f53f827372904f8d7b1356231350652bed8a8d /sway/tree/view.c
parentxwayland: pass focus to previous unmanaged surface on unmap (diff)
downloadsway-fcd0ab8f331a6e74fde113d665d4aed21bccdfc5.tar.gz
sway-fcd0ab8f331a6e74fde113d665d4aed21bccdfc5.tar.zst
sway-fcd0ab8f331a6e74fde113d665d4aed21bccdfc5.zip
view: Save all buffers associated with view
During the execution of a resize transaction, the buffer associated with a view's surface is saved and reused until the client acknowledges the resulting configure event. However, only one the main buffer of the main surface was stored and rendered, meaning that subsurfaces disappear during resize. Iterate over all, store and render buffers from all surfaces in the view to ensure that correct rendering is preserved.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 8e12a229..25951deb 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -36,6 +36,7 @@ void view_init(struct sway_view *view, enum sway_view_type type,
36 view->type = type; 36 view->type = type;
37 view->impl = impl; 37 view->impl = impl;
38 view->executed_criteria = create_list(); 38 view->executed_criteria = create_list();
39 wl_list_init(&view->saved_buffers);
39 view->allow_request_urgent = true; 40 view->allow_request_urgent = true;
40 view->shortcuts_inhibit = SHORTCUTS_INHIBIT_DEFAULT; 41 view->shortcuts_inhibit = SHORTCUTS_INHIBIT_DEFAULT;
41 wl_signal_init(&view->events.unmap); 42 wl_signal_init(&view->events.unmap);
@@ -54,6 +55,9 @@ void view_destroy(struct sway_view *view) {
54 "(might have a pending transaction?)")) { 55 "(might have a pending transaction?)")) {
55 return; 56 return;
56 } 57 }
58 if (!wl_list_empty(&view->saved_buffers)) {
59 view_remove_saved_buffer(view);
60 }
57 list_free(view->executed_criteria); 61 list_free(view->executed_criteria);
58 62
59 free(view->title_format); 63 free(view->title_format);
@@ -1176,23 +1180,38 @@ bool view_is_urgent(struct sway_view *view) {
1176} 1180}
1177 1181
1178void view_remove_saved_buffer(struct sway_view *view) { 1182void view_remove_saved_buffer(struct sway_view *view) {
1179 if (!sway_assert(view->saved_buffer, "Expected a saved buffer")) { 1183 if (!sway_assert(!wl_list_empty(&view->saved_buffers), "Expected a saved buffer")) {
1180 return; 1184 return;
1181 } 1185 }
1182 wlr_buffer_unlock(&view->saved_buffer->base); 1186 struct sway_saved_buffer *saved_buf, *tmp;
1183 view->saved_buffer = NULL; 1187 wl_list_for_each_safe(saved_buf, tmp, &view->saved_buffers, link) {
1188 wlr_buffer_unlock(&saved_buf->buffer->base);
1189 wl_list_remove(&saved_buf->link);
1190 free(saved_buf);
1191 }
1192}
1193
1194static void view_save_buffer_iterator(struct wlr_surface *surface,
1195 int sx, int sy, void *data) {
1196 struct sway_view *view = data;
1197
1198 if (surface && wlr_surface_has_buffer(surface)) {
1199 wlr_buffer_lock(&surface->buffer->base);
1200 struct sway_saved_buffer *saved_buffer = calloc(1, sizeof(struct sway_saved_buffer));
1201 saved_buffer->buffer = surface->buffer;
1202 saved_buffer->width = surface->current.width;
1203 saved_buffer->height = surface->current.height;
1204 saved_buffer->x = sx;
1205 saved_buffer->y = sy;
1206 wl_list_insert(&view->saved_buffers, &saved_buffer->link);
1207 }
1184} 1208}
1185 1209
1186void view_save_buffer(struct sway_view *view) { 1210void view_save_buffer(struct sway_view *view) {
1187 if (!sway_assert(!view->saved_buffer, "Didn't expect saved buffer")) { 1211 if (!sway_assert(wl_list_empty(&view->saved_buffers), "Didn't expect saved buffer")) {
1188 view_remove_saved_buffer(view); 1212 view_remove_saved_buffer(view);
1189 } 1213 }
1190 if (view->surface && wlr_surface_has_buffer(view->surface)) { 1214 view_for_each_surface(view, view_save_buffer_iterator, view);
1191 wlr_buffer_lock(&view->surface->buffer->base);
1192 view->saved_buffer = view->surface->buffer;
1193 view->saved_buffer_width = view->surface->current.width;
1194 view->saved_buffer_height = view->surface->current.height;
1195 }
1196} 1215}
1197 1216
1198bool view_is_transient_for(struct sway_view *child, 1217bool view_is_transient_for(struct sway_view *child,