mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
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.
This commit is contained in:
parent
613abdda6f
commit
fcd0ab8f33
5 changed files with 86 additions and 54 deletions
|
|
@ -280,38 +280,45 @@ static void render_saved_view(struct sway_view *view,
|
|||
struct sway_output *output, pixman_region32_t *damage, float alpha) {
|
||||
struct wlr_output *wlr_output = output->wlr_output;
|
||||
|
||||
if (!view->saved_buffer || !view->saved_buffer->texture) {
|
||||
if (wl_list_empty(&view->saved_buffers)) {
|
||||
return;
|
||||
}
|
||||
struct wlr_box box = {
|
||||
.x = view->container->surface_x - output->lx -
|
||||
view->saved_geometry.x,
|
||||
.y = view->container->surface_y - output->ly -
|
||||
view->saved_geometry.y,
|
||||
.width = view->saved_buffer_width,
|
||||
.height = view->saved_buffer_height,
|
||||
};
|
||||
struct sway_saved_buffer *saved_buf;
|
||||
wl_list_for_each(saved_buf, &view->saved_buffers, link) {
|
||||
if (!saved_buf->buffer->texture) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct wlr_box output_box = {
|
||||
.width = output->width,
|
||||
.height = output->height,
|
||||
};
|
||||
struct wlr_box box = {
|
||||
.x = view->container->surface_x - output->lx -
|
||||
view->saved_geometry.x + saved_buf->x,
|
||||
.y = view->container->surface_y - output->ly -
|
||||
view->saved_geometry.y + saved_buf->y,
|
||||
.width = saved_buf->width,
|
||||
.height = saved_buf->height,
|
||||
};
|
||||
|
||||
struct wlr_box intersection;
|
||||
bool intersects = wlr_box_intersection(&intersection, &output_box, &box);
|
||||
if (!intersects) {
|
||||
return;
|
||||
struct wlr_box output_box = {
|
||||
.width = output->width,
|
||||
.height = output->height,
|
||||
};
|
||||
|
||||
struct wlr_box intersection;
|
||||
bool intersects = wlr_box_intersection(&intersection, &output_box, &box);
|
||||
if (!intersects) {
|
||||
continue;
|
||||
}
|
||||
|
||||
scale_box(&box, wlr_output->scale);
|
||||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
||||
wlr_output->transform_matrix);
|
||||
|
||||
render_texture(wlr_output, damage, saved_buf->buffer->texture,
|
||||
&box, matrix, alpha);
|
||||
}
|
||||
|
||||
scale_box(&box, wlr_output->scale);
|
||||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
|
||||
wlr_output->transform_matrix);
|
||||
|
||||
render_texture(wlr_output, damage, view->saved_buffer->texture,
|
||||
&box, matrix, alpha);
|
||||
|
||||
// FIXME: we should set the surface that this saved buffer originates from
|
||||
// as sampled here.
|
||||
// https://github.com/swaywm/sway/pull/4465#discussion_r321082059
|
||||
|
|
@ -323,7 +330,7 @@ static void render_saved_view(struct sway_view *view,
|
|||
static void render_view(struct sway_output *output, pixman_region32_t *damage,
|
||||
struct sway_container *con, struct border_colors *colors) {
|
||||
struct sway_view *view = con->view;
|
||||
if (view->saved_buffer) {
|
||||
if (!wl_list_empty(&view->saved_buffers)) {
|
||||
render_saved_view(view, output, damage, view->container->alpha);
|
||||
} else if (view->surface) {
|
||||
render_view_toplevels(view, output, damage, view->container->alpha);
|
||||
|
|
@ -1020,7 +1027,7 @@ void output_render(struct sway_output *output, struct timespec *when,
|
|||
}
|
||||
|
||||
if (fullscreen_con->view) {
|
||||
if (fullscreen_con->view->saved_buffer) {
|
||||
if (!wl_list_empty(&fullscreen_con->view->saved_buffers)) {
|
||||
render_saved_view(fullscreen_con->view, output, damage, 1.0f);
|
||||
} else if (fullscreen_con->view->surface) {
|
||||
render_view_toplevels(fullscreen_con->view,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue