Add a function that allocates a pixmap and checks success
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
22
src/common.h
22
src/common.h
@ -1251,6 +1251,9 @@ extern session_t *ps_g;
|
||||
static inline void
|
||||
print_timestamp(session_t *ps);
|
||||
|
||||
void
|
||||
ev_xcb_error(session_t *ps, xcb_generic_error_t *err);
|
||||
|
||||
#ifdef DEBUG_BACKTRACE
|
||||
|
||||
#include <execinfo.h>
|
||||
@ -2530,3 +2533,22 @@ free_pixmap(session_t *ps, Pixmap *p) {
|
||||
*p = None;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pixmap and check that creation succeeded.
|
||||
*/
|
||||
static inline xcb_pixmap_t
|
||||
create_pixmap(session_t *ps, uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height)
|
||||
{
|
||||
xcb_connection_t *c = XGetXCBConnection(ps->dpy);
|
||||
xcb_pixmap_t pix = xcb_generate_id(c);
|
||||
xcb_void_cookie_t cookie = xcb_create_pixmap_checked(c, depth, pix, drawable, width, height);
|
||||
xcb_generic_error_t *err = xcb_request_check(c, cookie);
|
||||
if (err == NULL)
|
||||
return pix;
|
||||
|
||||
printf_err("Failed to create pixmap:");
|
||||
ev_xcb_error(ps, err);
|
||||
free(err);
|
||||
return XCB_NONE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user