diff options
author | Daniel d'Andrada <daniel.dandrada@canonical.com> | 2015-08-06 11:37:56 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-08-07 10:46:59 +0000 |
commit | 81f259a91b461b9779b66287f8592dbbd910fd18 (patch) | |
tree | 31b7e7e833b76e3ce4332f063473f0687103b27c | |
parent | c01f1c9a5e823078f5e3a3bb3bf50f80ba2ed31e (diff) | |
download | qtbase-81f259a91b461b9779b66287f8592dbbd910fd18.tar.gz |
Fix surface resize
If you call QWindowSystemInterface::handleExposeEvent() from the render
thread you won't give a change for the main thread to process further
resize events. In a long resize animation (like dragging a window border
with mouse) the resize events will queue up like crazy, leving
handleSurfaceResize() to deal with a ton of outdated resize events
once the resize animation is finally over.
Furthermore, as there's no synchronicity between the processing of resize
events and the consupmtion of buffers, there's no point in trying to tie
one to the other in any way. So better ignore the actual size information
from a resize event.
Change-Id: I5109245761f19a527d98c3c6f5d24789b633ed14
Reviewed-by: Gerry Boland <gerry.boland@canonical.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
-rw-r--r-- | src/plugins/platforms/mirclient/window.cpp | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/src/plugins/platforms/mirclient/window.cpp b/src/plugins/platforms/mirclient/window.cpp index 812b71e692..dd37d78948 100644 --- a/src/plugins/platforms/mirclient/window.cpp +++ b/src/plugins/platforms/mirclient/window.cpp @@ -98,7 +98,6 @@ public: MirConnection *connection; MirSurface* surface; QSize bufferSize; - QSize targetBufferSize; QMutex mutex; QSharedPointer<UbuntuClipboard> clipboard; }; @@ -318,17 +317,15 @@ void UbuntuWindow::handleSurfaceResize(int width, int height) LOG("UbuntuWindow::handleSurfaceResize(width=%d, height=%d)", width, height); // The current buffer size hasn't actually changed. so just render on it and swap - // buffers until we render on a buffer with the target size. - - d->targetBufferSize.rwidth() = width; - d->targetBufferSize.rheight() = height; - - if (d->bufferSize != d->targetBufferSize) { + // buffers in the hope that the next buffer will match the surface size advertised + // in this event. + // But since this event is processed by a thread different from the one that swaps + // buffers, you can never know if this information is already outdated as there's + // no synchronicity whatsoever between the processing of resize events and the + // consumption of buffers. + if (d->bufferSize.width() != width || d->bufferSize.height() != height) { QWindowSystemInterface::handleExposeEvent(window(), geometry()); - } else { - qWarning("[ubuntumirclient QPA] UbuntuWindow::handleSurfaceResize" - " current buffer already has the target size"); - d->targetBufferSize = QSize(); + QWindowSystemInterface::flushWindowSystemEvents(); } } @@ -430,20 +427,5 @@ void UbuntuWindow::onBuffersSwapped_threadSafe(int newBufferWidth, int newBuffer QPlatformWindow::setGeometry(newGeometry); QWindowSystemInterface::handleGeometryChange(window(), newGeometry, QRect()); - QWindowSystemInterface::handleExposeEvent(window(), newGeometry); - - } else { - // buffer size hasn't changed - if (d->targetBufferSize.isValid()) { - if (d->bufferSize != d->targetBufferSize) { - // but we still didn't reach the promised buffer size from the mir resize event. - // thus keep swapping buffers - QWindowSystemInterface::handleExposeEvent(window(), geometry()); - } else { - // target met. we have just provided a render with the target size and - // can therefore finally rest. - d->targetBufferSize = QSize(); - } - } } } |