Skip to content

Commit

Permalink
event: fix dumb bug in repair_win
Browse files Browse the repository at this point in the history
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 a5826b6)
Fixes: 1307d9e
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Feb 13, 2024
1 parent de9724f commit 41f9a58
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 41f9a58

Please sign in to comment.