From 10327549cb91aa77e778c03c797a705241f1f06d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Mar 2019 08:39:23 +0100 Subject: QOffscreenSurface: Suppress setting of a default geometry on the window When investigating the bug report, it was discovered that the offscreen window is assigned a default geometry by QPlatformWindow::initialGeometry(), causing subsequent resize events and flushing of event queues. Suppress that by making it a popup which is not subject to window title bar restrictions on Windows and setting the respective flags. Task-number: QTBUG-74176 Change-Id: I7f9c1a3bfd57072c8188a98124bde87491dd25eb Reviewed-by: Laszlo Agocs --- src/gui/kernel/qoffscreensurface.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index ae027af627..0cc11ca3bb 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -46,6 +46,8 @@ #include "qwindow.h" #include "qplatformwindow.h" +#include + QT_BEGIN_NAMESPACE /*! @@ -199,12 +201,18 @@ void QOffscreenSurface::create() if (QThread::currentThread() != qGuiApp->thread()) qWarning("Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures."); d->offscreenWindow = new QWindow(d->screen); + // Make the window frameless to prevent Windows from enlarging it, should it + // violate the minimum title bar width on the platform. + d->offscreenWindow->setFlags(d->offscreenWindow->flags() + | Qt::CustomizeWindowHint | Qt::FramelessWindowHint); d->offscreenWindow->setObjectName(QLatin1String("QOffscreenSurface")); // Remove this window from the global list since we do not want it to be destroyed when closing the app. // The QOffscreenSurface has to be usable even after exiting the event loop. QGuiApplicationPrivate::window_list.removeOne(d->offscreenWindow); d->offscreenWindow->setSurfaceType(QWindow::OpenGLSurface); d->offscreenWindow->setFormat(d->requestedFormat); + // Prevent QPlatformWindow::initialGeometry() and platforms from setting a default geometry. + qt_window_private(d->offscreenWindow)->setAutomaticPositionAndResizeEnabled(false); d->offscreenWindow->setGeometry(0, 0, d->size.width(), d->size.height()); d->offscreenWindow->create(); } -- cgit v1.2.3