From 88932d4339ea604a1bea8c09aef3945ac348df9c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 Jan 2017 13:31:06 +0100 Subject: Android: transform input rectangle correctly QRect::setX/setY will change both position and size. In this case, the width and/or height of the input rectangle could end up negative. The correct functions to use are moveLeft/moveTop which will preserve the size when changing the position. Task-number: QTBUG-58179 Change-Id: I71a2e38958754dc53e062ad1c780e2337f72ec32 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidinputcontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 12e85046f8..436e41bad5 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -354,8 +354,8 @@ static QRect inputItemRectangle() ? QHighDpiScaling::factor(window) : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); if (pixelDensity != 1.0) { - rect.setX(rect.x() * pixelDensity); - rect.setY(rect.y() * pixelDensity); + rect.moveLeft(rect.x() * pixelDensity); + rect.moveTop(rect.y() * pixelDensity); rect.setWidth(rect.width() * pixelDensity); rect.setHeight(rect.height() * pixelDensity); } -- cgit v1.2.3 From 49dc9aa409d727824f26b246054a22b5a7dd5980 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Jan 2017 10:40:18 +0100 Subject: Windows QPA: Do not return QPlatformIntegration::ShowIsMaximized in tablet mode The hint is not appropriate for Windows 10 tablet mode as it affects only main windows. Dialogs should still show up in normal size. Partially reverts change d377f14fd5b4fe3ed64392c6b743bac395f9f891. Task-number: QTBUG-58227 Change-Id: If9cf4990eb40913904cd97e17a7622bc6cbe84ca Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/windows/qwindowsintegration.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index f49ad0e767..3f74fd5296 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -512,11 +512,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: -- cgit v1.2.3 From dd52fd0024600d3beffc82d6da02b4239a62d725 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 17 Jan 2017 17:05:00 +0100 Subject: Ensure a pixel density of at least 1 for Qt::AA_EnableHighDpiScaling Very large 1080p TVs or any display which is running at an abnormally low resolution can have a DPI lower than 48, which means that qRound(dpi/96) will result in a 0 pixel density, causing critical issues for applications using Qt::AA_EnableHighDpiScaling. Make sure that we always have a pixel density of at least 1 to allow applications not having to worry about such displays. Task-number: QTBUG-56140 Change-Id: I1dafbf7794a99ae6f872984c0337d8ff0d1fc1c0 Reviewed-by: Shawn Rutledge Reviewed-by: Friedemann Kleint --- src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp | 2 +- src/plugins/platforms/windows/qwindowsscreen.cpp | 2 +- src/plugins/platforms/winrt/qwinrtscreen.cpp | 2 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index 3e1e93f1e4..863a115b74 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -226,7 +226,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/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 7a885b462e..c70323c06f 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -265,7 +265,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 f87ae9fd24..2a4b6c8907 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 a9675935f4..d8facdbb84 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -631,7 +631,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); -- cgit v1.2.3 From 1b1686d194731d940a40112635647536ac8ee676 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 22 Nov 2016 15:35:24 +0100 Subject: Fix mouse extra button mapping on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously extra mouse buttons apart from left, right and middle buttons, were mapped incorrectly with an offset of -1. This resulted in the first extra button being recognized as the middle button, the second extra button as the first extra button, etc. Fix consists in using a binary shift with proper offset to create the corresponding Qt::MouseButton value. [ChangeLog][macOS] Fixed extra mouse buttons to be mapped to correct Qt::MouseButton values. Change-Id: I9e6084586cd4737a172b7706a805211f0edff749 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 01fbb7bad2..3ab6b641fa 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -281,16 +281,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; } -- cgit v1.2.3 From 64e977cfac2fbe93fc234d3e134d126591d4c821 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 21 Jan 2017 00:29:28 +0900 Subject: Fix build without features.temporaryfile Change-Id: I3f26f122a20aa8e59baaf3f33b89cc776865ff8b Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- .../platforminputcontexts/compose/generator/qtablegenerator.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/plugins') 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 loadCache(const QComposeCacheFileHeader &co static bool saveCache(const QComposeCacheFileHeader &info, const QVector &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(&info); @@ -207,7 +210,11 @@ static bool saveCache(const QComposeCacheFileHeader &info, const QVector Date: Tue, 24 Jan 2017 13:36:09 -0800 Subject: Rename "interface" to "iface:" there's a #define in windows.h Change-Id: Ibe5b1b60c6ea47e19612fffd149cd2d07116584b Reviewed-by: Jake Petroules --- src/plugins/bearer/qnetworksession_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins') 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 -- cgit v1.2.3 From b6967d0c11a6f559350c105973780445e253d6b3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 13 Jan 2017 09:56:59 +0100 Subject: XCB QPA: Fix QScreen::grabWindow(0) to return the current screen Previously, the code queried the window to be grabbed for the geometry and thus returned the entire virtual desktop for multi screen setups. Use the QPlatformScreen's geometry in case of WID = 0. Task-number: QTBUG-58110 Change-Id: I3a9c0b0b3ea057f5e58f272f5c3fd40fafc073ba Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbscreen.cpp | 117 ++++++++++++++++--------------- 1 file changed, 59 insertions(+), 58 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index d8facdbb84..0ad9c97521 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -678,85 +678,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(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 }; @@ -766,9 +769,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); -- cgit v1.2.3