Never mind, after experimenting more I figured it out. Thanks again for your help.<br><br>#include <stdio.h><br>#include <stdint.h><br>#include <xcb/xcb.h><br><br>int main()<br>{<br> xcb_connection_t* c = xcb_connect(0, 0);<br>
xcb_screen_t* s = xcb_setup_roots_iterator(xcb_get_setup(c)).data;<br><br> xcb_window_t w = xcb_generate_id(c);<br><br> const uint32_t values = XCB_EVENT_MASK_EXPOSURE;<br><br> 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);<br>
<br> xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 1, 12, "WM_PROTOCOLS");<br> xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(c, cookie, 0);<br><br> xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(c, 0, 16, "WM_DELETE_WINDOW");<br>
xcb_intern_atom_reply_t* reply2 = xcb_intern_atom_reply(c, cookie2, 0);<br><br> xcb_change_property(c, XCB_PROP_MODE_REPLACE, w, (*reply).atom, 4, 32, 1, &(*reply2).atom);<br><br> xcb_map_window(c, w);<br> xcb_flush(c);<br>
<br> xcb_generic_event_t* event;<br> while((event = xcb_wait_for_event(c)))<br> {<br> puts("Event occurred");<br> switch((*event).response_type & ~0x80)<br> {<br> case XCB_EXPOSE:<br> puts("Expose");<br>
break;<br> case XCB_CLIENT_MESSAGE:<br> {<br> puts("Client Message");<br> if((*(xcb_client_message_event_t*)event).data.data32[0] == (*reply2).atom)<br> {<br> puts("Kill client");<br>
return 0;<br> }<br> break;<br> }<br> }<br> }<br><br> return 0;<br>}<br><br><div class="gmail_quote">On Fri, Dec 31, 2010 at 1:00 PM, Cinolt <span dir="ltr"><<a href="mailto:cinolt.yk@gmail.com">cinolt.yk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I've changed the property as you specified, however it seems the event isn't being sent. Here is my code:<br>
<br>#include <stdio.h><br>#include <stdint.h><br>#include <xcb/xcb.h><br><br>int main()<br>
{<br> xcb_connection_t* c = xcb_connect(0, 0);<br> xcb_screen_t* s = xcb_setup_roots_iterator(xcb_get_setup(c)).data;<br><br> xcb_window_t w = xcb_generate_id(c);<br><br> const uint32_t values = XCB_EVENT_MASK_EXPOSURE;<br>
<br> 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);<br><br> xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, 1, 12, "WM_PROTOCOLS");<br>
xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(c, cookie, 0);<br><br> xcb_change_property(c, XCB_PROP_MODE_REPLACE, w, (*reply).atom, 4, 32, 1, "WM_DELETE_WINDOW");<br><br> xcb_map_window(c, w);<br>
xcb_flush(c);<br>
<br> xcb_generic_event_t* event;<br> while((event = xcb_wait_for_event(c)))<br> {<br> puts("Event occurred");<br> switch((*event).response_type & ~0x80)<br> {<br> case XCB_EXPOSE:<br> puts("Expose");<br>
break;<br> }<br> }<br><br> return 0;<br>}<br><br>It should output "Event occurred" when any event occurs, and it does for Expose events, but not when I close out of the window. Any suggestions?<div>
<div></div><div class="h5"><br><br>
<div class="gmail_quote">On Fri, Dec 31, 2010 at 5:55 AM, Vincent Torri <span dir="ltr"><<a href="mailto:vtorri@univ-evry.fr" target="_blank">vtorri@univ-evry.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><br>
<br>
On Fri, 31 Dec 2010, Cinolt wrote:<br>
<br>
</div><div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello, I'm assuming that I need to call xcb_change_property on my window to<br>
change one of its properties. What should I set the type argument to, and am<br>
I correct in assuming that the data argument should be "WM_DELETE_WINDOW"?<br>
<br>
xcb_void_cookie_t xcb_change_property (xcb_connection_t *c,<br>
/* Connection to the X server */<br>
uint8_t mode,<br>
/* Property mode */<br>
xcb_window_t window,<br>
/* Window */<br>
xcb_atom_t property,<br>
/* Property to change */<br>
xcb_atom_t type,<br>
/* Type of the property */<br>
uint8_t format,<br>
/* Format of the property (8, 16, 32) */<br>
uint32_t data_len,<br>
/* Length of the data parameter */<br>
const void *data); /* Data */<br>
</blockquote>
<br></div>
I give you the way to find it by yourself if later you need to use ICCCM or EWMH again).<br>
<br>
In the link i gave you [1], it is a subsection of the ClientMessage events [2]. It is said that the window you want to delete should have the WM_PROTOCOLS property, with the atom WM_DELETE_WINDOW and that is it related to the ClientMessage event (see section 4.1.2.7) [3].<br>
<br>
So you need to change the property of your window. And indeed, you use xcb_change_property() to do that:<div><br>
<br>
xcb_void_cookie_t xcb_change_property(<br></div>
xcb_connection_t *c, /* Connection */<div><br>
uint8_t mode, /* Property mode */<br>
xcb_window_t window, /* Window */<br>
xcb_atom_t property, /* Property to change */<br>
xcb_atom_t type, /* Type of the property */<br>
uint8_t format, /* Format of the property (8, 16, 32) */<br>
uint32_t data_len, /* Length of the data parameter */<br>
const void *data); /* Data */<br>
<br></div>
* the parameters c and window are trivial.<br>
* mode: what you do with that property (replacing a value, append or<br>
prepend it). Replace it by passing XCB_PROP_MODE_REPLACE<br>
* property: create an atom with the "WM_PROTOCOLS" string (see<br>
xcb_inter_atom* functions)<br>
* type: the type of the property WM_PROTOCOLS is an atom (first ine of<br>
[3], so create an atom with the "ATOM" string (or use the value 4<br>
for the parameter 'type' as it is a predefined value).<br>
* format: as [2] mentions, it is 32<br>
* data is an array of the atoms you want to set for the WM_PROTOCOLS<br>
property. Here, it is just one atom: the WM_DELETE_WINDOW one (create<br>
it with "WM_DELETE_WINDOW")<br>
* data_len is the length of the above array, so pass just 1.<br>
<br>
Note that you can pass several atoms and not just only one: see [3] or [4].<br>
<br>
So now, when that window is deleted by clicking on the cross of the titlebar, you'll get a ClientMessage event in your event loop. See [2] to know what to do with that event.<br>
<br>
Vincent<div><br>
<br>
[1] <a href="http://tronche.com/gui/x/icccm/sec-4.html#s-4.2.8.1" target="_blank">http://tronche.com/gui/x/icccm/sec-4.html#s-4.2.8.1</a><br></div>
[2] <a href="http://tronche.com/gui/x/icccm/sec-4.html#s-4.2.8" target="_blank">http://tronche.com/gui/x/icccm/sec-4.html#s-4.2.8</a><br>
[3] <a href="http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.7" target="_blank">http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.7</a><br>
[4] <a href="http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html#id2507897" target="_blank">http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html#id2507897</a><br>
</blockquote></div><br>
</div></div></blockquote></div><br>