aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2023-04-27 10:25:40 +0200
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2024-01-18 18:36:54 +0300
commit06ad734e70227ad0527fe11b88ad37e93005ce0c (patch)
tree5a5e2606242e3d229f4979d2b7c5352a139730b0 /sway/desktop
parentxwayland: Cleanup geometry handling on commit (diff)
downloadsway-06ad734e70227ad0527fe11b88ad37e93005ce0c.tar.gz
sway-06ad734e70227ad0527fe11b88ad37e93005ce0c.tar.zst
sway-06ad734e70227ad0527fe11b88ad37e93005ce0c.zip
scene_graph: Port view saved buffers
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/transaction.c49
-rw-r--r--sway/desktop/xdg_shell.c10
-rw-r--r--sway/desktop/xwayland.c10
3 files changed, 31 insertions, 38 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index bb725795..1ae6642b 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -232,21 +232,6 @@ static void apply_workspace_state(struct sway_workspace *ws,
232static void apply_container_state(struct sway_container *container, 232static void apply_container_state(struct sway_container *container,
233 struct sway_container_state *state) { 233 struct sway_container_state *state) {
234 struct sway_view *view = container->view; 234 struct sway_view *view = container->view;
235 // Damage the old location
236 desktop_damage_whole_container(container);
237 if (view && !wl_list_empty(&view->saved_buffers)) {
238 struct sway_saved_buffer *saved_buf;
239 wl_list_for_each(saved_buf, &view->saved_buffers, link) {
240 struct wlr_box box = {
241 .x = saved_buf->x - view->saved_geometry.x,
242 .y = saved_buf->y - view->saved_geometry.y,
243 .width = saved_buf->width,
244 .height = saved_buf->height,
245 };
246 desktop_damage_box(&box);
247 }
248 }
249
250 // There are separate children lists for each instruction state, the 235 // There are separate children lists for each instruction state, the
251 // container's current state and the container's pending state 236 // container's current state and the container's pending state
252 // (ie. con->children). The list itself needs to be freed here. 237 // (ie. con->children). The list itself needs to be freed here.
@@ -256,17 +241,19 @@ static void apply_container_state(struct sway_container *container,
256 241
257 memcpy(&container->current, state, sizeof(struct sway_container_state)); 242 memcpy(&container->current, state, sizeof(struct sway_container_state));
258 243
259 if (view && !wl_list_empty(&view->saved_buffers)) { 244 if (view) {
260 if (!container->node.destroying || container->node.ntxnrefs == 1) { 245 if (view->saved_surface_tree) {
261 view_remove_saved_buffer(view); 246 if (!container->node.destroying || container->node.ntxnrefs == 1) {
247 view_remove_saved_buffer(view);
248 }
262 } 249 }
263 }
264 250
265 // If the view hasn't responded to the configure, center it within 251 // If the view hasn't responded to the configure, center it within
266 // the container. This is important for fullscreen views which 252 // the container. This is important for fullscreen views which
267 // refuse to resize to the size of the output. 253 // refuse to resize to the size of the output.
268 if (view && view->surface) { 254 if (view->surface) {
269 view_center_surface(view); 255 view_center_surface(view);
256 }
270 } 257 }
271 258
272 // Damage the new location 259 // Damage the new location
@@ -415,21 +402,11 @@ static void transaction_commit(struct sway_transaction *transaction) {
415 ++transaction->num_waiting; 402 ++transaction->num_waiting;
416 } 403 }
417 404
418 // From here on we are rendering a saved buffer of the view, which 405 view_send_frame_done(node->sway_container->view);
419 // means we can send a frame done event to make the client redraw it
420 // as soon as possible. Additionally, this is required if a view is
421 // mapping and its default geometry doesn't intersect an output.
422 struct timespec now;
423 clock_gettime(CLOCK_MONOTONIC, &now);
424 wlr_surface_send_frame_done(
425 node->sway_container->view->surface, &now);
426 } 406 }
427 if (!hidden && node_is_view(node) && 407 if (!hidden && node_is_view(node) &&
428 wl_list_empty(&node->sway_container->view->saved_buffers)) { 408 !node->sway_container->view->saved_surface_tree) {
429 view_save_buffer(node->sway_container->view); 409 view_save_buffer(node->sway_container->view);
430 memcpy(&node->sway_container->view->saved_geometry,
431 &node->sway_container->view->geometry,
432 sizeof(struct wlr_box));
433 } 410 }
434 node->instruction = instruction; 411 node->instruction = instruction;
435 } 412 }
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index fed820cf..95b5cb9d 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -332,8 +332,16 @@ static void handle_commit(struct wl_listener *listener, void *data) {
332 } 332 }
333 333
334 if (view->container->node.instruction) { 334 if (view->container->node.instruction) {
335 transaction_notify_view_ready_by_serial(view, 335 bool successful = transaction_notify_view_ready_by_serial(view,
336 xdg_surface->current.configure_serial); 336 xdg_surface->current.configure_serial);
337
338 // If we saved the view and this commit isn't what we're looking for
339 // that means the user will never actually see the buffers submitted to
340 // us here. Just send frame done events to these surfaces so they can
341 // commit another time for us.
342 if (view->saved_surface_tree && !successful) {
343 view_send_frame_done(view);
344 }
337 } 345 }
338} 346}
339 347
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 0967c7fc..e0c80c07 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -442,8 +442,16 @@ static void handle_commit(struct wl_listener *listener, void *data) {
442 } 442 }
443 443
444 if (view->container->node.instruction) { 444 if (view->container->node.instruction) {
445 transaction_notify_view_ready_by_geometry(view, 445 bool successful = transaction_notify_view_ready_by_geometry(view,
446 xsurface->x, xsurface->y, state->width, state->height); 446 xsurface->x, xsurface->y, state->width, state->height);
447
448 // If we saved the view and this commit isn't what we're looking for
449 // that means the user will never actually see the buffers submitted to
450 // us here. Just send frame done events to these surfaces so they can
451 // commit another time for us.
452 if (view->saved_surface_tree && !successful) {
453 view_send_frame_done(view);
454 }
447 } 455 }
448} 456}
449 457