aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/pugl_x11.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-07-23 08:03:38 +0200
committerDavid Robillard <d@drobilla.net>2017-07-23 08:03:38 +0200
commit8b8f97dac9dea213875db4cfc3a0bd2033b2f6a1 (patch)
treedaea776b728930009c9ab1066368d054c5f79496 /pugl/pugl_x11.c
parentadaf38d0984087ba9b6281dde46749dfb29a2a38 (diff)
downloadpugl-8b8f97dac9dea213875db4cfc3a0bd2033b2f6a1.tar.gz
pugl-8b8f97dac9dea213875db4cfc3a0bd2033b2f6a1.tar.bz2
pugl-8b8f97dac9dea213875db4cfc3a0bd2033b2f6a1.zip
Fix merging of expose events
Thanks JP Cimalando
Diffstat (limited to 'pugl/pugl_x11.c')
-rw-r--r--pugl/pugl_x11.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 6a9135b..24df87e 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -595,15 +595,21 @@ puglWaitForEvent(PuglView* view)
}
static void
-merge_draw_events(PuglEvent* dst, const PuglEvent* src)
+merge_expose_events(PuglEvent* dst, const PuglEvent* src)
{
if (!dst->type) {
*dst = *src;
} else {
- dst->expose.x = MIN(dst->expose.x, src->expose.x);
- dst->expose.y = MIN(dst->expose.y, src->expose.y);
- dst->expose.width = MAX(dst->expose.width, src->expose.width);
- dst->expose.height = MAX(dst->expose.height, src->expose.height);
+ const double max_x = MAX(dst->expose.x + dst->expose.width,
+ src->expose.x + src->expose.width);
+ const double max_y = MAX(dst->expose.y + dst->expose.height,
+ src->expose.y + src->expose.height);
+
+ dst->expose.x = MIN(dst->expose.x, src->expose.x);
+ dst->expose.y = MIN(dst->expose.y, src->expose.y);
+ dst->expose.width = max_x - dst->expose.x;
+ dst->expose.height = max_y - dst->expose.y;
+ dst->expose.count = MIN(dst->expose.count, src->expose.count);
}
}
@@ -642,10 +648,10 @@ puglProcessEvents(PuglView* view)
if (event.type == PUGL_EXPOSE) {
// Expand expose event to be dispatched after loop
- merge_draw_events(&expose_event, &event);
+ merge_expose_events(&expose_event, &event);
} else if (event.type == PUGL_CONFIGURE) {
// Expand configure event to be dispatched after loop
- merge_draw_events(&config_event, &event);
+ config_event = event;
} else {
// Dispatch event to application immediately
puglDispatchEvent(view, &event);