Skip to content

Commit 719f2a2

Browse files
committed
wm/win: use copy to save win image
Working around a quirk of the NVIDIA driver. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
1 parent 0d69980 commit 719f2a2

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/wm/win.c

+21-5
Original file line numberDiff line numberDiff line change
@@ -1933,11 +1933,27 @@ bool win_process_animation_and_state_change(struct session *ps, struct win *w, d
19331933
w->saved_win_image);
19341934
w->saved_win_image = NULL;
19351935
}
1936-
// TODO(yshui): might need to copy for NVIDIA. because acquiring a new
1937-
// window image before freeing the old one could be problematic with
1938-
// NVIDIA.
1939-
w->saved_win_image = w->win_image;
1940-
w->win_image = NULL;
1936+
if (ps->drivers & DRIVER_NVIDIA) {
1937+
if (w->win_image != NULL) {
1938+
w->saved_win_image = ps->backend_data->ops.new_image(
1939+
ps->backend_data, BACKEND_IMAGE_FORMAT_PIXMAP,
1940+
(ivec2){
1941+
.width = (int)win_ctx.width_before,
1942+
.height = (int)win_ctx.height_before,
1943+
});
1944+
region_t copy_region;
1945+
pixman_region32_init_rect(&copy_region, 0, 0,
1946+
(uint)win_ctx.width_before,
1947+
(uint)win_ctx.height_before);
1948+
ps->backend_data->ops.copy_area(
1949+
ps->backend_data, (ivec2){}, w->saved_win_image,
1950+
w->win_image, &copy_region);
1951+
pixman_region32_fini(&copy_region);
1952+
}
1953+
} else {
1954+
w->saved_win_image = w->win_image;
1955+
w->win_image = NULL;
1956+
}
19411957
w->saved_win_image_scale = (vec2){
19421958
.x = win_ctx.width / win_ctx.width_before,
19431959
.y = win_ctx.height / win_ctx.height_before,

0 commit comments

Comments
 (0)