aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-09 10:01:49 +0100
committerBert <ber.t@gmx.com>2011-02-09 10:01:49 +0100
commitd731741f046eecdf2788154b0387baf8f2e67007 (patch)
tree5f554c26bde98a11a2487297d2ffd5d6cd67e936
parenta5335e8ddde6aa53e6f625f5ce1ffd6f7ec098c5 (diff)
Handle WM_DELETE_WINDOW messages correctly, thanks to fungt
-rw-r--r--main.c4
-rw-r--r--window.c6
-rw-r--r--window.h2
3 files changed, 11 insertions, 1 deletions
diff --git a/main.c b/main.c
index 379b7bd..b0efc68 100644
--- a/main.c
+++ b/main.c
@@ -475,6 +475,10 @@ void run() {
timeout = 1;
}
break;
+ case ClientMessage:
+ if ((Atom) ev.xclient.data.l[0] == wm_delete_win)
+ return;
+ break;
}
}
}
diff --git a/window.c b/window.c
index ce69b5d..76a8e87 100644
--- a/window.c
+++ b/window.c
@@ -28,9 +28,10 @@
static Cursor arrow;
static Cursor hand;
-
static GC bgc;
+Atom wm_delete_win;
+
void win_set_sizehints(win_t *win) {
XSizeHints sizehints;
@@ -122,6 +123,9 @@ void win_open(win_t *win) {
XMapWindow(e->dpy, win->xwin);
XFlush(e->dpy);
+
+ wm_delete_win = XInternAtom(e->dpy, "WM_DELETE_WINDOW", False);
+ XSetWMProtocols(e->dpy, win->xwin, &wm_delete_win, 1);
if (options->fullscreen)
win_toggle_fullscreen(win);
diff --git a/window.h b/window.h
index db91b18..1ae431b 100644
--- a/window.h
+++ b/window.h
@@ -53,6 +53,8 @@ typedef struct win_s {
unsigned char fullscreen;
} win_t;
+extern Atom wm_delete_win;
+
void win_open(win_t*);
void win_close(win_t*);