[Xcb] Examples on using xcb-util-wm?

Uli Schlachter psychon at znc.in
Thu Sep 27 16:21:17 UTC 2018


On 27.09.2018 17:41, Christophe Lohr wrote:
> Hi,
>   I'm looking for some piece of code showing the use of the xcb_ewmh module.
> Let say I want to retreive _NET_CURRENT_DESKTOP and _NET_CLIENT_LIST
> (i.e. or something like the "wmctrl -l" command)
> How to proceed?
> What documentation should I read?

I took a look at the header file:

You begin by initializing a xcb_ewmh_connection_t via

 xcb_ewmh_connection_t ewmh;
 if (!xcb_ewmh_init_atoms_replies(&ewmh,
     xcb_ewmh_init_atoms(c, &ewmh), NULL))
   puts("init failed");

Then you can query _NET_CURRENT_DESKTOP via:

  uint32_t current_desktop;
  xcb_ewmh_get_current_desktop_reply(&ewmh,
    xcb_ewmh_get_current_desktop(&ewmh, 0),
    &current_desktop, 0);
(This function returns 0 on errors)
(now current_desktop contains the current desktop value)


Querying the client list works similar, but instead of an uint32_t, you
get an xcb_ewmh_get_windows_reply_t that is filled for you. This has a
an array ->windows of size ->windows_len containing the windows.

You can clean this up with xcb_ewmh_get_windows_reply_wipe() (think: free).

I hope this helps.

Cheers,
Uli
-- 
Sent from my Game Boy.


More information about the Xcb mailing list