aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/implementation.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-03-14 18:22:19 +0100
committerDavid Robillard <d@drobilla.net>2020-03-15 10:26:26 +0100
commit6c250b3cfd04218c7335af61e440c3a909b6d87f (patch)
tree4d39608a16e454af1bc16c09b860620bc64b7c91 /pugl/detail/implementation.c
parent02d565da853b6c7990c5944306b07e0dac69a1f6 (diff)
downloadpugl-6c250b3cfd04218c7335af61e440c3a909b6d87f.tar.gz
pugl-6c250b3cfd04218c7335af61e440c3a909b6d87f.tar.bz2
pugl-6c250b3cfd04218c7335af61e440c3a909b6d87f.zip
Move configure shortcut and frame update to common implementation
Diffstat (limited to 'pugl/detail/implementation.c')
-rw-r--r--pugl/detail/implementation.c25
1 files changed, 20 insertions, 5 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);