summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp30
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h5
3 files changed, 30 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 1f80ac5872..fee093f675 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1115,8 +1115,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::DisplayChangedEvent:
if (QWindowsTheme *t = QWindowsTheme::instance())
t->displayChanged();
+ QWindowsWindow::displayChanged();
return d->m_screenManager.handleDisplayChange(wParam, lParam);
case QtWindows::SettingChangedEvent:
+ QWindowsWindow::settingsChanged();
return d->m_screenManager.handleScreenChanges();
default:
break;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 7efefa9458..54a4f237ff 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -551,12 +551,6 @@ static QScreen *screenForName(const QWindow *w, const QString &name)
return winScreen;
}
-static QScreen *forcedScreenForGLWindow(const QWindow *w)
-{
- const QString forceToScreen = GpuDescription::detect().gpuSuitableScreen;
- return forceToScreen.isEmpty() ? nullptr : screenForName(w, forceToScreen);
-}
-
static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &context, const QMargins &invMargins)
{
const QPoint orgPos(context->frameX - invMargins.left(), context->frameY - invMargins.top());
@@ -565,7 +559,7 @@ static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &co
return orgPos;
// Workaround for QTBUG-50371
- const QScreen *screenForGL = forcedScreenForGLWindow(w);
+ const QScreen *screenForGL = QWindowsWindow::forcedScreenForGLWindow(w);
if (!screenForGL)
return orgPos;
@@ -1359,6 +1353,28 @@ void QWindowsWindow::setDropSiteEnabled(bool dropEnabled)
#endif // QT_CONFIG(clipboard) && QT_CONFIG(draganddrop)
}
+bool QWindowsWindow::m_screenForGLInitialized = false;
+
+void QWindowsWindow::displayChanged()
+{
+ m_screenForGLInitialized = false;
+}
+
+void QWindowsWindow::settingsChanged()
+{
+ m_screenForGLInitialized = false;
+}
+
+QScreen *QWindowsWindow::forcedScreenForGLWindow(const QWindow *w)
+{
+ static QString forceToScreen;
+ if (!m_screenForGLInitialized) {
+ forceToScreen = GpuDescription::detect().gpuSuitableScreen;
+ m_screenForGLInitialized = true;
+ }
+ return forceToScreen.isEmpty() ? nullptr : screenForName(w, forceToScreen);
+}
+
// Returns topmost QWindowsWindow ancestor even if there are embedded windows in the chain.
// Returns this window if it is the topmost ancestor.
QWindow *QWindowsWindow::topLevelOf(QWindow *w)
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index e8c30bd44b..b9b398b67b 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -297,6 +297,9 @@ public:
void handleHidden();
void handleCompositionSettingsChanged();
+ static void displayChanged();
+ static void settingsChanged();
+ static QScreen *forcedScreenForGLWindow(const QWindow *w);
static QWindowsWindow *windowsWindowOf(const QWindow *w);
static QWindow *topLevelOf(QWindow *w);
static inline void *userDataOf(HWND hwnd);
@@ -377,6 +380,8 @@ private:
HICON m_iconBig = 0;
void *m_surface = nullptr;
+ static bool m_screenForGLInitialized;
+
#if QT_CONFIG(vulkan)
// note: intentionally not using void * in order to avoid breaking x86
VkSurfaceKHR m_vkSurface = 0;