Make some of the error logs more informative
Print the X error causing the error as well. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
58582eb639
commit
23068c300c
17
src/picom.c
17
src/picom.c
|
@ -1355,9 +1355,7 @@ static void handle_pending_updates(EV_P_ struct session *ps) {
|
||||||
log_debug("Delayed handling of events, entering critical section");
|
log_debug("Delayed handling of events, entering critical section");
|
||||||
auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c));
|
auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_fatal("failed to grab x server");
|
log_fatal_x_error(e, "failed to grab x server");
|
||||||
x_print_error(e->full_sequence, e->major_code, e->minor_code,
|
|
||||||
e->error_code);
|
|
||||||
return quit(ps);
|
return quit(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1389,9 +1387,7 @@ static void handle_pending_updates(EV_P_ struct session *ps) {
|
||||||
|
|
||||||
e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c));
|
e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_fatal("failed to ungrab x server");
|
log_fatal_x_error(e, "failed to ungrab x server");
|
||||||
x_print_error(e->full_sequence, e->major_code, e->minor_code,
|
|
||||||
e->error_code);
|
|
||||||
return quit(ps);
|
return quit(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,8 +1697,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
||||||
XCB_EVENT_MASK_PROPERTY_CHANGE}));
|
XCB_EVENT_MASK_PROPERTY_CHANGE}));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_error("Failed to setup root window event mask");
|
log_error_x_error(e, "Failed to setup root window event mask");
|
||||||
free(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_prefetch_extension_data(ps->c, &xcb_render_id);
|
xcb_prefetch_extension_data(ps->c, &xcb_render_id);
|
||||||
|
@ -1903,8 +1898,8 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
e = xcb_request_check(
|
e = xcb_request_check(
|
||||||
ps->c, xcb_sync_create_fence(ps->c, ps->root, ps->sync_fence, 0));
|
ps->c, xcb_sync_create_fence(ps->c, ps->root, ps->sync_fence, 0));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_error("Failed to create a XSync fence. xrender-sync-fence "
|
log_error_x_error(e, "Failed to create a XSync fence. "
|
||||||
"will be disabled");
|
"xrender-sync-fence will be disabled");
|
||||||
ps->o.xrender_sync_fence = false;
|
ps->o.xrender_sync_fence = false;
|
||||||
ps->sync_fence = XCB_NONE;
|
ps->sync_fence = XCB_NONE;
|
||||||
free(e);
|
free(e);
|
||||||
|
@ -2118,7 +2113,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
|
|
||||||
e = xcb_request_check(ps->c, xcb_ungrab_server(ps->c));
|
e = xcb_request_check(ps->c, xcb_ungrab_server(ps->c));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_error("Failed to ungrab server");
|
log_error_x_error(e, "Failed to ungrab server");
|
||||||
free(e);
|
free(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
src/x.c
37
src/x.c
|
@ -205,8 +205,7 @@ x_create_picture_with_pictfmt_and_pixmap(xcb_connection_t *c,
|
||||||
c, tmp_picture, pixmap, pictfmt->id, valuemask, buf));
|
c, tmp_picture, pixmap, pictfmt->id, valuemask, buf));
|
||||||
free(buf);
|
free(buf);
|
||||||
if (e) {
|
if (e) {
|
||||||
x_print_error(e->full_sequence, e->major_code, e->minor_code, e->error_code);
|
log_error_x_error(e, "failed to create picture");
|
||||||
log_error("failed to create picture");
|
|
||||||
return XCB_NONE;
|
return XCB_NONE;
|
||||||
}
|
}
|
||||||
return tmp_picture;
|
return tmp_picture;
|
||||||
|
@ -265,7 +264,7 @@ bool x_fetch_region(xcb_connection_t *c, xcb_xfixes_region_t r, pixman_region32_
|
||||||
xcb_xfixes_fetch_region_reply_t *xr =
|
xcb_xfixes_fetch_region_reply_t *xr =
|
||||||
xcb_xfixes_fetch_region_reply(c, xcb_xfixes_fetch_region(c, r), &e);
|
xcb_xfixes_fetch_region_reply(c, xcb_xfixes_fetch_region(c, r), &e);
|
||||||
if (!xr) {
|
if (!xr) {
|
||||||
log_error("Failed to fetch rectangles");
|
log_error_x_error(e, "Failed to fetch rectangles");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,9 +300,10 @@ void x_set_picture_clip_region(xcb_connection_t *c, xcb_render_picture_t pict,
|
||||||
xcb_generic_error_t *e = xcb_request_check(
|
xcb_generic_error_t *e = xcb_request_check(
|
||||||
c, xcb_render_set_picture_clip_rectangles_checked(
|
c, xcb_render_set_picture_clip_rectangles_checked(
|
||||||
c, pict, clip_x_origin, clip_y_origin, to_u32_checked(nrects), xrects));
|
c, pict, clip_x_origin, clip_y_origin, to_u32_checked(nrects), xrects));
|
||||||
if (e)
|
if (e) {
|
||||||
log_error("Failed to set clip region");
|
log_error_x_error(e, "Failed to set clip region");
|
||||||
free(e);
|
free(e);
|
||||||
|
}
|
||||||
free(xrects);
|
free(xrects);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -312,9 +312,10 @@ void x_clear_picture_clip_region(xcb_connection_t *c, xcb_render_picture_t pict)
|
||||||
xcb_render_change_picture_value_list_t v = {.clipmask = XCB_NONE};
|
xcb_render_change_picture_value_list_t v = {.clipmask = XCB_NONE};
|
||||||
xcb_generic_error_t *e = xcb_request_check(
|
xcb_generic_error_t *e = xcb_request_check(
|
||||||
c, xcb_render_change_picture(c, pict, XCB_RENDER_CP_CLIP_MASK, &v));
|
c, xcb_render_change_picture(c, pict, XCB_RENDER_CP_CLIP_MASK, &v));
|
||||||
if (e)
|
if (e) {
|
||||||
log_error("failed to clear clip region");
|
log_error_x_error(e, "failed to clear clip region");
|
||||||
free(e);
|
free(e);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,8 +437,7 @@ xcb_pixmap_t x_create_pixmap(xcb_connection_t *c, uint8_t depth, xcb_drawable_t
|
||||||
if (err == NULL)
|
if (err == NULL)
|
||||||
return pix;
|
return pix;
|
||||||
|
|
||||||
log_error("Failed to create pixmap:");
|
log_error_x_error(err, "Failed to create pixmap");
|
||||||
x_print_error(err->sequence, err->major_code, err->minor_code, err->error_code);
|
|
||||||
free(err);
|
free(err);
|
||||||
return XCB_NONE;
|
return XCB_NONE;
|
||||||
}
|
}
|
||||||
|
@ -508,25 +508,26 @@ bool x_fence_sync(xcb_connection_t *c, xcb_sync_fence_t f) {
|
||||||
|
|
||||||
auto e = xcb_request_check(c, xcb_sync_trigger_fence_checked(c, f));
|
auto e = xcb_request_check(c, xcb_sync_trigger_fence_checked(c, f));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_error("Failed to trigger the fence.");
|
log_error_x_error(e, "Failed to trigger the fence");
|
||||||
free(e);
|
goto err;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e = xcb_request_check(c, xcb_sync_await_fence_checked(c, 1, &f));
|
e = xcb_request_check(c, xcb_sync_await_fence_checked(c, 1, &f));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_error("Failed to await on a fence.");
|
log_error_x_error(e, "Failed to await on a fence");
|
||||||
free(e);
|
goto err;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e = xcb_request_check(c, xcb_sync_reset_fence_checked(c, f));
|
e = xcb_request_check(c, xcb_sync_reset_fence_checked(c, f));
|
||||||
if (e) {
|
if (e) {
|
||||||
log_error("Failed to reset the fence.");
|
log_error_x_error(e, "Failed to reset the fence");
|
||||||
free(e);
|
goto err;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
err:
|
||||||
|
free(e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// xcb-render specific macros
|
// xcb-render specific macros
|
||||||
|
|
5
src/x.h
5
src/x.h
|
@ -73,6 +73,11 @@ struct xvisual_info {
|
||||||
__r; \
|
__r; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#define log_error_x_error(e, fmt, ...) \
|
||||||
|
LOG(ERROR, fmt " (%s)", ##__VA_ARGS__, x_strerror(e))
|
||||||
|
#define log_fatal_x_error(e, fmt, ...) \
|
||||||
|
LOG(FATAL, fmt " (%s)", ##__VA_ARGS__, x_strerror(e))
|
||||||
|
|
||||||
/// Wraps x_new_id. abort the program if x_new_id returns error
|
/// Wraps x_new_id. abort the program if x_new_id returns error
|
||||||
static inline uint32_t x_new_id(xcb_connection_t *c) {
|
static inline uint32_t x_new_id(xcb_connection_t *c) {
|
||||||
auto ret = xcb_generate_id(c);
|
auto ret = xcb_generate_id(c);
|
||||||
|
|
Loading…
Reference in New Issue