summaryrefslogtreecommitdiff
path: root/xev.c
diff options
context:
space:
mode:
authorNoah Levitt <nlevitt@columbia.edu>2007-12-06 05:03:41 -0500
committerJames Cloos <cloos@jhcloos.com>2007-12-06 05:13:05 -0500
commit49658a2112957b2b4874d2a9faccb6e501a0cda5 (patch)
treeb109bc719bfa1e18a5a6eaaa774aa25dbdb8efd7 /xev.c
parent990e7b0b33e894eeb395b4023cd4d0b67773777b (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>
Diffstat (limited to 'xev.c')
-rw-r--r--xev.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/xev.c b/xev.c
index 8ecf148..5b9a5cc 100644
--- a/xev.c
+++ b/xev.c
@@ -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);