summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-30 12:39:22 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-30 12:46:20 +0100
commit246799d8a7bf42c1f22fca7ef6d77e8d58054bad (patch)
treea0b92a804d7d2a30cd68fa327df5777d8bcc36ba /src/plugins
parent5ad191850becd7dc1d61d0975f141a5db64e6373 (diff)
parent02cc57f4edbae450ecfa8368052afa44f8aeee19 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: examples/network/network-chat/peermanager.cpp src/widgets/util/qsystemtrayicon.cpp src/widgets/util/qsystemtrayicon_qpa.cpp src/widgets/util/qsystemtrayicon_win.cpp src/widgets/util/qsystemtrayicon_x11.cpp Change-Id: I1c026df83818c0ccaf956980370e7522960627db
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp6
-rw-r--r--src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp9
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm12
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp119
8 files changed, 76 insertions, 81 deletions
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index 7756709e55..847479047f 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -210,10 +210,10 @@ QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
if (!engine || state != QNetworkSession::Connected || !publicConfig.isValid())
return QNetworkInterface();
- QString interface = engine->getInterfaceFromId(activeConfig.identifier());
- if (interface.isEmpty())
+ QString iface = engine->getInterfaceFromId(activeConfig.identifier());
+ if (iface.isEmpty())
return QNetworkInterface();
- return QNetworkInterface::interfaceFromName(interface);
+ return QNetworkInterface::interfaceFromName(iface);
}
#endif
diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
index bd25992457..ca9f7af127 100644
--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
@@ -194,8 +194,11 @@ static QVector<QComposeTableElement> loadCache(const QComposeCacheFileHeader &co
static bool saveCache(const QComposeCacheFileHeader &info, const QVector<QComposeTableElement> &vec)
{
const QString filePath = getCacheFilePath();
+#if QT_CONFIG(temporaryfile)
QSaveFile outputFile(filePath);
-
+#else
+ QFile outputFile(filePath);
+#endif
if (!outputFile.open(QIODevice::WriteOnly))
return false;
const char *data = reinterpret_cast<const char*>(&info);
@@ -207,7 +210,11 @@ static bool saveCache(const QComposeCacheFileHeader &info, const QVector<QCompos
if (outputFile.write(data, size) != size)
return false;
+#if QT_CONFIG(temporaryfile)
return outputFile.commit();
+#else
+ return true;
+#endif
}
TableGenerator::TableGenerator() : m_state(NoErrors),
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index fa0365dbf7..3e637b5db3 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -279,16 +279,8 @@ NSRect qt_mac_flipRect(const QRect &rect)
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
{
- if (buttonNum == 0)
- return Qt::LeftButton;
- if (buttonNum == 1)
- return Qt::RightButton;
- if (buttonNum == 2)
- return Qt::MiddleButton;
- if (buttonNum >= 3 && buttonNum <= 31) { // handle XButton1 and higher via logical shift
- return Qt::MouseButton(uint(Qt::MiddleButton) << (buttonNum - 3));
- }
- // else error: buttonNum too high, or negative
+ if (buttonNum >= 0 && buttonNum <= 31)
+ return Qt::MouseButton(1 << buttonNum);
return Qt::NoButton;
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
index 80708fd17a..534467b32c 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
@@ -228,7 +228,7 @@ QDpi QEglFSDeviceIntegration::logicalDpi() const
qreal QEglFSDeviceIntegration::pixelDensity() const
{
- return qRound(logicalDpi().first / qreal(100));
+ return qMax(1, qRound(logicalDpi().first / qreal(100)));
}
Qt::ScreenOrientation QEglFSDeviceIntegration::nativeOrientation() const
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 2f88989b3c..5a3020387a 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -510,11 +510,6 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co
return QVariant(keyBoardAutoRepeatRateMS());
#endif
case QPlatformIntegration::ShowIsMaximized:
-#ifndef QT_NO_CLIPBOARD
- return qt_windowsIsTabletMode(d->m_clipboard.clipboardViewer());
-#else
- break;
-#endif
case QPlatformIntegration::StartDragTime:
case QPlatformIntegration::StartDragDistance:
case QPlatformIntegration::KeyboardInputInterval:
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index c38e96bdb7..bd598630ba 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -258,7 +258,7 @@ qreal QWindowsScreen::pixelDensity() const
// the pixel density since it is reflects the Windows UI scaling.
// High DPI auto scaling should be disabled when the user chooses
// small fonts on a High DPI monitor, resulting in lower logical DPI.
- return qRound(logicalDpi().first / 96);
+ return qMax(1, qRound(logicalDpi().first / 96));
}
/*!
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp
index 060f1839cf..d9a9d3b20f 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.cpp
+++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp
@@ -647,7 +647,7 @@ QDpi QWinRTScreen::logicalDpi() const
qreal QWinRTScreen::pixelDensity() const
{
Q_D(const QWinRTScreen);
- return qRound(d->logicalDpi / 96);
+ return qMax(1, qRound(d->logicalDpi / 96));
}
qreal QWinRTScreen::scaleFactor() const
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 736b4852d8..5e136b5d7e 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -620,7 +620,7 @@ void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation)
m_sizeMillimeters = sizeInMillimeters(xGeometry.size(), virtualDpi());
qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4);
- m_pixelDensity = qRound(dpi/96);
+ m_pixelDensity = qMax(1, qRound(dpi/96));
m_geometry = QRect(xGeometry.topLeft(), xGeometry.size());
m_availableGeometry = xGeometry & m_virtualDesktop->workArea();
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);
@@ -667,85 +667,88 @@ void QXcbScreen::updateRefreshRate(xcb_randr_mode_t mode)
}
}
-QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) const
+static xcb_get_geometry_reply_t *getGeometryUnchecked(xcb_connection_t *connection, xcb_window_t window)
+{
+ const xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(connection, window);
+ return xcb_get_geometry_reply(connection, geometry_cookie, NULL);
+}
+
+static inline bool translate(xcb_connection_t *connection, xcb_window_t child, xcb_window_t parent,
+ int *x, int *y)
+{
+ const xcb_translate_coordinates_cookie_t translate_cookie =
+ xcb_translate_coordinates_unchecked(connection, child, parent, *x, *y);
+ xcb_translate_coordinates_reply_t *translate_reply =
+ xcb_translate_coordinates_reply(connection, translate_cookie, NULL);
+ if (!translate_reply)
+ return false;
+ *x = translate_reply->dst_x;
+ *y = translate_reply->dst_y;
+ free(translate_reply);
+ return true;
+}
+
+QPixmap QXcbScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const
{
if (width == 0 || height == 0)
return QPixmap();
- // TODO: handle multiple screens
+ int x = xIn;
+ int y = yIn;
QXcbScreen *screen = const_cast<QXcbScreen *>(this);
xcb_window_t root = screen->root();
- if (window == 0)
- window = root;
-
- xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), window);
-
- xcb_get_geometry_reply_t *reply =
- xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL);
-
- if (!reply) {
+ xcb_get_geometry_reply_t *rootReply = getGeometryUnchecked(xcb_connection(), root);
+ if (!rootReply)
return QPixmap();
- }
-
- if (width < 0)
- width = reply->width - x;
- if (height < 0)
- height = reply->height - y;
-
- geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), root);
- xcb_get_geometry_reply_t *root_reply =
- xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL);
- if (!root_reply) {
- free(reply);
- return QPixmap();
- }
-
- if (reply->depth == root_reply->depth) {
- // if the depth of the specified window and the root window are the
- // same, grab pixels from the root window (so that we get the any
- // overlapping windows and window manager frames)
-
- // map x and y to the root window
- xcb_translate_coordinates_cookie_t translate_cookie =
- xcb_translate_coordinates_unchecked(xcb_connection(), window, root, x, y);
+ const quint8 rootDepth = rootReply->depth;
+ free(rootReply);
- xcb_translate_coordinates_reply_t *translate_reply =
- xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, NULL);
-
- if (!translate_reply) {
- free(reply);
- free(root_reply);
+ QSize windowSize;
+ quint8 effectiveDepth = 0;
+ if (window) {
+ xcb_get_geometry_reply_t *windowReply = getGeometryUnchecked(xcb_connection(), window);
+ if (!windowReply)
return QPixmap();
+ windowSize = QSize(windowReply->width, windowReply->height);
+ effectiveDepth = windowReply->depth;
+ free(windowReply);
+ if (effectiveDepth == rootDepth) {
+ // if the depth of the specified window and the root window are the
+ // same, grab pixels from the root window (so that we get the any
+ // overlapping windows and window manager frames)
+
+ // map x and y to the root window
+ if (!translate(xcb_connection(), window, root, &x, &y))
+ return QPixmap();
+
+ window = root;
}
-
- x = translate_reply->dst_x;
- y = translate_reply->dst_y;
-
- window = root;
-
- free(translate_reply);
- free(reply);
- reply = root_reply;
} else {
- free(root_reply);
- root_reply = 0;
+ window = root;
+ effectiveDepth = rootDepth;
+ windowSize = m_geometry.size();
+ x += m_geometry.x();
+ y += m_geometry.y();
}
+ if (width < 0)
+ width = windowSize.width() - xIn;
+ if (height < 0)
+ height = windowSize.height() - yIn;
+
xcb_get_window_attributes_reply_t *attributes_reply =
xcb_get_window_attributes_reply(xcb_connection(), xcb_get_window_attributes_unchecked(xcb_connection(), window), NULL);
- if (!attributes_reply) {
- free(reply);
+ if (!attributes_reply)
return QPixmap();
- }
const xcb_visualtype_t *visual = screen->visualForId(attributes_reply->visual);
free(attributes_reply);
xcb_pixmap_t pixmap = xcb_generate_id(xcb_connection());
- xcb_create_pixmap(xcb_connection(), reply->depth, pixmap, window, width, height);
+ xcb_create_pixmap(xcb_connection(), effectiveDepth, pixmap, window, width, height);
uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE;
uint32_t gc_value_list[] = { XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS };
@@ -755,9 +758,7 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height)
xcb_copy_area(xcb_connection(), window, pixmap, gc, x, y, 0, 0, width, height);
- QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, reply->depth, visual);
-
- free(reply);
+ QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, effectiveDepth, visual);
xcb_free_gc(xcb_connection(), gc);
xcb_free_pixmap(xcb_connection(), pixmap);