diff options
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsintegration.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsintegration.cpp | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 089c3cd0fe..bd2014b8f2 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -33,7 +33,6 @@ ****************************************************************************/ #include "qwindowsintegration.h" -#include "qwindowsscaling.h" #include "qwindowswindow.h" #include "qwindowscontext.h" #include "qwindowsopenglcontext.h" @@ -45,7 +44,6 @@ # include "qwindowsfontdatabase_ft.h" #endif #include "qwindowsfontdatabase.h" -#include "qwindowsguieventdispatcher.h" #ifndef QT_NO_CLIPBOARD # include "qwindowsclipboard.h" # ifndef QT_NO_DRAGANDDROP @@ -64,9 +62,11 @@ # include "qwindowssessionmanager.h" #endif #include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/qpa/qplatforminputcontextfactory_p.h> -#include <QtCore/private/qeventdispatcher_win_p.h> +#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h> + #include <QtCore/QDebug> #include <QtCore/QVariant> @@ -223,12 +223,9 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL m_context.setProcessDpiAwareness(dpiAwareness); dpiAwarenessSet = true; } - // Determine suitable scale factor, don't mix Windows and Qt scaling - if (dpiAwareness != QtWindows::ProcessDpiUnaware) - QWindowsScaling::setFactor(QWindowsScaling::determineUiScaleFactor()); qCDebug(lcQpaWindows) - << __FUNCTION__ << "DpiAwareness=" << dpiAwareness <<",Scaling=" - << QWindowsScaling::factor(); + << __FUNCTION__ << "DpiAwareness=" << dpiAwareness + << "effective process DPI awareness=" << QWindowsContext::processDpiAwareness(); m_context.initTouch(m_options); } @@ -258,10 +255,9 @@ QWindowsIntegration::~QWindowsIntegration() void QWindowsIntegration::initialize() { - if (QPlatformInputContext *pluginContext = QPlatformInputContextFactory::create()) - d->m_inputContext.reset(pluginContext); - else - d->m_inputContext.reset(new QWindowsInputContext); + QString icStr = QPlatformInputContextFactory::requested(); + icStr.isNull() ? d->m_inputContext.reset(new QWindowsInputContext) + : d->m_inputContext.reset(QPlatformInputContextFactory::create(icStr)); } bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) const @@ -287,17 +283,19 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co return true; case AllGLFunctionsQueryable: return true; + case SwitchableWidgetComposition: + return true; default: return QPlatformIntegration::hasCapability(cap); } return false; } -QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const +QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const { QWindowsWindowData requested; requested.flags = window->flags(); - requested.geometry = QWindowsScaling::mapToNative(window->geometry()); + requested.geometry = QHighDpi::toNativePixels(window->geometry(), window); // Apply custom margins (see QWindowsWindow::setCustomMargins())). const QVariant customMarginsV = window->property("_q_windowsCustomMargins"); if (customMarginsV.isValid()) @@ -312,22 +310,30 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const << "\n Obtained : " << obtained.geometry << " margins=" << obtained.frame << " handle=" << obtained.hwnd << ' ' << obtained.flags << '\n'; - if (obtained.hwnd) { - if (requested.flags != obtained.flags) - window->setFlags(obtained.flags); - // Trigger geometry change signals of QWindow. - if ((obtained.flags & Qt::Desktop) != Qt::Desktop && requested.geometry != obtained.geometry) - QWindowSystemInterface::handleGeometryChange(window, QWindowsScaling::mapFromNative(obtained.geometry)); + if (Q_UNLIKELY(!obtained.hwnd)) + return Q_NULLPTR; + + QWindowsWindow *result = createPlatformWindowHelper(window, obtained); + Q_ASSERT(result); + + if (requested.flags != obtained.flags) + window->setFlags(obtained.flags); + // Trigger geometry/screen change signals of QWindow. + if ((obtained.flags & Qt::Desktop) != Qt::Desktop) { + if (requested.geometry != obtained.geometry) + QWindowSystemInterface::handleGeometryChange(window, obtained.geometry); + QPlatformScreen *screen = result->screenForGeometry(obtained.geometry); + if (screen && result->screen() != screen) + QWindowSystemInterface::handleWindowScreenChanged(window, screen->screen()); } - return obtained; + return result; } -QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const +// Overridden to return a QWindowsDirect2DWindow in Direct2D plugin. +QWindowsWindow *QWindowsIntegration::createPlatformWindowHelper(QWindow *window, const QWindowsWindowData &data) const { - QWindowsWindowData data = createWindowData(window); - return data.hwnd ? new QWindowsWindow(window, data) - : Q_NULLPTR; + return new QWindowsWindow(window, data); } #ifndef QT_NO_OPENGL @@ -335,11 +341,18 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() { #if defined(QT_OPENGL_DYNAMIC) + const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(); + QWindowsOpenGLTester::Renderer requestedRenderer = QWindowsOpenGLTester::requestedRenderer(); switch (requestedRenderer) { case QWindowsOpenGLTester::DesktopGl: - if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) + if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) { + if ((supportedRenderers & QWindowsOpenGLTester::DisableRotationFlag) + && !QWindowsScreen::setOrientationPreference(Qt::LandscapeOrientation)) { + qCWarning(lcQpaGl, "Unable to disable rotation."); + } return glCtx; + } qCWarning(lcQpaGl, "System OpenGL failed. Falling back to Software OpenGL."); return QOpenGLStaticContext::create(true); // If ANGLE is requested, use it, don't try anything else. @@ -360,10 +373,14 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() break; } - const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(); if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) { - if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) + if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) { + if ((supportedRenderers & QWindowsOpenGLTester::DisableRotationFlag) + && !QWindowsScreen::setOrientationPreference(Qt::LandscapeOrientation)) { + qCWarning(lcQpaGl, "Unable to disable rotation."); + } return glCtx; + } } if (QWindowsOpenGLTester::Renderers glesRenderers = supportedRenderers & QWindowsOpenGLTester::GlesMask) { if (QWindowsEGLStaticContext *eglCtx = QWindowsEGLStaticContext::create(glesRenderers)) |