2018-10-04 05:14:51 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// Copyright (c) 2014 Richard Grenville <pyxlcy@gmail.com>
|
|
|
|
#pragma once
|
2014-08-03 19:40:40 +08:00
|
|
|
|
|
|
|
#include "common.h"
|
2018-10-01 03:43:34 +08:00
|
|
|
#include "uthash.h"
|
2014-08-03 19:40:40 +08:00
|
|
|
|
|
|
|
typedef struct {
|
2019-03-10 20:34:37 +08:00
|
|
|
XID xid;
|
|
|
|
const char *type;
|
|
|
|
const char *file;
|
|
|
|
const char *func;
|
|
|
|
int line;
|
|
|
|
UT_hash_handle hh;
|
2014-08-03 19:40:40 +08:00
|
|
|
} xrc_xid_record_t;
|
|
|
|
|
|
|
|
#define M_POS_DATA_PARAMS const char *file, int line, const char *func
|
|
|
|
#define M_POS_DATA_PASSTHROUGH file, line, func
|
|
|
|
#define M_POS_DATA __FILE__, __LINE__, __func__
|
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
void xrc_add_xid_(XID xid, const char *type, M_POS_DATA_PARAMS);
|
2014-08-03 19:40:40 +08:00
|
|
|
|
|
|
|
#define xrc_add_xid(xid, type) xrc_add_xid_(xid, type, M_POS_DATA)
|
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
void xrc_delete_xid_(XID xid, M_POS_DATA_PARAMS);
|
2014-08-03 19:40:40 +08:00
|
|
|
|
|
|
|
#define xrc_delete_xid(xid) xrc_delete_xid_(xid, M_POS_DATA)
|
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
void xrc_report_xid(void);
|
2014-08-03 19:40:40 +08:00
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
void xrc_clear_xid(void);
|
2014-08-03 19:40:40 +08:00
|
|
|
|
|
|
|
// Pixmap
|
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
static inline void xcb_create_pixmap_(xcb_connection_t *c, uint8_t depth,
|
|
|
|
xcb_pixmap_t pixmap, xcb_drawable_t drawable,
|
|
|
|
uint16_t width, uint16_t height, M_POS_DATA_PARAMS) {
|
|
|
|
xcb_create_pixmap(c, depth, pixmap, drawable, width, height);
|
|
|
|
xrc_add_xid_(pixmap, "Pixmap", M_POS_DATA_PASSTHROUGH);
|
2014-08-03 19:40:40 +08:00
|
|
|
}
|
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
#define xcb_create_pixmap(c, depth, pixmap, drawable, width, height) \
|
|
|
|
xcb_create_pixmap_(c, depth, pixmap, drawable, width, height, M_POS_DATA)
|
2014-08-03 19:40:40 +08:00
|
|
|
|
2018-10-01 03:43:34 +08:00
|
|
|
static inline xcb_void_cookie_t
|
2019-03-10 20:34:37 +08:00
|
|
|
xcb_composite_name_window_pixmap_(xcb_connection_t *c, xcb_window_t window,
|
|
|
|
xcb_pixmap_t pixmap, M_POS_DATA_PARAMS) {
|
|
|
|
xcb_void_cookie_t ret = xcb_composite_name_window_pixmap(c, window, pixmap);
|
|
|
|
xrc_add_xid_(pixmap, "PixmapC", M_POS_DATA_PASSTHROUGH);
|
|
|
|
return ret;
|
2014-08-03 19:40:40 +08:00
|
|
|
}
|
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
#define xcb_composite_name_window_pixmap(dpy, window, pixmap) \
|
|
|
|
xcb_composite_name_window_pixmap_(dpy, window, pixmap, M_POS_DATA)
|
2014-08-03 19:40:40 +08:00
|
|
|
|
|
|
|
static inline void
|
2018-10-01 03:53:52 +08:00
|
|
|
xcb_free_pixmap_(xcb_connection_t *c, xcb_pixmap_t pixmap, M_POS_DATA_PARAMS) {
|
2019-03-10 20:34:37 +08:00
|
|
|
xcb_free_pixmap(c, pixmap);
|
|
|
|
xrc_delete_xid_(pixmap, M_POS_DATA_PASSTHROUGH);
|
2014-08-03 19:40:40 +08:00
|
|
|
}
|
|
|
|
|
2018-09-29 17:53:30 +08:00
|
|
|
#define xcb_free_pixmap(c, pixmap) xcb_free_pixmap_(c, pixmap, M_POS_DATA);
|