diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | xev.c | 24 |
2 files changed, 27 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2007-12-06 James Cloos <cloos@jhcloos.com> + + * xev.c: + Bug #319: handle WM_DELETE_WINDOW. (Noah Levitt) + 2006-06-02 Daniel Stone <daniel@freedesktop.org> * configure.ac: @@ -70,6 +70,9 @@ int screen; XIC xic = NULL; +Atom wm_delete_window; +Atom wm_protocols; + static void prologue (XEvent *eventp, char *event_name) { @@ -581,10 +584,23 @@ do_ClientMessage (XEvent *eventp) XClientMessageEvent *e = (XClientMessageEvent *) eventp; char *mname = XGetAtomName (dpy, e->message_type); - printf (" message_type 0x%lx (%s), format %d\n", - e->message_type, mname ? mname : Unknown, e->format); + if (e->message_type == wm_protocols) { + char *message = XGetAtomName (dpy, e->data.l[0]); + printf (" message_type 0x%lx (%s), format %d, message 0x%lx (%s)\n", + e->message_type, mname ? mname : Unknown, e->format, e->data.l[0], message); + if (message) XFree (message); + } + else { + printf (" message_type 0x%lx (%s), format %d\n", + e->message_type, mname ? mname : Unknown, e->format); + } if (mname) XFree (mname); + + if (e->format == 32 + && e->message_type == wm_protocols + && (Atom) e->data.l[0] == wm_delete_window) + exit (0); } static void @@ -885,6 +901,10 @@ main (int argc, char **argv) INNER_WINDOW_BORDER, attr.border_pixel, attr.background_pixel); + wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False); + wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + XSetWMProtocols(dpy, w, &wm_delete_window, 1); + XMapWindow (dpy, subw); /* map before w so that it appears */ XMapWindow (dpy, w); |