diff options
author | David Robillard <d@drobilla.net> | 2015-09-13 15:14:21 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-09-13 15:14:21 -0400 |
commit | 6e26c05d999af1ff47ce80d95dcb03f2c63ab380 (patch) | |
tree | 72566eca888bfa07e7cc539a23958a371b1cbc02 /pugl | |
parent | d457ac139797b05fdc214f8af458833b58033224 (diff) | |
download | pugl-6e26c05d999af1ff47ce80d95dcb03f2c63ab380.tar.gz pugl-6e26c05d999af1ff47ce80d95dcb03f2c63ab380.tar.bz2 pugl-6e26c05d999af1ff47ce80d95dcb03f2c63ab380.zip |
Resize draw context before dispatching configure.
Diffstat (limited to 'pugl')
-rw-r--r-- | pugl/pugl_x11.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index 35cca8c..43a1b26 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,29 @@ 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); - view->redisplay = true; + 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); } #endif + + // Dispatch event to application + puglDispatchEvent(view, &event); } if (view->redisplay) { |