[Xcb] XGetIconSizes()
Barton C Massey
bart at cs.pdx.edu
Wed May 20 02:00:51 PDT 2009
XCB's most-used client is still Xlib, but there's lots of
other things starting to use it. The xcb-util library is
definitely less developed that the core.
The standard XCB way to deal with things that return a list
of results is to return the raw data (in this case the
property value) and provide an iterator that will iterate
it, but what you did is fine in xcb-util also.
Bart
In message <4A10D28B.8080906 at netspace.net.au> you wrote:
> Russell Shaw wrote:
> > 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:
> ...
>
> I can return an array of size-hints now. Guess no-one is using xcb
> if basic stuff like this is missing.
>
>
> //XGetIconSizes in GetHints.c
> //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
> return xcb_get_property(c, 0, window, WM_ICON_SIZE, WM_ICON_SIZE, 0L, 60L);
> // 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
> return xcb_get_property_unchecked(c, 0, window, WM_ICON_SIZE, WM_ICON_SIZE,
> 0L, 60L); // 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
> **size_list, int *count,
> xcb_get_property_reply_t *reply)
> {
> if(!reply)
> return 0;
>
> unsigned long nitems = xcb_get_property_value_length(reply);
>
> if ((reply->type != WM_ICON_SIZE) ||
> (nitems < (XCB_NUM_WM_ICON_SIZE_HINTS_ELEMENTS)) ||
> (nitems % (XCB_NUM_WM_ICON_SIZE_HINTS_ELEMENTS) != 0) ||
> (reply->format != 32))
> return 0;
>
> unsigned long bytes = nitems * reply->format >> 3;
>
> xcb_wm_icon_size_hints_hints_t *hints = malloc(bytes);
>
> if (!hints) {
> return 0;
> }
>
> memcpy(hints, xcb_get_property_value(reply), bytes);
>
> *count = nitems/XCB_NUM_WM_ICON_SIZE_HINTS_ELEMENTS;
> *size_list = hints;
>
> 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 **size_list, int *count,
> 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(size_list, count, reply);
> free(reply);
> return ret;
> }
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
More information about the Xcb
mailing list