|
|
966857 |
From 02105099301450c890e1caba977ef44efdc43da7 Mon Sep 17 00:00:00 2001
|
|
|
966857 |
From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
966857 |
Date: Sat, 29 Jan 2022 21:59:33 +0200
|
|
|
966857 |
Subject: [PATCH 20/20] Make sure QQuickWidget and its offscreen window's
|
|
|
966857 |
screens are always in sync
|
|
|
966857 |
|
|
|
966857 |
By default, the offscreen window is placed on the primary screen.
|
|
|
966857 |
However, if the parent widget argument is passed to the QQuickWidget's
|
|
|
966857 |
constructor, then QQuickWidget's and the offscreen window's screens can
|
|
|
966857 |
be different and that can create rendering issues, e.g. blurry text if
|
|
|
966857 |
the primary screen and QQuickWidget's screen have different scale
|
|
|
966857 |
factors.
|
|
|
966857 |
|
|
|
966857 |
Change-Id: I10c62b5635664f943b11828773f14017f198a770
|
|
|
966857 |
Reviewed-by: David Edmundson <davidedmundson@kde.org>
|
|
|
966857 |
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
|
|
|
966857 |
(cherry picked from commit a2a2734bffa1459639b31fb3f4f83873ba44ab5c)
|
|
|
966857 |
---
|
|
|
966857 |
src/quickwidgets/qquickwidget.cpp | 26 +++++++++++---------------
|
|
|
966857 |
1 file changed, 11 insertions(+), 15 deletions(-)
|
|
|
966857 |
|
|
|
966857 |
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
|
|
|
966857 |
index 39780f8de3..223d91f579 100644
|
|
|
966857 |
--- a/src/quickwidgets/qquickwidget.cpp
|
|
|
966857 |
+++ b/src/quickwidgets/qquickwidget.cpp
|
|
|
966857 |
@@ -106,6 +106,7 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
|
|
|
966857 |
|
|
|
966857 |
renderControl = new QQuickWidgetRenderControl(q);
|
|
|
966857 |
offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
|
|
|
966857 |
+ offscreenWindow->setScreen(q->screen());
|
|
|
966857 |
offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
|
|
|
966857 |
offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
|
|
|
966857 |
// Do not call create() on offscreenWindow.
|
|
|
966857 |
@@ -901,9 +902,7 @@ void QQuickWidgetPrivate::createContext()
|
|
|
966857 |
|
|
|
966857 |
context = new QOpenGLContext;
|
|
|
966857 |
context->setFormat(offscreenWindow->requestedFormat());
|
|
|
966857 |
- const QWindow *win = q->window()->windowHandle();
|
|
|
966857 |
- if (win && win->screen())
|
|
|
966857 |
- context->setScreen(win->screen());
|
|
|
966857 |
+ context->setScreen(q->screen());
|
|
|
966857 |
QOpenGLContext *shareContext = qt_gl_global_share_context();
|
|
|
966857 |
if (!shareContext)
|
|
|
966857 |
shareContext = QWidgetPrivate::get(q->window())->shareContext();
|
|
|
966857 |
@@ -1520,19 +1519,16 @@ bool QQuickWidget::event(QEvent *e)
|
|
|
966857 |
d->handleWindowChange();
|
|
|
966857 |
break;
|
|
|
966857 |
|
|
|
966857 |
- case QEvent::ScreenChangeInternal:
|
|
|
966857 |
- if (QWindow *window = this->window()->windowHandle()) {
|
|
|
966857 |
- QScreen *newScreen = window->screen();
|
|
|
966857 |
-
|
|
|
966857 |
- if (d->offscreenWindow)
|
|
|
966857 |
- d->offscreenWindow->setScreen(newScreen);
|
|
|
966857 |
- if (d->offscreenSurface)
|
|
|
966857 |
- d->offscreenSurface->setScreen(newScreen);
|
|
|
966857 |
+ case QEvent::ScreenChangeInternal: {
|
|
|
966857 |
+ QScreen *newScreen = screen();
|
|
|
966857 |
+ if (d->offscreenWindow)
|
|
|
966857 |
+ d->offscreenWindow->setScreen(newScreen);
|
|
|
966857 |
+ if (d->offscreenSurface)
|
|
|
966857 |
+ d->offscreenSurface->setScreen(newScreen);
|
|
|
966857 |
#if QT_CONFIG(opengl)
|
|
|
966857 |
- if (d->context)
|
|
|
966857 |
- d->context->setScreen(newScreen);
|
|
|
966857 |
+ if (d->context)
|
|
|
966857 |
+ d->context->setScreen(newScreen);
|
|
|
966857 |
#endif
|
|
|
966857 |
- }
|
|
|
966857 |
|
|
|
966857 |
if (d->useSoftwareRenderer
|
|
|
966857 |
#if QT_CONFIG(opengl)
|
|
|
966857 |
@@ -1545,7 +1541,7 @@ bool QQuickWidget::event(QEvent *e)
|
|
|
966857 |
d->render(true);
|
|
|
966857 |
}
|
|
|
966857 |
break;
|
|
|
966857 |
-
|
|
|
966857 |
+ }
|
|
|
966857 |
case QEvent::Show:
|
|
|
966857 |
case QEvent::Move:
|
|
|
966857 |
d->updatePosition();
|
|
|
966857 |
--
|
|
|
966857 |
2.35.1
|
|
|
966857 |
|