aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkat witch <kat@kittywit.ch>2021-07-22 00:31:13 +0100
committerHarry Jeffery <harry@exec64.co.uk>2021-07-29 17:02:35 +0000
commitb194997c20fb1ade3aa2828676ca85a2738a8f3e (patch)
treede72d0a5355d2d4d833507ba0aca19adff186e2d /src
parent33560e8e2eac581e0002351d22dc7ed2116c747a (diff)
downloadimv-b194997c20fb1ade3aa2828676ca85a2738a8f3e.tar.gz
Fix lack of X11 window deletion event handling
Diffstat (limited to 'src')
-rw-r--r--src/x11_window.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/x11_window.c b/src/x11_window.c
index 12176aa..1eb60d0 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -25,6 +25,8 @@ struct imv_window {
GLXContext x_glc;
Atom x_state;
Atom x_fullscreen;
+ Atom wm_delete_window;
+ Atom wm_protocols;
int width;
int height;
struct {
@@ -107,7 +109,7 @@ struct imv_window *imv_window_create(int w, int h, const char *title)
assert(window->x_display);
Window root = DefaultRootWindow(window->x_display);
assert(root);
-
+
GLint att[] = {
GLX_RGBA,
GLX_DEPTH_SIZE,
@@ -140,6 +142,9 @@ struct imv_window *imv_window_create(int w, int h, const char *title)
};
XSetClassHint(window->x_display, window->x_window, &hint);
XMapWindow(window->x_display, window->x_window);
+ window->wm_protocols = XInternAtom(window->x_display, "WM_PROTOCOLS", false);
+ window->wm_delete_window = XInternAtom(window->x_display, "WM_DELETE_WINDOW", false);
+ XSetWMProtocols(window->x_display, window->x_window, &window->wm_delete_window, 1);
XStoreName(window->x_display, window->x_window, title);
window->x_glc = glXCreateContext(window->x_display, vi, NULL, GL_TRUE);
@@ -413,6 +418,13 @@ void imv_window_pump_events(struct imv_window *window, imv_event_handler handler
if (handler) {
handler(data, &e);
}
+ } else if (xev.type == ClientMessage) {
+ if (xev.xclient.message_type = window->wm_protocols && xev.xclient.data.l[0] == window->wm_delete_window) {
+ struct imv_event e = {
+ .type = IMV_EVENT_CLOSE
+ };
+ imv_window_push_event(window, &e);
+ }
}
}