From 41f9a5816c1a74d41e18cf273e6e76f96dba267a Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Tue, 6 Feb 2024 09:10:04 +0000 Subject: [PATCH] event: fix dumb bug in repair_win Basically we won't call xcb_damage_subtract if show_all_xerrors is set, which is very bad. Fixes that, and also make sure the damage subtract request is flushed in all branches. (cherry picked from commit a5826b6fb0dc4888ce922df5d82151972ff4b247) Fixes: 1307d9ec709c9fbbe99939d46ad04c57d5e4b501 Signed-off-by: Yuxuan Shui --- src/event.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/event.c b/src/event.c index 349fed59..2312ff79 100644 --- a/src/event.c +++ b/src/event.c @@ -585,16 +585,28 @@ static inline void repair_win(session_t *ps, struct managed_win *w) { region_t parts; pixman_region32_init(&parts); + // If this is the first time this window is damaged, we would redraw the + // whole window, so we don't need to fetch the damage region. But we still need + // to make sure the X server receives the DamageSubtract request, hence the + // `xcb_request_check` here. + // Otherwise, we fetch the damage regions. That means we will receive a reply + // from the X server, which implies it has received our request. if (!w->ever_damaged) { - win_extents(w, &parts); - if (!ps->o.show_all_xerrors) { - set_ignore_cookie(&ps->c, xcb_damage_subtract(ps->c.c, w->damage, - XCB_NONE, XCB_NONE)); + auto e = xcb_request_check( + ps->c.c, xcb_damage_subtract(ps->c.c, w->damage, XCB_NONE, XCB_NONE)); + if (e) { + if (ps->o.show_all_xerrors) { + x_print_error(e->sequence, e->major_code, e->minor_code, + e->error_code); + } + free(e); } + win_extents(w, &parts); } else { + auto cookie = + xcb_damage_subtract(ps->c.c, w->damage, XCB_NONE, ps->damaged_region); if (!ps->o.show_all_xerrors) { - set_ignore_cookie(&ps->c, xcb_damage_subtract(ps->c.c, w->damage, XCB_NONE, - ps->damaged_region)); + set_ignore_cookie(&ps->c, cookie); } x_fetch_region(&ps->c, ps->damaged_region, &parts); pixman_region32_translate(&parts, w->g.x + w->g.border_width,