[Xcb] Setting a Virtual Root and xcb_change_property

Philip Rushik prushik at gmail.com
Mon Mar 17 07:23:57 PDT 2014


Hi everybody,

I successfully wrote a program using xcb that runs in the background and
launches my program when the machine becomes idle. This covers my personal
use case, however, I would also like to be able to launch existing
xscreensaver programs with my xcb program. This requires me to create a
virtual root window.

>From what I understand, there are two different ways to do this, an
"official" way, and the common way. The official way it to set
_NET_VIRTUAL_ROOTS and _NET_CURRENT_DESKTOP on the real root window, and
the common way it to set __SWM_VROOT on the new virtual root window (to
what? my own XID?). This common way seems to be what xscreensaver expects
as well as passing the XID in an environment variable. In addition, for the
common way to work, it seems the new vroot needs to be a direct child of
the root window.

In any case, this requires me to do an xcb_change_property on either the
root window or the created window. I have seen code on how to do this in
xlib, but in XCB I can't figure it out for the life of me, but I gather
that it involves internal atoms.
My current code looks like this:

    atom_cookie = xcb_intern_atom (conn, 0, strlen("__SWM_VROOT"),
                   "__SWM_VROOT");
    atom_reply = xcb_intern_atom_reply (conn, atom_cookie, NULL);
    if (atom_reply)
    {
        atom = atom_reply->atom;
        free (atom_reply);
    }
    if (!atom)
        printf("didnt get atom\n");
//        return;

    xcb_reparent_window(conn,win,screen->root,0,0);
 xcb_change_property(conn,XCB_PROP_MODE_REPLACE,win,atom,XCB_ATOM_WINDOW,0,sizeof(win),&win);

This code compiles fine, but always gives me an error on execution (in
xtrace) looking like this:
000:>:0018:Error 2=Value: major=18, minor=0, bad=0

Now, I can't figure out what I am doing wrong, it seems totally legit to
me. Anybody have any vroot insight?

Regards and my utmost thanks,
--Philip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20140317/9223da6a/attachment.html>


More information about the Xcb mailing list