summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c2
-rw-r--r--ui.c10
-rw-r--r--ui.h3
3 files changed, 14 insertions, 1 deletions
diff --git a/main.c b/main.c
index fcbf219..0368e32 100644
--- a/main.c
+++ b/main.c
@@ -129,6 +129,8 @@ main(int argc, char **argv)
opt
);
break;
+ case UI_QUIT:
+ goto done;
default:
break;
}
diff --git a/ui.c b/ui.c
index f8c728c..80d6267 100644
--- a/ui.c
+++ b/ui.c
@@ -16,6 +16,7 @@ static int scr;
static unsigned long fg, bg;
static XSizeHints szhint;
static GC gc;
+static Atom wm_delete_window;
static Font freg, fital;
@@ -55,6 +56,9 @@ ui_init(int argc, char **argv)
XSelectInput(dsp, win, KeyPressMask | ExposureMask);
XMapRaised(dsp, win);
+ wm_delete_window = XInternAtom(dsp, "WM_DELETE_WINDOW", False);
+ XSetWMProtocols(dsp, win, &wm_delete_window, 1);
+
freg = XLoadFont(dsp, "-*-new century schoolbook-medium-r-*-*-24-*-*-*-*-*-*-*");
fital = XLoadFont(dsp, "-*-new century schoolbook-medium-i-*-*-24-*-*-*-*-*-*-*");
}
@@ -99,6 +103,12 @@ loop:
case Expose:
e->type = UI_REDRAW;
return 1;
+ case ClientMessage:
+ if (ev.xclient.data.l[0] == wm_delete_window) {
+ e->type = UI_QUIT;
+ return 1;
+ }
+ break;
}
fprintf(stderr, "[Unknown event %d]\n", ev.type);
goto loop;
diff --git a/ui.h b/ui.h
index 6c22238..015b1aa 100644
--- a/ui.h
+++ b/ui.h
@@ -7,7 +7,8 @@
typedef enum {
UI_REDRAW,
UI_KEY_DOWN,
- UI_KEY_UP
+ UI_KEY_UP,
+ UI_QUIT
} UiEventType;
typedef enum {