From aa8cb217c845c8ee3b16ea63c72878d462e69992 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 29 Sep 2018 11:18:09 +0200 Subject: [PATCH] Fix xcb error ignoring The existing mechanism with set_ignore_next() is (IMHO) ugly and also does not work with XCB requests. This commit adds a new function set_ignore_cookie() and fixes callers that were converted to XCB to use this new function instead. Signed-off-by: Uli Schlachter --- src/common.h | 8 ++++++++ src/compton.c | 12 ++++++------ src/compton.h | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/common.h b/src/common.h index c5ae484..68c103a 100644 --- a/src/common.h +++ b/src/common.h @@ -1995,6 +1995,14 @@ set_ignore_next(session_t *ps) { set_ignore(ps, NextRequest(ps->dpy)); } +/** + * Ignore X errors caused by given X request. + */ +static inline void +set_ignore_cookie(session_t *ps, xcb_void_cookie_t cookie) { + set_ignore(ps, cookie.sequence); +} + /** * Check if a window is a fullscreen window. * diff --git a/src/compton.c b/src/compton.c index 59593bf..f8ec4a9 100644 --- a/src/compton.c +++ b/src/compton.c @@ -1445,9 +1445,9 @@ win_paint_win(session_t *ps, win *w, XserverRegion reg_paint, // Fetch Pixmap if (!w->paint.pixmap && ps->has_name_pixmap) { - set_ignore_next(ps); w->paint.pixmap = xcb_generate_id(c); - xcb_composite_name_window_pixmap(c, w->id, w->paint.pixmap); + set_ignore_cookie(ps, + xcb_composite_name_window_pixmap(c, w->id, w->paint.pixmap)); if (w->paint.pixmap) free_fence(ps, &w->fence); } @@ -1997,12 +1997,12 @@ repair_win(session_t *ps, win *w) { if (!w->ever_damaged) { parts = win_extents(ps, w); - set_ignore_next(ps); - xcb_damage_subtract(c, w->damage, XCB_NONE, XCB_NONE); + set_ignore_cookie(ps, + xcb_damage_subtract(c, w->damage, XCB_NONE, XCB_NONE)); } else { parts = XFixesCreateRegion(ps->dpy, 0, 0); - set_ignore_next(ps); - xcb_damage_subtract(c, w->damage, XCB_NONE, parts); + set_ignore_cookie(ps, + xcb_damage_subtract(c, w->damage, XCB_NONE, parts)); XFixesTranslateRegion(ps->dpy, parts, w->g.x + w->g.border_width, w->g.y + w->g.border_width); diff --git a/src/compton.h b/src/compton.h index e7c67c0..cc7d753 100644 --- a/src/compton.h +++ b/src/compton.h @@ -164,8 +164,8 @@ inline static void free_damage(session_t *ps, xcb_damage_damage_t *p) { if (*p) { // BadDamage will be thrown if the window is destroyed - set_ignore_next(ps); - xcb_damage_destroy(XGetXCBConnection(ps->dpy), *p); + set_ignore_cookie(ps, + xcb_damage_destroy(XGetXCBConnection(ps->dpy), *p)); *p = None; } }