aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-03-09 21:49:56 +0100
committerDavid Robillard <d@drobilla.net>2020-03-09 22:17:44 +0100
commit9c82ba0aa44856130479de0667ee4cf2be1f2b37 (patch)
tree3c2d29757d4db88c3dc15f49489ec7742c5debb0 /pugl/detail
parent2fb85397366c58accbb77e5a7bd898877facc44d (diff)
downloadpugl-9c82ba0aa44856130479de0667ee4cf2be1f2b37.tar.gz
pugl-9c82ba0aa44856130479de0667ee4cf2be1f2b37.tar.bz2
pugl-9c82ba0aa44856130479de0667ee4cf2be1f2b37.zip
X11: Only send configure events if something has changed
Diffstat (limited to 'pugl/detail')
-rw-r--r--pugl/detail/implementation.c5
-rw-r--r--pugl/detail/types.h1
-rw-r--r--pugl/detail/x11.c34
3 files changed, 27 insertions, 13 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index 5c3da62..8deb50a 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -314,10 +314,15 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event)
break;
case PUGL_CREATE:
case PUGL_DESTROY:
+ view->backend->enter(view, NULL);
+ view->eventFunc(view, 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;
break;
case PUGL_EXPOSE:
view->backend->enter(view, &event->expose);
diff --git a/pugl/detail/types.h b/pugl/detail/types.h
index dc0cce0..2e41003 100644
--- a/pugl/detail/types.h
+++ b/pugl/detail/types.h
@@ -70,6 +70,7 @@ struct PuglViewImpl {
int minAspectY;
int maxAspectX;
int maxAspectY;
+ bool configured;
bool visible;
};
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index d3e4195..bcc0b49 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -257,6 +257,12 @@ 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;
}
@@ -617,19 +623,21 @@ flushPendingConfigure(PuglView* view)
{
PuglEvent* const configure = &view->impl->pendingConfigure;
- if (configure->type) {
- view->frame.x = configure->configure.x;
- view->frame.y = configure->configure.y;
-
- if (configure->configure.width != view->frame.width ||
- configure->configure.height != view->frame.height) {
- view->frame.width = configure->configure.width;
- view->frame.height = configure->configure.height;
-
- view->backend->resize(view,
- (int)view->frame.width,
- (int)view->frame.height);
- }
+ 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->backend->resize(view,
+ (int)view->frame.width,
+ (int)view->frame.height);
view->eventFunc(view, configure);
configure->type = 0;