aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/pugl_x11.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-21 18:38:43 +0200
committerDavid Robillard <d@drobilla.net>2019-07-21 21:31:00 +0200
commit081490898ed788a184eb74074130634ce9067174 (patch)
treefe0777f98f036a7f706dd4d80049f603bf6338bd /pugl/pugl_x11.c
parenta322ffa38b537e5e03c31ed7fe967cec9d468bb8 (diff)
downloadpugl-081490898ed788a184eb74074130634ce9067174.tar.gz
pugl-081490898ed788a184eb74074130634ce9067174.tar.bz2
pugl-081490898ed788a184eb74074130634ce9067174.zip
Fix handling of WM_DELETE_WINDOW
Diffstat (limited to 'pugl/pugl_x11.c')
-rw-r--r--pugl/pugl_x11.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 9fadc41..8bfcf17 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -77,6 +77,10 @@ puglCreateWindow(PuglView* view, const char* title)
impl->display = display;
impl->screen = DefaultScreen(display);
+ // Intern the various atoms we will need
+ impl->atoms.WM_PROTOCOLS = XInternAtom(display, "WM_PROTOCOLS", 0);
+ impl->atoms.WM_DELETE_WINDOW = XInternAtom(display, "WM_DELETE_WINDOW", 0);
+
if (view->ctx_type == PUGL_GL) {
#ifdef PUGL_HAVE_GL
impl->ctx = puglGetX11GlDrawContext();
@@ -153,8 +157,7 @@ puglCreateWindow(PuglView* view, const char* title)
}
if (!view->parent) {
- Atom wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
- XSetWMProtocols(display, win, &wmDelete, 1);
+ XSetWMProtocols(display, win, &view->impl->atoms.WM_DELETE_WINDOW, 1);
}
if (view->transient_parent) {
@@ -301,14 +304,14 @@ translateEvent(PuglView* view, XEvent xevent)
}
switch (xevent.type) {
- case ClientMessage: {
- char* type = XGetAtomName(view->impl->display,
- xevent.xclient.message_type);
- if (!strcmp(type, "WM_PROTOCOLS")) {
- event.type = PUGL_CLOSE;
+ case ClientMessage:
+ if (xevent.xclient.message_type == view->impl->atoms.WM_PROTOCOLS) {
+ const Atom protocol = xevent.xclient.data.l[0];
+ if (protocol == view->impl->atoms.WM_DELETE_WINDOW) {
+ event.type = PUGL_CLOSE;
+ }
}
break;
- }
case MapNotify: {
XWindowAttributes attrs = {0};
XGetWindowAttributes(view->impl->display, view->impl->win, &attrs);