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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2018-09-29 11:18:09 +02:00
parent 00ae9718ee
commit aa8cb217c8
3 changed files with 16 additions and 8 deletions

View File

@ -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.
*

View File

@ -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);

View File

@ -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;
}
}