summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp32
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp101
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h5
-rw-r--r--src/plugins/platforms/windows/qwindowsopenglcontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp256
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.h79
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp18
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h3
-rw-r--r--src/plugins/platforms/windows/windows.pri11
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp7
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.h12
15 files changed, 452 insertions, 90 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 1cc596ca8d..c253a9605b 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;
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 7fcb1f4ffe..f52c5b733c 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){
@@ -358,28 +358,34 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create()
}
EGLDisplay display = EGL_NO_DISPLAY;
+ EGLint major = 0;
+ EGLint minor = 0;
#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)
+ if (attributes) {
display = libEGL.eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc, attributes);
+ if (!libEGL.eglInitialize(display, &major, &minor)) {
+ display = EGL_NO_DISPLAY;
+ major = minor = 0;
+ }
+ }
}
-#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) {
@@ -387,9 +393,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create()
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)
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h
index 29df3ba882..c2b153e4c1 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 <EGL/egl.h>
QT_BEGIN_NAMESPACE
@@ -250,7 +251,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/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.
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 54fb138d85..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 &paramList);
~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;
}
@@ -328,61 +324,65 @@ 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;
-
- return ctx;
}
-bool QWindowsIntegrationPrivate::ensureStaticOpenGLContext()
+QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::create()
{
- if (m_staticOpenGLContext.isNull())
- m_staticOpenGLContext = QSharedPointer<QWindowsStaticOpenGLContext>(QWindowsStaticOpenGLContext::create());
- return !m_staticOpenGLContext.isNull();
+ return QWindowsStaticOpenGLContext::doCreate();
}
QPlatformOpenGLContext *QWindowsIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
qCDebug(lcQpaGl) << __FUNCTION__ << context->format();
- if (d->ensureStaticOpenGLContext()) {
- QScopedPointer<QWindowsOpenGLContext> result(d->m_staticOpenGLContext->createContext(context));
+ if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) {
+ QScopedPointer<QWindowsOpenGLContext> result(staticOpenGLContext->createContext(context));
if (result->isValid())
return result.take();
}
@@ -396,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>(QWindowsStaticOpenGLContext::create());
+ return d->m_staticOpenGLContext.data();
}
#endif // !QT_NO_OPENGL
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/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 ba3a95ce7a..f6caf8b06e 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,231 @@
****************************************************************************/
#include "qwindowsopengltester.h"
-#include "qt_windows.h"
#include "qwindowscontext.h"
+#include <QtCore/QVariantMap>
+#include <QtCore/QDebug>
+#include <QtCore/QTextStream>
+#include <QtCore/QCoreApplication>
+
+#ifndef Q_OS_WINCE
+# include <QtCore/qt_windows.h>
+# include <private/qsystemlibrary_p.h>
+# include <d3d9.h>
+# include <GL/gl.h>
+#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;
+}
+
+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
HMODULE lib = 0;
HWND wnd = 0;
HDC dc = 0;
@@ -109,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<GetString_t>(::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");
@@ -133,6 +382,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..6238eea4b0 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,14 +31,91 @@
**
****************************************************************************/
+#ifndef QWINDOWSOPENGLTESTER_H
+#define QWINDOWSOPENGLTESTER_H
+
#include <qtwindowsglobal.h>
+#include <QtCore/QByteArray>
+#include <QtCore/QFlags>
+
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:
+ 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
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 2e5308f157..65bc9742e4 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
@@ -555,8 +556,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;
@@ -995,7 +1000,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
@@ -2340,8 +2346,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 33be287f81..6d6d473ccd 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<QWindowsStaticOpenGLContext> staticOpenGLContext;
-#endif // QT_NO_OPENGL
static QWindowsWindowData create(const QWindow *w,
const QWindowsWindowData &parameters,
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
}
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; }