summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-11-23 07:13:00 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-11-23 07:13:00 +0100
commit1ed7a67a4cef8350103e4ea33b4bbd084f5d4c2d (patch)
tree03dd7b6f8d9ccc02da6d0d882793ec62c71b00f7 /src/plugins
parentdbb7817e13bc7f7ccb8f04b00a65eb3dcf8d25f8 (diff)
parent6a2b17eeec2d171d2afa17bdbc36456346bfd13b (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/corelib/kernel/qcoreapplication.cpp src/corelib/thread/qthread_unix.cpp Change-Id: Ia08d613c3f0bd08cb6dc3e3a57257207dfd4a099
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp3
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp5
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.h1
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.cpp5
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h1
-rw-r--r--src/plugins/platforms/ios/qiosscreen.h2
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm25
-rw-r--r--src/plugins/platforms/windows/openglblacklists/default.json4
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp174
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h65
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp19
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h6
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h1
19 files changed, 155 insertions, 199 deletions
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index 7f56846179..1e424dc223 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -201,6 +201,9 @@ static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interf
ComPtr<INetworkAdapter> adapter;
hr = profile->get_NetworkAdapter(&adapter);
+ // Indicates that no internet connection is available/the device is in airplane mode
+ if (hr == E_INVALIDARG)
+ return QNetworkConfiguration::BearerUnknown;
Q_ASSERT_SUCCEEDED(hr);
GUID id;
hr = adapter->get_NetworkAdapterId(&id);
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
index b86dfa3546..3bd6e76c52 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
@@ -39,12 +39,12 @@
#include "qwindowsdirect2dwindow.h"
#include "qwindowscontext.h"
-#include "qwindowsguieventdispatcher.h"
#include <qplatformdefs.h>
#include <QtCore/QCoreApplication>
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/qpa/qwindowsysteminterface.h>
+#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
index 10c8091815..064b9f6306 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
@@ -219,6 +219,11 @@ QDpi QEGLDeviceIntegration::logicalDpi() const
25.4 * s.height() / ps.height());
}
+qreal QEGLDeviceIntegration::pixelDensity() const
+{
+ return logicalDpi().first / qreal(100);
+}
+
Qt::ScreenOrientation QEGLDeviceIntegration::nativeOrientation() const
{
return Qt::PrimaryOrientation;
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
index 97082df7f5..5ec98b37d1 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
@@ -75,6 +75,7 @@ public:
virtual QSizeF physicalScreenSize() const;
virtual QSize screenSize() const;
virtual QDpi logicalDpi() const;
+ virtual qreal pixelDensity() const;
virtual Qt::ScreenOrientation nativeOrientation() const;
virtual Qt::ScreenOrientation orientation() const;
virtual int screenDepth() const;
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
index 6f8d0b88dd..a14e68b667 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
@@ -82,6 +82,11 @@ QDpi QEglFSScreen::logicalDpi() const
return qt_egl_device_integration()->logicalDpi();
}
+qreal QEglFSScreen::pixelDensity() const
+{
+ return qt_egl_device_integration()->pixelDensity();
+}
+
Qt::ScreenOrientation QEglFSScreen::nativeOrientation() const
{
return qt_egl_device_integration()->nativeOrientation();
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h
index 44e9da4a5a..8f1d87ea25 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.h
@@ -55,6 +55,7 @@ public:
QSizeF physicalSize() const Q_DECL_OVERRIDE;
QDpi logicalDpi() const Q_DECL_OVERRIDE;
+ qreal pixelDensity() const Q_DECL_OVERRIDE;
Qt::ScreenOrientation nativeOrientation() const Q_DECL_OVERRIDE;
Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h
index a0aa922a31..f31be9756c 100644
--- a/src/plugins/platforms/ios/qiosscreen.h
+++ b/src/plugins/platforms/ios/qiosscreen.h
@@ -73,7 +73,7 @@ private:
QRect m_geometry;
QRect m_availableGeometry;
int m_depth;
- uint m_unscaledDpi;
+ uint m_pixelDensity;
QSizeF m_physicalSize;
QIOSOrientationListener *m_orientationListener;
};
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 3e16efcd22..5cb06d591d 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -170,23 +170,28 @@ QIOSScreen::QIOSScreen(UIScreen *screen)
if (screen == [UIScreen mainScreen]) {
QString deviceIdentifier = deviceModelIdentifier();
- if (deviceIdentifier == QLatin1String("iPhone2,1") /* iPhone 3GS */
- || deviceIdentifier == QLatin1String("iPod3,1") /* iPod touch 3G */) {
+ // Based on https://en.wikipedia.org/wiki/List_of_iOS_devices#Display
+
+ // iPhone (1st gen), 3G, 3GS, and iPod Touch (1st–3rd gen) are 18-bit devices
+ if (deviceIdentifier.contains(QRegularExpression("^(iPhone1,[12]|iPhone2,1|iPod[1-3],1)$")))
m_depth = 18;
- } else {
+ else
m_depth = 24;
- }
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
- && !deviceIdentifier.contains(QRegularExpression("^iPad2,[567]$")) /* excluding iPad Mini */) {
- m_unscaledDpi = 132;
+ if (deviceIdentifier.contains(QRegularExpression("^iPhone(7,1|8,2)$"))) {
+ // iPhone 6 Plus or iPhone 6S Plus
+ m_pixelDensity = 401;
+ } else if (deviceIdentifier.contains(QRegularExpression("^iPad(1,1|2,[1-4]|3,[1-6]|4,[1-3]|5,[3-4]|6,[7-8])$"))) {
+ // All iPads except the iPad Mini series
+ m_pixelDensity = 132 * devicePixelRatio();
} else {
- m_unscaledDpi = 163; // Regular iPhone DPI
+ // All non-Plus iPhones, and iPad Minis
+ m_pixelDensity = 163 * devicePixelRatio();
}
} else {
// External display, hard to say
m_depth = 24;
- m_unscaledDpi = 96;
+ m_pixelDensity = 96;
}
for (UIWindow *existingWindow in [[UIApplication sharedApplication] windows]) {
@@ -249,7 +254,7 @@ void QIOSScreen::updateProperties()
if (m_geometry != previousGeometry) {
const qreal millimetersPerInch = 25.4;
- m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch;
+ m_physicalSize = QSizeF(m_geometry.size() * devicePixelRatio()) / m_pixelDensity * millimetersPerInch;
}
// At construction time, we don't yet have an associated QScreen, but we still want
diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json
index a5d42719a9..1e003e2d15 100644
--- a/src/plugins/platforms/windows/openglblacklists/default.json
+++ b/src/plugins/platforms/windows/openglblacklists/default.json
@@ -57,9 +57,9 @@
},
{
"id": 5,
- "description": "Intel GMA 3150 crashes (QTBUG-43243)",
+ "description": "Intel GMA 3150 (QTBUG-43243), Mobile Intel 945GM (QTBUG-47435) crash",
"vendor_id": "0x8086",
- "device_id": [ "0xA001", "0xA011" ],
+ "device_id": [ "0xA001", "0xA011", "0x27A0" ],
"os": {
"type": "win"
},
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
index 3f19e4401a..bd5c35037d 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
@@ -84,7 +84,8 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
if ((flags & Qt::FramelessWindowHint) && QWindowsWindow::setWindowLayered(rw->handle(), flags, hasAlpha, rw->opacity()) && hasAlpha) {
// Windows with alpha: Use blend function to update.
QRect r = QHighDpi::toNativePixels(window->frameGeometry(), window);
- QPoint frameOffset(QHighDpi::toNativePixels(QPoint(window->frameMargins().left(), window->frameMargins().top()), window));
+ QPoint frameOffset(QHighDpi::toNativePixels(QPoint(window->frameMargins().left(), window->frameMargins().top()),
+ static_cast<const QWindow *>(Q_NULLPTR)));
QRect dirtyRect = br.translated(offset + frameOffset);
SIZE size = {r.width(), r.height()};
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index 1fbef61029..800b79347c 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -67,19 +67,14 @@ Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap);
\ingroup qt-lighthouse-win
*/
-QWindowsCursorCacheKey::QWindowsCursorCacheKey(const QCursor &c)
- : shape(c.shape()), bitmapCacheKey(0), maskCacheKey(0)
+QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c)
+ : bitmapCacheKey(c.pixmap().cacheKey()), maskCacheKey(0)
{
- if (shape == Qt::BitmapCursor) {
- const qint64 pixmapCacheKey = c.pixmap().cacheKey();
- if (pixmapCacheKey) {
- bitmapCacheKey = pixmapCacheKey;
- } else {
- Q_ASSERT(c.bitmap());
- Q_ASSERT(c.mask());
- bitmapCacheKey = c.bitmap()->cacheKey();
- maskCacheKey = c.mask()->cacheKey();
- }
+ if (!bitmapCacheKey) {
+ Q_ASSERT(c.bitmap());
+ Q_ASSERT(c.mask());
+ bitmapCacheKey = c.bitmap()->cacheKey();
+ maskCacheKey = c.mask()->cacheKey();
}
}
@@ -206,6 +201,17 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
#endif
}
+// Create a cursor from image and mask of the format QImage::Format_Mono.
+static HCURSOR createBitmapCursor(const QCursor &cursor)
+{
+ Q_ASSERT(cursor.shape() == Qt::BitmapCursor && cursor.bitmap());
+ const QImage bbits = cursor.bitmap()->toImage().convertToFormat(QImage::Format_Mono);
+ const QImage mbits = cursor.mask()->toImage().convertToFormat(QImage::Format_Mono);
+ const bool invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
+ const bool invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
+ return createBitmapCursor(bbits, mbits, cursor.hotSpot(), invb, invm);
+}
+
static inline QSize systemCursorSize() { return QSize(GetSystemMetrics(SM_CXCURSOR), GetSystemMetrics(SM_CYCURSOR)); }
static inline QSize standardCursorSize() { return QSize(32, 32); }
@@ -215,7 +221,7 @@ static inline QSize standardCursorSize() { return QSize(32, 32); }
// createBitmapCursor() only work for standard sizes (32,48,64...), which does
// not work when scaling the 16x16 openhand cursor bitmaps to 150% (resulting
// in a non-standard 24x24 size).
-static QCursor createPixmapCursorFromData(const QSize &systemCursorSize,
+static QWindowsCursor::PixmapCursor createPixmapCursorFromData(const QSize &systemCursorSize,
// The cursor size the bitmap is targeted for
const QSize &bitmapTargetCursorSize,
// The actual size of the bitmap data
@@ -233,10 +239,10 @@ static QCursor createPixmapCursorFromData(const QSize &systemCursorSize,
rawImage = rawImage.transformed(transform, Qt::SmoothTransformation);
}
const QPoint hotSpot(rawImage.width() / 2, rawImage.height() / 2);
- return QCursor(rawImage, hotSpot.x(), hotSpot.y());
+ return QWindowsCursor::PixmapCursor(rawImage, hotSpot);
}
-QCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
+QWindowsCursor::PixmapCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
{
// Non-standard Windows cursors are created from bitmaps
static const uchar vsplit_bits[] = {
@@ -412,14 +418,14 @@ QCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
case Qt::ClosedHandCursor:
return createPixmapCursorFromData(systemCursorSize(), standardCursorSize(), 16, closedhand_bits, closedhandm_bits);
case Qt::DragCopyCursor:
- return QCursor(QPixmap(copyDragCursorXpmC), 0, 0);
+ return QWindowsCursor::PixmapCursor(QPixmap(copyDragCursorXpmC), QPoint(0, 0));
case Qt::DragMoveCursor:
- return QCursor(QPixmap(moveDragCursorXpmC), 0, 0);
+ return QWindowsCursor::PixmapCursor(QPixmap(moveDragCursorXpmC), QPoint(0, 0));
case Qt::DragLinkCursor:
- return QCursor(QPixmap(linkDragCursorXpmC), 0, 0);
+ return QWindowsCursor::PixmapCursor(QPixmap(linkDragCursorXpmC), QPoint(0, 0));
}
- return QCursor();
+ return QWindowsCursor::PixmapCursor();
}
#else // Q_OS_WINCE || QT_NO_IMAGEFORMAT_PNG
struct QWindowsCustomPngCursor {
@@ -430,7 +436,7 @@ struct QWindowsCustomPngCursor {
int hotSpotY;
};
-QCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
+QWindowsCursor::PixmapCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
{
static const QWindowsCustomPngCursor pngCursors[] = {
{ Qt::SplitVCursor, 32, "splitvcursor_32.png", 11, 11 },
@@ -473,11 +479,11 @@ QCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
}
if (!bestFit)
- return QCursor();
+ return PixmapCursor();
const QPixmap rawImage(QStringLiteral(":/qt-project.org/windows/cursors/images/") +
QString::fromLatin1(bestFit->fileName));
- return QCursor(rawImage, bestFit->hotSpotX, bestFit->hotSpotY);
+ return PixmapCursor(rawImage, QPoint(bestFit->hotSpotX, bestFit->hotSpotY));
}
#endif // Q_OS_WINCE || QT_NO_IMAGEFORMAT_PNG
@@ -486,8 +492,10 @@ struct QWindowsStandardCursorMapping {
LPCWSTR resource;
};
-HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
+HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape)
{
+ Q_ASSERT(cursorShape != Qt::BitmapCursor);
+
static const QWindowsStandardCursorMapping standardCursors[] = {
{ Qt::ArrowCursor, IDC_ARROW},
{ Qt::UpArrowCursor, IDC_UPARROW },
@@ -505,18 +513,7 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
{ Qt::PointingHandCursor, IDC_HAND }
};
- const Qt::CursorShape cursorShape = c.shape();
switch (cursorShape) {
- case Qt::BitmapCursor: {
- const QPixmap pixmap = c.pixmap();
- if (!pixmap.isNull())
- return QWindowsCursor::createPixmapCursor(pixmap, c.hotSpot());
- const QImage bbits = c.bitmap()->toImage().convertToFormat(QImage::Format_Mono);
- const QImage mbits = c.mask()->toImage().convertToFormat(QImage::Format_Mono);
- const bool invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
- const bool invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
- return createBitmapCursor(bbits, mbits, c.hotSpot(), invb, invm);
- }
case Qt::BlankCursor: {
QImage blank = QImage(systemCursorSize(), QImage::Format_Mono);
blank.fill(0); // ignore color table
@@ -529,7 +526,7 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
case Qt::DragCopyCursor:
case Qt::DragMoveCursor:
case Qt::DragLinkCursor:
- return createSystemCursor(customCursor(cursorShape));
+ return QWindowsCursor::createPixmapCursor(customCursor(cursorShape));
default:
break;
}
@@ -554,37 +551,41 @@ HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
\brief Return cached standard cursor resources or create new ones.
*/
-QWindowsWindowCursor QWindowsCursor::standardWindowCursor(Qt::CursorShape shape)
+CursorHandlePtr QWindowsCursor::standardWindowCursor(Qt::CursorShape shape)
{
- const QWindowsCursorCacheKey key(shape);
- CursorCache::iterator it = m_cursorCache.find(key);
- if (it == m_cursorCache.end())
- it = m_cursorCache.insert(key, QWindowsWindowCursor(QCursor(shape)));
- return it.value();
+ StandardCursorCache::Iterator it = m_standardCursorCache.find(shape);
+ if (it == m_standardCursorCache.end()) {
+ if (const HCURSOR hc = QWindowsCursor::createCursorFromShape(shape))
+ it = m_standardCursorCache.insert(shape, CursorHandlePtr(new CursorHandle(hc)));
+ }
+ return it != m_standardCursorCache.end() ? it.value() : CursorHandlePtr(new CursorHandle);
}
/*!
\brief Return cached pixmap cursor or create new one.
*/
-QWindowsWindowCursor QWindowsCursor::pixmapWindowCursor(const QCursor &c)
+CursorHandlePtr QWindowsCursor::pixmapWindowCursor(const QCursor &c)
{
- const QWindowsCursorCacheKey cacheKey(c);
- CursorCache::iterator it = m_cursorCache.find(cacheKey);
- if (it == m_cursorCache.end()) {
- if (m_cursorCache.size() > 50) {
+ const QWindowsPixmapCursorCacheKey cacheKey(c);
+ PixmapCursorCache::iterator it = m_pixmapCursorCache.find(cacheKey);
+ if (it == m_pixmapCursorCache.end()) {
+ if (m_pixmapCursorCache.size() > 50) {
// Prevent the cursor cache from growing indefinitely hitting GDI resource
// limits if new pixmap cursors are created repetitively by purging out
// all-noncurrent pixmap cursors (QTBUG-43515)
const HCURSOR currentCursor = GetCursor();
- for (it = m_cursorCache.begin(); it != m_cursorCache.end() ; ) {
- if (it.key().bitmapCacheKey && it.value().handle() != currentCursor)
- it = m_cursorCache.erase(it);
+ for (it = m_pixmapCursorCache.begin(); it != m_pixmapCursorCache.end() ; ) {
+ if (it.value()->handle() != currentCursor)
+ it = m_pixmapCursorCache.erase(it);
else
++it;
}
}
- it = m_cursorCache.insert(cacheKey, QWindowsWindowCursor(c));
+ const QPixmap pixmap = c.pixmap();
+ const HCURSOR hc = pixmap.isNull()
+ ? createBitmapCursor(c) : QWindowsCursor::createPixmapCursor(pixmap, c.hotSpot());
+ it = m_pixmapCursorCache.insert(cacheKey, CursorHandlePtr(new CursorHandle(hc)));
}
return it.value();
}
@@ -606,13 +607,13 @@ void QWindowsCursor::changeCursor(QCursor *cursorIn, QWindow *window)
if (!window)
return;
if (!cursorIn) {
- QWindowsWindow::baseWindowOf(window)->setCursor(QWindowsWindowCursor());
+ QWindowsWindow::baseWindowOf(window)->setCursor(CursorHandlePtr(new CursorHandle));
return;
}
- const QWindowsWindowCursor wcursor =
+ const CursorHandlePtr wcursor =
cursorIn->shape() == Qt::BitmapCursor ?
pixmapWindowCursor(*cursorIn) : standardWindowCursor(cursorIn->shape());
- if (wcursor.handle()) {
+ if (wcursor->handle()) {
QWindowsWindow::baseWindowOf(window)->setCursor(wcursor);
} else {
qWarning("%s: Unable to obtain system cursor for %d",
@@ -658,78 +659,11 @@ void QWindowsCursor::setPos(const QPoint &pos)
\brief Per-Window cursor. Contains a QCursor and manages its associated system
cursor handle resource.
- Based on QSharedDataPointer, so that it can be passed around and
- used as a property of QWindowsBaseWindow.
-
\internal
\ingroup qt-lighthouse-win
\sa QWindowsCursor
*/
-class QWindowsWindowCursorData : public QSharedData
-{
-public:
- QWindowsWindowCursorData() : m_cursor(Qt::ArrowCursor), m_handle(0) {}
- explicit QWindowsWindowCursorData(const QCursor &c);
- ~QWindowsWindowCursorData();
-
- const QCursor m_cursor;
- const HCURSOR m_handle;
-};
-
-QWindowsWindowCursorData::QWindowsWindowCursorData(const QCursor &c) :
- m_cursor(c),
- m_handle(QWindowsCursor::createSystemCursor(c))
-{
-}
-
-QWindowsWindowCursorData::~QWindowsWindowCursorData()
-{
- if (m_handle)
- DestroyCursor(m_handle);
-}
-
-QWindowsWindowCursor::QWindowsWindowCursor() :
- m_data(new QWindowsWindowCursorData)
-{
-}
-
-QWindowsWindowCursor::QWindowsWindowCursor(const QCursor &c) :
- m_data(new QWindowsWindowCursorData(c))
-{
-}
-
-QWindowsWindowCursor::~QWindowsWindowCursor()
-{
-}
-
-QWindowsWindowCursor::QWindowsWindowCursor(const QWindowsWindowCursor &rhs) :
- m_data(rhs.m_data)
-{
-}
-
-QWindowsWindowCursor & QWindowsWindowCursor::operator =(const QWindowsWindowCursor &rhs)
-{
- if (this != &rhs)
- m_data.operator =(rhs.m_data);
- return *this;
-}
-
-bool QWindowsWindowCursor::isNull() const
-{
- return m_data->m_handle == 0;
-}
-
-QCursor QWindowsWindowCursor::cursor() const
-{
- return m_data->m_cursor;
-}
-
-HCURSOR QWindowsWindowCursor::handle() const
-{
- return m_data->m_handle;
-}
-
QT_END_NAMESPACE
#endif // !QT_NO_CURSOR
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index f1763ddd7d..ac9e87d1fb 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -37,51 +37,49 @@
#include "qtwindows_additional.h"
#include <qpa/qplatformcursor.h>
-#include <QtCore/QSharedDataPointer>
+#include <QtCore/QSharedPointer>
#include <QtCore/QHash>
QT_BEGIN_NAMESPACE
-class QWindowsWindowCursorData;
-
-struct QWindowsCursorCacheKey
+struct QWindowsPixmapCursorCacheKey
{
- explicit QWindowsCursorCacheKey(const QCursor &c);
- explicit QWindowsCursorCacheKey(Qt::CursorShape s) : shape(s), bitmapCacheKey(0), maskCacheKey(0) {}
- QWindowsCursorCacheKey() : shape(Qt::CustomCursor), bitmapCacheKey(0), maskCacheKey(0) {}
+ explicit QWindowsPixmapCursorCacheKey(const QCursor &c);
- Qt::CursorShape shape;
qint64 bitmapCacheKey;
qint64 maskCacheKey;
};
-inline bool operator==(const QWindowsCursorCacheKey &k1, const QWindowsCursorCacheKey &k2)
+inline bool operator==(const QWindowsPixmapCursorCacheKey &k1, const QWindowsPixmapCursorCacheKey &k2)
{
- return k1.shape == k2.shape && k1.bitmapCacheKey == k2.bitmapCacheKey && k1.maskCacheKey == k2.maskCacheKey;
+ return k1.bitmapCacheKey == k2.bitmapCacheKey && k1.maskCacheKey == k2.maskCacheKey;
}
-inline uint qHash(const QWindowsCursorCacheKey &k, uint seed) Q_DECL_NOTHROW
+inline uint qHash(const QWindowsPixmapCursorCacheKey &k, uint seed) Q_DECL_NOTHROW
{
- return (uint(k.shape) + uint(k.bitmapCacheKey) + uint(k.maskCacheKey)) ^ seed;
+ return (uint(k.bitmapCacheKey) + uint(k.maskCacheKey)) ^ seed;
}
-class QWindowsWindowCursor
+class CursorHandle
{
+ Q_DISABLE_COPY(CursorHandle)
public:
- QWindowsWindowCursor();
- explicit QWindowsWindowCursor(const QCursor &c);
- ~QWindowsWindowCursor();
- QWindowsWindowCursor(const QWindowsWindowCursor &c);
- QWindowsWindowCursor &operator=(const QWindowsWindowCursor &c);
+ explicit CursorHandle(HCURSOR hcursor = Q_NULLPTR) : m_hcursor(hcursor) {}
+ ~CursorHandle()
+ {
+ if (m_hcursor)
+ DestroyCursor(m_hcursor);
+ }
- bool isNull() const;
- QCursor cursor() const;
- HCURSOR handle() const;
+ bool isNull() const { return !m_hcursor; }
+ HCURSOR handle() const { return m_hcursor; }
private:
- QSharedDataPointer<QWindowsWindowCursorData> m_data;
+ const HCURSOR m_hcursor;
};
+typedef QSharedPointer<CursorHandle> CursorHandlePtr;
+
class QWindowsCursor : public QPlatformCursor
{
public:
@@ -91,6 +89,13 @@ public:
CursorSuppressed // Cursor suppressed by touch interaction (Windows 8).
};
+ struct PixmapCursor {
+ explicit PixmapCursor(const QPixmap &pix = QPixmap(), const QPoint &h = QPoint()) : pixmap(pix), hotSpot(h) {}
+
+ QPixmap pixmap;
+ QPoint hotSpot;
+ };
+
QWindowsCursor();
void changeCursor(QCursor * widgetCursor, QWindow * widget) Q_DECL_OVERRIDE;
@@ -98,18 +103,22 @@ public:
void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
static HCURSOR createPixmapCursor(const QPixmap &pixmap, const QPoint &hotSpot);
- static HCURSOR createSystemCursor(const QCursor &c);
- static QCursor customCursor(Qt::CursorShape cursorShape);
+ static HCURSOR createPixmapCursor(const PixmapCursor &pc) { return createPixmapCursor(pc.pixmap, pc.hotSpot); }
+ static PixmapCursor customCursor(Qt::CursorShape cursorShape);
+
+ static HCURSOR createCursorFromShape(Qt::CursorShape cursorShape);
static QPoint mousePosition();
static CursorState cursorState();
- QWindowsWindowCursor standardWindowCursor(Qt::CursorShape s = Qt::ArrowCursor);
- QWindowsWindowCursor pixmapWindowCursor(const QCursor &c);
+ CursorHandlePtr standardWindowCursor(Qt::CursorShape s = Qt::ArrowCursor);
+ CursorHandlePtr pixmapWindowCursor(const QCursor &c);
private:
- typedef QHash<QWindowsCursorCacheKey, QWindowsWindowCursor> CursorCache;
+ typedef QHash<Qt::CursorShape, CursorHandlePtr> StandardCursorCache;
+ typedef QHash<QWindowsPixmapCursorCacheKey, CursorHandlePtr> PixmapCursorCache;
- CursorCache m_cursorCache;
+ StandardCursorCache m_standardCursorCache;
+ PixmapCursorCache m_pixmapCursorCache;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index fcd9911a56..5435c4820a 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -218,23 +218,14 @@ public:
STDMETHOD(GiveFeedback)(DWORD dwEffect);
private:
- class DragCursorHandle {
- Q_DISABLE_COPY(DragCursorHandle)
- public:
- DragCursorHandle(HCURSOR c) : cursor(c) {}
- ~DragCursorHandle() { DestroyCursor(cursor); }
- const HCURSOR cursor;
- };
- typedef QSharedPointer<DragCursorHandle> DragCursorHandlePtr;
-
struct CursorEntry {
CursorEntry() : cacheKey(0) {}
- CursorEntry(const QPixmap &p, qint64 cK, const DragCursorHandlePtr &c, const QPoint &h) :
+ CursorEntry(const QPixmap &p, qint64 cK, const CursorHandlePtr &c, const QPoint &h) :
pixmap(p), cacheKey(cK), cursor(c), hotSpot(h) {}
QPixmap pixmap;
qint64 cacheKey; // Cache key of cursor
- DragCursorHandlePtr cursor;
+ CursorHandlePtr cursor;
QPoint hotSpot;
};
@@ -273,7 +264,7 @@ QWindowsOleDropSource::~QWindowsOleDropSource()
QDebug operator<<(QDebug d, const QWindowsOleDropSource::CursorEntry &e)
{
d << "CursorEntry:" << e.pixmap.size() << '#' << e.cacheKey
- << "HCURSOR" << e.cursor->cursor << "hotspot:" << e.hotSpot;
+ << "HCURSOR" << e.cursor->handle() << "hotspot:" << e.hotSpot;
return d;
}
#endif // !QT_NO_DEBUG_STREAM
@@ -343,7 +334,7 @@ void QWindowsOleDropSource::createCursors()
}
if (const HCURSOR sysCursor = QWindowsCursor::createPixmapCursor(newPixmap, newHotSpot)) {
- const CursorEntry entry(newPixmap, cacheKey, DragCursorHandlePtr(new DragCursorHandle(sysCursor)), newHotSpot);
+ const CursorEntry entry(newPixmap, cacheKey, CursorHandlePtr(new CursorHandle(sysCursor)), newHotSpot);
if (it == m_cursors.end())
m_cursors.insert(action, entry);
else
@@ -456,7 +447,7 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect)
const CursorEntry &e = it.value();
switch (m_mode) {
case MouseDrag:
- SetCursor(e.cursor->cursor);
+ SetCursor(e.cursor->handle());
break;
case TouchDrag:
if (!m_touchDragWindow)
@@ -718,16 +709,16 @@ QPixmap QWindowsDrag::defaultCursor(Qt::DropAction action) const
switch (action) {
case Qt::CopyAction:
if (m_copyDragCursor.isNull())
- m_copyDragCursor = QWindowsCursor::customCursor(Qt::DragCopyCursor).pixmap();
+ m_copyDragCursor = QWindowsCursor::customCursor(Qt::DragCopyCursor).pixmap;
return m_copyDragCursor;
case Qt::TargetMoveAction:
case Qt::MoveAction:
if (m_moveDragCursor.isNull())
- m_moveDragCursor = QWindowsCursor::customCursor(Qt::DragMoveCursor).pixmap();
+ m_moveDragCursor = QWindowsCursor::customCursor(Qt::DragMoveCursor).pixmap;
return m_moveDragCursor;
case Qt::LinkAction:
if (m_linkDragCursor.isNull())
- m_linkDragCursor = QWindowsCursor::customCursor(Qt::DragLinkCursor).pixmap();
+ m_linkDragCursor = QWindowsCursor::customCursor(Qt::DragLinkCursor).pixmap;
return m_linkDragCursor;
default:
break;
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 33c7ccfdce..877bdfec17 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -393,6 +393,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false));
case ContextMenuOnMouseRelease:
return QVariant(true);
+ case WheelScrollLines:
+ return dWordSystemParametersInfo(SPI_GETWHEELSCROLLLINES, 3);
default:
break;
}
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 01e2a804bd..c49682cc26 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -928,6 +928,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
m_hdc(0),
m_windowState(Qt::WindowNoState),
m_opacity(1.0),
+ m_cursor(new CursorHandle),
m_dropTarget(0),
m_savedStyle(0),
m_format(aWindow->requestedFormat()),
@@ -2113,13 +2114,13 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
#ifndef QT_NO_CURSOR
// Return the default cursor (Arrow) from QWindowsCursor's cache.
-static inline QWindowsWindowCursor defaultCursor(const QWindow *w)
+static inline CursorHandlePtr defaultCursor(const QWindow *w)
{
if (QScreen *screen = w->screen())
if (const QPlatformScreen *platformScreen = screen->handle())
if (QPlatformCursor *cursor = platformScreen->cursor())
return static_cast<QWindowsCursor *>(cursor)->standardWindowCursor(Qt::ArrowCursor);
- return QWindowsWindowCursor(Qt::ArrowCursor);
+ return CursorHandlePtr(new CursorHandle(QWindowsCursor::createCursorFromShape(Qt::ArrowCursor)));
}
// Check whether to apply a new cursor. Either the window in question is
@@ -2133,7 +2134,7 @@ static inline bool applyNewCursor(const QWindow *w)
for (const QWindow *p = underMouse; p ; p = p->parent()) {
if (p == w)
return true;
- if (!QWindowsWindow::baseWindowOf(p)->cursor().isNull())
+ if (!QWindowsWindow::baseWindowOf(p)->cursor()->isNull())
return false;
}
return false;
@@ -2149,25 +2150,25 @@ static inline bool applyNewCursor(const QWindow *w)
void QWindowsWindow::applyCursor()
{
#ifndef QT_NO_CURSOR
- if (m_cursor.isNull()) { // Recurse up to parent with non-null cursor. Set default for toplevel.
+ if (m_cursor->isNull()) { // Recurse up to parent with non-null cursor. Set default for toplevel.
if (const QWindow *p = window()->parent()) {
QWindowsWindow::baseWindowOf(p)->applyCursor();
} else {
- SetCursor(defaultCursor(window()).handle());
+ SetCursor(defaultCursor(window())->handle());
}
} else {
- SetCursor(m_cursor.handle());
+ SetCursor(m_cursor->handle());
}
#endif
}
-void QWindowsWindow::setCursor(const QWindowsWindowCursor &c)
+void QWindowsWindow::setCursor(const CursorHandlePtr &c)
{
#ifndef QT_NO_CURSOR
- if (c.handle() != m_cursor.handle()) {
+ if (c->handle() != m_cursor->handle()) {
const bool apply = applyNewCursor(window());
qCDebug(lcQpaWindows) << window() << __FUNCTION__
- << c.cursor().shape() << " doApply=" << apply;
+ << c->handle() << " doApply=" << apply;
m_cursor = c;
if (apply)
applyCursor();
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 40d7a3f076..4172a3d850 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -225,9 +225,9 @@ public:
#endif // !Q_OS_WINCE
#ifndef QT_NO_CURSOR
- QWindowsWindowCursor cursor() const { return m_cursor; }
+ CursorHandlePtr cursor() const { return m_cursor; }
#endif
- void setCursor(const QWindowsWindowCursor &c);
+ void setCursor(const CursorHandlePtr &c);
void applyCursor();
inline bool testFlag(unsigned f) const { return (m_flags & f) != 0; }
@@ -278,7 +278,7 @@ private:
Qt::WindowState m_windowState;
qreal m_opacity;
#ifndef QT_NO_CURSOR
- QWindowsWindowCursor m_cursor;
+ CursorHandlePtr m_cursor;
#endif
QWindowsOleDropTarget *m_dropTarget;
unsigned m_savedStyle;
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 23bb6c16ec..9db5df995a 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -260,8 +260,10 @@ HRESULT QWinRTIntegration::onBackButtonPressed(IInspectable *, IBackPressedEvent
Q_D(QWinRTIntegration);
QWindow *window = d->mainScreen->topWindow();
QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
- const bool pressed = QWindowSystemInterface::handleKeyEvent(window, QEvent::KeyPress, Qt::Key_Back, Qt::NoModifier);
- const bool released = QWindowSystemInterface::handleKeyEvent(window, QEvent::KeyRelease, Qt::Key_Back, Qt::NoModifier);
+ const bool pressed = QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyPress, Qt::Key_Back, Qt::NoModifier,
+ 0, 0, 0, QString(), false, 1, false);
+ const bool released = QWindowSystemInterface::handleExtendedKeyEvent(window, QEvent::KeyRelease, Qt::Key_Back, Qt::NoModifier,
+ 0, 0, 0, QString(), false, 1, false);
QWindowSystemInterface::setSynchronousWindowSystemEvents(false);
args->put_Handled(pressed || released);
return S_OK;
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index bcc571c3c8..d76f1245e8 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -500,10 +500,7 @@ void QXcbWindow::create()
properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS);
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING);
- if (platformScreen->syncRequestSupported())
- m_usingSyncProtocol = supportsSyncProtocol();
- else
- m_usingSyncProtocol = false;
+ m_usingSyncProtocol = platformScreen->syncRequestSupported();
if (m_usingSyncProtocol)
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST);
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index b2c5fa7d4d..41c4b4443d 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -176,7 +176,6 @@ public Q_SLOTS:
protected:
virtual void resolveFormat() { m_format = window()->requestedFormat(); }
virtual void *createVisual() { return Q_NULLPTR; }
- virtual bool supportsSyncProtocol() { return !window()->supportsOpenGL(); }
QXcbScreen *parentScreen();