[Xcb] How to use xcb_icccm

Michael Stapelberg michael+xcb at stapelberg.de
Sat Nov 24 14:59:05 PST 2012


Hi Micah,

Micah Nordland <mpnordland at gmail.com> writes:
> std::string Window::getWMName()
> {
>     //xcb_generic_error_t e;
>     xcb_icccm_get_text_property_reply_t prop;
>     xcb_get_property_cookie_t cookie =
> xcb_icccm_get_wm_name_unchecked(globalconf.conn, id);
>     xcb_icccm_get_wm_name_reply(globalconf.conn, cookie, &prop, NULL);
>     std::string name = prop.name;
>     return name;
> }
>
> and when I try to out put the name, I get this:
> This is the window's name <garbage characters>
Without actually testing it, I suspect that you need to consider
name_len as the reply is not NUL-terminated:

    char *name;
    asprintf(&name, "%.*s", prop.name_len, prop.name);

-- 
Best regards,
Michael


More information about the Xcb mailing list