[Xcb] Setting the WM_TRANSIENT_FOR property on a window

Jamey Sharp jamey at minilop.net
Mon Mar 22 11:52:53 PDT 2010


On Mon, Mar 22, 2010 at 5:19 AM, Arnaud Fontaine <arnaud at andesi.org> wrote:
> I have attached to this email  a patch (0001) adding missing setters for
> WM_CLASS and WM_TRANSIENT_FOR properties.

I think in set_wm_class_string you want memcpy rather than strncpy.
strncpy will do extra, wasted work looking for nulls before the end,
and gives the mistaken impression to a reader of the code that the
_len parameters are maximums, not necessarily the actual length.

If I were designing this API, I'd probably make it the caller's
problem to concatenate the two strings. Callers might hate me for it,
but at least I wouldn't have to think about memory allocation or
whether the input is valid. ;-) Applications usually use string
literals for instance and class, right? It's easy to write a literal
containing both values ("instance\0class") and then nobody has to call
malloc. Even applications that use dynamic strings may be able to
allocate them more efficiently than xcb-icccm can.

But that's my preference for things like libxcb itself. Feel free to
do things more conveniently here. :-)

Jamey


More information about the Xcb mailing list