From 2bdcea9d31d07c32e085a5194873c735e519855d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 12 Dec 2014 15:20:58 +0100 Subject: iOS: Remove QIOSKeyboardListener self-change assert/guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're fairly confident self won't change in that case, and the assert was causing warnings in release builds. Change-Id: I4a826579bb4cedef8423e8d43cb370e1f3b80407 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 76c02d939f..bbfc03667e 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -75,9 +75,7 @@ static QUIView *focusView() - (id)initWithQIOSInputContext:(QIOSInputContext *)context { - id originalSelf = self; if (self = [super initWithTarget:self action:@selector(gestureStateChanged:)]) { - Q_ASSERT(self == originalSelf); m_context = context; -- cgit v1.2.3 From 58fc02241a96b18a1062f2495d40dcdc047a7d5c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 Jan 2015 09:59:52 +0100 Subject: Windows: Release mouse capture when window is blocked by modal window. The capture needs to be cleared when for example a modal dialog is opened from a timer slot or similar while moving the window. Task-number: QTBUG-43308 Change-Id: Id0c01080d67d1057004a7f85b037dce5e220de42 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 7d67aa0d09..4df27faf81 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1770,6 +1770,8 @@ void QWindowsWindow::windowEvent(QEvent *event) case QEvent::WindowBlocked: // Blocked by another modal window. setEnabled(false); setFlag(BlockedByModal); + if (hasMouseCapture()) + ReleaseCapture(); break; case QEvent::WindowUnblocked: setEnabled(true); -- cgit v1.2.3 From 5517d1fde55ee3d4601b4a47543d846467b4d267 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 Jan 2015 12:31:59 +0100 Subject: Windows: Remove check for minimum/maximum size constraints. The warning was triggered when increasing the fixed size of a window. If there is a real violation of the size constraints, the below warning will show. Task-number: QTBUG-43420 Change-Id: I85d7d0a91d040aa3ddeff8c3d105351efd5e14a9 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 4df27faf81..6279b6f4af 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1307,21 +1307,7 @@ void QWindowsWindow::setGeometryDp(const QRect &rectIn) const QMargins margins = frameMarginsDp(); rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top())); } - const QSize oldSize = m_data.geometry.size(); m_data.geometry = rect; - const QSize newSize = rect.size(); - // Check on hint. - if (newSize != oldSize) { - const QWindowsGeometryHint hint(window(), m_data.customMargins); - if (!hint.validSize(newSize)) { - qWarning("%s: Attempt to set a size (%dx%d) violating the constraints" - "(%dx%d - %dx%d) on window %s/'%s'.", __FUNCTION__, - newSize.width(), newSize.height(), - hint.minimumSize.width(), hint.minimumSize.height(), - hint.maximumSize.width(), hint.maximumSize.height(), - window()->metaObject()->className(), qPrintable(window()->objectName())); - } - } if (m_data.hwnd) { // A ResizeEvent with resulting geometry will be sent. If we cannot // achieve that size (for example, window title minimal constraint), -- cgit v1.2.3 From bb16ceac6871a9096547f5170ff174e87a605437 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 5 Jan 2015 14:26:03 +0100 Subject: Prevent buffer overrun when getting the glyph images The change 35bc3dc45aacaf36a8bdfccc7627136cc2e5b185 moved some padding out of QTextureGlyphCache into the font engines directly, however this was not done for the DirectWrite font engine so it caused a buffer overrun. Task-number: QTBUG-41782 Change-Id: I4e643159036f06c5edd8a742dc6694d517a47826 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/windows/qwindowsfontenginedirectwrite.cpp | 17 +++++++++++++++-- .../platforms/windows/qwindowsfontenginedirectwrite.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 648f68bb19..ed512f78ca 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -515,8 +515,9 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t, const QTransform &xform) { glyph_metrics_t metrics = QFontEngine::boundingBox(t, xform); - int width = (metrics.width + margin * 2 + 4).ceil().toInt() ; - int height = (metrics.height + margin * 2 + 4).ceil().toInt(); + // This needs to be kept in sync with alphaMapBoundingBox + int width = (metrics.width + margin * 2).ceil().toInt() ; + int height = (metrics.height + margin * 2).ceil().toInt(); UINT16 glyphIndex = t; FLOAT glyphAdvance = metrics.xoff.toReal(); @@ -699,6 +700,18 @@ QString QWindowsFontEngineDirectWrite::fontNameSubstitute(const QString &familyN return QSettings(QLatin1String(keyC), QSettings::NativeFormat).value(familyName, familyName).toString(); } +glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph, QFixed pos, const QTransform &matrix, GlyphFormat format) +{ + Q_UNUSED(pos); + int margin = 0; + if (format == QFontEngine::Format_A32 || format == QFontEngine::Format_ARGB) + margin = glyphMargin(QFontEngine::Format_A32); + glyph_metrics_t gm = QFontEngine::boundingBox(glyph, matrix); + gm.width += margin * 2; + gm.height += margin * 2; + return gm; +} + QT_END_NAMESPACE #endif // QT_NO_DIRECTWRITE diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h index 2addb90de3..e0466c138d 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h @@ -75,6 +75,7 @@ public: glyph_metrics_t boundingBox(const QGlyphLayout &glyphs); glyph_metrics_t boundingBox(glyph_t g); + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat); QFixed ascent() const; QFixed descent() const; -- cgit v1.2.3 From 8f9ced985727136dc7d1502b7212a54f65b8b113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 12 Dec 2014 15:14:04 +0100 Subject: iOS: Raise window level instead of hiding statusbar during VKB scroll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hiding the statusbar using the normal iOS APIs result in QScreen reporting new availableGeometry, which is not what we want. The scroll of the screen is a purely visual effect, and shouldn't have any effect on observable Qt APIs besides the keyboard rect changing. Instead of actually hiding the statusbar, we achieve the same effect by raising the key window (and any other application windows, including the keyboard) to the level of the statusbar, effectively putting them above the statusbar. This still leaves popups and alert windows above the key window, as normal. Change-Id: Ib7694240ca86cfb9000de35bf0c49343ffb37e32 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 17 ++++++++++++++++- src/plugins/platforms/ios/qiosviewcontroller.mm | 8 +------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index bbfc03667e..6e56f47954 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -503,7 +503,22 @@ void QIOSInputContext::scroll(int y) [rootView.layer addAnimation:animation forKey:@"AnimateSubLayerTransform"]; rootView.layer.sublayerTransform = translationTransform; - [rootView.qtViewController updateProperties]; + bool keyboardScrollIsActive = y != 0; + + // Raise all known windows to above the status-bar if we're scrolling the screen, + // while keeping the relative window level between the windows the same. + NSArray *applicationWindows = [[UIApplication sharedApplication] windows]; + static QHash originalWindowLevels; + for (UIWindow *window in applicationWindows) { + if (keyboardScrollIsActive && !originalWindowLevels.contains(window)) + originalWindowLevels.insert(window, window.windowLevel); + + UIWindowLevel windowLevelAdjustment = keyboardScrollIsActive ? UIWindowLevelStatusBar : 0; + window.windowLevel = originalWindowLevels.value(window) + windowLevelAdjustment; + + if (!keyboardScrollIsActive) + originalWindowLevels.remove(window); + } } completion:^(BOOL){ if (self) { diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index a2d81e3b6c..f678f7e807 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -281,14 +281,8 @@ // All decisions are based on the the top level window focusWindow = qt_window_private(focusWindow)->topLevelWindow(); - bool hasScrolledRootViewDueToVirtualKeyboard = - !CATransform3DIsIdentity(self.view.layer.sublayerTransform); - bool currentStatusBarVisibility = self.prefersStatusBarHidden; - self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen - || hasScrolledRootViewDueToVirtualKeyboard; - self.preferredStatusBarUpdateAnimation = hasScrolledRootViewDueToVirtualKeyboard ? - UIStatusBarAnimationFade : UIStatusBarAnimationNone; + self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen; if (self.prefersStatusBarHidden != currentStatusBarVisibility) { #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) -- cgit v1.2.3 From d40b66a8ef98777c69ac293dac9a332f88832c23 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 7 Jan 2015 14:50:41 +0100 Subject: Fix use-after-free bug xcb_image_destroy() calls free on m_xcb_image and then few lines down we access member of m_xcb_image. Swap order of these two actions. Change-Id: I01fb43a066459cce462df6af22161c35cef524eb Task-number: QTBUG-43623 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 0b9717759b..f4382c7b50 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -145,8 +145,6 @@ void QXcbShmImage::destroy() if (segmentSize && m_shm_info.shmaddr) Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg)); - xcb_image_destroy(m_xcb_image); - if (segmentSize) { if (m_shm_info.shmaddr) { shmdt(m_shm_info.shmaddr); @@ -156,6 +154,8 @@ void QXcbShmImage::destroy() } } + xcb_image_destroy(m_xcb_image); + if (m_gc) Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); } -- cgit v1.2.3 From 72bc032ca8f7fc00900a9ca20bab8560ccf99727 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 24 Dec 2014 10:11:02 +1000 Subject: Refactor networkmanager QtBearer backend to use QDBusAbstractInterface. Using QDBusInterface causes introspection, which may not be permitted by some platforms. Change-Id: I953d27b9c0fc7c21d52fefeb8c7760a7235aed9d Reviewed-by: Alex Blasche --- .../networkmanager/qnetworkmanagerengine.cpp | 52 +- .../networkmanager/qnetworkmanagerservice.cpp | 556 +++++---------------- .../bearer/networkmanager/qnetworkmanagerservice.h | 88 +--- 3 files changed, 186 insertions(+), 510 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index f0977b4735..f52b9d4b4d 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -125,7 +125,6 @@ void QNetworkManagerEngine::setupConfigurations() activeConnectionsList.insert(acPath.path(), activeConnection); connect(activeConnection, SIGNAL(propertiesChanged(QMap)), this, SLOT(activeConnectionPropertiesChanged(QMap))); - activeConnection->setConnections(); QStringList devices = activeConnection->devices(); if (!devices.isEmpty()) { @@ -180,7 +179,7 @@ void QNetworkManagerEngine::connectToId(const QString &id) NMDeviceType connectionType = connection->getType(); QString dbusDevicePath; - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); QString specificPath = configuredAccessPoints.key(settingsPath); if (isConnectionActive(settingsPath)) @@ -277,7 +276,6 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QMap)), this, SLOT(activeConnectionPropertiesChanged(QMap))); - activeConnection->setConnections(); } const QString id = activeConnection->connection().path(); @@ -373,10 +371,10 @@ void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connecti { QMutexLocker locker(&mutex); for (int i = 0; i < connections.count(); ++i) { - if (connectionsList.contains(connections.at(i)->connectionInterface()->path())) + if (connectionsList.contains(connections.at(i)->path())) continue; - const QString settingsPath = connections.at(i)->connectionInterface()->path(); + const QString settingsPath = connections.at(i)->path(); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(settingsPath); @@ -399,11 +397,10 @@ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) connect(iDevice,SIGNAL(connectionsChanged(QStringList)), this,SLOT(deviceConnectionsChanged(QStringList))); - iDevice->setConnections(); interfaceDevices.insert(path.path(),iDevice); if (iDevice->deviceType() == DEVICE_TYPE_WIFI) { QNetworkManagerInterfaceDeviceWireless *wirelessDevice = - new QNetworkManagerInterfaceDeviceWireless(iDevice->connectionInterface()->path(),this); + new QNetworkManagerInterfaceDeviceWireless(iDevice->path(),this); connect(wirelessDevice, SIGNAL(accessPointAdded(QString)), this, SLOT(newAccessPoint(QString))); @@ -417,9 +414,9 @@ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) if (iDevice->deviceType() == DEVICE_TYPE_ETHERNET) { QNetworkManagerInterfaceDeviceWired *wiredDevice = - new QNetworkManagerInterfaceDeviceWired(iDevice->connectionInterface()->path(),this); + new QNetworkManagerInterfaceDeviceWired(iDevice->path(),this); connect(wiredDevice,SIGNAL(carrierChanged(bool)),this,SLOT(wiredCarrierChanged(bool))); - wiredDevices.insert(iDevice->connectionInterface()->path(), wiredDevice); + wiredDevices.insert(iDevice->path(), wiredDevice); } } @@ -454,7 +451,7 @@ void QNetworkManagerEngine::wiredCarrierChanged(bool carrier) for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); if (connection->getType() == DEVICE_TYPE_ETHERNET - && settingsPath.path() == connection->connectionInterface()->path()) { + && settingsPath.path() == connection->path()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(settingsPath.path()); @@ -486,9 +483,9 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, } QNetworkManagerSettingsConnection *connection = - new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(), + new QNetworkManagerSettingsConnection(settings->service(), path.path(),this); - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); if (accessPointConfigurations.contains(settingsPath)) { return; } @@ -506,7 +503,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, for (int i = 0; i < accessPoints.count(); ++i) { if (connection->getSsid() == accessPoints.at(i)->ssid()) { // remove the corresponding accesspoint from configurations - apPath = accessPoints.at(i)->connectionInterface()->path(); + apPath = accessPoints.at(i)->path(); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(apPath); if (ptr) { @@ -533,7 +530,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, i.next(); if (i.value()->deviceType() == deviceType) { QNetworkManagerInterfaceDeviceWired *wiredDevice - = wiredDevices.value(i.value()->connectionInterface()->path()); + = wiredDevices.value(i.value()->path()); if (wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; } @@ -564,7 +561,7 @@ bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath) QNetworkManagerSettingsConnection *settingsConnection = connectionFromId(settingsPath); if (settingsConnection->getType() == DEVICE_TYPE_MODEM) { - return isActiveContext(settingsConnection->connectionInterface()->path()); + return isActiveContext(settingsConnection->path()); } return false; @@ -611,7 +608,7 @@ void QNetworkManagerEngine::updateConnection() qobject_cast(sender()); if (!connection) return; - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings()); @@ -682,20 +679,19 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path) bool okToAdd = true; for (int i = 0; i < accessPoints.count(); ++i) { - if (accessPoints.at(i)->connectionInterface()->path() == path) { + if (accessPoints.at(i)->path() == path) { okToAdd = false; } } if (okToAdd) { accessPoints.append(accessPoint); - accessPoint->setConnections(); } // Check if configuration exists for connection. if (!accessPoint->ssid().isEmpty()) { for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); if (accessPoint->ssid() == connection->getSsid()) { if (!configuredAccessPoints.contains(path)) { @@ -741,18 +737,18 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path) QMutexLocker locker(&mutex); for (int i = 0; i < accessPoints.count(); ++i) { QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); - if (accessPoint->connectionInterface()->path() == path) { + if (accessPoint->path() == path) { accessPoints.removeOne(accessPoint); - if (configuredAccessPoints.contains(accessPoint->connectionInterface()->path())) { + if (configuredAccessPoints.contains(accessPoint->path())) { // find connection and change state to Defined - configuredAccessPoints.remove(accessPoint->connectionInterface()->path()); + configuredAccessPoints.remove(accessPoint->path()); for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet - const QString settingsPath = connection->connectionInterface()->path(); + const QString settingsPath = connection->path(); const QString connectionId = settingsPath; QNetworkConfigurationPrivatePointer ptr = @@ -804,7 +800,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) { QNetworkManagerInterfaceDevice device(devicePath.path(),this); if (device.deviceType() == DEVICE_TYPE_ETHERNET) { - QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.connectionInterface()->path()); + QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.path()); if (wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; break; @@ -819,10 +815,10 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri if (connectionSsid == accessPoints.at(i)->ssid() && map.value("802-11-wireless").value("seen-bssids").toStringList().contains(accessPoints.at(i)->hwAddress())) { cpPriv->state |= QNetworkConfiguration::Discovered; - if (!configuredAccessPoints.contains(accessPoints.at(i)->connectionInterface()->path())) { - configuredAccessPoints.insert(accessPoints.at(i)->connectionInterface()->path(),settingsPath); + if (!configuredAccessPoints.contains(accessPoints.at(i)->path())) { + configuredAccessPoints.insert(accessPoints.at(i)->path(),settingsPath); - const QString accessPointId = accessPoints.at(i)->connectionInterface()->path(); + const QString accessPointId = accessPoints.at(i)->path(); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(accessPointId); @@ -881,7 +877,7 @@ QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const { for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); - if (id == connection->connectionInterface()->path()) + if (id == connection->path()) return connection; } diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 9f4ae55e78..16a7e475e0 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -47,32 +47,24 @@ #ifndef QT_NO_DBUS +#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties" + QT_BEGIN_NAMESPACE -class QNetworkManagerInterfacePrivate -{ -public: - QDBusInterface *connectionInterface; - bool valid; -}; QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfacePrivate(); - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - QLatin1String(NM_DBUS_PATH), - QLatin1String(NM_DBUS_INTERFACE), - QDBusConnection::systemBus(),parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + NM_DBUS_INTERFACE, + QDBusConnection::systemBus(),parent) +{ + if (!isValid()) { return; } - d->valid = true; - QDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + PropertiesDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), - QLatin1String("org.freedesktop.DBus.Properties"), + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus()); QList argumentList; argumentList << QLatin1String(NM_DBUS_INTERFACE); @@ -81,13 +73,17 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) argumentList); if (!propsReply.isError()) { propertyMap = propsReply.value(); + } else { + qWarning() << Q_FUNC_INFO << "propsReply"< > nmReply - = d->connectionInterface->call(QLatin1String("GetDevices")); + = call(QLatin1String("GetDevices")); nmReply.waitForFinished(); if (!nmReply.isError()) { devicesPathList = nmReply.value(); + } else { + qWarning() << Q_FUNC_INFO <<"nmReply"<connectionInterface; - delete d; -} - -bool QNetworkManagerInterface::isValid() -{ - return d->valid; } bool QNetworkManagerInterface::setConnections() @@ -138,16 +127,11 @@ bool QNetworkManagerInterface::setConnections() return allOk; } -QDBusInterface *QNetworkManagerInterface::connectionInterface() const -{ - return d->connectionInterface; -} - QList QNetworkManagerInterface::getDevices() { if (devicesPathList.isEmpty()) { //qWarning() << "using blocking call!"; - QDBusReply > reply = d->connectionInterface->call(QLatin1String("GetDevices")); + QDBusReply > reply = call(QLatin1String("GetDevices")); devicesPathList = reply.value(); } return devicesPathList; @@ -157,7 +141,7 @@ void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath QDBusObjectPath devicePath, QDBusObjectPath specificObject) { - QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"), + QDBusPendingCall pendingCall = asyncCall(QLatin1String("ActivateConnection"), QVariant::fromValue(connectionPath), QVariant::fromValue(devicePath), QVariant::fromValue(specificObject)); @@ -167,9 +151,9 @@ void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath this, SIGNAL(activationFinished(QDBusPendingCallWatcher*))); } -void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) const +void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) { - d->connectionInterface->asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath)); + asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath)); } bool QNetworkManagerInterface::wirelessEnabled() const @@ -245,73 +229,38 @@ void QNetworkManagerInterface::propertiesSwap(QMap map) } } -class QNetworkManagerInterfaceAccessPointPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfaceAccessPointPrivate(); - d->path = dbusPathName; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), - QDBusConnection::systemBus(),parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + dbusPathName, + NM_DBUS_INTERFACE_ACCESS_POINT, + QDBusConnection::systemBus(),parent) +{ + if (!isValid()) { return; } - QDBusInterface accessPointPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), + PropertiesDBusInterface *accessPointPropertiesInterface = new PropertiesDBusInterface(QLatin1String(NM_DBUS_SERVICE), + dbusPathName, + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus()); QList argumentList; argumentList << QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT); QDBusPendingReply propsReply - = accessPointPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), + = accessPointPropertiesInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), argumentList); if (!propsReply.isError()) { propertyMap = propsReply.value(); } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + dbusPathName, QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - - d->valid = true; - } QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceAccessPoint::isValid() -{ - return d->valid; -} - -bool QNetworkManagerInterfaceAccessPoint::setConnections() -{ - if (!isValid()) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerInterfaceAccessPoint::connectionInterface() const -{ - return d->connectionInterface; } quint32 QNetworkManagerInterfaceAccessPoint::flags() const @@ -386,31 +335,19 @@ void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap } } -class QNetworkManagerInterfaceDevicePrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent) - : QObject(parent) + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + deviceObjectPath, + NM_DBUS_INTERFACE_DEVICE, + QDBusConnection::systemBus(),parent) { - d = new QNetworkManagerInterfaceDevicePrivate(); - d->path = deviceObjectPath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE), - QDBusConnection::systemBus(),parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + if (!isValid()) { return; } - QDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), + PropertiesDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + deviceObjectPath, + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus(),parent); QList argumentList; @@ -424,35 +361,14 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + deviceObjectPath, QLatin1String(NM_DBUS_INTERFACE_DEVICE), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - d->valid = true; } QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDevice::isValid() -{ - return d->valid; -} - -bool QNetworkManagerInterfaceDevice::setConnections() -{ - if (!isValid()) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerInterfaceDevice::connectionInterface() const -{ - return d->connectionInterface; } QString QNetworkManagerInterfaceDevice::udi() const @@ -519,31 +435,19 @@ void QNetworkManagerInterfaceDevice::propertiesSwap(QMap map) Q_EMIT propertiesChanged(map); } -class QNetworkManagerInterfaceDeviceWiredPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfaceDeviceWiredPrivate(); - d->path = ifaceDevicePath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + NM_DBUS_INTERFACE_DEVICE_WIRED, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - QDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), - QDBusConnection::systemBus(),parent); + PropertiesDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + DBUS_PROPERTIES_INTERFACE, + QDBusConnection::systemBus(),parent); QList argumentList; argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED); @@ -556,36 +460,14 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + ifaceDevicePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - - d->valid = true; } QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDeviceWired::isValid() -{ - - return d->valid; -} - -bool QNetworkManagerInterfaceDeviceWired::setConnections() -{ - if (!isValid()) - return false; - return true; -} - -QDBusInterface *QNetworkManagerInterfaceDeviceWired::connectionInterface() const -{ - return d->connectionInterface; } QString QNetworkManagerInterfaceDeviceWired::hwAddress() const @@ -639,39 +521,27 @@ void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap Q_EMIT propertiesChanged(map); } -class QNetworkManagerInterfaceDeviceWirelessPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerInterfaceDeviceWirelessPrivate(); - d->path = ifaceDevicePath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + NM_DBUS_INTERFACE_DEVICE_WIRELESS, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - + interfacePath = ifaceDevicePath; QDBusPendingReply > nmReply - = d->connectionInterface->call(QLatin1String("GetAccessPoints")); + = call(QLatin1String("GetAccessPoints")); if (!nmReply.isError()) { accessPointsList = nmReply.value(); } - QDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String("org.freedesktop.DBus.Properties"), + PropertiesDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + interfacePath, + DBUS_PROPERTIES_INTERFACE, QDBusConnection::systemBus(),parent); QList argumentList; @@ -684,31 +554,21 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + interfacePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); QDBusPendingReply > reply - = d->connectionInterface->asyncCall(QLatin1String("GetAccessPoints")); + = asyncCall(QLatin1String("GetAccessPoints")); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(reply); connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(accessPointsFinished(QDBusPendingCallWatcher*))); - - - d->valid = true; } QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDeviceWireless::isValid() -{ - return d->valid; } void QNetworkManagerInterfaceDeviceWireless::slotAccessPointAdded(QDBusObjectPath path) @@ -732,16 +592,16 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections() bool allOk = true; if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("AccessPointAdded"), - this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { + interfacePath, + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), + QLatin1String("AccessPointAdded"), + this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { allOk = false; } if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + interfacePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("AccessPointRemoved"), this, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) { @@ -749,7 +609,7 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections() } if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + interfacePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("ScanDone"), this, SLOT(scanIsDone()))) { @@ -771,17 +631,12 @@ void QNetworkManagerInterfaceDeviceWireless::accessPointsFinished(QDBusPendingCa } } -QDBusInterface *QNetworkManagerInterfaceDeviceWireless::connectionInterface() const -{ - return d->connectionInterface; -} - QList QNetworkManagerInterfaceDeviceWireless::getAccessPoints() { if (accessPointsList.isEmpty()) { //qWarning() << "Using blocking call!"; QDBusReply > reply - = d->connectionInterface->call(QLatin1String("GetAccessPoints")); + = call(QLatin1String("GetAccessPoints")); accessPointsList = reply.value(); } return accessPointsList; @@ -829,7 +684,7 @@ void QNetworkManagerInterfaceDeviceWireless::scanIsDone() void QNetworkManagerInterfaceDeviceWireless::requestScan() { - d->connectionInterface->asyncCall(QLatin1String("RequestScan")); + asyncCall(QLatin1String("RequestScan")); } void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap map) @@ -844,29 +699,17 @@ void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMappath = ifaceDevicePath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, + NM_DBUS_INTERFACE_DEVICE_MODEM, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - QDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, + PropertiesDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + ifaceDevicePath, QLatin1String("org.freedesktop.DBus.Properties"), QDBusConnection::systemBus(),parent); @@ -880,36 +723,14 @@ QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const Q } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + ifaceDevicePath, QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - d->valid = true; } QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerInterfaceDeviceModem::isValid() -{ - - return d->valid; -} - -bool QNetworkManagerInterfaceDeviceModem::setConnections() -{ - if (!isValid() ) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerInterfaceDeviceModem::connectionInterface() const -{ - return d->connectionInterface; } QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const @@ -936,59 +757,39 @@ void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap Q_EMIT propertiesChanged(map); } -class QNetworkManagerSettingsPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerSettingsPrivate(); - d->path = settingsService; - d->connectionInterface = new QDBusInterface(settingsService, - QLatin1String(NM_DBUS_PATH_SETTINGS), - QLatin1String(NM_DBUS_IFACE_SETTINGS), - QDBusConnection::systemBus()); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(settingsService, + NM_DBUS_PATH_SETTINGS, + NM_DBUS_IFACE_SETTINGS, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - + interfacePath = settingsService; QDBusPendingReply > nmReply - = d->connectionInterface->call(QLatin1String("ListConnections")); + = call(QLatin1String("ListConnections")); if (!nmReply.isError()) { connectionsList = nmReply.value(); } - - d->valid = true; } QNetworkManagerSettings::~QNetworkManagerSettings() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerSettings::isValid() -{ - return d->valid; } bool QNetworkManagerSettings::setConnections() { bool allOk = true; - - if (!QDBusConnection::systemBus().connect(d->path, + if (!QDBusConnection::systemBus().connect(interfacePath, QLatin1String(NM_DBUS_PATH_SETTINGS), QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"), this, SIGNAL(newConnection(QDBusObjectPath)))) { allOk = false; + qWarning() << Q_FUNC_INFO << "NewConnection could not be connected"; } return allOk; @@ -999,7 +800,7 @@ QList QNetworkManagerSettings::listConnections() if (connectionsList.isEmpty()) { //qWarning() << "Using blocking call!"; QDBusReply > reply - = d->connectionInterface->call(QLatin1String("ListConnections")); + = call(QLatin1String("ListConnections")); connectionsList = reply.value(); } return connectionsList; @@ -1010,59 +811,30 @@ QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid) { QList argumentList; argumentList << QVariant::fromValue(uuid); - QDBusReply reply = d->connectionInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList); + QDBusReply reply = callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList); return reply.value().path(); } -QDBusInterface *QNetworkManagerSettings::connectionInterface() const -{ - return d->connectionInterface; -} - - -class QNetworkManagerSettingsConnectionPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - QString service; - QNmSettingsMap settingsMap; - bool valid; -}; - QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent) - : QObject(parent) + : QDBusAbstractInterface(settingsService, + connectionObjectPath, + NM_DBUS_IFACE_SETTINGS_CONNECTION, + QDBusConnection::systemBus(), parent) { qDBusRegisterMetaType(); - d = new QNetworkManagerSettingsConnectionPrivate(); - d->path = connectionObjectPath; - d->service = settingsService; - d->connectionInterface = new QDBusInterface(settingsService, - d->path, - QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + if (!isValid()) { return; } - d->valid = true; - + interfacepath = connectionObjectPath; QDBusPendingReply nmReply - = d->connectionInterface->call(QLatin1String("GetSettings")); + = call(QLatin1String("GetSettings")); if (!nmReply.isError()) { - d->settingsMap = nmReply.value(); + settingsMap = nmReply.value(); } } QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerSettingsConnection::isValid() -{ - return d->valid; } bool QNetworkManagerSettingsConnection::setConnections() @@ -1072,16 +844,16 @@ bool QNetworkManagerSettingsConnection::setConnections() QDBusConnection dbusConnection = QDBusConnection::systemBus(); bool allOk = true; - if (!dbusConnection.connect(d->service, - d->path, + if (!dbusConnection.connect(service(), + interfacepath, QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"), this, SIGNAL(updated()))) { allOk = false; } - if (!dbusConnection.connect(d->service, - d->path, + if (!dbusConnection.connect(service(), + interfacepath, QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"), this, SIGNAL(slotSettingsRemoved()))) { @@ -1092,28 +864,23 @@ bool QNetworkManagerSettingsConnection::setConnections() void QNetworkManagerSettingsConnection::slotSettingsRemoved() { - Q_EMIT removed(d->path); -} - -QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const -{ - return d->connectionInterface; + Q_EMIT removed(interfacepath); } QNmSettingsMap QNetworkManagerSettingsConnection::getSettings() { - if (d->settingsMap.isEmpty()) { + if (settingsMap.isEmpty()) { //qWarning() << "Using blocking call!"; - QDBusReply reply = d->connectionInterface->call(QLatin1String("GetSettings")); - d->settingsMap = reply.value(); + QDBusReply reply = call(QLatin1String("GetSettings")); + settingsMap = reply.value(); } - return d->settingsMap; + return settingsMap; } NMDeviceType QNetworkManagerSettingsConnection::getType() { const QString devType = - d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString(); + settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString(); if (devType == QLatin1String("802-3-ethernet")) return DEVICE_TYPE_ETHERNET; @@ -1128,7 +895,7 @@ NMDeviceType QNetworkManagerSettingsConnection::getType() bool QNetworkManagerSettingsConnection::isAutoConnect() { const QVariant autoConnect = - d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect")); + settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect")); // NetworkManager default is to auto connect if (!autoConnect.isValid()) @@ -1139,27 +906,27 @@ bool QNetworkManagerSettingsConnection::isAutoConnect() quint64 QNetworkManagerSettingsConnection::getTimestamp() { - return d->settingsMap.value(QLatin1String("connection")) + return settingsMap.value(QLatin1String("connection")) .value(QLatin1String("timestamp")).toUInt(); } QString QNetworkManagerSettingsConnection::getId() { - return d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString(); + return settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString(); } QString QNetworkManagerSettingsConnection::getUuid() { - const QString id = d->settingsMap.value(QLatin1String("connection")) + const QString id = settingsMap.value(QLatin1String("connection")) .value(QLatin1String("uuid")).toString(); // is no uuid, return the connection path - return id.isEmpty() ? d->connectionInterface->path() : id; + return id.isEmpty() ? path() : id; } QString QNetworkManagerSettingsConnection::getSsid() { - return d->settingsMap.value(QLatin1String("802-11-wireless")) + return settingsMap.value(QLatin1String("802-11-wireless")) .value(QLatin1String("ssid")).toString(); } @@ -1168,10 +935,10 @@ QString QNetworkManagerSettingsConnection::getMacAddress() NMDeviceType type = getType(); if (type == DEVICE_TYPE_ETHERNET) { - return d->settingsMap.value(QLatin1String("802-3-ethernet")) + return settingsMap.value(QLatin1String("802-3-ethernet")) .value(QLatin1String("mac-address")).toString(); } else if (type == DEVICE_TYPE_WIFI) { - return d->settingsMap.value(QLatin1String("802-11-wireless")) + return settingsMap.value(QLatin1String("802-11-wireless")) .value(QLatin1String("mac-address")).toString(); } else { return QString(); @@ -1181,36 +948,24 @@ QString QNetworkManagerSettingsConnection::getMacAddress() QStringList QNetworkManagerSettingsConnection::getSeenBssids() { if (getType() == DEVICE_TYPE_WIFI) { - return d->settingsMap.value(QLatin1String("802-11-wireless")) + return settingsMap.value(QLatin1String("802-11-wireless")) .value(QLatin1String("seen-bssids")).toStringList(); } else { return QStringList(); } } -class QNetworkManagerConnectionActivePrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerConnectionActivePrivate(); - d->path = activeConnectionObjectPath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + activeConnectionObjectPath, + NM_DBUS_INTERFACE_ACTIVE_CONNECTION, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - QDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, + PropertiesDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), + activeConnectionObjectPath, QLatin1String("org.freedesktop.DBus.Properties"), QDBusConnection::systemBus()); @@ -1228,35 +983,14 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString & } QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - d->path, + activeConnectionObjectPath, QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap))); - d->valid = true; } QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerConnectionActive::isValid() -{ - return d->valid; -} - -bool QNetworkManagerConnectionActive::setConnections() -{ - if (!isValid()) - return false; - - return true; -} - -QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const -{ - return d->connectionInterface; } QDBusObjectPath QNetworkManagerConnectionActive::connection() const @@ -1327,44 +1061,24 @@ void QNetworkManagerConnectionActive::propertiesSwap(QMap map) } } -class QNetworkManagerIp4ConfigPrivate -{ -public: - QDBusInterface *connectionInterface; - QString path; - bool valid; -}; - QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectPath, QObject *parent) - : QObject(parent) -{ - d = new QNetworkManagerIp4ConfigPrivate(); - d->path = deviceObjectPath; - d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), - d->path, - QLatin1String(NM_DBUS_INTERFACE_IP4_CONFIG), - QDBusConnection::systemBus(), parent); - if (!d->connectionInterface->isValid()) { - d->valid = false; + : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), + deviceObjectPath, + NM_DBUS_INTERFACE_IP4_CONFIG, + QDBusConnection::systemBus(), parent) +{ + if (!isValid()) { return; } - d->valid = true; } QNetworkManagerIp4Config::~QNetworkManagerIp4Config() { - delete d->connectionInterface; - delete d; -} - -bool QNetworkManagerIp4Config::isValid() -{ - return d->valid; } QStringList QNetworkManagerIp4Config::domains() const { - return d->connectionInterface->property("Domains").toStringList(); + return property("Domains").toStringList(); } QT_END_NAMESPACE diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index e645159d71..f945532603 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -55,6 +55,7 @@ #include #include #include +#include #include #ifndef QT_NO_DBUS @@ -128,8 +129,7 @@ Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ServerThing)) QT_BEGIN_NAMESPACE -class QNetworkManagerInterfacePrivate; -class QNetworkManagerInterface : public QObject +class QNetworkManagerInterface : public QDBusAbstractInterface { Q_OBJECT @@ -151,10 +151,9 @@ public: QList getDevices(); void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject); - void deactivateConnection(QDBusObjectPath connectionPath) const; + void deactivateConnection(QDBusObjectPath connectionPath); QDBusObjectPath path() const; - QDBusInterface *connectionInterface() const; bool wirelessEnabled() const; bool wirelessHardwareEnabled() const; @@ -162,7 +161,6 @@ public: NMState state(); QString version() const; bool setConnections(); - bool isValid(); Q_SIGNALS: void deviceAdded(QDBusObjectPath); @@ -177,14 +175,12 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfacePrivate *d; QVariantMap propertyMap; QList devicesPathList; }; -class QNetworkManagerInterfaceAccessPointPrivate; -class QNetworkManagerInterfaceAccessPoint : public QObject +class QNetworkManagerInterfaceAccessPoint : public QDBusAbstractInterface { Q_OBJECT @@ -229,8 +225,6 @@ public: explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0); ~QNetworkManagerInterfaceAccessPoint(); - QDBusInterface *connectionInterface() const; - quint32 flags() const; quint32 wpaFlags() const; quint32 rsnFlags() const; @@ -240,8 +234,7 @@ public: quint32 mode() const; quint32 maxBitrate() const; quint32 strength() const; - bool setConnections(); - bool isValid(); + // bool setConnections(); Q_SIGNALS: void propertiesChanged(QMap ); @@ -251,12 +244,10 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceAccessPointPrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerInterfaceDevicePrivate; -class QNetworkManagerInterfaceDevice : public QObject +class QNetworkManagerInterfaceDevice : public QDBusAbstractInterface { Q_OBJECT @@ -267,14 +258,11 @@ public: QString udi() const; QString networkInterface() const; - QDBusInterface *connectionInterface() const; quint32 ip4Address() const; quint32 state() const; quint32 deviceType() const; QDBusObjectPath ip4config() const; - bool setConnections(); - bool isValid(); Q_SIGNALS: void stateChanged(const QString &, quint32); @@ -284,12 +272,10 @@ Q_SIGNALS: private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceDevicePrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerInterfaceDeviceWiredPrivate; -class QNetworkManagerInterfaceDeviceWired : public QObject +class QNetworkManagerInterfaceDeviceWired : public QDBusAbstractInterface { Q_OBJECT @@ -299,12 +285,9 @@ public: QObject *parent = 0); ~QNetworkManagerInterfaceDeviceWired(); - QDBusInterface *connectionInterface() const; QString hwAddress() const; quint32 speed() const; bool carrier() const; - bool setConnections(); - bool isValid(); QStringList availableConnections(); Q_SIGNALS: @@ -316,12 +299,10 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceDeviceWiredPrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerInterfaceDeviceWirelessPrivate; -class QNetworkManagerInterfaceDeviceWireless : public QObject +class QNetworkManagerInterfaceDeviceWireless : public QDBusAbstractInterface { Q_OBJECT @@ -343,7 +324,6 @@ public: QDBusObjectPath path() const; QList getAccessPoints(); - QDBusInterface *connectionInterface() const; QString hwAddress() const; quint32 mode() const; @@ -351,7 +331,6 @@ public: QDBusObjectPath activeAccessPoint() const; quint32 wirelessCapabilities() const; bool setConnections(); - bool isValid(); void requestScan(); Q_SIGNALS: @@ -372,13 +351,12 @@ private Q_SLOTS: void accessPointsFinished(QDBusPendingCallWatcher *watcher); private: - QNetworkManagerInterfaceDeviceWirelessPrivate *d; QVariantMap propertyMap; QList accessPointsList; + QString interfacePath; }; -class QNetworkManagerInterfaceDeviceModemPrivate; -class QNetworkManagerInterfaceDeviceModem : public QObject +class QNetworkManagerInterfaceDeviceModem : public QDBusAbstractInterface { Q_OBJECT @@ -397,12 +375,6 @@ public: QObject *parent = 0); ~QNetworkManagerInterfaceDeviceModem(); - QDBusObjectPath path() const; - QDBusInterface *connectionInterface() const; - - bool setConnections(); - bool isValid(); - ModemCapabilities modemCapabilities() const; ModemCapabilities currentCapabilities() const; @@ -414,14 +386,12 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerInterfaceDeviceModemPrivate *d; QVariantMap propertyMap; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities) -class QNetworkManagerSettingsPrivate; -class QNetworkManagerSettings : public QObject +class QNetworkManagerSettings : public QDBusAbstractInterface { Q_OBJECT @@ -430,22 +400,19 @@ public: explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0); ~QNetworkManagerSettings(); - QDBusInterface *connectionInterface() const; QList listConnections(); QString getConnectionByUuid(const QString &uuid); bool setConnections(); - bool isValid(); Q_SIGNALS: void newConnection(QDBusObjectPath); void connectionsListReady(); private: - QNetworkManagerSettingsPrivate *d; QList connectionsList; + QString interfacePath; }; -class QNetworkManagerSettingsConnectionPrivate; -class QNetworkManagerSettingsConnection : public QObject +class QNetworkManagerSettingsConnection : public QDBusAbstractInterface { Q_OBJECT @@ -454,7 +421,6 @@ public: QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = 0); ~QNetworkManagerSettingsConnection(); - QDBusInterface *connectionInterface() const; QNmSettingsMap getSettings(); bool setConnections(); NMDeviceType getType(); @@ -465,7 +431,6 @@ public: QString getSsid(); QString getMacAddress(); QStringList getSeenBssids(); - bool isValid(); Q_SIGNALS: void updated(); @@ -474,13 +439,12 @@ Q_SIGNALS: private Q_SLOTS: void slotSettingsRemoved(); - private: - QNetworkManagerSettingsConnectionPrivate *d; + QNmSettingsMap settingsMap; + QString interfacepath; }; -class QNetworkManagerConnectionActivePrivate; -class QNetworkManagerConnectionActive : public QObject +class QNetworkManagerConnectionActive : public QDBusAbstractInterface { Q_OBJECT @@ -495,15 +459,12 @@ public: explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0); ~ QNetworkManagerConnectionActive(); - QDBusInterface *connectionInterface() const; QDBusObjectPath connection() const; QDBusObjectPath specificObject() const; QStringList devices() const; quint32 state() const; bool defaultRoute() const; bool default6Route() const; - bool setConnections(); - bool isValid(); Q_SIGNALS: @@ -514,12 +475,10 @@ private Q_SLOTS: void propertiesSwap(QMap); private: - QNetworkManagerConnectionActivePrivate *d; QVariantMap propertyMap; }; -class QNetworkManagerIp4ConfigPrivate; -class QNetworkManagerIp4Config : public QObject +class QNetworkManagerIp4Config : public QDBusAbstractInterface { Q_OBJECT @@ -528,10 +487,17 @@ public: ~QNetworkManagerIp4Config(); QStringList domains() const; - bool isValid(); +}; - private: - QNetworkManagerIp4ConfigPrivate *d; +class PropertiesDBusInterface : public QDBusAbstractInterface +{ +public: + PropertiesDBusInterface(const QString &service, const QString &path, + const QString &interface, const QDBusConnection &connection, + QObject *parent = 0) + : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent) + {} + ~PropertiesDBusInterface() = default; }; QT_END_NAMESPACE -- cgit v1.2.3 From e6699afbee77b853773579d29d78a1ade2a4ab2c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 7 Jan 2015 15:19:07 +0100 Subject: Fix physical DPI and size for rotated screens on X11 Rotated screens would use the unrotated physical geometry, causing the calculated physical DPI to be completely wrong. In RandR, the output does not rotate, so the physical size is always for the unrotated display. The transformation is done on the crtc. http://www.x.org/releases/X11R7.6/doc/randrproto/randrproto.txt Task-number: QTBUG-43688 Change-Id: Ifde192fcc99a37d0bfd6d57b4cdeac124a054ca3 Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge Reviewed-by: Uli Schlachter --- src/plugins/platforms/xcb/qxcbscreen.cpp | 22 +++++++++++++++++++++- src/plugins/platforms/xcb/qxcbscreen.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8bdedba8ac..73f27c7117 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -53,7 +53,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, , m_screen(scr) , m_crtc(output ? output->crtc : 0) , m_outputName(outputName) - , m_sizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize()) + , m_outputSizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize()) , m_virtualSize(scr->width_in_pixels, scr->height_in_pixels) , m_virtualSizeMillimeters(scr->width_in_millimeters, scr->height_in_millimeters) , m_orientation(Qt::PrimaryOrientation) @@ -71,6 +71,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, updateGeometry(output ? output->timestamp : 0); updateRefreshRate(); + const int dpr = int(devicePixelRatio()); // On VNC, it can be that physical size is unknown while // virtual size is known (probably back-calculated from DPI and resolution) @@ -93,6 +94,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, qDebug(" virtual height.: %lf", m_virtualSizeMillimeters.height()); qDebug(" virtual geom...: %d x %d", m_virtualSize.width(), m_virtualSize.height()); qDebug(" avail virt geom: %d x %d +%d +%d", m_availableGeometry.width(), m_availableGeometry.height(), m_availableGeometry.x(), m_availableGeometry.y()); + qDebug(" orientation....: %d", m_orientation); qDebug(" pixel ratio....: %d", m_devicePixelRatio); qDebug(" depth..........: %d", screen()->root_depth); qDebug(" white pixel....: %x", screen()->white_pixel); @@ -413,6 +415,24 @@ void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp) if (crtc) { xGeometry = QRect(crtc->x, crtc->y, crtc->width, crtc->height); xAvailableGeometry = xGeometry; + switch (crtc->rotation) { + case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal + m_orientation = Qt::LandscapeOrientation; + m_sizeMillimeters = m_outputSizeMillimeters; + break; + case XCB_RANDR_ROTATION_ROTATE_90: // xrandr --rotate left + m_orientation = Qt::PortraitOrientation; + m_sizeMillimeters = m_outputSizeMillimeters.transposed(); + break; + case XCB_RANDR_ROTATION_ROTATE_180: // xrandr --rotate inverted + m_orientation = Qt::InvertedLandscapeOrientation; + m_sizeMillimeters = m_outputSizeMillimeters; + break; + case XCB_RANDR_ROTATION_ROTATE_270: // xrandr --rotate right + m_orientation = Qt::InvertedPortraitOrientation; + m_sizeMillimeters = m_outputSizeMillimeters.transposed(); + break; + } free(crtc); } } diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index ca0aee2cc4..b9ee331104 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -111,6 +111,7 @@ private: xcb_screen_t *m_screen; xcb_randr_crtc_t m_crtc; QString m_outputName; + QSizeF m_outputSizeMillimeters; QSizeF m_sizeMillimeters; QRect m_geometry; QRect m_availableGeometry; -- cgit v1.2.3 From d62cd6508a54fbc7950b669c1bc966663d7c10b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 7 Jan 2015 13:44:34 +0100 Subject: iOS: Move implementation details of QIOSViewController to class extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I602d8f1c9f20d3bfed4db3405460021146b546d8 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosviewcontroller.h | 10 ++++------ src/plugins/platforms/ios/qiosviewcontroller.mm | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h index 586edd589d..684e06e030 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.h +++ b/src/plugins/platforms/ios/qiosviewcontroller.h @@ -35,15 +35,13 @@ class QIOSScreen; -@interface QIOSViewController : UIViewController { - QIOSScreen *m_screen; -} +@interface QIOSViewController : UIViewController + +- (id)initWithQIOSScreen:(QIOSScreen *)screen; +- (void)updateProperties; -@property (nonatomic, assign) BOOL changingOrientation; @property (nonatomic, assign) BOOL prefersStatusBarHidden; @property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation; -- (id)initWithQIOSScreen:(QIOSScreen *)screen; -- (void)updateProperties; @end diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index f678f7e807..8f59d41509 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -119,6 +119,12 @@ // ------------------------------------------------------------------------- +@interface QIOSViewController () { + QIOSScreen *m_screen; +} +@property (nonatomic, assign) BOOL changingOrientation; +@end + @implementation QIOSViewController - (id)initWithQIOSScreen:(QIOSScreen *)screen -- cgit v1.2.3 From 95cb745e002c38e821b385e90d954adf73363e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 11 Dec 2013 14:37:19 +0100 Subject: iOS: Fix QWindow::reportContentOrientationChange on iOS6+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On iOS 6 and above, [UIViewController supportedInterfaceOrientations] needs to return 0 for [UIApplication setStatusBarOrientation] to work. This means once you report a content orientation other than the primary orientation, you'll disable auto-rotation. Reporting the orientation as Qt::PrimaryOrientation restores the auto-rotation behavior. Change-Id: I1b8c765c507728fdbc5b828e0b4215324014e221 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosscreen.mm | 17 +++++ src/plugins/platforms/ios/qiosviewcontroller.h | 4 ++ src/plugins/platforms/ios/qiosviewcontroller.mm | 93 +++++++++++++++++++++---- src/plugins/platforms/ios/qioswindow.mm | 19 +++-- 4 files changed, 116 insertions(+), 17 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 4af2a4965f..712bf0098b 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -46,6 +46,7 @@ #include #include "qiosapplicationdelegate.h" #include "qiosviewcontroller.h" +#include "quiview.h" #include @@ -244,6 +245,22 @@ void QIOSScreen::updateProperties() m_geometry = fromCGRect([rootView convertRect:m_uiScreen.bounds fromView:m_uiWindow]).toRect(); m_availableGeometry = fromCGRect([rootView convertRect:m_uiScreen.applicationFrame fromView:m_uiWindow]).toRect(); + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 && ![m_uiWindow.rootViewController shouldAutorotate]) { + // Setting the statusbar orientation (content orientation) on iOS8+ will result in the UIScreen + // updating its geometry and available geometry, which in the case of content orientation is not + // what we want. We want to reflect the screen geometry based on the locked orientation, and + // adjust the available geometry based on the repositioned status bar for the current status + // bar orientation. + + Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(rootView.qtViewController.lockedOrientation)); + Qt::ScreenOrientation contenOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation)); + + QTransform transform = screen()->transformBetween(lockedOrientation, contenOrientation, m_geometry).inverted(); + + m_geometry = transform.mapRect(m_geometry); + m_availableGeometry = transform.mapRect(m_availableGeometry); + } + if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) { const qreal millimetersPerInch = 25.4; m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h index 684e06e030..df7ce0ff4a 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.h +++ b/src/plugins/platforms/ios/qiosviewcontroller.h @@ -40,6 +40,10 @@ class QIOSScreen; - (id)initWithQIOSScreen:(QIOSScreen *)screen; - (void)updateProperties; +@property (nonatomic, assign) UIInterfaceOrientation lockedOrientation; + +// UIViewController +@property (nonatomic, assign) BOOL shouldAutorotate; @property (nonatomic, assign) BOOL prefersStatusBarHidden; @property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 8f59d41509..0afd2bf8ba 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -153,6 +153,7 @@ #endif self.changingOrientation = NO; + self.shouldAutorotate = [super shouldAutorotate]; // Status bar may be initially hidden at startup through Info.plist self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false); @@ -179,6 +180,10 @@ [center addObserver:self selector:@selector(willChangeStatusBarFrame:) name:UIApplicationWillChangeStatusBarFrameNotification object:[UIApplication sharedApplication]]; + + [center addObserver:self selector:@selector(didChangeStatusBarOrientation:) + name:UIApplicationDidChangeStatusBarOrientationNotification + object:[UIApplication sharedApplication]]; } - (void)viewDidUnload @@ -189,19 +194,16 @@ // ------------------------------------------------------------------------- --(BOOL)shouldAutorotate -{ - // Until a proper orientation and rotation API is in place, we always auto rotate. - // If auto rotation is not wanted, you would need to switch it off manually from Info.plist. - return YES; -} - #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0) -(NSUInteger)supportedInterfaceOrientations { - // We need to tell iOS that we support all orientations in order to set - // status bar orientation when application content orientation changes. - return UIInterfaceOrientationMaskAll; + // As documented by Apple in the iOS 6.0 release notes, setStatusBarOrientation:animated: + // only works if the supportedInterfaceOrientations of the view controller is 0, making + // us responsible for ensuring that the status bar orientation is consistent. We enter + // this mode when auto-rotation is disabled due to an explicit content orientation being + // set on the focus window. Note that this is counter to what the documentation for + // supportedInterfaceOrientations says, which states that the method should not return 0. + return [self shouldAutorotate] ? UIInterfaceOrientationMaskAll : 0; } #endif @@ -209,7 +211,7 @@ -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { Q_UNUSED(interfaceOrientation); - return YES; + return [self shouldAutorotate]; } #endif @@ -256,6 +258,22 @@ }]; } +- (void)didChangeStatusBarOrientation:(NSNotification *)notification +{ + Q_UNUSED(notification); + + if (self.view.window.screen != [UIScreen mainScreen]) + return; + + // If the statusbar changes orientation due to auto-rotation we don't care, + // there will be re-layout anyways. Only if the statusbar changes due to + // reportContentOrientation, we need to update the window layout. + if (self.changingOrientation) + return; + + [self.view setNeedsLayout]; +} + - (void)viewWillLayoutSubviews { if (!QCoreApplication::instance()) @@ -287,6 +305,8 @@ // All decisions are based on the the top level window focusWindow = qt_window_private(focusWindow)->topLevelWindow(); + UIApplication *uiApplication = [UIApplication sharedApplication]; + bool currentStatusBarVisibility = self.prefersStatusBarHidden; self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen; @@ -297,13 +317,60 @@ } else #endif { - [[UIApplication sharedApplication] - setStatusBarHidden:self.prefersStatusBarHidden + [uiApplication setStatusBarHidden:self.prefersStatusBarHidden withAnimation:self.preferredStatusBarUpdateAnimation]; } [self.view setNeedsLayout]; } + + + // -------------- Content orientation --------------- + + static BOOL kAnimateContentOrientationChanges = YES; + + Qt::ScreenOrientation contentOrientation = focusWindow->contentOrientation(); + if (contentOrientation != Qt::PrimaryOrientation) { + // An explicit content orientation has been reported for the focus window, + // so we keep the status bar in sync with content orientation. This will ensure + // that the task bar (and associated gestures) are also rotated accordingly. + + if (self.shouldAutorotate) { + // We are moving from Qt::PrimaryOrientation to an explicit orientation, + // so we need to store the current statusbar orientation, as we need it + // later when mapping screen coordinates for QScreen and for returning + // to Qt::PrimaryOrientation. + self.lockedOrientation = uiApplication.statusBarOrientation; + + // Calling setStatusBarOrientation only has an effect when auto-rotation is + // disabled, which makes sense when there's an explicit content orientation. + self.shouldAutorotate = NO; + } + + [uiApplication setStatusBarOrientation: + UIInterfaceOrientation(fromQtScreenOrientation(contentOrientation)) + animated:kAnimateContentOrientationChanges]; + + } else { + // The content orientation is set to Qt::PrimaryOrientation, meaning + // that auto-rotation should be enabled. But we may be coming out of + // a state of locked orientation, which needs some cleanup before we + // can enable auto-rotation again. + if (!self.shouldAutorotate) { + // First we need to restore the statusbar to what it was at the + // time of locking the orientation, otherwise iOS will be very + // confused when it starts doing auto-rotation again. + [uiApplication setStatusBarOrientation: + UIInterfaceOrientation(self.lockedOrientation) + animated:kAnimateContentOrientationChanges]; + + // Then we can re-enable auto-rotation + self.shouldAutorotate = YES; + + // And finally let iOS rotate the root view to match the device orientation + [UIViewController attemptRotationToDeviceOrientation]; + } + } } #if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 480062e4de..6c4614408d 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -75,6 +75,15 @@ QIOSWindow::QIOSWindow(QWindow *window) setWindowState(window->windowState()); setOpacity(window->opacity()); + + Qt::ScreenOrientation initialOrientation = window->contentOrientation(); + if (initialOrientation != Qt::PrimaryOrientation) { + // Start up in portrait, then apply possible content orientation, + // as per Apple's documentation. + dispatch_async(dispatch_get_main_queue(), ^{ + handleContentOrientationChange(initialOrientation); + }); + } } QIOSWindow::~QIOSWindow() @@ -322,10 +331,12 @@ void QIOSWindow::updateWindowLevel() void QIOSWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation) { - // Keep the status bar in sync with content orientation. This will ensure - // that the task bar (and associated gestures) are aligned correctly: - UIInterfaceOrientation uiOrientation = UIInterfaceOrientation(fromQtScreenOrientation(orientation)); - [[UIApplication sharedApplication] setStatusBarOrientation:uiOrientation animated:NO]; + // Update the QWindow representation straight away, so that + // we can update the statusbar orientation based on the new + // content orientation. + qt_window_private(window())->contentOrientation = orientation; + + [m_view.qtViewController updateProperties]; } void QIOSWindow::applicationStateChanged(Qt::ApplicationState) -- cgit v1.2.3 From 56a82e87e654fa9e77bee8956e94e08a77941e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 7 Jan 2015 15:14:17 +0100 Subject: iOS: Prevent recursion when updating/syncing QIOSViewController properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I22f1eaa892cba23c498ae210a9a483e468268581 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosviewcontroller.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 0afd2bf8ba..01bc84ae68 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -41,6 +41,8 @@ #import "qiosviewcontroller.h" +#include + #include #include #include @@ -121,6 +123,7 @@ @interface QIOSViewController () { QIOSScreen *m_screen; + BOOL m_updatingProperties; } @property (nonatomic, assign) BOOL changingOrientation; @end @@ -289,6 +292,15 @@ if (!isQtApplication()) return; + // Prevent recursion caused by updating the status bar appearance (position + // or visibility), which in turn may cause a layout of our subviews, and + // a reset of window-states, which themselves affect the view controller + // properties such as the statusbar visibilty. + if (m_updatingProperties) + return; + + QScopedValueRollback updateRollback(m_updatingProperties, YES); + QWindow *focusWindow = QGuiApplication::focusWindow(); // If we don't have a focus window we leave the statusbar -- cgit v1.2.3 From a0737f65a62a5d72f15f5f1196b86f16605d936b Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 8 Jan 2015 17:11:43 +0200 Subject: Fixes for surface creation/destruction - After reset a surface we must call makeCurrent before we are usign swapBuffers. - No need to set the surface in QPA when surfaceCreated are called in QtSurface.java, some time the OpenGL surface is not fully initialized at this stage. Is better to wait for surfaceChanged which is always fired at least once. - DO NOT reset m_surfaceId to 1 when there is no surface. The problem is that if we have one surface and when we distory it we don't (need to) wait for its surfaceChanged/surfaceDestroyed notifications, and if we create another one quicly it will have the same id (1). Task-number: QTBUG-39712 Change-Id: I2aa31e5b59d81ef3b03624d4636a4381eea6d543 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/androidjnimain.cpp | 2 -- .../android/qandroidplatformopenglcontext.cpp | 6 ++++-- .../android/qandroidplatformopenglwindow.cpp | 20 ++++++++++++-------- .../platforms/android/qandroidplatformopenglwindow.h | 4 ++-- .../platforms/android/qandroidplatformscreen.cpp | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index d1e78dfe5d..1c157c79c3 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -376,8 +376,6 @@ namespace QtAndroid const auto &it = m_surfaces.find(surfaceId); if (it != m_surfaces.end()) m_surfaces.remove(surfaceId); - if (m_surfaces.isEmpty()) - m_surfaceId = 1; QJNIEnvironmentPrivate env; if (!env) diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp index 5781f0d7c6..4c38178343 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp @@ -50,8 +50,10 @@ QAndroidPlatformOpenGLContext::QAndroidPlatformOpenGLContext(const QSurfaceForma void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface) { - if (surface->surface()->surfaceClass() == QSurface::Window) - static_cast(surface)->checkNativeSurface(eglConfig()); + if (surface->surface()->surfaceClass() == QSurface::Window && + static_cast(surface)->checkNativeSurface(eglConfig())) { + QEGLPlatformContext::makeCurrent(surface); + } QEGLPlatformContext::swapBuffers(surface); } diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp index 8dc8e84f0a..de7f1f6990 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp @@ -138,19 +138,19 @@ EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config) return m_eglSurface; } -void QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config) +bool QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config) { QMutexLocker lock(&m_surfaceMutex); if (m_nativeSurfaceId == -1 || !m_androidSurfaceObject.isValid()) - return; + return false; // makeCurrent is NOT needed. createEgl(config); - // we've create another surface, the window should be repainted QRect availableGeometry = screen()->availableGeometry(); if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size()))); + return true; // makeCurrent is needed! } void QAndroidPlatformOpenGLWindow::applicationStateChanged(Qt::ApplicationState state) @@ -209,15 +209,19 @@ void QAndroidPlatformOpenGLWindow::surfaceChanged(JNIEnv *jniEnv, jobject surfac Q_UNUSED(jniEnv); Q_UNUSED(w); Q_UNUSED(h); + lockSurface(); m_androidSurfaceObject = surface; - m_surfaceWaitCondition.wakeOne(); + if (surface) // wait until we have a valid surface to draw into + m_surfaceWaitCondition.wakeOne(); unlockSurface(); - // repaint the window - QRect availableGeometry = screen()->availableGeometry(); - if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) - QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size()))); + if (surface) { + // repaint the window, when we have a valid surface + QRect availableGeometry = screen()->availableGeometry(); + if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) + QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size()))); + } } QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.h b/src/plugins/platforms/android/qandroidplatformopenglwindow.h index 71787edee1..6d6548fc6a 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.h +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.h @@ -54,7 +54,7 @@ public: EGLSurface eglSurface(EGLConfig config); QSurfaceFormat format() const; - void checkNativeSurface(EGLConfig config); + bool checkNativeSurface(EGLConfig config); void applicationStateChanged(Qt::ApplicationState); @@ -66,7 +66,7 @@ protected: void clearEgl(); private: - EGLDisplay m_eglDisplay; + EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; EGLSurface m_eglSurface = EGL_NO_SURFACE; EGLNativeWindowType m_nativeWindow = nullptr; diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index b70f936be1..092ade2e4a 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -391,7 +391,7 @@ Qt::ScreenOrientation QAndroidPlatformScreen::nativeOrientation() const void QAndroidPlatformScreen::surfaceChanged(JNIEnv *env, jobject surface, int w, int h) { lockSurface(); - if (surface && w && h) { + if (surface && w > 0 && h > 0) { releaseSurface(); m_nativeSurface = ANativeWindow_fromSurface(env, surface); QMetaObject::invokeMethod(this, "setDirty", Qt::QueuedConnection, Q_ARG(QRect, QRect(0, 0, w, h))); -- cgit v1.2.3 From 3ba1b989a6c7e22e8f0b92c59c5bbb52cdcab638 Mon Sep 17 00:00:00 2001 From: Tomasz Olszak Date: Fri, 9 Jan 2015 22:20:02 +0100 Subject: xcb: build fix when XCB_USE_XLIB is not defined. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When XCB_USE_XLIB was not defined QXcbXSettings still used XIproto.h. This change removes XIProto.h dependency and leaves QXcbXSettings uninitialized when XCB_USE_XLIB is not defined. QXcbXSettings::initialize() is already used in other parts of code e.g. qxcbcursor.cpp. Change-Id: I48eb82e39c5c091b41e8ec19e742a21d41de2610 Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbxsettings.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 13d42832db..a1dadb0e54 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -36,7 +36,9 @@ #include #include +#ifdef XCB_USE_XLIB #include +#endif //XCB_USE_XLIB QT_BEGIN_NAMESPACE /* Implementation of http://standards.freedesktop.org/xsettings-spec/xsettings-0.5.html */ @@ -138,6 +140,7 @@ public: return value + 4 - remainder; } +#ifdef XCB_USE_XLIB void populateSettings(const QByteArray &xSettings) { if (xSettings.length() < 12) @@ -212,6 +215,7 @@ public: } } +#endif //XCB_USE_XLIB QXcbScreen *screen; xcb_window_t x_settings_window; @@ -258,8 +262,10 @@ QXcbXSettings::QXcbXSettings(QXcbScreen *screen) const uint32_t event_mask[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY|XCB_EVENT_MASK_PROPERTY_CHANGE }; xcb_change_window_attributes(screen->xcb_connection(),d_ptr->x_settings_window,event,event_mask); +#ifdef XCB_USE_XLIB d_ptr->populateSettings(d_ptr->getSettings()); d_ptr->initialized = true; +#endif //XCB_USE_XLIB } QXcbXSettings::~QXcbXSettings() @@ -279,7 +285,9 @@ void QXcbXSettings::handlePropertyNotifyEvent(const xcb_property_notify_event_t Q_D(QXcbXSettings); if (event->window != d->x_settings_window) return; +#ifdef XCB_USE_XLIB d->populateSettings(d->getSettings()); +#endif //XCB_USE_XLIB } void QXcbXSettings::registerCallbackForProperty(const QByteArray &property, QXcbXSettings::PropertyChangeFunc func, void *handle) -- cgit v1.2.3 From 075ae987c48ce732e6a22c1eba71023fa0ea1775 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 7 Jan 2015 15:44:12 +0100 Subject: X11 devicePixelRatio screen mapping fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix screen detection and window geometry when screens have different displayPixelRatios. We must use the native coordinate system to figure out which screen a window belongs to. Also, when a window moves to a screen with a different devicePixelRatio, we must recalculate the Qt geometry. Task-number: QTBUG-43713 Change-Id: I93063e37354ff88f3c8a13320b76dfb272e43a9c Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbscreen.cpp | 5 ++++- src/plugins/platforms/xcb/qxcbscreen.h | 2 ++ src/plugins/platforms/xcb/qxcbwindow.cpp | 29 +++++++++++++++++++++++++++-- src/plugins/platforms/xcb/qxcbwindow.h | 2 ++ 4 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 73f27c7117..f8d68c68f0 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -77,8 +77,10 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, // virtual size is known (probably back-calculated from DPI and resolution) if (m_sizeMillimeters.isEmpty()) m_sizeMillimeters = m_virtualSizeMillimeters; - if (m_geometry.isEmpty()) + if (m_geometry.isEmpty()) { m_geometry = QRect(QPoint(), m_virtualSize/dpr); + m_nativeGeometry = QRect(QPoint(), m_virtualSize); + } if (m_availableGeometry.isEmpty()) m_availableGeometry = m_geometry; @@ -461,6 +463,7 @@ void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp) m_devicePixelRatio = qRound(dpi/96); const int dpr = int(devicePixelRatio()); // we may override m_devicePixelRatio m_geometry = QRect(xGeometry.topLeft()/dpr, xGeometry.size()/dpr); + m_nativeGeometry = QRect(xGeometry.topLeft(), xGeometry.size()); m_availableGeometry = QRect(xAvailableGeometry.topLeft()/dpr, xAvailableGeometry.size()/dpr); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index b9ee331104..4675b12d9c 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -62,6 +62,7 @@ public: QWindow *topLevelAt(const QPoint &point) const; QRect geometry() const { return m_geometry; } + QRect nativeGeometry() const { return m_nativeGeometry; } QRect availableGeometry() const {return m_availableGeometry;} int depth() const { return m_screen->root_depth; } QImage::Format format() const; @@ -114,6 +115,7 @@ private: QSizeF m_outputSizeMillimeters; QSizeF m_sizeMillimeters; QRect m_geometry; + QRect m_nativeGeometry; QRect m_availableGeometry; QSize m_virtualSize; QSizeF m_virtualSizeMillimeters; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e1ccc3f086..590e296f61 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1831,6 +1831,23 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even } } +// Temporary workaround for bug in QPlatformScreen::screenForNativeGeometry +// we need the native geometries to detect our screen, but that's not +// available in cross-platform code. Will be fixed properly when highDPI +// support is refactored to expose the native coordinate system. + +QPlatformScreen *QXcbWindow::screenForNativeGeometry(const QRect &newGeometry) const +{ + QXcbScreen *currentScreen = static_cast(screen()); + if (!parent() && !currentScreen->nativeGeometry().intersects(newGeometry)) { + Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { + if (static_cast(screen)->nativeGeometry().intersects(newGeometry)) + return screen; + } + } + return currentScreen; +} + void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) { bool fromSendEvent = (event->response_type & 0x80); @@ -1847,15 +1864,23 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * } } - QRect rect = mapFromNative(QRect(pos, QSize(event->width, event->height)), int(devicePixelRatio())); + const int dpr = devicePixelRatio(); + const QRect nativeRect = QRect(pos, QSize(event->width, event->height)); + const QRect rect = mapFromNative(nativeRect, dpr); QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); - QPlatformScreen *newScreen = screenForGeometry(rect); + QPlatformScreen *newScreen = screenForNativeGeometry(nativeRect); if (newScreen != m_screen) { m_screen = static_cast(newScreen); QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); + int newDpr = devicePixelRatio(); + if (newDpr != dpr) { + QRect newRect = mapFromNative(nativeRect, newDpr); + QPlatformWindow::setGeometry(newRect); + QWindowSystemInterface::handleGeometryChange(window(), newRect); + } } m_configureNotifyPending = false; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 12d20d004d..254421e57d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -154,6 +154,8 @@ public: qreal devicePixelRatio() const; + QPlatformScreen *screenForNativeGeometry(const QRect &newGeometry) const; + public Q_SLOTS: void updateSyncRequestCounter(); -- cgit v1.2.3 From 3f0b8a9f198cd1e0e8ae9150561f93fb1b931b7e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 8 Jan 2015 13:55:32 +0100 Subject: Multi-screen DPI support for X11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calculate the logical DPI independently per screen, but only when auto dpr is enabled. Using a constant DPI value for all screens, based on the combined geometry is arguably incorrect, but changing this now will cause pixel-size fonts to behave visibly different from point-size fonts when moving the window to a different screen. However, with QT_DEVICE_PIXEL_RATIO=auto, the pixel size fonts are already changing when the devicePixelRatio changes. Without this change, the point-size fonts will *not* adapt, which is a clear bug. Task-number: QTBUG-43713 Change-Id: I3e71618f9d55b7828ccd70b69a7b7ce656c69d65 Reviewed-by: Friedemann Kleint Reviewed-by: Jørgen Lind Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbscreen.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index f8d68c68f0..6559a0bdba 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -317,8 +317,14 @@ QDpi QXcbScreen::logicalDpi() const if (m_forcedDpi > 0) return QDpi(m_forcedDpi/dpr, m_forcedDpi/dpr); - return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr, - Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr); + static const bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto"; + if (auto_dpr) { + return QDpi(Q_MM_PER_INCH * m_geometry.width() / m_sizeMillimeters.width(), + Q_MM_PER_INCH * m_geometry.height() / m_sizeMillimeters.height()); + } else { + return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr, + Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr); + } } -- cgit v1.2.3 From 13ecde3b7af364be2db466029f796f3cb6310685 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 13 Jan 2015 12:53:04 +0100 Subject: iOS: guard text responder from clearing selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When programatically setting a text selection on iOS, we call [UITextInputDelegate selectionWillChange] to report the change. If auto correction is enabled, UIKit will then reset the current tracking, and for some reason tell us to clear the selection. This is contradictory to us saying the the selection is about to change, and will cause an unwanted recursion back to Qt. Since there seems to be no way to stop UIKit from doing this, this patch will instead add a guard that refuses to change the selection recursively while processing a selection change from Qt. Task-number: QTBUG-43716 Change-Id: Id487a57cdda55d7e2d09c3efc14c7f03f566f15a Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.h | 1 + src/plugins/platforms/ios/qiostextresponder.mm | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiostextresponder.h b/src/plugins/platforms/ios/qiostextresponder.h index 118ab8958a..21b61bf8da 100644 --- a/src/plugins/platforms/ios/qiostextresponder.h +++ b/src/plugins/platforms/ios/qiostextresponder.h @@ -51,6 +51,7 @@ class QIOSInputContext; QIOSInputContext *m_inputContext; QString m_markedText; BOOL m_inSendEventToFocusObject; + BOOL m_inSelectionChange; } - (id)initWithInputContext:(QIOSInputContext *)context; diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index bebc7577f8..15fade0838 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -171,6 +171,7 @@ return self; m_inSendEventToFocusObject = NO; + m_inSelectionChange = NO; m_inputContext = inputContext; QVariantMap platformData = [self imValue:Qt::ImPlatformData].toMap(); @@ -302,6 +303,7 @@ return; if (updatedProperties & (Qt::ImCursorPosition | Qt::ImAnchorPosition)) { + QScopedValueRollback rollback(m_inSelectionChange, true); [self.inputDelegate selectionWillChange:self]; [self.inputDelegate selectionDidChange:self]; } @@ -349,6 +351,15 @@ - (void)setSelectedTextRange:(UITextRange *)range { + if (m_inSelectionChange) { + // After [UITextInputDelegate selectionWillChange], UIKit will cancel + // any ongoing auto correction (if enabled) and ask us to set an empty selection. + // This is contradictory to our current attempt to set a selection, so we ignore + // the callback. UIKit will be re-notified of the new selection after + // [UITextInputDelegate selectionDidChange]. + return; + } + QUITextRange *r = static_cast(range); QList attrs; attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.range.location, r.range.length, 0); -- cgit v1.2.3 From ccb5978c6d45569e590bba527255fafbcb840d08 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 3 Dec 2014 14:08:39 +0100 Subject: Fix namespacing of QNSViewMouseMoveHelper Task-number: QTBUG-43061 Change-Id: Ied8cdf49c34ef155b0f0bbc7e547b7c01bcd1d11 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.h | 4 ++-- src/plugins/platforms/cocoa/qnsview.mm | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 8d8df13dc3..fa71ab4086 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -48,7 +48,7 @@ class QCocoaBackingStore; class QCocoaGLContext; QT_END_NAMESPACE -Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper); +Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); @interface QT_MANGLE_NAMESPACE(QNSView) : NSView { QImage m_backingStore; @@ -72,7 +72,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper); bool m_shouldSetGLContextinDrawRect; #endif NSString *m_inputSource; - QNSViewMouseMoveHelper *m_mouseMoveHelper; + QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper; bool m_resendKeyEvent; } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 699340795d..771b464805 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -83,7 +83,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; - (CGFloat)deviceDeltaZ; @end -@interface QNSViewMouseMoveHelper : NSObject +@interface QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) : NSObject { QNSView *view; } @@ -97,7 +97,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; @end -@implementation QNSViewMouseMoveHelper +@implementation QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) - (id)initWithView:(QNSView *)theView { @@ -158,7 +158,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; currentCustomDragTypes = 0; m_sendUpAsRightButton = false; m_inputSource = 0; - m_mouseMoveHelper = [[QNSViewMouseMoveHelper alloc] initWithView:self]; + m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self]; m_resendKeyEvent = false; if (!touchDevice) { -- cgit v1.2.3 From 988f1b2e5745646cf1bd7f9f65507356ff2ba12e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 Jan 2015 16:21:41 +0100 Subject: Windows: Use DND effect chosen in DragEnter/Move for Drop. The value of pdwEffect passed to IOleDropTarget::Drop() is always the one with which the drag was initiated. Task-number: QTBUG-43466 Change-Id: I045fef634b55d4f113b393aa0ad4aa15d37db372 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsdrag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index fce60c3169..d3eb049269 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -626,7 +626,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, const QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(), m_lastPoint / QWindowsScaling::factor(), - translateToQDragDropActions(*pdwEffect)); + translateToQDragDropActions(m_chosenEffect)); if (response.isAccepted()) { const Qt::DropAction action = response.acceptedAction(); -- cgit v1.2.3 From c1d08afd31074a2733057ed6620735ef2f4dd8c6 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Jan 2015 10:14:44 +0100 Subject: Fix constantly growing window bug with devicePixelRatio Rectangles need to be mapped differently depending on what they are used for. Expose events need to cover the entire geometry, so they must be rounded up, potentially increasing the size. If we use the same conversion for window geometries, it is possible to end up with a feedback loop if the window reacts to the new size. Task-number: QTBUG-43743 Change-Id: I7881cc77bf2148fed2ae743c4226617a61197434 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 590e296f61..4fd71f1635 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -151,7 +151,7 @@ static inline QRect mapToNative(const QRect &qtRect, int dpr) return QRect(qtRect.x() * dpr, qtRect.y() * dpr, qtRect.width() * dpr, qtRect.height() * dpr); } -// When converting native rects to Qt rects: round top/left towards the origin and +// When mapping expose events to Qt rects: round top/left towards the origin and // bottom/right away from the origin, making sure that we cover the whole widget static inline QPoint dpr_floor(const QPoint &p, int dpr) @@ -164,11 +164,15 @@ static inline QPoint dpr_ceil(const QPoint &p, int dpr) return QPoint((p.x() + dpr - 1) / dpr, (p.y() + dpr - 1) / dpr); } -static inline QRect mapFromNative(const QRect &xRect, int dpr) +static inline QRect mapExposeFromNative(const QRect &xRect, int dpr) { return QRect(dpr_floor(xRect.topLeft(), dpr), dpr_ceil(xRect.bottomRight(), dpr)); } +static inline QRect mapGeometryFromNative(const QRect &xRect, int dpr) +{ + return QRect(xRect.topLeft() / dpr, xRect.bottomRight() / dpr); +} // Returns \c true if we should set WM_TRANSIENT_FOR on \a w static inline bool isTransient(const QWindow *w) @@ -1718,7 +1722,7 @@ public: return false; if (expose->count == 0) m_pending = false; - *m_region |= mapFromNative(QRect(expose->x, expose->y, expose->width, expose->height), m_dpr); + *m_region |= mapExposeFromNative(QRect(expose->x, expose->y, expose->width, expose->height), m_dpr); return true; } @@ -1746,7 +1750,7 @@ void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event) { const int dpr = int(devicePixelRatio()); QRect x_rect(event->x, event->y, event->width, event->height); - QRect rect = mapFromNative(x_rect, dpr); + QRect rect = mapExposeFromNative(x_rect, dpr); if (m_exposeRegion.isEmpty()) m_exposeRegion = rect; @@ -1866,7 +1870,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * const int dpr = devicePixelRatio(); const QRect nativeRect = QRect(pos, QSize(event->width, event->height)); - const QRect rect = mapFromNative(nativeRect, dpr); + const QRect rect = mapGeometryFromNative(nativeRect, dpr); QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); @@ -1877,7 +1881,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); int newDpr = devicePixelRatio(); if (newDpr != dpr) { - QRect newRect = mapFromNative(nativeRect, newDpr); + QRect newRect = mapGeometryFromNative(nativeRect, newDpr); QPlatformWindow::setGeometry(newRect); QWindowSystemInterface::handleGeometryChange(window(), newRect); } -- cgit v1.2.3 From a8a00f646b57b5a7ca2cf8603311888ff6ff09f8 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 13 Jan 2015 12:45:28 +0100 Subject: Turn off font hinting when we do high DPI scaling Font hinting depends on the specific pixel size, and ends up very wrong when the painter is scaled. Change-Id: I2007ec7e7ad8d52358d76e88e030ea4df7e91455 Task-number: QTBUG-43809 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 6 +++++- src/plugins/platforms/xcb/qxcbnativeinterface.h | 3 ++- src/plugins/platforms/xcb/qxcbscreen.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbscreen.h | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 3058b29f2d..31dedd40a2 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -78,7 +78,8 @@ static int resourceType(const QByteArray &key) QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"), QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"), QByteArrayLiteral("rootwindow"), - QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled") + QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled"), + QByteArrayLiteral("nofonthinting") }; const QByteArray *end = names + sizeof(names) / sizeof(names[0]); const QByteArray *result = std::find(names, end, key); @@ -283,6 +284,9 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q case GetTimestamp: result = getTimestamp(xcbScreen); break; + case NoFontHinting: + result = xcbScreen->noFontHinting() ? this : 0; //qboolptr... + break; default: break; } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index b667f1a372..330dd008c4 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -67,7 +67,8 @@ public: X11Screen, RootWindow, ScreenSubpixelType, - ScreenAntialiasingEnabled + ScreenAntialiasingEnabled, + NoFontHinting }; QXcbNativeInterface(); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 6559a0bdba..7136455754 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -62,6 +62,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, , m_forcedDpi(-1) , m_devicePixelRatio(1) , m_hintStyle(QFontEngine::HintStyle(-1)) + , m_noFontHinting(false) , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1)) , m_antialiasingEnabled(-1) , m_xSettings(0) @@ -86,6 +87,12 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr, readXResources(); + // disable font hinting when we do UI scaling + static bool dpr_scaling_enabled = (qgetenv("QT_DEVICE_PIXEL_RATIO").toInt() > 1 + || qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto"); + if (dpr_scaling_enabled) + m_noFontHinting = true; + #ifdef Q_XCB_DEBUG qDebug(); qDebug("Screen output %s of xcb screen %d:", m_outputName.toUtf8().constData(), m_number); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 4675b12d9c..e9ab2edaa0 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -98,6 +98,7 @@ public: void readXResources(); QFontEngine::HintStyle hintStyle() const { return m_hintStyle; } + bool noFontHinting() const { return m_noFontHinting; } QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; } int antialiasingEnabled() const { return m_antialiasingEnabled; } @@ -132,6 +133,7 @@ private: int m_forcedDpi; int m_devicePixelRatio; QFontEngine::HintStyle m_hintStyle; + bool m_noFontHinting; QFontEngine::SubpixelAntialiasingType m_subpixelType; int m_antialiasingEnabled; QXcbXSettings *m_xSettings; -- cgit v1.2.3 From 17cce246487ca8a9b2d1999bfdbbb3b368b44177 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 14 Jan 2015 20:35:21 +0100 Subject: Only call ShowWindow() once when going from FullScreen to Maximized Since going from FullScreen to Maximized is taken care of inside the FullScreen block then we don't want to call ShowWindow() again in the Maximized block. Therefore the Maximized block is moved so it is only invoked if it is not coming or going to fullscreen. As the minimized case is not accounted for in FullScreen that is left as is in its own if block. Task-number: QTBUG-43849 Change-Id: I3141347e072c50b2a4475098d7b8ee0b207578a7 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6279b6f4af..e7061dbfde 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1620,17 +1620,6 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) setFlag(FrameDirty); - if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) { - if (visible && !(newState == Qt::WindowMinimized)) { - setFlag(WithinMaximize); - if (newState == Qt::WindowFullScreen) - setFlag(MaximizeToFullScreen); - ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE); - clearFlag(WithinMaximize); - clearFlag(MaximizeToFullScreen); - } - } - if ((oldState == Qt::WindowFullScreen) != (newState == Qt::WindowFullScreen)) { #ifdef Q_OS_WINCE HWND handle = FindWindow(L"HHTaskBar", L""); @@ -1710,6 +1699,15 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) m_savedStyle = 0; m_savedFrameGeometry = QRect(); } + } else if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) { + if (visible && !(newState == Qt::WindowMinimized)) { + setFlag(WithinMaximize); + if (newState == Qt::WindowFullScreen) + setFlag(MaximizeToFullScreen); + ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE); + clearFlag(WithinMaximize); + clearFlag(MaximizeToFullScreen); + } } if ((oldState == Qt::WindowMinimized) != (newState == Qt::WindowMinimized)) { -- cgit v1.2.3 From 7c9497ad6ae9cb4b596bc76c70077577d97fe3cb Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 12 Jan 2015 20:58:53 +0100 Subject: Respect the hotspot passed in for the cursor When the hotspot is set to be QPoint(0,0) then QPoint will see this as being a null QPoint. However, it is a valid position as far as the hot spot for the cursor is concerned, so we default to QPoint(-1,-1) instead and check for that. Task-number: QTBUG-43787 Change-Id: Ibf6253033016c4b556b8a2a79c89819a4d5825cb Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscursor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index d10c7fdb20..9a42b7712d 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -126,13 +126,15 @@ HCURSOR QWindowsCursor::createPixmapCursor(const QPixmap &pixmap, const QPoint & // Create a cursor from image and mask of the format QImage::Format_Mono. static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits, - QPoint hotSpot = QPoint(), + QPoint hotSpot = QPoint(-1, -1), bool invb = false, bool invm = false) { const int width = bbits.width(); const int height = bbits.height(); - if (hotSpot.isNull()) - hotSpot = QPoint(width / 2, height / 2); + if (hotSpot.x() < 0) + hotSpot.setX(width / 2); + if (hotSpot.y() < 0) + hotSpot.setY(height / 2); const int n = qMax(1, width / 8); #if !defined(Q_OS_WINCE) QScopedArrayPointer xBits(new uchar[height * n]); -- cgit v1.2.3