aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-22 17:01:32 +0200
committerDavid Robillard <d@drobilla.net>2019-07-23 20:28:56 +0200
commit8d8e662f135b01fd7ed67a8f3074f7958dfb28f0 (patch)
treee7bec95846dd8c161ff6ea72156c9b554a4ad869
parentb00a145fa35024b2112b22777075f6ab41cf6f1f (diff)
X11: Improve live resize smoothness
This avoids a double context swap when both a configure and expose event arrive in the same loop iteration, which happens often during resize.
-rw-r--r--pugl/pugl_x11.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index e0adc31..512a383 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -527,16 +527,22 @@ puglProcessEvents(PuglView* view)
}
}
- if (config_event.type) {
- // Resize drawing context before dispatching
- view->impl->ctx.resize(view,
- (int)config_event.configure.width,
- (int)config_event.configure.height);
- puglDispatchEvent(view, (const PuglEvent*)&config_event);
- }
+ if (config_event.type || expose_event.type) {
+ puglEnterContext(view);
+
+ if (config_event.type) {
+ view->width = (int)config_event.configure.width;
+ view->height = (int)config_event.configure.height;
+ view->impl->ctx.resize(view, view->width, view->height);
+ view->eventFunc(view, (const PuglEvent*)&config_event);
+ }
- if (expose_event.type) {
- puglDispatchEvent(view, (const PuglEvent*)&expose_event);
+ if (expose_event.type && expose_event.expose.count == 0) {
+ view->eventFunc(view, (const PuglEvent*)&expose_event);
+ puglLeaveContext(view, true);
+ } else {
+ puglLeaveContext(view, false);
+ }
}
return PUGL_SUCCESS;