From c1c69abf7bc964b6e2c1c5d5c1ba7f1542dcecc4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Feb 2020 14:55:16 +0100 Subject: Only resize backend when necessary This avoids resizing the backend when the window is only moved, which fixes flicker with Cairo where resizing is expensive. --- pugl/detail/win.c | 23 ++++++++++++++--------- pugl/detail/x11.c | 20 ++++++++++++-------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/pugl/detail/win.c b/pugl/detail/win.c index 9debb6d..6ef9255 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -435,20 +435,25 @@ handleConfigure(PuglView* view, PuglEvent* event) (LPPOINT)&rect, 2); - view->frame.x = rect.left; - view->frame.y = rect.top; - view->frame.width = rect.right - rect.left; - view->frame.height = rect.bottom - rect.top; + const LONG width = rect.right - rect.left; + const LONG height = rect.bottom - rect.top; + + view->frame.x = rect.left; + view->frame.y = rect.top; event->configure.type = PUGL_CONFIGURE; event->configure.x = view->frame.x; event->configure.y = view->frame.y; - event->configure.width = view->frame.width; - event->configure.height = view->frame.height; + event->configure.width = width; + event->configure.height = height; + + if (view->frame.width != width || view->frame.height != height) { + view->frame.width = width; + view->frame.height = height; + + view->backend->resize(view, width, height); + } - view->backend->resize(view, - rect.right - rect.left, - rect.bottom - rect.top); return rect; } diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index 49c843b..4099553 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -648,14 +648,18 @@ flushPendingConfigure(PuglView* view) PuglEvent* const configure = &view->impl->pendingConfigure; if (configure->type) { - 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->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); + } view->eventFunc(view, configure); configure->type = 0; -- cgit v1.2.1