diff options
author | Noah Levitt <nlevitt@columbia.edu> | 2007-12-06 05:03:41 -0500 |
---|---|---|
committer | James Cloos <cloos@jhcloos.com> | 2007-12-06 05:13:05 -0500 |
commit | 49658a2112957b2b4874d2a9faccb6e501a0cda5 (patch) | |
tree | b109bc719bfa1e18a5a6eaaa774aa25dbdb8efd7 | |
parent | 990e7b0b33e894eeb395b4023cd4d0b67773777b (diff) |
Handle WM_DELETE_WINDOW
From bug 319ยน:
Make xev exit on WM_DELETE_WINDOW.
1] https://bugs.freedesktop.org/show_bug.cgi?id=319
Signed-off-by: James Cloos <cloos@jhcloos.com>
-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); |