nsxivd731741
Handle WM_DELETE_WINDOW messages correctly, thanks to fungt
+11 −1
3 files changed
| @@ -475,6 +475,10 @@ void run() { | |||
| 475 | 475 | timeout = 1; | |
| 476 | 476 | } | |
| 477 | 477 | break; | |
| 478 | + | case ClientMessage: | |
| 479 | + | if ((Atom) ev.xclient.data.l[0] == wm_delete_win) | |
| 480 | + | return; | |
| 481 | + | break; | |
| 478 | 482 | } | |
| 479 | 483 | } | |
| 480 | 484 | } | |
| @@ -28,9 +28,10 @@ | |||
| 28 | 28 | ||
| 29 | 29 | static Cursor arrow; | |
| 30 | 30 | static Cursor hand; | |
| 31 | − | ||
| 32 | 31 | static GC bgc; | |
| 33 | 32 | ||
| 33 | + | Atom wm_delete_win; | |
| 34 | + | ||
| 34 | 35 | void win_set_sizehints(win_t *win) { | |
| 35 | 36 | XSizeHints sizehints; | |
| 36 | 37 | ||
| @@ -122,6 +123,9 @@ void win_open(win_t *win) { | |||
| 122 | 123 | ||
| 123 | 124 | XMapWindow(e->dpy, win->xwin); | |
| 124 | 125 | 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); | |
| 125 | 129 | ||
| 126 | 130 | if (options->fullscreen) | |
| 127 | 131 | win_toggle_fullscreen(win); | |
| @@ -53,6 +53,8 @@ typedef struct win_s { | |||
| 53 | 53 | unsigned char fullscreen; | |
| 54 | 54 | } win_t; | |
| 55 | 55 | ||
| 56 | + | extern Atom wm_delete_win; | |
| 57 | + | ||
| 56 | 58 | void win_open(win_t*); | |
| 57 | 59 | void win_close(win_t*); | |
| 58 | 60 | ||