[Xcb] Setting the WM_TRANSIENT_FOR property on a window

Arnaud Fontaine arnaud at andesi.org
Tue Mar 23 06:20:03 PDT 2010


>>>>> Jamey Sharp <jamey at minilop.net> writes:

Hi Jamey,

    >  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.

Sounds a really  good idea as it means more  flexibility for the caller.
Indeed, for ChangeProperty on _NET_DESKTOP_NAMES in xcb-util/emwh, I let
the  caller takes  care  of  preparing a  NULL-separated  string of  the
strings for desktop names itself...

Arnaud


More information about the Xcb mailing list