[Xcb] XGetIconSizes()
Russell Shaw
rjshaw at netspace.net.au
Sun May 17 19:20:36 PDT 2009
Russell Shaw wrote:
> Hi,
> What's the XCB replacement for XGetIconSizes() ?
Looks like there isn't one. XGetIconSizes() returns a list
of "XIconSize" structs. I couldn't figure out how to return
a list, so i'm just using the first one:
//xcb_wm_hints_t
/**
* @brief Size hints structure.
*/
typedef struct {
/** WM-specified minimum icon size */
uint32_t min_width, min_height;
/** WM-specified maximum icon size */
uint32_t max_width, max_height;
/** WM-specified resize increments */
int32_t width_inc, height_inc;
} xcb_wm_icon_size_hints_hints_t;
/** Number of elements in this structure */
#define XCB_NUM_WM_ICON_SIZE_HINTS_ELEMENTS 6
//xcb_get_wm_hints
xcb_get_property_cookie_t
xcb_get_wm_icon_size_hints(xcb_connection_t *c, xcb_window_t window)
{
return xcb_get_property(c, 0, window, WM_ICON_SIZE, WM_ICON_SIZE, 0L,
XCB_NUM_WM_ICON_SIZE_HINTS_ELEMENTS); // 60L in Xlib
}
//xcb_get_wm_hints_unchecked
xcb_get_property_cookie_t
xcb_get_wm_icon_size_hints_unchecked(xcb_connection_t *c, xcb_window_t window)
{
return xcb_get_property_unchecked(c, 0, window, WM_ICON_SIZE, WM_ICON_SIZE,
0L, XCB_NUM_WM_ICON_SIZE_HINTS_ELEMENTS); // 60L in Xlib
}
//xcb_get_wm_hints_from_reply
uint8_t
xcb_get_wm_icon_size_hints_from_reply(xcb_wm_icon_size_hints_hints_t *hints,
xcb_get_property_reply_t *reply)
{
if(!reply)
return 0;
int length = xcb_get_property_value_length(reply);
if ((reply->type != WM_ICON_SIZE) ||
(length < (XCB_NUM_WM_ICON_SIZE_HINTS_ELEMENTS - 1)) ||
(reply->format != 32))
return 0;
memcpy(hints, (xcb_wm_icon_size_hints_hints_t *) xcb_get_property_value(reply),
length * reply->format >> 3);
return 1;
}
//xcb_get_wm_hints_reply
uint8_t
xcb_get_wm_icon_size_hints_reply(xcb_connection_t *c,
xcb_get_property_cookie_t cookie,
xcb_wm_icon_size_hints_hints_t *hints,
xcb_generic_error_t **e)
{
xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
int ret = xcb_get_wm_icon_size_hints_from_reply(hints, reply);
free(reply);
return ret;
}
More information about the Xcb
mailing list