From 0fa092cbae1593ca73577ecf9ec71283ae3f2498 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 8 Jan 2015 15:43:29 +0100 Subject: Windows: Add GPU detection. Compile qwindowsopengltester on all platforms and add struct GpuDescription with detection method based on IDirect3D9 (dynamically loaded). Expose as a QVariantMap-property to QWindowsNativeInterface to be able to access it from qtdiag. Task-number: QTBUG-43263 Change-Id: I3c6cd0bbbe36465e0e05f7064ecfc943d6ea4101 Reviewed-by: Laszlo Agocs --- .../platforms/windows/qwindowsnativeinterface.cpp | 8 +- .../platforms/windows/qwindowsnativeinterface.h | 5 +- .../platforms/windows/qwindowsopengltester.cpp | 142 ++++++++++++++++++++- .../platforms/windows/qwindowsopengltester.h | 58 ++++++++- src/plugins/platforms/windows/windows.pri | 11 +- 5 files changed, 213 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 002f4ae92c..12ecc53f92 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -35,6 +35,7 @@ #include "qwindowswindow.h" #include "qwindowscontext.h" #include "qwindowsopenglcontext.h" +#include "qwindowsopengltester.h" #include "qwindowsintegration.h" #include "qwindowsmime.h" @@ -216,4 +217,9 @@ int QWindowsNativeInterface::registerMimeType(const QString &mimeType) return QWindowsMime::registerMimeType(mimeType); } +QVariant QWindowsNativeInterface::gpu() const +{ + return GpuDescription::detect().toVariant(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h index 3d47dbe721..349ed28b1d 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.h +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -58,6 +58,7 @@ class QWindowsNativeInterface : public QPlatformNativeInterface { Q_OBJECT Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose) + Q_PROPERTY(QVariant gpu READ gpu STORED false) public: void *nativeResourceForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE; @@ -81,6 +82,8 @@ public: bool asyncExpose() const; void setAsyncExpose(bool value); + QVariant gpu() const; + QVariantMap windowProperties(QPlatformWindow *window) const Q_DECL_OVERRIDE; QVariant windowProperty(QPlatformWindow *window, const QString &name) const Q_DECL_OVERRIDE; QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index ba3a95ce7a..5ef3dc0855 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -32,13 +32,148 @@ ****************************************************************************/ #include "qwindowsopengltester.h" -#include "qt_windows.h" #include "qwindowscontext.h" +#include +#include +#include + +#ifndef Q_OS_WINCE +# include +# include +# include +#endif + QT_BEGIN_NAMESPACE +QString GpuDriverVersion::toString() const +{ + return QString::number(product) + + QLatin1Char('.') + QString::number(version) + + QLatin1Char('.') + QString::number(subVersion) + + QLatin1Char('.') + QString::number(build); +} + +int GpuDriverVersion::compare(const GpuDriverVersion &rhs) const +{ + if (product < rhs.product) + return -1; + if (product > rhs.product) + return 1; + if (version < rhs.version) + return -1; + if (version > rhs.version) + return 1; + if (subVersion < rhs.subVersion) + return -1; + if (subVersion > rhs.subVersion) + return 1; + if (build < rhs.build) + return -1; + if (build > rhs.build) + return 1; + return 0; +} + +GpuDescription GpuDescription::detect() +{ +#ifndef Q_OS_WINCE + typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT); + + GpuDescription result; + QSystemLibrary d3d9lib(QStringLiteral("d3d9")); + if (!d3d9lib.load()) + return result; + PtrDirect3DCreate9 direct3DCreate9 = (PtrDirect3DCreate9)d3d9lib.resolve("Direct3DCreate9"); + if (!direct3DCreate9) + return result; + IDirect3D9 *direct3D9 = direct3DCreate9(D3D_SDK_VERSION); + if (!direct3D9) + return result; + D3DADAPTER_IDENTIFIER9 adapterIdentifier; + const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier); + direct3D9->Release(); + if (SUCCEEDED(hr)) { + result.vendorId = int(adapterIdentifier.VendorId); + result.deviceId = int(adapterIdentifier.DeviceId); + result.revision = int(adapterIdentifier.Revision); + result.subSysId = int(adapterIdentifier.SubSysId); + result.driverVersion.product = HIWORD(adapterIdentifier.DriverVersion.HighPart); + result.driverVersion.version = LOWORD(adapterIdentifier.DriverVersion.HighPart); + result.driverVersion.subVersion = HIWORD(adapterIdentifier.DriverVersion.LowPart); + result.driverVersion.build = LOWORD(adapterIdentifier.DriverVersion.LowPart); + result.driverName = adapterIdentifier.Driver; + result.description = adapterIdentifier.Description; + } + return result; +#else // !Q_OS_WINCE + GpuDescription result; + result.vendorId = result.deviceId = result.revision + = result.driverVersion.product = result.driverVersion.version + = result.driverVersion.build = 1; + result.driverName = result.description = QByteArrayLiteral("Generic"); + return result; +#endif +} + +QDebug operator<<(QDebug d, const GpuDriverVersion &v) +{ + QDebugStateSaver s(d); + d.nospace(); + d << v.product << '.' << v.version << '.' << v.subVersion << '.' << v.build; + return d; +} + +QDebug operator<<(QDebug d, const GpuDescription &gd) +{ + QDebugStateSaver s(d); + d.nospace(); + d << hex << showbase << "GpuDescription(vendorId=" << gd.vendorId + << ", deviceId=" << gd.deviceId << ", subSysId=" << gd.subSysId + << dec << noshowbase << ", revision=" << gd.revision + << ", driver: " << gd.driverName + << ", version=" << gd.driverVersion << ", " << gd.description << ')'; + return d; +} + +// Return printable string formatted like the output of the dxdiag tool. +QString GpuDescription::toString() const +{ + QString result; + QTextStream str(&result); + str << " Card name: " << description + << "\n Driver Name: " << driverName + << "\n Driver Version: " << driverVersion.toString() + << "\n Vendor ID: 0x" << qSetPadChar(QLatin1Char('0')) + << uppercasedigits << hex << qSetFieldWidth(4) << vendorId + << "\n Device ID: 0x" << qSetFieldWidth(4) << deviceId + << "\n SubSys ID: 0x" << qSetFieldWidth(8) << subSysId + << "\n Revision ID: 0x" << qSetFieldWidth(4) << revision + << dec; + return result; +} + +QVariant GpuDescription::toVariant() const +{ + QVariantMap result; + result.insert(QStringLiteral("vendorId"), QVariant(vendorId)); + result.insert(QStringLiteral("deviceId"), QVariant(deviceId)); + result.insert(QStringLiteral("subSysId"),QVariant(subSysId)); + result.insert(QStringLiteral("revision"), QVariant(revision)); + result.insert(QStringLiteral("driver"), QVariant(QLatin1String(driverName))); + result.insert(QStringLiteral("driverProduct"), QVariant(driverVersion.product)); + result.insert(QStringLiteral("driverVersion"), QVariant(driverVersion.version)); + result.insert(QStringLiteral("driverSubVersion"), QVariant(driverVersion.subVersion)); + result.insert(QStringLiteral("driverBuild"), QVariant(driverVersion.build)); + result.insert(QStringLiteral("driverVersionString"), driverVersion.toString()); + result.insert(QStringLiteral("description"), QVariant(QLatin1String(description))); + result.insert(QStringLiteral("printable"), QVariant(toString())); + return result; +} + bool QWindowsOpenGLTester::testDesktopGL() { +#ifndef Q_OS_WINCE HMODULE lib = 0; HWND wnd = 0; HDC dc = 0; @@ -133,6 +268,9 @@ cleanup: // No FreeLibrary. Some implementations, Mesa in particular, deadlock when trying to unload. return result; +#else // !Q_OS_WINCE + return false; +#endif } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index 40a8e9d3ac..98b707dcd2 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -31,10 +31,64 @@ ** ****************************************************************************/ +#ifndef QWINDOWSOPENGLTESTER_H +#define QWINDOWSOPENGLTESTER_H + #include +#include + QT_BEGIN_NAMESPACE +class QDebug; +class QVariant; + +struct GpuDriverVersion // ### fixme: Use QVersionNumber in Qt 5.5? +{ + GpuDriverVersion(int p = 0, int v = 0, int sv =0, int b = 0) : product(p), version(v), subVersion(sv), build(b) {} + QString toString() const; + int compare(const GpuDriverVersion &rhs) const; + + int product; + int version; + int subVersion; + int build; +}; + +inline bool operator==(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return !v1.compare(v2); } +inline bool operator!=(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2); } +inline bool operator< (const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) < 0; } +inline bool operator<=(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) <= 0; } +inline bool operator> (const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) > 0; } +inline bool operator>=(const GpuDriverVersion &v1, const GpuDriverVersion &v2) + { return v1.compare(v2) >= 0; } + +QDebug operator<<(QDebug d, const GpuDriverVersion &gd); + +struct GpuDescription +{ + GpuDescription() : vendorId(0), deviceId(0), revision(0), subSysId(0) {} + + static GpuDescription detect(); + QString toString() const; + QVariant toVariant() const; + + int vendorId; + int deviceId; + int revision; + int subSysId; + GpuDriverVersion driverVersion; + QByteArray driverName; + QByteArray description; +}; + +QDebug operator<<(QDebug d, const GpuDescription &gd); + class QWindowsOpenGLTester { public: @@ -42,3 +96,5 @@ public: }; QT_END_NAMESPACE + +#endif // QWINDOWSOPENGLTESTER_H diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index 8e5f35d293..246598677f 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -40,7 +40,8 @@ SOURCES += \ $$PWD/qwindowsservices.cpp \ $$PWD/qwindowsnativeimage.cpp \ $$PWD/qwindowsnativeinterface.cpp \ - $$PWD/qwindowsscaling.cpp + $$PWD/qwindowsscaling.cpp \ + $$PWD/qwindowsopengltester.cpp HEADERS += \ $$PWD/qwindowswindow.h \ @@ -66,9 +67,8 @@ HEADERS += \ $$PWD/qplatformfunctions_wince.h \ $$PWD/qwindowsnativeimage.h \ $$PWD/qwindowsnativeinterface.h \ - $$PWD/qwindowsscaling.h - -!wince: HEADERS += $$PWD/qwindowsopengltester.h + $$PWD/qwindowsscaling.h \ + $$PWD/qwindowsopengltester.h INCLUDEPATH += $$PWD @@ -84,8 +84,7 @@ contains(QT_CONFIG, opengles2) { # Dynamic GL needs both WGL and EGL contains(QT_CONFIG,dynamicgl) { - SOURCES += $$PWD/qwindowseglcontext.cpp \ - $$PWD/qwindowsopengltester.cpp + SOURCES += $$PWD/qwindowseglcontext.cpp HEADERS += $$PWD/qwindowseglcontext.h } -- cgit v1.2.3 From 97a82f62c46c272fe3ef1cd9d5c2214b6a7626af Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 12 Jan 2015 15:59:36 +0100 Subject: Windows: Add infrastructure to be able to a GL renderer based on GPU. Introduce flags for the renderer type and move code to qwindowsopengltester. Introduce QWindowsOpenGLTester::supportedGlesRenderers() where type-dependent checking can be added. Change-Id: I4bbffaf861cb0fdbea0919e081e3626fb5a872de Task-number: QTBUG-43263 Reviewed-by: Laszlo Agocs --- .../platforms/windows/qwindowseglcontext.cpp | 19 +++-- src/plugins/platforms/windows/qwindowseglcontext.h | 3 +- .../platforms/windows/qwindowsintegration.cpp | 76 ++++++++++++-------- .../platforms/windows/qwindowsopenglcontext.h | 3 + .../platforms/windows/qwindowsopengltester.cpp | 82 ++++++++++++++++++++++ .../platforms/windows/qwindowsopengltester.h | 21 ++++++ 6 files changed, 162 insertions(+), 42 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index c0d0c1f77c..bde0503ee0 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -340,7 +340,7 @@ QWindowsEGLStaticContext::QWindowsEGLStaticContext(EGLDisplay display, int versi { } -QWindowsEGLStaticContext *QWindowsEGLStaticContext::create() +QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester::Renderers preferredType) { const HDC dc = QWindowsContext::instance()->displayContext(); if (!dc){ @@ -359,27 +359,26 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create() EGLDisplay display = EGL_NO_DISPLAY; #ifdef EGL_ANGLE_platform_angle_opengl - if (libEGL.eglGetPlatformDisplayEXT && qEnvironmentVariableIsSet("QT_ANGLE_PLATFORM")) { + if (libEGL.eglGetPlatformDisplayEXT + && (preferredType & QWindowsOpenGLTester::AngleBackendMask)) { const EGLint anglePlatformAttributes[][5] = { { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_NONE }, { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, EGL_NONE }, { EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_USE_WARP_ANGLE, EGL_TRUE, EGL_NONE } }; const EGLint *attributes = 0; - const QByteArray anglePlatform = qgetenv("QT_ANGLE_PLATFORM"); - if (anglePlatform == "d3d11") + if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11) attributes = anglePlatformAttributes[0]; - else if (anglePlatform == "d3d9") + else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d9) attributes = anglePlatformAttributes[1]; - else if (anglePlatform == "warp") + else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11Warp) attributes = anglePlatformAttributes[2]; - else - qCWarning(lcQpaGl) << "Invalid value set for QT_ANGLE_PLATFORM:" << anglePlatform; - if (attributes) display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes); } -#endif // EGL_ANGLE_platform_angle_opengl +#else // EGL_ANGLE_platform_angle_opengl + Q_UNUSED(preferredType) +#endif if (display == EGL_NO_DISPLAY) display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc); if (!display) { diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h index 63a7c25a6f..45ccbfb734 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.h +++ b/src/plugins/platforms/windows/qwindowseglcontext.h @@ -35,6 +35,7 @@ #define QWINDOWSEGLCONTEXT_H #include "qwindowsopenglcontext.h" +#include "qwindowsopengltester.h" #include QT_BEGIN_NAMESPACE @@ -249,7 +250,7 @@ class QWindowsEGLStaticContext : public QWindowsStaticOpenGLContext Q_DISABLE_COPY(QWindowsEGLStaticContext) public: - static QWindowsEGLStaticContext *create(); + static QWindowsEGLStaticContext *create(QWindowsOpenGLTester::Renderers preferredType); ~QWindowsEGLStaticContext(); EGLDisplay display() const { return m_display; } diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 54fb138d85..82686f38ad 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -328,47 +328,61 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons } #ifndef QT_NO_OPENGL -static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0; -QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create() +QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() { - QWindowsStaticOpenGLContext *ctx = 0; - #if defined(QT_OPENGL_DYNAMIC) - const QByteArray requested = qgetenv("QT_OPENGL"); // angle, desktop, software - const bool angleRequested = QCoreApplication::testAttribute(Qt::AA_UseOpenGLES) || requested == "angle"; - const bool desktopRequested = QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL) || requested == "desktop"; - const bool softwareRequested = QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL) || requested == "software"; - + QWindowsOpenGLTester::Renderer requestedRenderer = QWindowsOpenGLTester::requestedRenderer(); + switch (requestedRenderer) { + case QWindowsOpenGLTester::DesktopGl: + if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) + 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. - if (angleRequested) { - ctx = QWindowsEGLStaticContext::create(); - } else { - // If opengl32.dll seems to be OpenGL 2.x capable, or desktop OpenGL is requested, use it. - if (!softwareRequested && (desktopRequested || QWindowsOpenGLTester::testDesktopGL())) - ctx = QOpenGLStaticContext::create(); - // If failed and desktop OpenGL is not explicitly requested, try ANGLE. - if (!ctx && !desktopRequested && !softwareRequested) - ctx = QWindowsEGLStaticContext::create(); - // Try software. - if (!ctx) { - ctx = QOpenGLStaticContext::create(true); - // If software was explicitly requested but failed, try the regular one. - if (!ctx && softwareRequested && QWindowsOpenGLTester::testDesktopGL()) { - qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL."); - ctx = QOpenGLStaticContext::create(); - } - } + case QWindowsOpenGLTester::AngleRendererD3d9: + case QWindowsOpenGLTester::AngleRendererD3d11: + case QWindowsOpenGLTester::AngleRendererD3d11Warp: + return QWindowsEGLStaticContext::create(requestedRenderer); + case QWindowsOpenGLTester::Gles: + return QWindowsEGLStaticContext::create(QWindowsOpenGLTester::supportedGlesRenderers()); + case QWindowsOpenGLTester::SoftwareRasterizer: + if (QWindowsStaticOpenGLContext *swCtx = QOpenGLStaticContext::create(true)) + return swCtx; + qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL."); + if (QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DesktopGl) + return QOpenGLStaticContext::create(); + return Q_NULLPTR; + default: + break; } + + const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(); + if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) { + if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) + return glCtx; + } + if (QWindowsOpenGLTester::Renderers glesRenderers = supportedRenderers & QWindowsOpenGLTester::GlesMask) { + if (QWindowsEGLStaticContext *eglCtx = QWindowsEGLStaticContext::create(glesRenderers)) + return eglCtx; + } + return QOpenGLStaticContext::create(true); #elif defined(QT_OPENGL_ES_2) - ctx = QWindowsEGLStaticContext::create(); + QWindowsOpenGLTester::Renderers glesRenderers = QWindowsOpenGLTester::requestedGlesRenderer(); + if (glesRenderers == QWindowsOpenGLTester::InvalidRenderer) + glesRenderers = QWindowsOpenGLTester::supportedGlesRenderers(); + return QWindowsEGLStaticContext::create(glesRenderers); #elif !defined(QT_NO_OPENGL) - ctx = QOpenGLStaticContext::create(); + return QOpenGLStaticContext::create(); #endif +} - q_staticOpenGLContext = ctx; +static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0; - return ctx; +QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create() +{ + q_staticOpenGLContext = QWindowsStaticOpenGLContext::doCreate(); + return q_staticOpenGLContext; } bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext() diff --git a/src/plugins/platforms/windows/qwindowsopenglcontext.h b/src/plugins/platforms/windows/qwindowsopenglcontext.h index 2f724f3dd7..550bf00a40 100644 --- a/src/plugins/platforms/windows/qwindowsopenglcontext.h +++ b/src/plugins/platforms/windows/qwindowsopenglcontext.h @@ -58,6 +58,9 @@ public: // reimplement these. virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/) { return 0; } virtual void destroyWindowSurface(void * /*nativeSurface*/) { } + +private: + static QWindowsStaticOpenGLContext *doCreate(); }; class QWindowsOpenGLContext : public QPlatformOpenGLContext diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 5ef3dc0855..ac886b6bee 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #ifndef Q_OS_WINCE # include @@ -171,6 +172,87 @@ QVariant GpuDescription::toVariant() const return result; } +QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedGlesRenderer() +{ +#ifndef Q_OS_WINCE + const char platformVar[] = "QT_ANGLE_PLATFORM"; + if (qEnvironmentVariableIsSet(platformVar)) { + const QByteArray anglePlatform = qgetenv(platformVar); + if (anglePlatform == "d3d11") + return QWindowsOpenGLTester::AngleRendererD3d11; + if (anglePlatform == "d3d9") + return QWindowsOpenGLTester::AngleRendererD3d9; + if (anglePlatform == "warp") + return QWindowsOpenGLTester::AngleRendererD3d11Warp; + qCWarning(lcQpaGl) << "Invalid value set for " << platformVar << ": " << anglePlatform; + } +#endif // !Q_OS_WINCE + return QWindowsOpenGLTester::InvalidRenderer; +} + +QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer() +{ +#ifndef Q_OS_WINCE + const char openGlVar[] = "QT_OPENGL"; + if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) { + const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer(); + return glesRenderer != InvalidRenderer ? glesRenderer : Gles; + } + if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL)) + return QWindowsOpenGLTester::DesktopGl; + if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) + return QWindowsOpenGLTester::SoftwareRasterizer; + if (qEnvironmentVariableIsSet(openGlVar)) { + const QByteArray requested = qgetenv(openGlVar); + if (requested == "angle") { + const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer(); + return glesRenderer != InvalidRenderer ? glesRenderer : Gles; + } + if (requested == "desktop") + return QWindowsOpenGLTester::DesktopGl; + if (requested == "software") + return QWindowsOpenGLTester::SoftwareRasterizer; + qCWarning(lcQpaGl) << "Invalid value set for " << openGlVar << ": " << requested; + } +#endif // !Q_OS_WINCE + return QWindowsOpenGLTester::InvalidRenderer; +} + +static inline QWindowsOpenGLTester::Renderers + detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly) +{ + Q_UNUSED(gpu) +#ifndef Q_OS_WINCE + // Add checks for card types with known issues here. + QWindowsOpenGLTester::Renderers result(QWindowsOpenGLTester::AngleRendererD3d11 + | QWindowsOpenGLTester::AngleRendererD3d9 + | QWindowsOpenGLTester::AngleRendererD3d11Warp + | QWindowsOpenGLTester::SoftwareRasterizer); + + if (!glesOnly && QWindowsOpenGLTester::testDesktopGL()) + result |= QWindowsOpenGLTester::DesktopGl; + return result; +#else // !Q_OS_WINCE + return QWindowsOpenGLTester::Gles; +#endif +} + +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers() +{ + const GpuDescription gpu = GpuDescription::detect(); + const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, true); + qDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; + return result; +} + +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers() +{ + const GpuDescription gpu = GpuDescription::detect(); + const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, false); + qDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; + return result; +} + bool QWindowsOpenGLTester::testDesktopGL() { #ifndef Q_OS_WINCE diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index 98b707dcd2..6238eea4b0 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -37,6 +37,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -92,9 +93,29 @@ QDebug operator<<(QDebug d, const GpuDescription &gd); class QWindowsOpenGLTester { public: + enum Renderer { + InvalidRenderer = 0x0000, + DesktopGl = 0x0001, + AngleRendererD3d11 = 0x0002, + AngleRendererD3d9 = 0x0004, + AngleRendererD3d11Warp = 0x0008, // "Windows Advanced Rasterization Platform" + AngleBackendMask = AngleRendererD3d11 | AngleRendererD3d9 | AngleRendererD3d11Warp, + Gles = 0x0010, // ANGLE/unspecified or Generic GLES for Windows CE. + GlesMask = Gles | AngleBackendMask, + SoftwareRasterizer = 0x0020 + }; + Q_DECLARE_FLAGS(Renderers, Renderer) + + static Renderer requestedGlesRenderer(); + static Renderer requestedRenderer(); + static Renderers supportedGlesRenderers(); + static Renderers supportedRenderers(); + static bool testDesktopGL(); }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsOpenGLTester::Renderers) + QT_END_NAMESPACE #endif // QWINDOWSOPENGLTESTER_H -- cgit v1.2.3 From 9b35c2cc27741e335a231afd7bc7842602ddc8a2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 14 Jan 2015 12:29:24 +0100 Subject: Windows: Fix crash when focus window does not have a native window. Check and warn in that case. Change-Id: Ic513334b5aa48e1c7e44685c30da3e9be52c3c52 Task-number: QTBUG-43833 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 94a27d146f..ad63a57d3e 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -209,7 +209,7 @@ void QWindowsInputContext::setFocusObject(QObject *object) imeNotifyCancelComposition(m_compositionContext.hwnd); const QWindow *window = QGuiApplication::focusWindow(); - if (object && window) { + if (object && window && window->handle()) { QWindowsWindow *platformWindow = QWindowsWindow::baseWindowOf(window); if (inputMethodAccepted()) { // Re-enable IME by associating default context saved on first disabling. -- cgit v1.2.3 From 5856f6e3057a881747d77e87f8934dd67860bed6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 13 Jan 2015 12:49:40 +0100 Subject: Fix regression with frameless dialogs on Windows Task-number: QTBUG-41162 Change-Id: I6d4e6d0e8a262fead30d642d632f6b4021cc20ab Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6279b6f4af..b8ad744d05 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -514,8 +514,12 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag if (flags & Qt::WindowSystemMenuHint) style |= WS_SYSMENU; else if (dialog) { - style |= WS_SYSMENU | WS_BORDER; // QTBUG-2027, dialogs without system menu. - exStyle |= WS_EX_DLGMODALFRAME; + // QTBUG-2027, dialogs without system menu. + style |= WS_SYSMENU; + if (!(flags & Qt::FramelessWindowHint)) { + style |= WS_BORDER; + exStyle |= WS_EX_DLGMODALFRAME; + } } if (flags & Qt::WindowMinimizeButtonHint) style |= WS_MINIMIZEBOX; -- cgit v1.2.3 From 5bb2e84a764f611cf4470f2ddc0bb427c4d110cc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 16 Jan 2015 10:18:00 +0100 Subject: Fall back to ANGLE on OpenGL 1.x Apparently on some cards, that only provide OpenGL 1.4, the check for OpenGL 2 specific functions is not sufficient (presumably some old extensions provide the functions and so the test passes, even though it really shouldn't) To avoid crashing the apps later on, we should check the context version and activate the fall back to ANGLE if it's below 2.0. Task-number: QTBUG-43870 Change-Id: Id0e3d8ad1f632334ba03bbb1a4802413f28436dc Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowsopengltester.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index ac886b6bee..f6caf8b06e 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -43,6 +43,7 @@ # include # include # include +# include #endif QT_BEGIN_NAMESPACE @@ -326,6 +327,37 @@ bool QWindowsOpenGLTester::testDesktopGL() goto cleanup; // Now that there is finally a context current, try doing something useful. + + // Check the version. If we got 1.x then it's all hopeless and we can stop right here. + typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name); + GetString_t GetString = reinterpret_cast(::GetProcAddress(lib, "glGetString")); + if (GetString) { + const char *versionStr = (const char *) GetString(GL_VERSION); + if (versionStr) { + const QByteArray version(versionStr); + const int majorDot = version.indexOf('.'); + if (majorDot != -1) { + int minorDot = version.indexOf('.', majorDot + 1); + if (minorDot == -1) + minorDot = version.size(); + const int major = version.mid(0, majorDot).toInt(); + const int minor = version.mid(majorDot + 1, minorDot - majorDot - 1).toInt(); + qCDebug(lcQpaGl, "Basic wglCreateContext gives version %d.%d", major, minor); + // Try to be as lenient as possible. Missing version, bogus values and + // such are all accepted. The driver may still be functional. Only + // check for known-bad cases, like versions "1.4.0 ...". + if (major == 1) { + result = false; + qCDebug(lcQpaGl, "OpenGL version too low"); + } + } + } + } else { + result = false; + qCDebug(lcQpaGl, "OpenGL 1.x entry points not found"); + } + + // Check for a shader-specific function. if (WGL_GetProcAddress("glCreateShader")) { result = true; qCDebug(lcQpaGl, "OpenGL 2.0 entry points available"); -- cgit v1.2.3 From 3c21c4581dbd957d9f660dd52d0298ecef1001cb Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 7 Jan 2015 13:51:38 +0100 Subject: Fix drag and drop regression Fix regression introduced by e4becdc3d310a0dd1a6d34d0796a52b21dedeb2d Add QPlatformDrag::ownsDragObject() function, QDragManager can use the return value of this function to decide if it should take care of deleting QDrag object or platform plugin will take care of deleting QDrag. XCB platform plugins uses async dnd data delivery mechanism. It allows user to drop something and then continue working with the assurance that the target will get the data regardless of how slow the network connections are, which means that a source window should preserve QDrag data until dnd has finished. Change-Id: I1fbad7380cddec98b756698993dd397409833150 Task-number: QTBUG-43436 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/xcb/qxcbdrag.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbdrag.h | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 7037e102e2..ec0399ed5f 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -999,6 +999,8 @@ void QXcbDrag::handleFinished(const xcb_client_message_event_t *event) if (at != -1) { Transaction t = transactions.takeAt(at); + if (t.drag) + t.drag->deleteLater(); // QDragManager *manager = QDragManager::self(); // Window target = current_target; @@ -1186,6 +1188,11 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) } } +bool QXcbDrag::ownsDragObject() const +{ + return true; +} + QXcbDropData::QXcbDropData(QXcbDrag *d) : QXcbMime(), drag(d) diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index e273492837..63a344a098 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -70,12 +70,11 @@ public: virtual QMimeData *platformDropData(); - - void startDrag(); - void cancel(); - void move(const QMouseEvent *me); - void drop(const QMouseEvent *me); - void endDrag(); + void startDrag() Q_DECL_OVERRIDE; + void cancel() Q_DECL_OVERRIDE; + void move(const QMouseEvent *me) Q_DECL_OVERRIDE; + void drop(const QMouseEvent *me) Q_DECL_OVERRIDE; + void endDrag() Q_DECL_OVERRIDE; void handleEnter(QWindow *window, const xcb_client_message_event_t *event); void handlePosition(QWindow *w, const xcb_client_message_event_t *event); @@ -87,6 +86,7 @@ public: void handleFinished(const xcb_client_message_event_t *event); bool dndEnable(QXcbWindow *win, bool on); + bool ownsDragObject() const Q_DECL_OVERRIDE; void updatePixmap(); xcb_timestamp_t targetTime() { return target_time; } -- cgit v1.2.3 From a8f37e47751d7d29ab63bef55f5849056f826e8b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 15 Jan 2015 17:04:29 +0100 Subject: Windows: Delay creation of the static OpenGL context. Delay initialization/GL detection until a surface is requested. Remove member variable from window and access static context from QWindowsIntegration only. Task-number: QTBUG-43832 Change-Id: I4b9a324b58af4399df5c314bfb2b952455b1e080 Reviewed-by: Laszlo Agocs --- .../platforms/windows/qwindowsintegration.cpp | 35 ++++++++-------------- src/plugins/platforms/windows/qwindowswindow.cpp | 10 +++++-- src/plugins/platforms/windows/qwindowswindow.h | 3 -- 3 files changed, 20 insertions(+), 28 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 82686f38ad..58d675876b 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -130,7 +130,6 @@ struct QWindowsIntegrationPrivate { explicit QWindowsIntegrationPrivate(const QStringList ¶mList); ~QWindowsIntegrationPrivate(); - bool ensureStaticOpenGLContext(); unsigned m_options; QWindowsContext m_context; @@ -266,7 +265,9 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co case OpenGL: return true; case ThreadedOpenGL: - return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->supportsThreadedOpenGL() : false; + if (const QWindowsStaticOpenGLContext *glContext = QWindowsIntegration::staticOpenGLContext()) + return glContext->supportsThreadedOpenGL(); + return false; #endif // !QT_NO_OPENGL case WindowMasks: return true; @@ -312,11 +313,6 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const QWindowSystemInterface::handleGeometryChange(window, QWindowsScaling::mapFromNative(obtained.geometry)); } -#ifndef QT_NO_OPENGL - d->ensureStaticOpenGLContext(); - obtained.staticOpenGLContext = d->m_staticOpenGLContext; -#endif // QT_NO_OPENGL - return obtained; } @@ -377,26 +373,16 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() #endif } -static QWindowsStaticOpenGLContext *q_staticOpenGLContext = 0; - QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create() { - q_staticOpenGLContext = QWindowsStaticOpenGLContext::doCreate(); - return q_staticOpenGLContext; -} - -bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext() -{ - if (m_staticOpenGLContext.isNull()) - m_staticOpenGLContext = QSharedPointer(QWindowsStaticOpenGLContext::create()); - return !m_staticOpenGLContext.isNull(); + return QWindowsStaticOpenGLContext::doCreate(); } QPlatformOpenGLContext *QWindowsIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { qCDebug(lcQpaGl) << __FUNCTION__ << context->format(); - if (d->ensureStaticOpenGLContext()) { - QScopedPointer result(d->m_staticOpenGLContext->createContext(context)); + if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) { + QScopedPointer result(staticOpenGLContext->createContext(context)); if (result->isValid()) return result.take(); } @@ -410,13 +396,18 @@ QOpenGLContext::OpenGLModuleType QWindowsIntegration::openGLModuleType() #elif !defined(QT_OPENGL_DYNAMIC) return QOpenGLContext::LibGL; #else - return d->ensureStaticOpenGLContext() ? d->m_staticOpenGLContext->moduleType() : QOpenGLContext::LibGL; + if (const QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) + return staticOpenGLContext->moduleType(); + return QOpenGLContext::LibGL; #endif } QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext() { - return q_staticOpenGLContext; + QWindowsIntegrationPrivate *d = QWindowsIntegration::instance()->d.data(); + if (d->m_staticOpenGLContext.isNull()) + d->m_staticOpenGLContext = QSharedPointer(QWindowsStaticOpenGLContext::create()); + return d->m_staticOpenGLContext.data(); } #endif // !QT_NO_OPENGL diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index b8ad744d05..926e7da67e 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -37,6 +37,7 @@ #include "qwindowsdrag.h" #include "qwindowsscreen.h" #include "qwindowsscaling.h" +#include "qwindowsintegration.h" #ifdef QT_NO_CURSOR # include "qwindowscursor.h" #endif @@ -958,7 +959,8 @@ void QWindowsWindow::destroyWindow() setDropSiteEnabled(false); #ifndef QT_NO_OPENGL if (m_surface) { - m_data.staticOpenGLContext->destroyWindowSurface(m_surface); + if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) + staticOpenGLContext->destroyWindowSurface(m_surface); m_surface = 0; } #endif @@ -2302,8 +2304,10 @@ void *QWindowsWindow::surface(void *nativeConfig) #ifdef QT_NO_OPENGL return 0; #else - if (!m_surface) - m_surface = m_data.staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig); + if (!m_surface) { + if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) + m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig); + } return m_surface; #endif diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 9822ebce45..922d00f230 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -107,9 +107,6 @@ struct QWindowsWindowData QMargins customMargins; // User-defined, additional frame for NCCALCSIZE HWND hwnd; bool embedded; -#ifndef QT_NO_OPENGL - QSharedPointer staticOpenGLContext; -#endif // QT_NO_OPENGL static QWindowsWindowData create(const QWindow *w, const QWindowsWindowData ¶meters, -- cgit v1.2.3 From 23996a9e4007d12cf3eee8f80cebedaf2bcca2e1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 15 Jan 2015 18:02:38 +0100 Subject: Windows: make TranslucentBackground functional always QOpenGLWidget and QQuickWidget was not functional when WA_TranslucentBackground was set. This is due to the static "isGL" type of checks that are not suitable since 5.3 due to RasterGLSurface windows which may or may not be OpenGL windows, depending on their content. To handle this, we have to do some check on every makeCurrent and perform the necessary calls (most importantly SetLayeredWindowAttributes). Task-number: QTBUG-43854 Change-Id: If19c79482ec4f0a8b795ee710d52ed7e08b52563 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 8 +-- src/plugins/platforms/windows/qwindowscontext.h | 2 +- .../platforms/windows/qwindowseglcontext.cpp | 1 + .../platforms/windows/qwindowsglcontext.cpp | 1 + src/plugins/platforms/windows/qwindowswindow.cpp | 64 +++++++++++++++++----- src/plugins/platforms/windows/qwindowswindow.h | 4 +- 6 files changed, 59 insertions(+), 21 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 13a3d044a0..2dab4f699f 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -430,7 +430,7 @@ void QWindowsContext::setKeyGrabber(QWindow *w) // Window class registering code (from qapplication_win.cpp) -QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) +QString QWindowsContext::registerWindowClass(const QWindow *w) { Q_ASSERT(w); const Qt::WindowFlags flags = w->flags(); @@ -438,7 +438,9 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) // Determine style and icon. uint style = CS_DBLCLKS; bool icon = true; - if (isGL || (flags & Qt::MSWindowsOwnDC)) + // The following will not set CS_OWNDC for any widget window, even if it contains a + // QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage. + if (w->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC)) style |= CS_OWNDC; if (!(flags & Qt::NoDropShadowWindowHint) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) && (type == Qt::Popup || w->property("_q_windowsDropShadow").toBool())) { @@ -471,8 +473,6 @@ QString QWindowsContext::registerWindowClass(const QWindow *w, bool isGL) default: break; } - if (isGL) - cname += QStringLiteral("GL"); if (style & CS_DROPSHADOW) cname += QStringLiteral("DropShadow"); if (style & CS_SAVEBITS) diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 28202219d6..5c2e21192b 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -161,7 +161,7 @@ public: int defaultDPI() const; - QString registerWindowClass(const QWindow *w, bool isGL); + QString registerWindowClass(const QWindow *w); QString registerWindowClass(QString cname, WNDPROC proc, unsigned style = 0, HBRUSH brush = 0, bool icon = false); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index c0d0c1f77c..fbd56e2b02 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -573,6 +573,7 @@ bool QWindowsEGLContext::makeCurrent(QPlatformSurface *surface) QWindowsEGLStaticContext::libEGL.eglBindAPI(m_api); QWindowsWindow *window = static_cast(surface); + window->aboutToMakeCurrent(); EGLSurface eglSurface = static_cast(window->surface(m_eglConfig)); Q_ASSERT(eglSurface); diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 0e3e6826ec..3348241d37 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -1267,6 +1267,7 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface) // Do we already have a DC entry for that window? QWindowsWindow *window = static_cast(surface); + window->aboutToMakeCurrent(); const HWND hwnd = window->handle(); if (const QOpenGLContextData *contextData = findByHWND(m_windowContexts, hwnd)) { // Repeated calls to wglMakeCurrent when vsync is enabled in the driver will diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index e7061dbfde..0b72f6db4d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -205,6 +205,18 @@ static inline QSize clientSize(HWND hwnd) return qSizeOfRect(rect); } +static inline bool windowIsOpenGL(const QWindow *w) +{ + switch (w->surfaceType()) { + case QSurface::OpenGLSurface: + return true; + case QSurface::RasterGLSurface: + return qt_window_private(const_cast(w))->compositing; + default: + return false; + } +} + static bool applyBlurBehindWindow(HWND hwnd) { #ifdef Q_OS_WINCE @@ -328,6 +340,17 @@ static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bo #endif // !Q_OS_WINCE } +static inline void updateGLWindowSettings(const QWindow *w, HWND hwnd, Qt::WindowFlags flags, qreal opacity) +{ + const bool isGL = windowIsOpenGL(w); + const bool hasAlpha = w->format().hasAlpha(); + + if (isGL && hasAlpha) + applyBlurBehindWindow(hwnd); + + setWindowOpacity(hwnd, flags, hasAlpha, isGL, opacity); +} + /*! \class WindowCreationData \brief Window creation code. @@ -369,14 +392,13 @@ struct WindowCreationData void fromWindow(const QWindow *w, const Qt::WindowFlags flags, unsigned creationFlags = 0); inline WindowData create(const QWindow *w, const WindowData &data, QString title) const; inline void applyWindowFlags(HWND hwnd) const; - void initialize(HWND h, bool frameChange, qreal opacityLevel) const; + void initialize(const QWindow *w, HWND h, bool frameChange, qreal opacityLevel) const; Qt::WindowFlags flags; HWND parentHandle; Qt::WindowType type; unsigned style; unsigned exStyle; - bool isGL; bool topLevel; bool popup; bool dialog; @@ -389,7 +411,7 @@ struct WindowCreationData QDebug operator<<(QDebug debug, const WindowCreationData &d) { debug.nospace() << QWindowsWindow::debugWindowFlags(d.flags) - << " GL=" << d.isGL << " topLevel=" << d.topLevel << " popup=" + << " topLevel=" << d.topLevel << " popup=" << d.popup << " dialog=" << d.dialog << " desktop=" << d.desktop << " embedded=" << d.embedded << " tool=" << d.tool << " style=" << debugWinStyle(d.style) @@ -420,8 +442,6 @@ static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags) void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flagsIn, unsigned creationFlags) { - isGL = w->surfaceType() == QWindow::OpenGLSurface; - hasAlpha = w->format().hasAlpha(); flags = flagsIn; // Sometimes QWindow doesn't have a QWindow parent but does have a native parent window, @@ -494,7 +514,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag // ### Commented out for now as it causes some problems, but // this should be correct anyway, so dig some more into this #ifdef Q_FLATTEN_EXPOSE - if (isGL) + if (windowIsOpenGL(w)) // a bit incorrect since the is-opengl status may change from false to true at any time later on style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // see SetPixelFormat #else style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN ; @@ -569,7 +589,7 @@ QWindowsWindowData const HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0); - const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w, isGL); + const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w); const QRect geometryDip = QWindowsScaling::mapFromNative(data.geometry); QRect fixedGeometryDip = QPlatformWindow::initialGeometry(w, geometryDip, defaultWindowWidth, defaultWindowHeight); @@ -612,9 +632,6 @@ QWindowsWindowData result.embedded = embedded; result.customMargins = context->customMargins; - if (isGL && hasAlpha) - applyBlurBehindWindow(result.hwnd); - return result; } @@ -637,7 +654,7 @@ void WindowCreationData::applyWindowFlags(HWND hwnd) const << debugWinExStyle(newExStyle); } -void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLevel) const +void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChange, qreal opacityLevel) const { if (desktop || !hwnd) return; @@ -662,8 +679,7 @@ void WindowCreationData::initialize(HWND hwnd, bool frameChange, qreal opacityLe else EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED); } - - setWindowOpacity(hwnd, flags, hasAlpha, isGL, opacityLevel); + updateGLWindowSettings(w, hwnd, flags, opacityLevel); } else { // child. SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, swpFlags); } @@ -1045,7 +1061,7 @@ QWindowsWindowData creationData.fromWindow(w, parameters.flags); QWindowsWindowData result = creationData.create(w, parameters, title); // Force WM_NCCALCSIZE (with wParam=1) via SWP_FRAMECHANGED for custom margin. - creationData.initialize(result.hwnd, !parameters.customMargins.isNull(), 1); + creationData.initialize(w, result.hwnd, !parameters.customMargins.isNull(), 1); return result; } @@ -1532,7 +1548,7 @@ QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt, WindowCreationData creationData; creationData.fromWindow(window(), wt, flags); creationData.applyWindowFlags(m_data.hwnd); - creationData.initialize(m_data.hwnd, true, m_opacity); + creationData.initialize(window(), m_data.hwnd, true, m_opacity); QWindowsWindowData result = m_data; result.flags = creationData.flags; @@ -2303,4 +2319,22 @@ void *QWindowsWindow::surface(void *nativeConfig) #endif } +void QWindowsWindow::aboutToMakeCurrent() +{ +#ifndef QT_NO_OPENGL + // For RasterGLSurface windows, that become OpenGL windows dynamically, it might be + // time to set up some GL specifics. This is particularly important for layered + // windows (WS_EX_LAYERED due to alpha > 0). + const bool isCompositing = qt_window_private(window())->compositing; + if (isCompositing != testFlag(Compositing)) { + if (isCompositing) + setFlag(Compositing); + else + clearFlag(Compositing); + + updateGLWindowSettings(window(), m_data.hwnd, m_data.flags, m_opacity); + } +#endif +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 9822ebce45..33be287f81 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -140,7 +140,8 @@ public: WithinCreate = 0x20000, WithinMaximize = 0x40000, MaximizeToFullScreen = 0x80000, - InputMethodDisabled =0x100000 + InputMethodDisabled = 0x100000, + Compositing = 0x200000 }; QWindowsWindow(QWindow *window, const QWindowsWindowData &data); @@ -253,6 +254,7 @@ public: void setWindowIcon(const QIcon &icon); void *surface(void *nativeConfig); + void aboutToMakeCurrent(); #ifndef Q_OS_WINCE void setAlertState(bool enabled); -- cgit v1.2.3 From 6a081125a5b1b7d629a2c6e16a696ecc06dbb427 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 19 Jan 2015 11:57:22 +0100 Subject: Make -static -opengl dynamic builds succeed Right now it breaks in qwindowseglcontext due to its ifdefs for static ANGLE-only builds. The checks for QT_STATIC should be extended with QT_OPENGL_DYNAMIC so that it continues to resolve functions dynamically in -opengl dynamic builds even when combined with -static. Task-number: QTBUG-43993 Change-Id: Iac6d0353ef16a32a22ab1db0a833fbb0165f328c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowseglcontext.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowseglcontext.h | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index fbd56e2b02..7fcb1f4ffe 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE QWindowsLibEGL QWindowsEGLStaticContext::libEGL; QWindowsLibGLESv2 QWindowsEGLStaticContext::libGLESv2; -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) #ifdef Q_CC_MINGW static void *resolveFunc(HMODULE lib, const char *name) @@ -111,7 +111,7 @@ void *QWindowsLibEGL::resolve(const char *name) #endif // !QT_STATIC -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) # define RESOLVE(signature, name) signature(resolve( #name )); #else # define RESOLVE(signature, name) signature(&::name); @@ -127,7 +127,7 @@ bool QWindowsLibEGL::init() qCDebug(lcQpaGl) << "Qt: Using EGL from" << dllName; -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16()); if (!m_lib) { qErrnoWarning(::GetLastError(), "Failed to load %s", dllName); @@ -159,7 +159,7 @@ bool QWindowsLibEGL::init() return eglGetError && eglGetDisplay && eglInitialize; } -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *QWindowsLibGLESv2::resolve(const char *name) { void *proc = m_lib ? resolveFunc(m_lib, name) : 0; @@ -179,7 +179,7 @@ bool QWindowsLibGLESv2::init() #endif qCDebug(lcQpaGl) << "Qt: Using OpenGL ES 2.0 from" << dllName; -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16()); if (!m_lib) { qErrnoWarning(::GetLastError(), "Failed to load %s", dllName); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h index 63a7c25a6f..29df3ba882 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.h +++ b/src/plugins/platforms/windows/qwindowseglcontext.h @@ -74,7 +74,7 @@ struct QWindowsLibEGL __eglMustCastToProperFunctionPointerType (EGLAPIENTRY * eglGetProcAddress)(const char *procname); private: -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *resolve(const char *name); HMODULE m_lib; #endif @@ -83,7 +83,8 @@ private: struct QWindowsLibGLESv2 { bool init(); -#ifndef QT_STATIC + +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *moduleHandle() const { return m_lib; } #else void *moduleHandle() const { return Q_NULLPTR; } @@ -238,7 +239,7 @@ struct QWindowsLibGLESv2 void (APIENTRY * glDepthRangef)(GLclampf nearVal, GLclampf farVal); private: -#ifndef QT_STATIC +#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC) void *resolve(const char *name); HMODULE m_lib; #endif -- cgit v1.2.3 From 91d6aafad4805fb760a51f64565929952a37c5bf Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 19 Jan 2015 13:18:17 +0100 Subject: Windows: avoid generating exposes on plain moves The fake expose generation for shrunk windows is causing side effects with desktop GL: it will generate expose events even when only moving the window. This is bad. So change the condition to look for shrinking and do nothing if the size is same as before. This is reported to cause perf issues with e.g. QOpenGLWindow or similar where an expose does an immediate repaint (potentially with block swap). Task-number: QTBUG-32121 Change-Id: I4687ea8210cee6691d608450c48b1dbef52d6df3 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 0b72f6db4d..1d8645f5f4 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1394,7 +1394,7 @@ void QWindowsWindow::handleGeometryChange() // QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive // expose events when shrinking, synthesize. if (!testFlag(OpenGL_ES2) && isExposed() - && !(m_data.geometry.width() > previousGeometry.width() || m_data.geometry.height() > previousGeometry.height())) { + && !(m_data.geometry.width() >= previousGeometry.width() || m_data.geometry.height() >= previousGeometry.height())) { fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); } if (previousGeometry.topLeft() != m_data.geometry.topLeft()) { -- cgit v1.2.3 From 0b62cd8da7d8ee078b799b95088a63626099caa4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Jan 2015 15:00:05 +0100 Subject: Windows: Fix coordinate offset when positioning the taskbar on the left. For windows that do not have WS_EX_TOOLWINDOW set, the WINDOWPLACEMENT API uses workspace/available aera coordinates. Introduce a helper function to return the offset and use that. Task-number: QTBUG-43872 Change-Id: I329c640f180524699b45b855b4583f447c4a0987 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsscreen.cpp | 9 +++++++ src/plugins/platforms/windows/qwindowsscreen.h | 2 ++ src/plugins/platforms/windows/qwindowswindow.cpp | 34 ++++++++++++++++++++---- 3 files changed, 40 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index fd57d9ee61..ae8020a53e 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -497,4 +497,13 @@ bool QWindowsScreenManager::handleScreenChanges() return true; } +const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const +{ + foreach (QWindowsScreen *scr, m_screens) { + if (scr->geometryDp().contains(p)) + return scr; + } + return Q_NULLPTR; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index aa1408358b..28256f3000 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -137,6 +137,8 @@ public: bool handleDisplayChange(WPARAM wParam, LPARAM lParam); const WindowsScreenList &screens() const { return m_screens; } + const QWindowsScreen *screenAtDp(const QPoint &p) const; + private: void removeScreen(int index); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 1d8645f5f4..fbb61a1aff 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -169,6 +169,25 @@ QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p) } #endif // !Q_OS_WINCE +// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT +// is in workspace/available area coordinates. +static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point) +{ +#ifndef Q_OS_WINCE + if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) + return QPoint(0, 0); + const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager(); + const QWindowsScreen *screen = screenManager.screens().size() == 1 + ? screenManager.screens().first() : screenManager.screenAtDp(point); + if (screen) + return screen->availableGeometryDp().topLeft() - screen->geometryDp().topLeft(); +#else + Q_UNUSED(hwnd) + Q_UNUSED(point) +#endif + return QPoint(0, 0); +} + // Return the frame geometry relative to the parent // if there is one. static inline QRect frameGeometry(HWND hwnd, bool topLevel) @@ -179,8 +198,10 @@ static inline QRect frameGeometry(HWND hwnd, bool topLevel) WINDOWPLACEMENT windowPlacement; windowPlacement.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hwnd, &windowPlacement); - if (windowPlacement.showCmd == SW_SHOWMINIMIZED) - return qrectFromRECT(windowPlacement.rcNormalPosition); + if (windowPlacement.showCmd == SW_SHOWMINIMIZED) { + const QRect result = qrectFromRECT(windowPlacement.rcNormalPosition); + return result.translated(windowPlacementOffset(hwnd, result.topLeft())); + } } #endif // !Q_OS_WINCE GetWindowRect(hwnd, &rect); // Screen coordinates. @@ -1297,8 +1318,10 @@ static QRect normalFrameGeometry(HWND hwnd) #ifndef Q_OS_WINCE WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); - if (GetWindowPlacement(hwnd, &wp)) - return qrectFromRECT(wp.rcNormalPosition); + if (GetWindowPlacement(hwnd, &wp)) { + const QRect result = qrectFromRECT(wp.rcNormalPosition); + return result.translated(windowPlacementOffset(hwnd, result.topLeft())); + } #else Q_UNUSED(hwnd) #endif @@ -1427,7 +1450,8 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const // window, set the normal position of the window. if ((windowPlacement.showCmd == SW_MAXIMIZE && !IsWindowVisible(m_data.hwnd)) || windowPlacement.showCmd == SW_SHOWMINIMIZED) { - windowPlacement.rcNormalPosition = RECTfromQRect(frameGeometry); + windowPlacement.rcNormalPosition = + RECTfromQRect(frameGeometry.translated(-windowPlacementOffset(m_data.hwnd, frameGeometry.topLeft()))); windowPlacement.showCmd = windowPlacement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWMINIMIZED : SW_HIDE; result = SetWindowPlacement(m_data.hwnd, &windowPlacement); } else -- cgit v1.2.3 From 9e4ef3539a5770f1b422b73b41dc3218ff4efc81 Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Tue, 20 Jan 2015 12:40:50 +0100 Subject: Fix finding widgets for Windows Embedded Compact ChildWindowFromPoint does not work properly under wince, so lets use the plain old WindowFromPoint. Task-number: QTBUG-44022 Change-Id: I49bae6409f2d11ddc01bea01f4c2f91a02b90892 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 13a3d044a0..ffa7f82d8e 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -676,7 +676,7 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c const HWND child = ChildWindowFromPointEx(*hwnd, point, cwexFlags); #else Q_UNUSED(cwexFlags) - const HWND child = ChildWindowFromPoint(*hwnd, point); + const HWND child = WindowFromPoint(point); #endif if (!child || child == *hwnd) return false; -- cgit v1.2.3 From 06602f9c96e9ea07851fa1d8a43b9792a825c4cd Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Jan 2015 10:48:39 +0100 Subject: Android: Don't force-include android-9 headers in qpa plugin When we supported platforms < android-9, we needed to include some headers which were introduced in android-9 to compile the QPA plugin. This is no longer needed, and also creates problems when you pick e.g. android-21 as your platform, since some definitions (specifically fd_set) are different in the two sets of headers, giving us an undefined reference to QEventDispatcherUNIX::select(). Change-Id: Ifd28479b4bf3be0e9e62200a01fc4cf2cc855215 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/android.pro | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index 3c3a4b4b2e..e6f4db0e94 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -8,12 +8,7 @@ DEFINES += QT_STATICPLUGIN load(qt_plugin) -!contains(ANDROID_PLATFORM, android-9) { - INCLUDEPATH += $$NDK_ROOT/platforms/android-9/arch-$$ANDROID_ARCHITECTURE/usr/include - LIBS += -L$$NDK_ROOT/platforms/android-9/arch-$$ANDROID_ARCHITECTURE/usr/lib -ljnigraphics -landroid -} else { - LIBS += -ljnigraphics -landroid -} +LIBS += -ljnigraphics -landroid QT += core-private gui-private platformsupport-private -- cgit v1.2.3 From db853fa75dc6598b30ce512997fc8bad0a37354f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Jan 2015 10:52:33 +0100 Subject: Android: Fix name of header in .pro file Gets rid of warning that the file is missing, but probably doesn't have any other effect since the file in question does not require moc-ing. Change-Id: I22085a55c212b6285341d61462dfaf548787e11c Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/android.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro index e6f4db0e94..3ba817bf5b 100644 --- a/src/plugins/platforms/android/android.pro +++ b/src/plugins/platforms/android/android.pro @@ -49,7 +49,7 @@ SOURCES += $$PWD/androidplatformplugin.cpp \ $$PWD/qandroideventdispatcher.cpp HEADERS += $$PWD/qandroidplatformintegration.h \ - $$PWD/androidandroiddeadlockprotector.h \ + $$PWD/androiddeadlockprotector.h \ $$PWD/androidjnimain.h \ $$PWD/androidjniaccessibility.h \ $$PWD/androidjniinput.h \ -- cgit v1.2.3 From 2b5df245d6cdbfb3150ee815debccf655af8f19f Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Tue, 20 Jan 2015 13:17:36 +0100 Subject: Implement Multitouch handling for WinCE Implemented handling of GID_DirectManipulation for WinCE. Derive touch information out of gesture event directmanipulation. Task-number: QTBUG-31216 Change-Id: I74e90f32d2384fc3550b47af0b72edf0292dea8f Reviewed-by: Friedemann Kleint --- .../platforms/windows/qtwindows_additional.h | 4 + src/plugins/platforms/windows/qtwindowsglobal.h | 3 + src/plugins/platforms/windows/qwindowscontext.cpp | 2 + .../platforms/windows/qwindowsmousehandler.cpp | 86 +++++++++++++++++++++- .../platforms/windows/qwindowsmousehandler.h | 4 + src/plugins/platforms/windows/qwindowswindow.cpp | 4 + 6 files changed, 100 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qtwindows_additional.h b/src/plugins/platforms/windows/qtwindows_additional.h index 9451b9ce55..4e77350132 100644 --- a/src/plugins/platforms/windows/qtwindows_additional.h +++ b/src/plugins/platforms/windows/qtwindows_additional.h @@ -166,4 +166,8 @@ typedef TOUCHINPUT const * PCTOUCHINPUT; #endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE) +#ifndef WM_GESTURE +# define WM_GESTURE 0x0119 +#endif + #endif // QTWINDOWS_ADDITIONAL_H diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h index 90e6d6ab9d..083d82ed8c 100644 --- a/src/plugins/platforms/windows/qtwindowsglobal.h +++ b/src/plugins/platforms/windows/qtwindowsglobal.h @@ -109,6 +109,7 @@ enum WindowsEventType // Simplify event types DisplayChangedEvent = 437, SettingChangedEvent = DisplayChangedEvent + 1, ContextMenu = 123, + GestureEvent = 124, UnknownEvent = 542 }; @@ -247,6 +248,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI case WM_APPCOMMAND: return QtWindows::AppCommandEvent; #endif + case WM_GESTURE: + return QtWindows::GestureEvent; default: break; } diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 2dab4f699f..1cc596ca8d 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -905,6 +905,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return QWindowsInputContext::instance()->endComposition(hwnd); case QtWindows::InputMethodRequest: return QWindowsInputContext::instance()->handleIME_Request(wParam, lParam, result); + case QtWindows::GestureEvent: + return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); case QtWindows::InputMethodOpenCandidateWindowEvent: case QtWindows::InputMethodCloseCandidateWindowEvent: // TODO: Release/regrab mouse if a popup has mouse grab. diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index acb692579b..0fa34041d6 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -422,11 +422,12 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, } // from bool QApplicationPrivate::translateTouchEvent() -bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, +bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType, MSG msg, LRESULT *) { #ifndef Q_OS_WINCE + Q_UNUSED(hwnd); typedef QWindowSystemInterface::TouchPoint QTouchPoint; typedef QList QTouchPointList; @@ -495,8 +496,87 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, m_touchDevice, touchPoints); return true; -#else - return false; +#else //Q_OS_WINCE + GESTUREINFO gi; + memset(&gi, 0, sizeof(GESTUREINFO)); + gi.cbSize = sizeof(GESTUREINFO); + + if (!GetGestureInfo((HGESTUREINFO)msg.lParam, &gi)) + return false; + + const QPoint position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y); + + if (gi.dwID != GID_DIRECTMANIPULATION) + return true; + static QPoint lastTouchPos; + const QRect screenGeometry = window->screen()->geometry(); + QWindowSystemInterface::TouchPoint touchPoint; + static QWindowSystemInterface::TouchPoint touchPoint2; + touchPoint.id = 0;//gi.dwInstanceID; + touchPoint.pressure = 1.0; + + if (gi.dwFlags & GF_BEGIN) + touchPoint.state = Qt::TouchPointPressed; + else if (gi.dwFlags & GF_END) + touchPoint.state = Qt::TouchPointReleased; + else if (gi.dwFlags == 0) + touchPoint.state = Qt::TouchPointMoved; + else + return true; + touchPoint2.pressure = 1.0; + touchPoint2.id = 1; + const QPoint winEventPosition = position; + const int deltaX = GID_DIRECTMANIPULATION_DELTA_X(gi.ullArguments); + const int deltaY = GID_DIRECTMANIPULATION_DELTA_Y(gi.ullArguments); + //Touch points are taken from the whole screen so map the position to the screen + const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition); + const QPoint globalPosition2 = QWindowsGeometryHint::mapToGlobal(hwnd, QPoint(position.x() + deltaX, position.y() + deltaY)); + + touchPoint.normalPosition = + QPointF( (qreal)globalPosition.x() / screenGeometry.width(), (qreal)globalPosition.y() / screenGeometry.height() ); + + touchPoint.area.moveCenter(globalPosition); + + QList pointList; + pointList.append(touchPoint); + if (deltaX != 0 && deltaY != 0) { + touchPoint2.state = m_had2ndTouchPoint ? Qt::TouchPointMoved : Qt::TouchPointPressed; + m_had2ndTouchPoint = true; + touchPoint2.normalPosition = + QPointF( (qreal)globalPosition2.x() / screenGeometry.width(), (qreal)globalPosition2.y() / screenGeometry.height() ); + + touchPoint2.area.moveCenter(globalPosition2); + lastTouchPos = globalPosition2; + pointList.append(touchPoint2); + } else if (m_had2ndTouchPoint) { + touchPoint2.normalPosition = + QPointF( (qreal)lastTouchPos.x() / screenGeometry.width(), (qreal)lastTouchPos.y() / screenGeometry.height() ); + + touchPoint2.area.moveCenter(lastTouchPos); + touchPoint2.state = Qt::TouchPointReleased; + pointList.append(touchPoint2); + m_had2ndTouchPoint = false; + } + + if (!m_touchDevice) { + m_touchDevice = new QTouchDevice; + // TODO: Device used to be hardcoded to screen in previous code. + m_touchDevice->setType(QTouchDevice::TouchScreen); + m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition); + QWindowSystemInterface::registerTouchDevice(m_touchDevice); + } + + QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, pointList); + // handle window focusing in/out + if (window != m_windowUnderMouse) { + if (m_windowUnderMouse) + QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse); + if (window) + QWindowSystemInterface::handleEnterEvent(window); + m_windowUnderMouse = window; + } + + return true; #endif } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h index 6491de93b5..60fe26b2b9 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.h +++ b/src/plugins/platforms/windows/qwindowsmousehandler.h @@ -79,6 +79,10 @@ private: QTouchDevice *m_touchDevice; bool m_leftButtonDown; QWindow *m_previousCaptureWindow; +#ifdef Q_OS_WINCE +//This is required to send a touch up if we don't get a second touch position any more + bool m_had2ndTouchPoint; +#endif }; Qt::MouseButtons QWindowsMouseHandler::keyStateToMouseButtons(int wParam) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index fbb61a1aff..2e5308f157 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -639,6 +639,10 @@ QWindowsWindowData context->frameX, context->frameY, context->frameWidth, context->frameHeight, parentHandle, NULL, appinst, NULL); +#ifdef Q_OS_WINCE + if (DisableGestures(result.hwnd, TGF_GID_ALL, TGF_SCOPE_WINDOW)) + EnableGestures(result.hwnd, TGF_GID_DIRECTMANIPULATION, TGF_SCOPE_WINDOW); +#endif qCDebug(lcQpaWindows).nospace() << "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: " << context->obtainedGeometry << context->margins; -- cgit v1.2.3 From 5b1da97b6b4a011f9ce5582869a7a957f6f1369c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Jan 2015 13:23:41 +0100 Subject: Revert "Fix font enumeration, with the same family name, on Windows." This reverts commit 8456adf0eeb9df8dd5f0547d4ad5a81888295f03. The change introduces a massive slowdown of the application startup caused by the inner enumeration. Task-number: QTBUG-43774 Task-number: QTBUG-40828 Change-Id: I694938eab93ea409d97537b55e8a025bb7a0e393 Reviewed-by: Konstantin Ritt --- .../platforms/windows/qwindowsfontdatabase.cpp | 36 ++-------------------- .../platforms/windows/qwindowsfontdatabase_ft.cpp | 36 ++-------------------- 2 files changed, 4 insertions(+), 68 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index f15783490e..246032dc94 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -964,31 +964,6 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr return 1; } -static int QT_WIN_CALLBACK storeFontSub(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) -{ - Q_UNUSED(textmetric) - Q_UNUSED(type) - - HDC dummy = GetDC(0); - LOGFONT lf; - lf.lfCharSet = DEFAULT_CHARSET; - if (wcslen(f->elfLogFont.lfFaceName) >= LF_FACESIZE) { - qWarning("%s: Unable to enumerate family '%s'.", - __FUNCTION__, qPrintable(QString::fromWCharArray(f->elfLogFont.lfFaceName))); - return 1; - } - wmemcpy(lf.lfFaceName, f->elfLogFont.lfFaceName, - wcslen(f->elfLogFont.lfFaceName) + 1); - lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)namesSetIn, 0); - ReleaseDC(0, dummy); - - // keep on enumerating - return 1; -} - void QWindowsFontDatabase::populateFontDatabase() { m_families.clear(); @@ -1024,15 +999,8 @@ void QWindowsFontDatabase::populate(const QString &family) wmemcpy(lf.lfFaceName, reinterpret_cast(family.utf16()), family.size() + 1); lf.lfPitchAndFamily = 0; - - if (family.isEmpty()) { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFontSub, - (LPARAM)&m_families, 0); - } else { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)&m_families, 0); - } - + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, + (LPARAM)&m_families, 0); ReleaseDC(0, dummy); } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 42e5a8c6ad..0fc5e0dc0c 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -375,31 +375,6 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr return 1; } -static int QT_WIN_CALLBACK storeFontSub(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) -{ - Q_UNUSED(textmetric) - Q_UNUSED(type) - - HDC dummy = GetDC(0); - LOGFONT lf; - lf.lfCharSet = DEFAULT_CHARSET; - if (wcslen(f->elfLogFont.lfFaceName) >= LF_FACESIZE) { - qWarning("%s: Unable to enumerate family '%s'.", - __FUNCTION__, qPrintable(QString::fromWCharArray(f->elfLogFont.lfFaceName))); - return 1; - } - wmemcpy(lf.lfFaceName, f->elfLogFont.lfFaceName, - wcslen(f->elfLogFont.lfFaceName) + 1); - lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)namesSetIn, 0); - ReleaseDC(0, dummy); - - // keep on enumerating - return 1; -} - void QWindowsFontDatabaseFT::populateFontDatabase() { m_families.clear(); @@ -434,15 +409,8 @@ void QWindowsFontDatabaseFT::populate(const QString &family) wmemcpy(lf.lfFaceName, reinterpret_cast(family.utf16()), family.size() + 1); lf.lfPitchAndFamily = 0; - - if (family.isEmpty()) { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFontSub, - (LPARAM)&m_families, 0); - } else { - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)&m_families, 0); - } - + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, + (LPARAM)&m_families, 0); ReleaseDC(0, dummy); } -- cgit v1.2.3 From 44ab91aaa131c5a2c398cf30a97046578150db38 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Jan 2015 19:40:35 +0100 Subject: Windows/ANGLE: Fix initialization of contexts. Immediately try to initialize a context obtained by eglGetPlatformDisplayEXT() and clear display in case it fails, falling back to eglGetDisplay(). Change-Id: Ia6c1c6da4daff6651153c854eda4fb8749bdc526 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowseglcontext.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index bde0503ee0..7f0421ad90 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -358,6 +358,8 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: } EGLDisplay display = EGL_NO_DISPLAY; + EGLint major = 0; + EGLint minor = 0; #ifdef EGL_ANGLE_platform_angle_opengl if (libEGL.eglGetPlatformDisplayEXT && (preferredType & QWindowsOpenGLTester::AngleBackendMask)) { @@ -373,8 +375,13 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: attributes = anglePlatformAttributes[1]; else if (preferredType & QWindowsOpenGLTester::AngleRendererD3d11Warp) attributes = anglePlatformAttributes[2]; - if (attributes) + if (attributes) { display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes); + if (!libEGL.eglInitialize(display, &major, &minor)) { + display = EGL_NO_DISPLAY; + major = minor = 0; + } + } } #else // EGL_ANGLE_platform_angle_opengl Q_UNUSED(preferredType) @@ -386,9 +393,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester: return 0; } - EGLint major; - EGLint minor; - if (!libEGL.eglInitialize(display, &major, &minor)) { + if (!major && !libEGL.eglInitialize(display, &major, &minor)) { int err = libEGL.eglGetError(); qWarning("%s: Could not initialize EGL display: error 0x%x\n", Q_FUNC_INFO, err); if (err == 0x3001) -- cgit v1.2.3 From f8c8c79029867a087c9a753269d82b808c16f047 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 2 Feb 2015 13:10:50 +0100 Subject: Fix build of egl integration Add missing includes and reorder includes to avoid X defines breakage Change-Id: Iaf95ae2488df3d3301436262ed79f7091b4be0a9 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/eglfs/qeglfscontext.cpp | 13 +++++++------ src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | 2 +- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 20 ++++++++++---------- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 4 +++- src/plugins/platforms/eglfs/qeglfswindow.cpp | 6 ++++-- .../platforms/minimalegl/qminimaleglwindow.cpp | 4 ++-- 6 files changed, 27 insertions(+), 22 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 6216fa8575..6470280e2c 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -31,15 +31,16 @@ ** ****************************************************************************/ -#include "qeglfscontext.h" -#include "qeglfswindow.h" -#include "qeglfshooks.h" +#include +#include +#include #include #include -#include -#include -#include + +#include "qeglfswindow.h" +#include "qeglfshooks.h" +#include "qeglfscontext.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp index 26d77a2abb..120c603125 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp @@ -31,10 +31,10 @@ ** ****************************************************************************/ -#include "qeglfshooks.h" #include #include #include +#include "qeglfshooks.h" #if defined(Q_OS_LINUX) #include diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2a4eae3fe2..fbdd1d4c4d 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -31,26 +31,26 @@ ** ****************************************************************************/ -#include "qeglfsintegration.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include "qeglfsintegration.h" #include "qeglfswindow.h" #include "qeglfshooks.h" #include "qeglfscontext.h" -#include - #include #include #include #include -#include -#include -#include -#include -#include -#include - #include static void initResources() diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index cd68540581..bc93fe28e7 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -31,10 +31,12 @@ ** ****************************************************************************/ +#include +#include + #include "qeglfsscreen.h" #include "qeglfswindow.h" #include "qeglfshooks.h" -#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index f5839e086d..39a3ef94e9 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -31,8 +31,7 @@ ** ****************************************************************************/ -#include "qeglfswindow.h" -#include "qeglfshooks.h" +#include #include #include #include @@ -40,6 +39,9 @@ #include #include +#include "qeglfswindow.h" +#include "qeglfshooks.h" + #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp index 906a1308da..d4bee2c9e4 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp @@ -31,10 +31,10 @@ ** ****************************************************************************/ -#include "qminimaleglwindow.h" - #include +#include "qminimaleglwindow.h" + QT_BEGIN_NAMESPACE QMinimalEglWindow::QMinimalEglWindow(QWindow *w) -- cgit v1.2.3 From 392d8b5a75b4ac70b3dc4e856793771d86c50d82 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 Jan 2015 15:20:07 +0100 Subject: Windows: Fix screen changed emission for programmatic moves. Assign geometry in setGeometryDp() only when minimized as otherwise the variable will be set by the handling of the resize event triggered by setGeometry_sys()handleGeometryChange(). As it is, it suppresses the emission of screen change signals for programmatic move operations since the move is not detected. Change-Id: I5cd32bb16fd41dd720c16ddf84b88df642677af7 Task-number: QTBUG-44070 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 65bc9742e4..c268954314 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1356,7 +1356,8 @@ void QWindowsWindow::setGeometryDp(const QRect &rectIn) const QMargins margins = frameMarginsDp(); rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top())); } - m_data.geometry = rect; + if (m_windowState == Qt::WindowMinimized) + m_data.geometry = rect; // Otherwise set by handleGeometryChange() triggered by event. if (m_data.hwnd) { // A ResizeEvent with resulting geometry will be sent. If we cannot // achieve that size (for example, window title minimal constraint), -- cgit v1.2.3 From c96b5d2b062e2757772a81927936e2a81be41c8e Mon Sep 17 00:00:00 2001 From: Daiwei Li Date: Thu, 22 Jan 2015 02:32:27 -0800 Subject: Cocoa: Keep menu invisible when adding it to a menubar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In MenuBar.qml, it's possible for __isNative to be set after visible on a child QQuickMenu. In that case, the qcocoamenu.mm will have set submenu to nil, only to be overridden in insertNativeMenu when __isNative is set. Change-Id: Id3c6bca03f937528d05b166cbd6a6d1011db43e8 Task-number: QTBUG-44168 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index aceb9b619b..0b46508782 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -100,7 +100,9 @@ void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu) menu->setMenuBar(this); syncMenu(static_cast(menu)); - [m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()]; + if (menu->isVisible()) { + [m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()]; + } } void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before) -- cgit v1.2.3 From c88e354993f8db3da741b1492f7578e9e0fdb07f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Jan 2015 16:18:00 +0100 Subject: Windows: Rewrite font database to use delayed population. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-43774 Change-Id: I3b0b0ead0953b3b88a6d0092c694a2a00f70acf7 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Konstantin Ritt Reviewed-by: Tor Arne Vestbø --- .../platforms/windows/qwindowsfontdatabase.cpp | 83 +++++++++++++--------- .../platforms/windows/qwindowsfontdatabase.h | 3 +- 2 files changed, 51 insertions(+), 35 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 246032dc94..9c26a227b8 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -946,9 +946,8 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, } static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM namesSetIn) + int type, LPARAM) { - typedef QSet StringSet; const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName); const uchar charSet = f->elfLogFont.lfCharSet; @@ -957,51 +956,69 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is // identical to a TEXTMETRIC except for the last four members, which we don't use // anyway - if (addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type)) - reinterpret_cast(namesSetIn)->insert(familyName); + addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type); // keep on enumerating return 1; } -void QWindowsFontDatabase::populateFontDatabase() +void QWindowsFontDatabase::populateFamily(const QString &familyName) { - m_families.clear(); - removeApplicationFonts(); - populate(); // Called multiple times. - // Work around EnumFontFamiliesEx() not listing the system font, see below. - const QString sysFontFamily = QGuiApplication::font().family(); - if (!m_families.contains(sysFontFamily)) - populate(sysFontFamily); + qCDebug(lcQpaFonts) << familyName; + if (familyName.size() >= LF_FACESIZE) { + qCWarning(lcQpaFonts) << "Unable to enumerate family '" << familyName << '\''; + return; + } + HDC dummy = GetDC(0); + LOGFONT lf; + lf.lfCharSet = DEFAULT_CHARSET; + familyName.toWCharArray(lf.lfFaceName); + lf.lfFaceName[familyName.size()] = 0; + lf.lfPitchAndFamily = 0; + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, 0, 0); + ReleaseDC(0, dummy); } -/*! - \brief Populate font database using EnumFontFamiliesEx(). - - Normally, leaving the name empty should enumerate - all fonts, however, system fonts like "MS Shell Dlg 2" - are only found when specifying the name explicitly. -*/ +namespace { +// Context for enumerating system fonts, records whether the default font has been encountered, +// which is normally not enumerated by EnumFontFamiliesEx(). +struct PopulateFamiliesContext +{ + PopulateFamiliesContext(const QString &f) : systemDefaultFont(f), seenSystemDefaultFont(false) {} -void QWindowsFontDatabase::populate(const QString &family) - { + QString systemDefaultFont; + bool seenSystemDefaultFont; +}; +} // namespace - qCDebug(lcQpaFonts) << __FUNCTION__ << m_families.size() << family; +static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *, int, LPARAM lparam) +{ + // the "@family" fonts are just the same as "family". Ignore them. + const wchar_t *faceNameW = f->elfLogFont.lfFaceName; + if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) { + const QString faceName = QString::fromWCharArray(faceNameW); + QPlatformFontDatabase::registerFontFamily(faceName); + PopulateFamiliesContext *context = reinterpret_cast(lparam); + if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont) + context->seenSystemDefaultFont = true; + } + return 1; // continue +} +void QWindowsFontDatabase::populateFontDatabase() +{ + removeApplicationFonts(); HDC dummy = GetDC(0); LOGFONT lf; lf.lfCharSet = DEFAULT_CHARSET; - if (family.size() >= LF_FACESIZE) { - qWarning("%s: Unable to enumerate family '%s'.", - __FUNCTION__, qPrintable(family)); - return; - } - wmemcpy(lf.lfFaceName, reinterpret_cast(family.utf16()), - family.size() + 1); + lf.lfFaceName[0] = 0; lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, - (LPARAM)&m_families, 0); + PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family()); + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontFamilies, reinterpret_cast(&context), 0); ReleaseDC(0, dummy); + // Work around EnumFontFamiliesEx() not listing the system font. + if (!context.seenSystemDefaultFont) + QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont); } typedef QSharedPointer QWindowsFontEngineDataPtr; @@ -1365,7 +1382,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, // Fonts based on files are added via populate, as they will show up in font enumeration. for (int j = 0; j < families.count(); ++j) - populate(families.at(j)); + populateFamily(families.at(j)); } m_applicationFonts << font; @@ -1645,7 +1662,7 @@ QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFon result.append(QWindowsFontDatabase::extraTryFontsForFamily(family)); qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint - << script << result << m_families.size(); + << script << result; return result; } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index 4abf2d703e..8a682e6bec 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -70,6 +70,7 @@ public: ~QWindowsFontDatabase(); void populateFontDatabase() Q_DECL_OVERRIDE; + void populateFamily(const QString &familyName) Q_DECL_OVERRIDE; QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) Q_DECL_OVERRIDE; QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE; QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE; @@ -99,9 +100,7 @@ public: static QString familyForStyleHint(QFont::StyleHint styleHint); private: - void populate(const QString &family = QString()); void removeApplicationFonts(); - QSet m_families; struct WinApplicationFont { HANDLE handle; -- cgit v1.2.3 From 912f1ebaad29e5a0b8acba48691a565ba56c6b9e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Jan 2015 16:39:12 +0100 Subject: Windows: Pass geometry in device-independent pixel when determining screen. Fixes the emission of QWindow::screenChanged() when running with QT_DEVICE_PIXEL_RATIO != 1. QPlatformScreen::screenForGeometry() takes device-independent pixel. Task-number: QTBUG-44070 Change-Id: I963ecf62743d06784d62bc2f467e09fe5474e57f Reviewed-by: Alessandro Portale --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index c268954314..0216b40e3e 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1432,7 +1432,7 @@ void QWindowsWindow::handleGeometryChange() fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); } if (previousGeometry.topLeft() != m_data.geometry.topLeft()) { - QPlatformScreen *newScreen = screenForGeometry(m_data.geometry); + QPlatformScreen *newScreen = screenForGeometry(geometryDip); if (newScreen != screen()) QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); } -- cgit v1.2.3 From 1b329bfc79d34d7859e27a1fc2aa6eb58e690dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 22 Jan 2015 14:59:19 +0100 Subject: Cocoa: Don't crash on no target window. findEventTargetWindow() will return 0 if m_window is a top-level window with Qt::WindowTransparentForInput set. Change-Id: I413dabf2a8993b0522653c4e586bb304b642f3ed Task-number: QTBUG-44013 Reviewed-by: Timur Pocheptsov Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 771b464805..5d3befa25b 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1824,6 +1824,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]); QWindow *target = findEventTargetWindow(m_window); + if (!target) + return NSDragOperationNone; // update these so selecting move/copy/link works QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers: [[NSApp currentEvent] modifierFlags]]; @@ -1843,6 +1845,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (void)draggingExited:(id )sender { QWindow *target = findEventTargetWindow(m_window); + if (!target) + return; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); @@ -1855,6 +1859,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (BOOL)performDragOperation:(id )sender { QWindow *target = findEventTargetWindow(m_window); + if (!target) + return false; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); @@ -1880,6 +1886,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin Q_UNUSED(img); Q_UNUSED(operation); QWindow *target = findEventTargetWindow(m_window); + if (!target) + return; // keep our state, and QGuiApplication state (buttons member) in-sync, // or future mouse events will be processed incorrectly -- cgit v1.2.3 From 612953a626ec21b8518ee23a4f5268b566cf41e5 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 29 Jan 2015 16:22:08 +0100 Subject: xcb: delay showing tray icon window until it is embedded Otherwise there is a race condition: when the tray implementation gets around to embedding the window, if it was already shown, it will be unmapped, embedded, and then remapped. Some tray implementations will resize the tray icon to 1 pixel wide in that case. We also never want to show a window that was intended for the tray in any other location, so it's better that it remain invisible until we are sure it is embedded. Task-number: QTBUG-31762 Task-number: QTBUG-35658 Task-number: QTBUG-32811 Change-Id: Id324b0bfded0f8258ff1686a223cb2c069827d42 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4fd71f1635..96c5663d83 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -755,6 +755,9 @@ void QXcbWindow::show() if (connection()->time() != XCB_TIME_CURRENT_TIME) updateNetWmUserTime(connection()->time()); + if (window()->objectName() == QLatin1String("QSystemTrayIconSysWindow")) + return; // defer showing until XEMBED_EMBEDDED_NOTIFY + Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); if (QGuiApplication::modalWindow() == window()) @@ -2338,7 +2341,10 @@ void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event) switch (event->data.data32[1]) { case XEMBED_WINDOW_ACTIVATE: case XEMBED_WINDOW_DEACTIVATE: + break; case XEMBED_EMBEDDED_NOTIFY: + Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); + m_screen->windowShown(this); break; case XEMBED_FOCUS_IN: Qt::FocusReason reason; -- cgit v1.2.3 From 0d990b9ca117514fe83f53b39f25d6272304f2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A5re=20S=C3=A4rs?= Date: Thu, 22 Jan 2015 22:40:37 +0200 Subject: Fix Meta+... shortcuts on XCB If the window contains a widget that accepts text input, a Meta+... shortcut will be interpreted as if no modifier was pressed. This fix enables the usage of Meta+... shortcuts for the XCB platform plugin. Change-Id: I80034b7e6bbbf18471c86fc77320d5038f5740be Task-number: QTBUG-43572 Reviewed-by: Aleix Pol Gonzalez Reviewed-by: Milian Wolff Reviewed-by: David Edmundson Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 5fb745717b..85fef3912c 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -933,7 +933,7 @@ xkb_keysym_t QXcbKeyboard::lookupLatinKeysym(xkb_keycode_t keycode) const QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const { // turn off the modifier bits which doesn't participate in shortcuts - Qt::KeyboardModifiers notNeeded = Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier; + Qt::KeyboardModifiers notNeeded = Qt::KeypadModifier | Qt::GroupSwitchModifier; Qt::KeyboardModifiers modifiers = event->modifiers() &= ~notNeeded; // create a fresh kb state and test against the relevant modifier combinations struct xkb_state *kb_state = xkb_state_new(xkb_keymap); @@ -963,10 +963,12 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(xkb_keymap, "Shift"); xkb_mod_index_t altMod = xkb_keymap_mod_get_index(xkb_keymap, "Alt"); xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control"); + xkb_mod_index_t metaMod = xkb_keymap_mod_get_index(xkb_keymap, "Meta"); Q_ASSERT(shiftMod < 32); Q_ASSERT(altMod < 32); Q_ASSERT(controlMod < 32); + Q_ASSERT(metaMod < 32); xkb_mod_mask_t depressed; int qtKey = 0; @@ -987,6 +989,8 @@ QList QXcbKeyboard::possibleKeys(const QKeyEvent *event) const depressed |= (1 << shiftMod); if (neededMods & Qt::ControlModifier) depressed |= (1 << controlMod); + if (neededMods & Qt::MetaModifier) + depressed |= (1 << metaMod); xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, 0, 0, lockedLayout); sym = xkb_state_key_get_one_sym(kb_state, keycode); } -- cgit v1.2.3