x: add function for converting x error to string
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
574eca3c25
commit
58582eb639
32
src/x.c
32
src/x.c
@ -324,11 +324,13 @@ enum { XSyncBadCounter = 0,
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X11 error handler function.
|
* Convert a X11 error to string
|
||||||
*
|
*
|
||||||
* XXX consider making this error to string
|
* @return a pointer to a string. this pointer shouldn NOT be freed, same buffer is used
|
||||||
|
* for multiple calls to this function,
|
||||||
*/
|
*/
|
||||||
void x_print_error(unsigned long serial, uint8_t major, uint16_t minor, uint8_t error_code) {
|
static const char *
|
||||||
|
_x_strerror(unsigned long serial, uint8_t major, uint16_t minor, uint8_t error_code) {
|
||||||
session_t *const ps = ps_g;
|
session_t *const ps = ps_g;
|
||||||
|
|
||||||
int o = 0;
|
int o = 0;
|
||||||
@ -337,6 +339,7 @@ void x_print_error(unsigned long serial, uint8_t major, uint16_t minor, uint8_t
|
|||||||
#define CASESTRRET2(s) \
|
#define CASESTRRET2(s) \
|
||||||
case s: name = #s; break
|
case s: name = #s; break
|
||||||
|
|
||||||
|
// TODO separate error code out from session_t
|
||||||
o = error_code - ps->xfixes_error;
|
o = error_code - ps->xfixes_error;
|
||||||
switch (o) { CASESTRRET2(XCB_XFIXES_BAD_REGION); }
|
switch (o) { CASESTRRET2(XCB_XFIXES_BAD_REGION); }
|
||||||
|
|
||||||
@ -398,8 +401,27 @@ void x_print_error(unsigned long serial, uint8_t major, uint16_t minor, uint8_t
|
|||||||
|
|
||||||
#undef CASESTRRET2
|
#undef CASESTRRET2
|
||||||
|
|
||||||
log_debug("X error %d %s request %d minor %d serial %lu", error_code, name, major,
|
thread_local static char buffer[256];
|
||||||
minor, serial);
|
snprintf(buffer, sizeof(buffer), "X error %d %s request %d minor %d serial %lu",
|
||||||
|
error_code, name, major, minor, serial);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a X11 error
|
||||||
|
*/
|
||||||
|
void x_print_error(unsigned long serial, uint8_t major, uint16_t minor, uint8_t error_code) {
|
||||||
|
log_debug("%s", _x_strerror(serial, major, minor, error_code));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a xcb_generic_error_t to a string that describes the error
|
||||||
|
*
|
||||||
|
* @return a pointer to a string. this pointer shouldn NOT be freed, same buffer is used
|
||||||
|
* for multiple calls to this function,
|
||||||
|
*/
|
||||||
|
const char *x_strerror(xcb_generic_error_t *e) {
|
||||||
|
return _x_strerror(e->full_sequence, e->major_code, e->minor_code, e->error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
12
src/x.h
12
src/x.h
@ -191,12 +191,18 @@ void x_set_picture_clip_region(xcb_connection_t *, xcb_render_picture_t, int16_t
|
|||||||
void x_clear_picture_clip_region(xcb_connection_t *, xcb_render_picture_t pict);
|
void x_clear_picture_clip_region(xcb_connection_t *, xcb_render_picture_t pict);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X11 error handler function.
|
* Log a X11 error
|
||||||
*
|
|
||||||
* XXX consider making this error to string
|
|
||||||
*/
|
*/
|
||||||
void x_print_error(unsigned long serial, uint8_t major, uint16_t minor, uint8_t error_code);
|
void x_print_error(unsigned long serial, uint8_t major, uint16_t minor, uint8_t error_code);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a xcb_generic_error_t to a string that describes the error
|
||||||
|
*
|
||||||
|
* @return a pointer to a string. this pointer shouldn NOT be freed, same buffer is used
|
||||||
|
* for multiple calls to this function,
|
||||||
|
*/
|
||||||
|
const char *x_strerror(xcb_generic_error_t *e);
|
||||||
|
|
||||||
xcb_pixmap_t x_create_pixmap(xcb_connection_t *, uint8_t depth, xcb_drawable_t drawable,
|
xcb_pixmap_t x_create_pixmap(xcb_connection_t *, uint8_t depth, xcb_drawable_t drawable,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user