Browse Source

Handle WM_DELETE_WINDOW messages correctly, thanks to fungt

master
Bert 14 years ago
parent
commit
d731741f04
3 changed files with 11 additions and 1 deletions
  1. +4
    -0
      main.c
  2. +5
    -1
      window.c
  3. +2
    -0
      window.h

+ 4
- 0
main.c View File

@@ -475,6 +475,10 @@ void run() {
timeout = 1; timeout = 1;
} }
break; break;
case ClientMessage:
if ((Atom) ev.xclient.data.l[0] == wm_delete_win)
return;
break;
} }
} }
} }


+ 5
- 1
window.c View File

@@ -28,9 +28,10 @@


static Cursor arrow; static Cursor arrow;
static Cursor hand; static Cursor hand;

static GC bgc; static GC bgc;


Atom wm_delete_win;

void win_set_sizehints(win_t *win) { void win_set_sizehints(win_t *win) {
XSizeHints sizehints; XSizeHints sizehints;


@@ -122,6 +123,9 @@ void win_open(win_t *win) {


XMapWindow(e->dpy, win->xwin); XMapWindow(e->dpy, win->xwin);
XFlush(e->dpy); 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) if (options->fullscreen)
win_toggle_fullscreen(win); win_toggle_fullscreen(win);


+ 2
- 0
window.h View File

@@ -53,6 +53,8 @@ typedef struct win_s {
unsigned char fullscreen; unsigned char fullscreen;
} win_t; } win_t;


extern Atom wm_delete_win;

void win_open(win_t*); void win_open(win_t*);
void win_close(win_t*); void win_close(win_t*);




Loading…
Cancel
Save