Krolyxon
Commit d731741

Branches

Refs →

nsxivd731741

Handle WM_DELETE_WINDOW messages correctly, thanks to fungt

Author
Bert
Date
2011-02-09 10:01 +0100
Parent
a5335e8
Commit
d731741f046eecdf2788154b0387baf8f2e67007

+11 −1

3 files changed

  1. M main.c +4 −0
  2. M window.c +5 −1
  3. M window.h +2 −0
M main.c View
@@ -475,6 +475,10 @@ void run() {
475475 timeout = 1;
476476 }
477477 break;
478+ case ClientMessage:
479+ if ((Atom) ev.xclient.data.l[0] == wm_delete_win)
480+ return;
481+ break;
478482 }
479483 }
480484 }
M window.c View
@@ -28,9 +28,10 @@
2828
2929 static Cursor arrow;
3030 static Cursor hand;
31−
3231 static GC bgc;
3332
33+Atom wm_delete_win;
34+
3435 void win_set_sizehints(win_t *win) {
3536 XSizeHints sizehints;
3637
@@ -122,6 +123,9 @@ void win_open(win_t *win) {
122123
123124 XMapWindow(e->dpy, win->xwin);
124125 XFlush(e->dpy);
126+
127+ wm_delete_win = XInternAtom(e->dpy, "WM_DELETE_WINDOW", False);
128+ XSetWMProtocols(e->dpy, win->xwin, &wm_delete_win, 1);
125129
126130 if (options->fullscreen)
127131 win_toggle_fullscreen(win);
M window.h View
@@ -53,6 +53,8 @@ typedef struct win_s {
5353 unsigned char fullscreen;
5454 } win_t;
5555
56+extern Atom wm_delete_win;
57+
5658 void win_open(win_t*);
5759 void win_close(win_t*);
5860