From 9210536db1523063601b1887e966c94e3b2d91ad Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 30 Mar 2024 00:32:24 +0000 Subject: [PATCH] win: keep track of per-window damage This is not used anywhere yet, but is intended for damage calculation refactor. Signed-off-by: Yuxuan Shui --- src/event.c | 10 ++++++++-- src/win.c | 2 ++ src/win.h | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/event.c b/src/event.c index afaa5ac3..e5621e43 100644 --- a/src/event.c +++ b/src/event.c @@ -704,11 +704,17 @@ static inline void repair_win(session_t *ps, struct managed_win *w) { } // Remove the part in the damage area that could be ignored + region_t without_ignored; + pixman_region32_init(&without_ignored); if (w->reg_ignore && win_is_region_ignore_valid(ps, w)) { - pixman_region32_subtract(&parts, &parts, w->reg_ignore); + pixman_region32_subtract(&without_ignored, &parts, w->reg_ignore); } - add_damage(ps, &parts); + add_damage(ps, &without_ignored); + pixman_region32_fini(&without_ignored); + + pixman_region32_translate(&parts, -w->g.x, -w->g.y); + pixman_region32_copy(&w->damaged, &parts); pixman_region32_fini(&parts); } diff --git a/src/win.c b/src/win.c index 28911f0f..d28bacdd 100644 --- a/src/win.c +++ b/src/win.c @@ -1805,6 +1805,7 @@ struct win *attr_ret_nonnull maybe_allocate_managed_win(session_t *ps, struct wi }; win_set_properties_stale(new, init_stale_props, ARR_SIZE(init_stale_props)); c2_window_state_init(ps->c2_state, &new->c2_state); + pixman_region32_init(&new->damaged); return &new->base; } @@ -2179,6 +2180,7 @@ void destroy_win_finish(session_t *ps, struct win *w) { w2->prev_trans = NULL; } } + pixman_region32_fini(&mw->damaged); } free(w); diff --git a/src/win.h b/src/win.h index a37a457a..5a937eff 100644 --- a/src/win.h +++ b/src/win.h @@ -299,6 +299,9 @@ struct managed_win { /// Background texture of the window glx_texture_t *glx_texture_bg; #endif + + /// The damaged region of the window, in window local coordinates. + region_t damaged; }; /// Process pending updates/images flags on a window. Has to be called in X critical