[Xcb] Handling Close Event
Vincent Torri
vtorri at univ-evry.fr
Fri Dec 31 17:28:44 PST 2010
On Fri, 31 Dec 2010, Cinolt wrote:
> I've changed the property as you specified, however it seems the event isn't
> being sent. Here is my code:
>
> #include <stdio.h>
> #include <stdint.h>
> #include <xcb/xcb.h>
>
> int main()
> {
> xcb_connection_t* c = xcb_connect(0, 0);
> xcb_screen_t* s = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
>
> xcb_window_t w = xcb_generate_id(c);
>
> const uint32_t values = XCB_EVENT_MASK_EXPOSURE;
>
> xcb_create_window(c, 0, w, (*s).root, 0, 0, 128, 128, 0,
> XCB_WINDOW_CLASS_INPUT_OUTPUT, (*s).root_visual, XCB_CW_EVENT_MASK,
> &values);
>
> xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 1, 12,
> "WM_PROTOCOLS");
> xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(c, cookie, 0);
>
> xcb_change_property(c, XCB_PROP_MODE_REPLACE, w, (*reply).atom, 4, 32, 1,
> "WM_DELETE_WINDOW");
the last parameter is wrong. You have to pass an atom, not a string. The
string is used to create the atom
xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(c, 1, 17, "WM_DELETE_WINDOWS");
xcb_intern_atom_reply_t* reply2 = xcb_intern_atom_reply(c, cookie2, 0);
xcb_change_property(c, XCB_PROP_MODE_REPLACE, w, (*reply).atom, 4, 32, 1, &reply2->atom);
you can improve the code by requesting all the cookies first, then getting
the replies later when you need them
happy new year :)
Vincent Torri
More information about the Xcb
mailing list