diff options
Diffstat (limited to 'pugl')
-rw-r--r-- | pugl/detail/implementation.c | 25 | ||||
-rw-r--r-- | pugl/detail/implementation.h | 4 | ||||
-rw-r--r-- | pugl/detail/x11.c | 30 |
3 files changed, 23 insertions, 36 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c index 9d3d6b4..7d7a54f 100644 --- a/pugl/detail/implementation.c +++ b/pugl/detail/implementation.c @@ -1,5 +1,5 @@ /* - Copyright 2012-2019 David Robillard <http://drobilla.net> + Copyright 2012-2020 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -356,6 +356,15 @@ puglDecodeUTF8(const uint8_t* buf) return 0xFFFD; } +static inline bool +puglMustConfigure(PuglView* view, const PuglEventConfigure* configure) +{ + return !view->configured || configure->x != view->frame.x || + configure->y != view->frame.y || + configure->width != view->frame.width || + configure->height != view->frame.height; +} + void puglDispatchEvent(PuglView* view, const PuglEvent* event) { @@ -369,10 +378,16 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) view->backend->leave(view, NULL); break; case PUGL_CONFIGURE: - view->backend->enter(view, NULL); - view->eventFunc(view, event); - view->backend->leave(view, NULL); - view->configured = true; + if (puglMustConfigure(view, &event->configure)) { + view->frame.x = event->configure.x; + view->frame.y = event->configure.y; + view->frame.width = event->configure.width; + view->frame.height = event->configure.height; + + view->backend->enter(view, NULL); + view->eventFunc(view, event); + view->backend->leave(view, NULL); + } break; case PUGL_EXPOSE: view->backend->enter(view, &event->expose); diff --git a/pugl/detail/implementation.h b/pugl/detail/implementation.h index a6914fc..e368cbc 100644 --- a/pugl/detail/implementation.h +++ b/pugl/detail/implementation.h @@ -1,5 +1,5 @@ /* - Copyright 2012-2019 David Robillard <http://drobilla.net> + Copyright 2012-2020 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -50,7 +50,7 @@ void puglFreeViewInternals(PuglView* view); /** Return the Unicode code point for `buf` or the replacement character. */ uint32_t puglDecodeUTF8(const uint8_t* buf); -/** Dispatch `event` to `view`, optimising configure/expose if possible. */ +/** Dispatch `event` to `view`, entering graphics context if necessary. */ void puglDispatchEvent(PuglView* view, const PuglEvent* event); /** Set internal (stored in view) clipboard contents. */ diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index ea7f9a3..05746d7 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -257,12 +257,6 @@ puglCreateWindow(PuglView* view, const char* title) const PuglEvent createEvent = {{PUGL_CREATE, 0}}; puglDispatchEvent(view, &createEvent); - view->impl->pendingConfigure.configure.type = PUGL_CONFIGURE; - view->impl->pendingConfigure.configure.x = view->frame.x; - view->impl->pendingConfigure.configure.y = view->frame.y; - view->impl->pendingConfigure.configure.width = view->frame.width; - view->impl->pendingConfigure.configure.height = view->frame.height; - return PUGL_SUCCESS; } @@ -679,28 +673,6 @@ mergeExposeEvents(PuglEvent* dst, const PuglEvent* src) } } -static void -flushPendingConfigure(PuglView* view) -{ - PuglEvent* const configure = &view->impl->pendingConfigure; - - if (!view->configured || - (configure->type && - (configure->configure.x != view->frame.x || - configure->configure.y != view->frame.y || - configure->configure.width != view->frame.width || - configure->configure.height != view->frame.height))) { - - view->frame.x = configure->configure.x; - view->frame.y = configure->configure.y; - view->frame.width = configure->configure.width; - view->frame.height = configure->configure.height; - - view->eventFunc(view, configure); - configure->type = 0; - } -} - PUGL_API PuglStatus puglDispatchEvents(PuglWorld* world) { @@ -810,7 +782,7 @@ puglDispatchEvents(PuglWorld* world) if (configure->type || expose->type) { view->backend->enter(view, &expose->expose); - flushPendingConfigure(view); + view->eventFunc(view, configure); view->eventFunc(view, expose); view->backend->leave(view, &expose->expose); |