From: Michael Stapelberg Date: Wed, 24 Mar 2010 15:52:16 +0000 (+0100) Subject: Handle destroy notify events like unmap notify events X-Git-Tag: 3.e~6^2~37 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=46e7cf5fe13f17870db66819544baf737dc2d648;p=i3%2Fi3 Handle destroy notify events like unmap notify events This helps for windows which are immediately destroyed instead of unmapped, like when starting i3status | ./foobar | dzen2 -dock and foobar does not exist (i3status and dzen2 will get a SIGPIPE). --- diff --git a/include/handlers.h b/include/handlers.h index 03be5281..c7cbb322 100644 --- a/include/handlers.h +++ b/include/handlers.h @@ -94,6 +94,18 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, */ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event); +/** + * A destroy notify event is sent when the window is not unmapped, but + * immediately destroyed (for example when starting a window and immediately + * killing the program which started it). + * + * We just pass on the event to the unmap notify handler (by copying the + * important fields in the event data structure). + * + */ +int handle_destroy_notify_event(void *data, xcb_connection_t *conn, + xcb_destroy_notify_event_t *event); + /** * Called when a window changes its title * diff --git a/src/handlers.c b/src/handlers.c index 53a5cf38..624c3430 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -571,6 +571,26 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti return 1; } +/* + * A destroy notify event is sent when the window is not unmapped, but + * immediately destroyed (for example when starting a window and immediately + * killing the program which started it). + * + * We just pass on the event to the unmap notify handler (by copying the + * important fields in the event data structure). + * + */ +int handle_destroy_notify_event(void *data, xcb_connection_t *conn, xcb_destroy_notify_event_t *event) { + DLOG("destroy notify for 0x%08x, 0x%08x\n", event->event, event->window); + + xcb_unmap_notify_event_t unmap; + unmap.sequence = event->sequence; + unmap.event = event->event; + unmap.window = event->window; + + return handle_unmap_notify_event(NULL, conn, &unmap); +} + /* * Called when a window changes its title * diff --git a/src/mainx.c b/src/mainx.c index c80b8168..e779361b 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -414,6 +414,9 @@ int main(int argc, char *argv[], char *env[]) { it any longer. Usually, the client destroys the window shortly afterwards. */ xcb_event_set_unmap_notify_handler(&evenths, handle_unmap_notify_event, NULL); + /* Destroy notify is handled the same as unmap notify */ + xcb_event_set_destroy_notify_handler(&evenths, handle_destroy_notify_event, NULL); + /* Configure notify = window’s configuration (geometry, stacking, …). We only need it to set up ignore the following enter_notify events */ xcb_event_set_configure_notify_handler(&evenths, handle_configure_event, NULL);