From 9c82ba0aa44856130479de0667ee4cf2be1f2b37 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 9 Mar 2020 21:49:56 +0100 Subject: X11: Only send configure events if something has changed --- pugl/detail/implementation.c | 5 +++++ pugl/detail/types.h | 1 + pugl/detail/x11.c | 34 +++++++++++++++++++++------------- 3 files changed, 27 insertions(+), 13 deletions(-) (limited to 'pugl') 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; -- cgit v1.2.1