aboutsummaryrefslogtreecommitdiff
path: root/pugl/pugl_x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'pugl/pugl_x11.c')
-rw-r--r--pugl/pugl_x11.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 35cca8c3..8167ece5 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -505,10 +505,8 @@ PuglStatus
puglProcessEvents(PuglView* view)
{
XEvent xevent;
- bool resized = false;
while (XPending(view->impl->display) > 0) {
XNextEvent(view->impl->display, &xevent);
- bool ignore = false;
if (xevent.type == ClientMessage) {
// Handle close message
char* type = XGetAtomName(view->impl->display,
@@ -529,32 +527,32 @@ puglProcessEvents(PuglView* view)
next.xkey.time == xevent.xkey.time &&
next.xkey.keycode == xevent.xkey.keycode) {
XNextEvent(view->impl->display, &xevent);
- ignore = true;
+ continue;
}
}
} else if (xevent.type == FocusIn) {
XSetICFocus(view->impl->xic);
} else if (xevent.type == FocusOut) {
XUnsetICFocus(view->impl->xic);
- } else if (xevent.type == ConfigureNotify) {
- resized = true;
}
- if (!ignore) {
- // Translate and dispatch event
- const PuglEvent event = translateEvent(view, xevent);
- puglDispatchEvent(view, &event);
- }
- }
+ // Translate X11 event to Pugl event
+ const PuglEvent event = translateEvent(view, xevent);
- if (resized) {
#ifdef PUGL_HAVE_CAIRO
- if (view->ctx_type == PUGL_CAIRO) {
- cairo_xlib_surface_set_size(
- view->impl->surface, view->width, view->height);
+ if (event.type == PUGL_CONFIGURE && view->ctx_type == PUGL_CAIRO) {
+ // Resize surfaces/contexts before dispatching
+ cairo_xlib_surface_set_size(view->impl->surface,
+ event.configure.width,
+ event.configure.height);
view->redisplay = true;
}
#endif
+
+ // Dispatch event to application
+ if (!(view->redisplay && event.type == PUGL_EXPOSE)) {
+ puglDispatchEvent(view, &event);
+ }
}
if (view->redisplay) {