aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/pugl_x11.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-09-01 22:26:22 -0400
committerDavid Robillard <d@drobilla.net>2016-09-01 22:26:22 -0400
commit02d2704a0be7443907f5752c00b71feb58cc11dd (patch)
treef2d22fd08c10b2ff1f7762d0dc8feb3561aafa5d /pugl/pugl_x11.c
parent252421757e4e8ca9f482f2885ef9c09492c06757 (diff)
downloadpugl-02d2704a0be7443907f5752c00b71feb58cc11dd.tar.gz
pugl-02d2704a0be7443907f5752c00b71feb58cc11dd.tar.bz2
pugl-02d2704a0be7443907f5752c00b71feb58cc11dd.zip
Add PUGL_CLOSE event
This allows purely event-driven applications to handle window close. Something more extensible for WM message seems like it might be a good idea here, but I can't think of specific uses, so this will do.
Diffstat (limited to 'pugl/pugl_x11.c')
-rw-r--r--pugl/pugl_x11.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 4d7010b..f91aa24 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -461,6 +461,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;
+ }
+ break;
+ }
case ConfigureNotify:
event.type = PUGL_CONFIGURE;
event.configure.x = xevent.xconfigure.x;
@@ -605,17 +613,7 @@ puglProcessEvents(PuglView* view)
XEvent xevent;
while (XPending(view->impl->display) > 0) {
XNextEvent(view->impl->display, &xevent);
- if (xevent.type == ClientMessage) {
- // Handle close message
- char* type = XGetAtomName(view->impl->display,
- xevent.xclient.message_type);
- if (!strcmp(type, "WM_PROTOCOLS") && view->closeFunc) {
- view->closeFunc(view);
- view->redisplay = false;
- }
- XFree(type);
- continue;
- } else if (xevent.type == KeyRelease) {
+ if (xevent.type == KeyRelease) {
// Ignore key repeat if necessary
if (view->ignoreKeyRepeat &&
XEventsQueued(view->impl->display, QueuedAfterReading)) {