summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Levitt <nlevitt@columbia.edu>2007-12-06 10:03:41 (GMT)
committerSung-Jin Park <sj76.park@samsung.com>2013-09-03 03:32:30 (GMT)
commit2da6af46377f6da7e42555fef77f94821f3f5cf0 (patch)
treeb109bc719bfa1e18a5a6eaaa774aa25dbdb8efd7
parent49515a50254c521c8c5df804b217387ed5ef3f5c (diff)
downloadxev-2da6af46377f6da7e42555fef77f94821f3f5cf0.zip
xev-2da6af46377f6da7e42555fef77f94821f3f5cf0.tar.gz
xev-2da6af46377f6da7e42555fef77f94821f3f5cf0.tar.bz2
Handle WM_DELETE_WINDOW From bug 319ยน:refs/changes/73/9173/1
Make xev exit on WM_DELETE_WINDOW. 1] https://bugs.freedesktop.org/show_bug.cgi?id=319 Change-Id: I1a8b868ae7f02ede0a54404e7c7a904645fb83e0 Signed-off-by: James Cloos <cloos@jhcloos.com>
-rw-r--r--ChangeLog5
-rw-r--r--xev.c24
2 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index b7f7baa..d796248 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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:
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);