Exit on window close on Linux. (#35)

This commit is contained in:
Bao Chi Tran Nguyen 2021-08-30 22:57:26 +02:00 committed by GitHub
parent 4d763e6d47
commit 9f453457fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -411,6 +411,8 @@ static void gfx_glx_get_dimensions(uint32_t *width, uint32_t *height) {
}
static void gfx_glx_handle_events(void) {
Atom wm_delete_window = XInternAtom(glx.dpy, "WM_DELETE_WINDOW", 0);
XSetWMProtocols(glx.dpy, glx.win, & wm_delete_window, 1);
while (XPending(glx.dpy)) {
XEvent xev;
XNextEvent(glx.dpy, &xev);
@ -438,6 +440,11 @@ static void gfx_glx_handle_events(void) {
}
}
}
if (xev.type == ClientMessage) {
if (xev.xclient.data.l[0] == wm_delete_window) {
exit(0);
}
}
}
}