Question

I'm trying to write a fullscreen application with xcb for my own edification and I'm having trouble with the above. I've found a couple pieces of code that do this using Xlib, but none with xcb. I've found the xcb_ewmh_connection_t structure and I'm tentatively using it like this:

xcb_connection_t *Connection = xcb_connect(NULL, NULL);
xcb_ewmh_connection_t EWMH;
xcb_intern_atom_cookie_t *EWMHCookie = xcb_ewmh_init_atoms(Connection, &EWMH);

and then using the atoms inside the structure with EWMH._NET_WM_STATE, etc.

Given this little background, how can I go about hinting the window manager that the window should be fullscreen?

Was it helpful?

Solution

Examining xcb_ewmh.h, it looks to me like you also need to call

if(!xcb_ewmh_init_atoms_replies(&EWMH, EWMHCookie, NULL))
    /* handle errors */;

Once you've done that, the _NET_WM_STATE documentation should help for how to use this particular property.

See the ICCCM section on Client Properties for background on this technique of using properties to communicate to the window manager.

See the ChangeProperty request for how to set properties in general. That maps to the xcb_change_property function by the usual protocol stub rules.

I hope that's enough references to get you going!

OTHER TIPS

I am not sure, whether xcb_change_property is the right way to go as the specification states:

A Client wishing to change the state of a window MUST send a _NET_WM_STATE client message to the root window.

So far, I haven't seen any WM that ignores if you set it using xcb_change_property, though. Still, it might not work on other WMs.


[...] MUST send [...] a client message

would translate to following code:

xcb_client_message_event_t  payload = 
{
    .response_type  = XCB_CLIENT_MESSAGE,
    .type           = atoms._NET_WM_STATE,
    .format         = 32,
    .window         = window_handle,
    .data           =
    {
        .data32[0]  = fullscreen
            ? atoms._NET_WM_STATE_ADD
            : atoms._NET_WM_STATE_REMOVE,
        .data32[1]  = atoms._NET_WM_STATE_FULLSCREEN,
        .data32[2]  = XCB_ATOM_NONE
    }
};

xcb_send_event(
    conn,
    1,
    window_handle,
    XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
    | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
    (const char*) &payload
);

xcb_flush(conn);

atoms is just a struct where I store atoms after querying their value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top