diff options
Diffstat (limited to 'src/plugins')
71 files changed, 460 insertions, 430 deletions
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index 3cd9290420..f02b6befb8 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -129,6 +129,9 @@ void QNetworkManagerEngine::setupConfigurations() // Get active connections. foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) { + if (activeConnectionsList.contains(acPath.path())) + continue; + QNetworkManagerConnectionActive *activeConnection = new QNetworkManagerConnectionActive(acPath.path(),this); activeConnectionsList.insert(acPath.path(), activeConnection); @@ -141,14 +144,6 @@ void QNetworkManagerEngine::setupConfigurations() connectionInterfaces.insert(activeConnection->connection().path(),device.networkInterface()); } } - - // Get current list of access points. - foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) { - locker.unlock(); - deviceAdded(devicePath); //add all accesspoints - locker.relock(); - } - // Get connections. foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) { locker.unlock(); @@ -224,6 +219,10 @@ void QNetworkManagerEngine::disconnectFromId(const QString &id) QMutexLocker locker(&mutex); QNetworkManagerSettingsConnection *connection = connectionFromId(id); + + if (!connection) + return; + QNmSettingsMap map = connection->getSettings(); bool connectionAutoconnect = map.value("connection").value("autoconnect",true).toBool(); //if not present is true !! if (connectionAutoconnect) { //autoconnect connections will simply be reconnected by nm @@ -253,11 +252,6 @@ void QNetworkManagerEngine::requestUpdate() QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection); } -void QNetworkManagerEngine::scanFinished() -{ - QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection); -} - void QNetworkManagerEngine::interfacePropertiesChanged(const QMap<QString, QVariant> &properties) { QMutexLocker locker(&mutex); @@ -399,57 +393,6 @@ void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connecti } } -void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) -{ - QNetworkManagerInterfaceDevice *iDevice; - iDevice = new QNetworkManagerInterfaceDevice(path.path(),this); - connect(iDevice,SIGNAL(connectionsChanged(QStringList)), - this,SLOT(deviceConnectionsChanged(QStringList))); - - interfaceDevices.insert(path.path(),iDevice); - if (iDevice->deviceType() == DEVICE_TYPE_WIFI) { - QNetworkManagerInterfaceDeviceWireless *wirelessDevice = - new QNetworkManagerInterfaceDeviceWireless(iDevice->path(),this); - - connect(wirelessDevice, SIGNAL(accessPointAdded(QString)), - this, SLOT(newAccessPoint(QString))); - connect(wirelessDevice, SIGNAL(accessPointRemoved(QString)), - this, SLOT(removeAccessPoint(QString))); - connect(wirelessDevice,SIGNAL(scanDone()),this,SLOT(scanFinished())); - wirelessDevice->setConnections(); - - wirelessDevices.insert(path.path(), wirelessDevice); - } - - if (iDevice->deviceType() == DEVICE_TYPE_ETHERNET) { - QNetworkManagerInterfaceDeviceWired *wiredDevice = - new QNetworkManagerInterfaceDeviceWired(iDevice->path(),this); - connect(wiredDevice,SIGNAL(carrierChanged(bool)),this,SLOT(wiredCarrierChanged(bool))); - wiredDevices.insert(iDevice->path(), wiredDevice); - } -} - -void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path) -{ - QMutexLocker locker(&mutex); - - if (interfaceDevices.contains(path.path())) { - locker.unlock(); - delete interfaceDevices.take(path.path()); - locker.relock(); - } - if (wirelessDevices.contains(path.path())) { - locker.unlock(); - delete wirelessDevices.take(path.path()); - locker.relock(); - } - if (wiredDevices.contains(path.path())) { - locker.unlock(); - delete wiredDevices.take(path.path()); - locker.relock(); - } -} - void QNetworkManagerEngine::wiredCarrierChanged(bool carrier) { QNetworkManagerInterfaceDeviceWired *deviceWired = qobject_cast<QNetworkManagerInterfaceDeviceWired *>(sender()); @@ -540,7 +483,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, if (i.value()->deviceType() == deviceType) { QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(i.value()->path()); - if (wiredDevice->carrier()) { + if (wiredDevice && wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; } } @@ -568,7 +511,7 @@ bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath) cons } QNetworkManagerSettingsConnection *settingsConnection = connectionFromId(settingsPath); - if (settingsConnection->getType() == DEVICE_TYPE_MODEM) { + if (settingsConnection && settingsConnection->getType() == DEVICE_TYPE_MODEM) { return isActiveContext(settingsConnection->path()); } @@ -597,15 +540,10 @@ void QNetworkManagerEngine::removeConnection(const QString &path) emit configurationRemoved(ptr); locker.relock(); } + // add base AP back into configurations - QMapIterator<QString, QString> i(configuredAccessPoints); - while (i.hasNext()) { - i.next(); - if (i.value() == path) { - configuredAccessPoints.remove(i.key()); - newAccessPoint(i.key()); - } - } + + // removed along with all AP props code... } void QNetworkManagerEngine::updateConnection() @@ -679,114 +617,6 @@ void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher) } } -void QNetworkManagerEngine::newAccessPoint(const QString &path) -{ - QMutexLocker locker(&mutex); - QNetworkManagerInterfaceAccessPoint *accessPoint = - new QNetworkManagerInterfaceAccessPoint(path,this); - - bool okToAdd = true; - for (int i = 0; i < accessPoints.count(); ++i) { - if (accessPoints.at(i)->path() == path) { - okToAdd = false; - } - } - if (okToAdd) { - accessPoints.append(accessPoint); - } - // 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->path(); - - if (accessPoint->ssid() == connection->getSsid()) { - if (!configuredAccessPoints.contains(path)) { - configuredAccessPoints.insert(path,settingsPath); - } - - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.value(settingsPath); - ptr->mutex.lock(); - QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; - ptr->state = (flag | QNetworkConfiguration::Discovered); - - if (isConnectionActive(settingsPath)) - ptr->state = (flag | QNetworkConfiguration::Active); - ptr->mutex.unlock(); - - locker.unlock(); - emit configurationChanged(ptr); - return; - } - } - } - - // New access point. - QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); - - ptr->name = accessPoint->ssid(); - ptr->isValid = true; - ptr->id = path; - ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->purpose = QNetworkConfiguration::PublicPurpose; - ptr->state = QNetworkConfiguration::Undefined; - ptr->bearerType = QNetworkConfiguration::BearerWLAN; - - accessPointConfigurations.insert(ptr->id, ptr); - - locker.unlock(); - emit configurationAdded(ptr); -} - -void QNetworkManagerEngine::removeAccessPoint(const QString &path) -{ - QMutexLocker locker(&mutex); - for (int i = 0; i < accessPoints.count(); ++i) { - QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); - if (accessPoint->path() == path) { - accessPoints.removeOne(accessPoint); - - if (configuredAccessPoints.contains(accessPoint->path())) { - // find connection and change state to Defined - 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->path(); - const QString connectionId = settingsPath; - - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.value(connectionId); - ptr->mutex.lock(); - ptr->state = QNetworkConfiguration::Defined; - ptr->mutex.unlock(); - - locker.unlock(); - emit configurationChanged(ptr); - locker.relock(); - break; - } - } - } else { - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.take(path); - - if (ptr) { - locker.unlock(); - emit configurationRemoved(ptr); - locker.relock(); - } - } - delete accessPoint; - break; - } - } -} - QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &settingsPath, const QNmSettingsMap &map) { @@ -809,7 +639,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri QNetworkManagerInterfaceDevice device(devicePath.path(),this); if (device.deviceType() == DEVICE_TYPE_ETHERNET) { QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.path()); - if (wiredDevice->carrier()) { + if (wiredDevice && wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; break; } @@ -1068,10 +898,6 @@ void QNetworkManagerEngine::nmRegistered(const QString &) managerInterface = new QNetworkManagerInterface(this); systemSettings = new QNetworkManagerSettings(NM_DBUS_SERVICE, this); - connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)), - this, SLOT(deviceAdded(QDBusObjectPath))); - connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)), - this, SLOT(deviceRemoved(QDBusObjectPath))); connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)), this, SLOT(activationFinished(QDBusPendingCallWatcher*))); connect(managerInterface, SIGNAL(propertiesChanged(QMap<QString,QVariant>)), diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index ac70881f63..74fe24b5ab 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -99,19 +99,12 @@ private Q_SLOTS: void interfacePropertiesChanged(const QMap<QString, QVariant> &properties); void activeConnectionPropertiesChanged(const QMap<QString, QVariant> &properties); - void deviceAdded(const QDBusObjectPath &path); - void deviceRemoved(const QDBusObjectPath &path); - void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0); void removeConnection(const QString &path); void updateConnection(); void activationFinished(QDBusPendingCallWatcher *watcher); void deviceConnectionsChanged(const QStringList &activeConnectionsList); - void newAccessPoint(const QString &path); - void removeAccessPoint(const QString &path); - void scanFinished(); - void wiredCarrierChanged(bool); void nmRegistered(const QString &serviceName = QString()); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 081cb1288d..3e77580015 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -101,6 +101,21 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) QNetworkManagerInterface::~QNetworkManagerInterface() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + QLatin1String(NM_DBUS_INTERFACE), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + QLatin1String(NM_DBUS_INTERFACE), + QLatin1String("DeviceAdded"), + this,SIGNAL(deviceAdded(QDBusObjectPath))); + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + QLatin1String(NM_DBUS_INTERFACE), + QLatin1String("DeviceRemoved"), + this,SIGNAL(deviceRemoved(QDBusObjectPath))); } bool QNetworkManagerInterface::setConnections() @@ -239,28 +254,6 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q NM_DBUS_INTERFACE_ACCESS_POINT, QDBusConnection::systemBus(),parent) { - if (!isValid()) { - return; - } - PropertiesDBusInterface *accessPointPropertiesInterface = new PropertiesDBusInterface(QLatin1String(NM_DBUS_SERVICE), - dbusPathName, - DBUS_PROPERTIES_INTERFACE, - QDBusConnection::systemBus()); - - QList<QVariant> argumentList; - argumentList << QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT); - QDBusPendingReply<QVariantMap> propsReply - = accessPointPropertiesInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), - argumentList); - if (!propsReply.isError()) { - propertyMap = propsReply.value(); - } - - QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - dbusPathName, - QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), - QLatin1String("PropertiesChanged"), - this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint() @@ -370,6 +363,11 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_DEVICE), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QString QNetworkManagerInterfaceDevice::udi() const @@ -467,6 +465,11 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QString QNetworkManagerInterfaceDeviceWired::hwAddress() const @@ -554,77 +557,20 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap<QString,QVariant>))); - - QDBusPendingReply<QList<QDBusObjectPath> > reply - = asyncCall(QLatin1String("GetAccessPoints")); - - QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(reply); - connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(accessPointsFinished(QDBusPendingCallWatcher*))); } QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless() { -} - -void QNetworkManagerInterfaceDeviceWireless::slotAccessPointAdded(QDBusObjectPath path) -{ - if (path.path().length() > 2) - Q_EMIT accessPointAdded(path.path()); -} - -void QNetworkManagerInterfaceDeviceWireless::slotAccessPointRemoved(QDBusObjectPath path) -{ - if (path.path().length() > 2) - Q_EMIT accessPointRemoved(path.path()); + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } bool QNetworkManagerInterfaceDeviceWireless::setConnections() { - if (!isValid()) - return false; - - QDBusConnection dbusConnection = QDBusConnection::systemBus(); - bool allOk = true; - - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - interfacePath, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("AccessPointAdded"), - this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { - allOk = false; - } - - - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - interfacePath, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("AccessPointRemoved"), - this, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) { - allOk = false; - } - - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - interfacePath, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("ScanDone"), - this, SLOT(scanIsDone()))) { - allOk = false; - } - return allOk; -} - -void QNetworkManagerInterfaceDeviceWireless::accessPointsFinished(QDBusPendingCallWatcher *watcher) -{ - QDBusPendingReply<QList<QDBusObjectPath> > reply(*watcher); - watcher->deleteLater(); - if (!reply.isError()) { - accessPointsList = reply.value(); - } - - for (int i = 0; i < accessPointsList.size(); i++) { - Q_EMIT accessPointAdded(accessPointsList.at(i).path()); - } + return true; } QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints() @@ -673,11 +619,6 @@ quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const return 0; } -void QNetworkManagerInterfaceDeviceWireless::scanIsDone() -{ - Q_EMIT scanDone(); -} - void QNetworkManagerInterfaceDeviceWireless::requestScan() { asyncCall(QLatin1String("RequestScan")); @@ -724,6 +665,12 @@ QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const Q QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_PATH_SETTINGS), + QLatin1String(NM_DBUS_IFACE_SETTINGS), + QLatin1String("NewConnection"), + this, SIGNAL(newConnection(QDBusObjectPath))); } QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const @@ -825,6 +772,16 @@ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QStri QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection() { + QDBusConnection::systemBus().disconnect(service(), + path(), + QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), + QLatin1String("Updated"), + this, SIGNAL(updated())); + QDBusConnection::systemBus().disconnect(service(), + path(), + QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), + QLatin1String("Removed"), + this, SIGNAL(slotSettingsRemoved())); } bool QNetworkManagerSettingsConnection::setConnections() @@ -981,6 +938,11 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString & QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QDBusObjectPath QNetworkManagerConnectionActive::connection() const diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index 561bded156..65e618d15f 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -328,7 +328,6 @@ public: QObject *parent = 0); ~QNetworkManagerInterfaceDeviceWireless(); - QDBusObjectPath path() const; QList <QDBusObjectPath> getAccessPoints(); QString hwAddress() const; @@ -341,21 +340,11 @@ public: void requestScan(); Q_SIGNALS: void propertiesChanged(QMap<QString,QVariant>); - void accessPointAdded(const QString &); - void accessPointRemoved(const QString &); - void scanDone(); void propertiesReady(); - void accessPointsReady(); private Q_SLOTS: - void scanIsDone(); void propertiesSwap(QMap<QString,QVariant>); - void slotAccessPointAdded(QDBusObjectPath); - void slotAccessPointRemoved(QDBusObjectPath); - - void accessPointsFinished(QDBusPendingCallWatcher *watcher); - private: QVariantMap propertyMap; QList <QDBusObjectPath> accessPointsList; diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 476b456563..bae74bf9a1 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -415,7 +415,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, backingstore = QImage(qMax(backingstore.width(), w), qMax(backingstore.height(), h), QImage::Format_RGB32); - memset(bits, 0, image->byteCount()); + memset(backingstore.bits(), 0, backingstore.byteCount()); } const int dest_bpl = backingstore.bytesPerLine(); unsigned char *dest_data = backingstore.bits(); diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 994fe8386b..736c66ebc0 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -101,11 +101,13 @@ QIBusPlatformInputContext::QIBusPlatformInputContext () QString socketPath = QIBusPlatformInputContextPrivate::getSocketPath(); QFile file(socketPath); if (file.open(QFile::ReadOnly)) { +#ifndef QT_NO_FILESYSTEMWATCHER // If KDE session save is used or restart ibus-daemon, // the applications could run before ibus-daemon runs. // We watch the getSocketPath() to get the launching ibus-daemon. m_socketWatcher.addPath(socketPath); connect(&m_socketWatcher, SIGNAL(fileChanged(QString)), this, SLOT(socketChanged(QString))); +#endif } m_timer.setSingleShot(true); @@ -408,8 +410,10 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal && window != NULL) { const QPoint globalPos = window->screen()->handle()->cursor()->pos(); const QPoint pos = window->mapFromGlobal(globalPos); +#ifndef QT_NO_CONTEXTMENU QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers); +#endif } #endif // QT_NO_CONTEXTMENU QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, @@ -449,8 +453,10 @@ void QIBusPlatformInputContext::connectToBus() d->initBus(); connectToContextSignals(); +#ifndef QT_NO_FILESYSTEMWATCHER if (m_socketWatcher.files().size() == 0) m_socketWatcher.addPath(QIBusPlatformInputContextPrivate::getSocketPath()); +#endif } void QIBusPlatformInputContext::globalEngineChanged(const QString &engine_name) diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h index 4f2722480e..94fa5c3d60 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -110,7 +110,9 @@ public Q_SLOTS: private: QIBusPlatformInputContextPrivate *d; bool m_eventFilterUseSynchronousMode; +#ifndef QT_NO_FILESYSTEMWATCHER QFileSystemWatcher m_socketWatcher; +#endif QTimer m_timer; void connectToContextSignals(); diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.h b/src/plugins/platforms/cocoa/qcocoaclipboard.h index 52fec61f39..cab2cfaa91 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.h +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.h @@ -41,6 +41,9 @@ #define QCOCOACLIPBOARD_H #include <qpa/qplatformclipboard.h> + +#ifndef QT_NO_CLIPBOARD + #include "qmacclipboard.h" #include <QtCore/QScopedPointer> @@ -71,4 +74,6 @@ private: QT_END_NAMESPACE -#endif +#endif // QT_NO_CLIPBOARD + +#endif // QCOCOACLIPBOARD_H diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm index 7209c93a94..b4745900dc 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm @@ -39,6 +39,8 @@ #include "qcocoaclipboard.h" +#ifndef QT_NO_CLIPBOARD + QT_BEGIN_NAMESPACE QCocoaClipboard::QCocoaClipboard() @@ -105,3 +107,5 @@ void QCocoaClipboard::handleApplicationStateChanged(Qt::ApplicationState state) #include "moc_qcocoaclipboard.cpp" QT_END_NAMESPACE + +#endif // QT_NO_CLIPBOARD diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index aaa12c6edb..cc8436dcfe 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -177,8 +177,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); { Q_UNUSED(notification); [self updateQtColor]; - if (mHelper) - emit mHelper->colorSelected(mQtColor); } - (void)windowWillClose:(NSNotification *)notification diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 31a0a3d600..0375dd85f2 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -589,15 +589,6 @@ void QCocoaFileDialogHelper::QNSOpenSavePanelDelegate_panelClosed(bool accepted) QCocoaMenuBar::resetKnownMenuItemsToQt(); if (accepted) { emit accept(); - - QString filter = selectedNameFilter(); - if (filter.isEmpty()) - emit filterSelected(filter); - - QList<QUrl> files = selectedFiles(); - emit filesSelected(files); - if (files.count() == 1) - emit fileSelected(files.first()); } else { emit reject(); } diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index dfda22d376..dc7dfb788f 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -365,7 +365,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); emit mHelper->reject(); } else { emit mHelper->accept(); - emit mHelper->fontSelected(mHelper->currentFont()); } } } diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm index 24dc8ab42a..04d6d6b806 100644 --- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm @@ -137,8 +137,8 @@ void QCocoaInputContext::updateLocale() m_locale = locale; emitLocaleChanged(); } - CFRelease(langRef); } + CFRelease(source); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 9b0b5959a4..85ea2d8ba9 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -130,7 +130,9 @@ public: #ifndef QT_NO_ACCESSIBILITY QCocoaAccessibility *accessibility() const Q_DECL_OVERRIDE; #endif +#ifndef QT_NO_CLIPBOARD QCocoaClipboard *clipboard() const Q_DECL_OVERRIDE; +#endif QCocoaDrag *drag() const Q_DECL_OVERRIDE; QStringList themeNames() const Q_DECL_OVERRIDE; @@ -169,7 +171,9 @@ private: #endif QScopedPointer<QPlatformTheme> mPlatformTheme; QList<QCocoaScreen *> mScreens; +#ifndef QT_NO_CLIPBOARD QCocoaClipboard *mCocoaClipboard; +#endif QScopedPointer<QCocoaDrag> mCocoaDrag; QScopedPointer<QCocoaNativeInterface> mNativeInterface; QScopedPointer<QCocoaServices> mServices; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index c3890bcd46..1793bd404e 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -283,7 +283,9 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) #ifndef QT_NO_ACCESSIBILITY , mAccessibility(new QCocoaAccessibility) #endif +#ifndef QT_NO_CLIPBOARD , mCocoaClipboard(new QCocoaClipboard) +#endif , mCocoaDrag(new QCocoaDrag) , mNativeInterface(new QCocoaNativeInterface) , mServices(new QCocoaServices) @@ -366,11 +368,13 @@ QCocoaIntegration::~QCocoaIntegration() [[NSApplication sharedApplication] setDelegate: 0]; } +#ifndef QT_NO_CLIPBOARD // Delete the clipboard integration and destroy mime type converters. // Deleting the clipboard integration flushes promised pastes using // the mime converters - the ordering here is important. delete mCocoaClipboard; QMacInternalPasteboardMime::destroyMimeTypes(); +#endif // Delete screens in reverse order to avoid crash in case of multiple screens while (!mScreens.isEmpty()) { @@ -531,10 +535,12 @@ QCocoaAccessibility *QCocoaIntegration::accessibility() const } #endif +#ifndef QT_NO_CLIPBOARD QCocoaClipboard *QCocoaIntegration::clipboard() const { return mCocoaClipboard; } +#endif QCocoaDrag *QCocoaIntegration::drag() const { diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index 6b80162e4d..b77071536b 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -71,7 +71,7 @@ public: void syncSeparatorsCollapsible(bool enable) Q_DECL_OVERRIDE; - void syncModalState(bool modal); + void propagateEnabledState(bool enabled); void setIcon(const QIcon &icon) Q_DECL_OVERRIDE { Q_UNUSED(icon) } @@ -104,9 +104,10 @@ private: NSMenu *m_nativeMenu; NSMenuItem *m_attachedItem; quintptr m_tag; - bool m_enabled; - bool m_visible; - bool m_isOpen; + bool m_enabled:1; + bool m_parentEnabled:1; + bool m_visible:1; + bool m_isOpen:1; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 32cf9ebc53..4260b17772 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -155,10 +155,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { - if (![menuItem tag]) + QCocoaMenuItem *cocoaItem = reinterpret_cast<QCocoaMenuItem *>(menuItem.tag); + if (!cocoaItem) return YES; - QCocoaMenuItem* cocoaItem = reinterpret_cast<QCocoaMenuItem *>([menuItem tag]); return cocoaItem->isEnabled(); } @@ -256,6 +256,7 @@ QCocoaMenu::QCocoaMenu() : m_attachedItem(0), m_tag(0), m_enabled(true), + m_parentEnabled(true), m_visible(true), m_isOpen(false) { @@ -331,6 +332,8 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem) else if (isOpen() && item->nsItem()) // Someone's adding new items after aboutToShow() was emitted item->menu()->setAttachedItem(item->nsItem()); + item->setParentEnabled(isEnabled()); + if (item->isMerged()) return; @@ -375,6 +378,9 @@ void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem) if (cocoaItem->menuParent() == this) cocoaItem->setMenuParent(0); + // Ignore any parent enabled state + cocoaItem->setParentEnabled(true); + m_menuItems.removeOne(cocoaItem); if (!cocoaItem->isMerged()) { if (m_nativeMenu != [cocoaItem->nsItem() menu]) { @@ -465,13 +471,17 @@ void QCocoaMenu::syncSeparatorsCollapsible(bool enable) void QCocoaMenu::setEnabled(bool enabled) { + if (m_enabled == enabled) + return; m_enabled = enabled; - syncModalState(!m_enabled); + const bool wasParentEnabled = m_parentEnabled; + propagateEnabledState(m_enabled); + m_parentEnabled = wasParentEnabled; // Reset to the parent value } bool QCocoaMenu::isEnabled() const { - return m_attachedItem ? [m_attachedItem isEnabled] : m_enabled; + return m_attachedItem ? [m_attachedItem isEnabled] : m_enabled && m_parentEnabled; } void QCocoaMenu::setVisible(bool visible) @@ -605,20 +615,19 @@ QList<QCocoaMenuItem *> QCocoaMenu::merged() const return result; } -void QCocoaMenu::syncModalState(bool modal) +void QCocoaMenu::propagateEnabledState(bool enabled) { - QMacAutoReleasePool pool; + QMacAutoReleasePool pool; // FIXME Is this still needed for Creator? See 6a0bb4206a2928b83648 - if (!m_enabled) - modal = true; + m_parentEnabled = enabled; + if (!m_enabled && enabled) // Some ancestor was enabled, but this menu is not + return; foreach (QCocoaMenuItem *item, m_menuItems) { - if (item->menu()) { // recurse into submenus - item->menu()->syncModalState(modal); - continue; - } - - item->syncModalState(modal); + if (QCocoaMenu *menu = item->menu()) + menu->propagateEnabledState(enabled); + else + item->setParentEnabled(enabled); } } diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index ded7ab541b..26af0d3f63 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -322,7 +322,7 @@ void QCocoaMenuBar::updateMenuBarImmediately() menu->setMenuParent(mb); // force a sync? mb->syncMenu(menu); - menu->syncModalState(disableForModal); + menu->propagateEnabledState(!disableForModal); } QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader]; diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h index aafc66e06f..23f788687c 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.h +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h @@ -90,7 +90,9 @@ public: void setIsSeparator(bool isSeparator) Q_DECL_OVERRIDE; void setFont(const QFont &font) Q_DECL_OVERRIDE; void setRole(MenuRole role) Q_DECL_OVERRIDE; +#ifndef QT_NO_SHORTCUT void setShortcut(const QKeySequence& shortcut) Q_DECL_OVERRIDE; +#endif void setCheckable(bool checkable) Q_DECL_OVERRIDE { Q_UNUSED(checkable) } void setChecked(bool isChecked) Q_DECL_OVERRIDE; void setEnabled(bool isEnabled) Q_DECL_OVERRIDE; @@ -103,10 +105,10 @@ public: NSMenuItem *sync(); void syncMerged(); - void syncModalState(bool modal); + void setParentEnabled(bool enabled); inline bool isMerged() const { return m_merged; } - inline bool isEnabled() const { return m_enabled; } + inline bool isEnabled() const { return m_enabled && m_parentEnabled; } inline bool isSeparator() const { return m_isSeparator; } QCocoaMenu *menu() const { return m_menu; } @@ -119,20 +121,23 @@ private: NSMenuItem *m_native; NSView *m_itemView; QString m_text; - bool m_textSynced; QIcon m_icon; QPointer<QCocoaMenu> m_menu; - bool m_isVisible; - bool m_enabled; - bool m_isSeparator; QFont m_font; MenuRole m_role; MenuRole m_detectedRole; +#ifndef QT_NO_SHORTCUT QKeySequence m_shortcut; - bool m_checked; - bool m_merged; +#endif quintptr m_tag; int m_iconSize; + bool m_textSynced:1; + bool m_isVisible:1; + bool m_enabled:1; + bool m_parentEnabled:1; + bool m_isSeparator:1; + bool m_checked:1; + bool m_merged:1; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 3504f967bf..cac166a409 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -68,6 +68,7 @@ static quint32 constructModifierMask(quint32 accel_key) return ret; } +#ifndef QT_NO_SHORTCUT // return an autoreleased string given a QKeySequence (currently only looks at the first one). NSString *keySequenceToKeyEqivalent(const QKeySequence &accel) { @@ -86,20 +87,22 @@ NSUInteger keySequenceModifierMask(const QKeySequence &accel) { return constructModifierMask(accel[0]); } +#endif QCocoaMenuItem::QCocoaMenuItem() : m_native(NULL), m_itemView(nil), - m_textSynced(false), m_menu(NULL), + m_role(NoRole), + m_tag(0), + m_iconSize(16), + m_textSynced(false), m_isVisible(true), m_enabled(true), + m_parentEnabled(true), m_isSeparator(false), - m_role(NoRole), m_checked(false), - m_merged(false), - m_tag(0), - m_iconSize(16) + m_merged(false) { } @@ -135,15 +138,23 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu) if (menu == m_menu) return; - if (m_menu) { - if (m_menu->menuParent() == this) - m_menu->setMenuParent(0); + if (m_menu && m_menu->menuParent() == this) { + m_menu->setMenuParent(0); + // Free the menu from its parent's influence + m_menu->propagateEnabledState(true); + if (m_native && m_menu->attachedItem() == m_native) + m_menu->setAttachedItem(nil); } QMacAutoReleasePool pool; m_menu = static_cast<QCocoaMenu *>(menu); if (m_menu) { + if (m_native) { + // Skip automatic menu item validation + m_native.action = nil; + } m_menu->setMenuParent(this); + m_menu->propagateEnabledState(isEnabled()); } else { // we previously had a menu, but no longer // clear out our item so the nexy sync() call builds a new one @@ -174,10 +185,12 @@ void QCocoaMenuItem::setRole(MenuRole role) m_role = role; } +#ifndef QT_NO_SHORTCUT void QCocoaMenuItem::setShortcut(const QKeySequence& shortcut) { m_shortcut = shortcut; } +#endif void QCocoaMenuItem::setChecked(bool isChecked) { @@ -186,7 +199,11 @@ void QCocoaMenuItem::setChecked(bool isChecked) void QCocoaMenuItem::setEnabled(bool enabled) { - m_enabled = enabled; + if (m_enabled != enabled) { + m_enabled = enabled; + if (m_menu) + m_menu->propagateEnabledState(isEnabled()); + } } void QCocoaMenuItem::setNativeContents(WId item) @@ -301,11 +318,13 @@ NSMenuItem *QCocoaMenuItem::sync() [m_native setView:m_itemView]; QString text = mergeText(); +#ifndef QT_NO_SHORTCUT QKeySequence accel = mergeAccel(); // Show multiple key sequences as part of the menu text. if (accel.count() > 1) text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")"); +#endif QString finalString = QPlatformTheme::removeMnemonics(text); bool useAttributedTitle = false; @@ -327,10 +346,13 @@ NSMenuItem *QCocoaMenuItem::sync() [m_native setTitle: QCFString::toNSString(finalString)]; } +#ifndef QT_NO_SHORTCUT if (accel.count() == 1) { [m_native setKeyEquivalent:keySequenceToKeyEqivalent(accel)]; [m_native setKeyEquivalentModifierMask:keySequenceModifierMask(accel)]; - } else { + } else +#endif + { [m_native setKeyEquivalent:@""]; [m_native setKeyEquivalentModifierMask:NSCommandKeyMask]; } @@ -371,6 +393,7 @@ QString QCocoaMenuItem::mergeText() return m_text; } +#ifndef QT_NO_SHORTCUT QKeySequence QCocoaMenuItem::mergeAccel() { QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader]; @@ -383,6 +406,7 @@ QKeySequence QCocoaMenuItem::mergeAccel() return m_shortcut; } +#endif void QCocoaMenuItem::syncMerged() { @@ -394,12 +418,13 @@ void QCocoaMenuItem::syncMerged() [m_native setHidden: !m_isVisible]; } -void QCocoaMenuItem::syncModalState(bool modal) +void QCocoaMenuItem::setParentEnabled(bool enabled) { - if (modal) - [m_native setEnabled:NO]; - else - [m_native setEnabled:YES]; + if (m_parentEnabled != enabled) { + m_parentEnabled = enabled; + if (m_menu) + m_menu->propagateEnabledState(isEnabled()); + } } QPlatformMenuItem::MenuRole QCocoaMenuItem::effectiveRole() const diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index e8d8a473c3..0640faeb8a 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -75,6 +75,9 @@ #define QT_MAC_SYSTEMTRAY_USE_GROWL #include "qcocoasystemtrayicon.h" + +#ifndef QT_NO_SYSTEMTRAYICON + #include <qtemporaryfile.h> #include <qimagewriter.h> #include <qdebug.h> @@ -464,3 +467,5 @@ private: return qmenu; } @end + +#endif // QT_NO_SYSTEMTRAYICON diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index cb8ffee556..95175871a4 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -137,8 +137,10 @@ bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const { switch (dialogType) { +#ifndef QT_NO_FILEDIALOG case QPlatformTheme::FileDialog: return new QCocoaFileDialogHelper(); +#endif #ifndef QT_NO_COLORDIALOG case QPlatformTheme::ColorDialog: return new QCocoaColorDialogHelper(); diff --git a/src/plugins/platforms/ios/qiosclipboard.h b/src/plugins/platforms/ios/qiosclipboard.h index b9ba4a2669..f3ccfcace0 100644 --- a/src/plugins/platforms/ios/qiosclipboard.h +++ b/src/plugins/platforms/ios/qiosclipboard.h @@ -40,10 +40,13 @@ #ifndef QIOSCLIPBOARD_H #define QIOSCLIPBOARD_H +#include <qpa/qplatformclipboard.h> + +#ifndef QT_NO_CLIPBOARD + #import <UIKit/UIKit.h> #include <QMimeData> -#include <qpa/qplatformclipboard.h> @class QUIClipboard; @@ -67,4 +70,6 @@ private: QT_END_NAMESPACE +#endif // QT_NO_CLIPBOARD + #endif // QIOSCLIPBOARD_H diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm index fb75cc793c..960c9f39db 100644 --- a/src/plugins/platforms/ios/qiosclipboard.mm +++ b/src/plugins/platforms/ios/qiosclipboard.mm @@ -39,6 +39,8 @@ #include "qiosclipboard.h" +#ifndef QT_NO_CLIPBOARD + #include <QtPlatformSupport/private/qmacmime_p.h> #include <QtCore/QMimeData> #include <QtGui/QGuiApplication> @@ -247,3 +249,5 @@ bool QIOSClipboard::ownsMode(QClipboard::Mode mode) const } QT_END_NAMESPACE + +#endif // QT_NO_CLIPBOARD diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index 36c3bbf6f1..d9a43a683e 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -72,7 +72,9 @@ public: QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE; QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE; +#ifndef QT_NO_CLIPBOARD QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE; +#endif QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE; QPlatformServices *services() const Q_DECL_OVERRIDE; @@ -85,7 +87,9 @@ public: QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE; QTouchDevice *touchDevice(); +#ifndef QT_NO_ACCESSIBILITY QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE; +#endif // Called from Objective-C class QIOSScreenTracker, which can't be friended void addScreen(QPlatformScreen *screen) { screenAdded(screen); } diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 297b549ec2..94dd643116 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -74,7 +74,7 @@ QIOSIntegration *QIOSIntegration::instance() QIOSIntegration::QIOSIntegration() : m_fontDatabase(new QCoreTextFontDatabase) -#ifndef Q_OS_TVOS +#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD) , m_clipboard(new QIOSClipboard) #endif , m_inputContext(0) @@ -131,7 +131,7 @@ QIOSIntegration::~QIOSIntegration() delete m_fontDatabase; m_fontDatabase = 0; -#ifndef Q_OS_TVOS +#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD) delete m_clipboard; m_clipboard = 0; #endif @@ -221,6 +221,7 @@ QPlatformFontDatabase * QIOSIntegration::fontDatabase() const return m_fontDatabase; } +#ifndef QT_NO_CLIPBOARD QPlatformClipboard *QIOSIntegration::clipboard() const { #ifndef Q_OS_TVOS @@ -229,6 +230,7 @@ QPlatformClipboard *QIOSIntegration::clipboard() const return 0; #endif } +#endif QPlatformInputContext *QIOSIntegration::inputContext() const { @@ -276,12 +278,14 @@ QTouchDevice *QIOSIntegration::touchDevice() return m_touchDevice; } +#ifndef QT_NO_ACCESSIBILITY QPlatformAccessibility *QIOSIntegration::accessibility() const { if (!m_accessibility) m_accessibility = new QIOSPlatformAccessibility; return m_accessibility; } +#endif QPlatformNativeInterface *QIOSIntegration::nativeInterface() const { diff --git a/src/plugins/platforms/ios/qiosmenu.h b/src/plugins/platforms/ios/qiosmenu.h index dab5720d48..b7371a5f49 100644 --- a/src/plugins/platforms/ios/qiosmenu.h +++ b/src/plugins/platforms/ios/qiosmenu.h @@ -68,7 +68,9 @@ public: void setRole(MenuRole role) Q_DECL_OVERRIDE; void setCheckable(bool) Q_DECL_OVERRIDE {} void setChecked(bool) Q_DECL_OVERRIDE {} +#ifndef QT_NO_SHORTCUT void setShortcut(const QKeySequence&) Q_DECL_OVERRIDE; +#endif void setEnabled(bool enabled) Q_DECL_OVERRIDE; void setIconSize(int) Q_DECL_OVERRIDE {} diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index d5211cdd8a..6165e480dc 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -304,10 +304,12 @@ void QIOSMenuItem::setRole(QPlatformMenuItem::MenuRole role) m_role = role; } +#ifndef QT_NO_SHORTCUT void QIOSMenuItem::setShortcut(const QKeySequence &sequence) { m_shortcut = sequence; } +#endif void QIOSMenuItem::setEnabled(bool enabled) { @@ -547,6 +549,7 @@ QIOSMenuItemList QIOSMenu::filterFirstResponderActions(const QIOSMenuItemList &m for (int i = 0; i < menuItems.count(); ++i) { QIOSMenuItem *menuItem = menuItems.at(i); +#ifndef QT_NO_SHORTCUT QKeySequence shortcut = menuItem->m_shortcut; if ((shortcut == QKeySequence::Cut && [responder canPerformAction:@selector(cut:) withSender:nil]) || (shortcut == QKeySequence::Copy && [responder canPerformAction:@selector(copy:) withSender:nil]) @@ -560,6 +563,7 @@ QIOSMenuItemList QIOSMenu::filterFirstResponderActions(const QIOSMenuItemList &m || (shortcut == QKeySequence::Underline && [responder canPerformAction:@selector(toggleUnderline:) withSender:nil])) { continue; } +#endif filteredMenuItems.append(menuItem); } return filteredMenuItems; diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.h b/src/plugins/platforms/ios/qiosplatformaccessibility.h index 2374457591..989eaa4fb8 100644 --- a/src/plugins/platforms/ios/qiosplatformaccessibility.h +++ b/src/plugins/platforms/ios/qiosplatformaccessibility.h @@ -42,6 +42,8 @@ #include <qpa/qplatformaccessibility.h> +#ifndef QT_NO_ACCESSIBILITY + QT_BEGIN_NAMESPACE class QIOSPlatformAccessibility: public QPlatformAccessibility @@ -56,3 +58,5 @@ public: QT_END_NAMESPACE #endif + +#endif diff --git a/src/plugins/platforms/ios/qiosplatformaccessibility.mm b/src/plugins/platforms/ios/qiosplatformaccessibility.mm index 2ebe23c939..bc51850760 100644 --- a/src/plugins/platforms/ios/qiosplatformaccessibility.mm +++ b/src/plugins/platforms/ios/qiosplatformaccessibility.mm @@ -39,6 +39,8 @@ #include "qiosplatformaccessibility.h" +#ifndef QT_NO_ACCESSIBILITY + #include <QtGui/QtGui> #include "qioswindow.h" @@ -85,3 +87,5 @@ void QIOSPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *even break; } } + +#endif diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 5ec05ec8ce..cd7945641e 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -911,7 +911,7 @@ UIFont *uifont = [UIFont fontWithName:qfont.family().toNSString() size:qfont.pointSize()]; if (!uifont) return [NSDictionary dictionary]; - return [NSDictionary dictionaryWithObject:uifont forKey:UITextInputTextFontKey]; + return [NSDictionary dictionaryWithObject:uifont forKey:NSFontAttributeName]; } #endif diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.h b/src/plugins/platforms/ios/quiaccessibilityelement.h index 1a9ae2a1a7..03abf5407e 100644 --- a/src/plugins/platforms/ios/quiaccessibilityelement.h +++ b/src/plugins/platforms/ios/quiaccessibilityelement.h @@ -43,6 +43,8 @@ #import <UIKit/UIKit.h> #import <QtGui/QtGui> +#ifndef QT_NO_ACCESSIBILITY + @interface QMacAccessibilityElement : UIAccessibilityElement {} @@ -54,3 +56,4 @@ @end #endif +#endif diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm index 39a879fc23..105d7cd65f 100644 --- a/src/plugins/platforms/ios/quiaccessibilityelement.mm +++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm @@ -39,6 +39,8 @@ #include "quiaccessibilityelement.h" +#ifndef QT_NO_ACCESSIBILITY + #include "private/qaccessiblecache_p.h" @implementation QMacAccessibilityElement @@ -221,3 +223,5 @@ } @end + +#endif diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 9f910dfe5e..2c32e56525 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -551,5 +551,7 @@ @end +#ifndef QT_NO_ACCESSIBILITY // Include category as an alternative to using -ObjC (Apple QA1490) #include "quiview_accessibility.mm" +#endif diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index b5de192346..db365ce739 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -1,5 +1,7 @@ TARGET = qlinuxfb +DEFINES += QT_NO_FOREACH + QT += core-private gui-private platformsupport-private SOURCES = main.cpp qlinuxfbintegration.cpp qlinuxfbscreen.cpp diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 6ca651fdf7..a2e09611b4 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -320,7 +320,7 @@ bool QLinuxFbScreen::initialize() bool doSwitchToGraphicsMode = true; // Parse arguments - foreach (const QString &arg, mArgs) { + for (const QString &arg : qAsConst(mArgs)) { QRegularExpressionMatch match; if (arg == QLatin1String("nographicsmodeswitch")) doSwitchToGraphicsMode = false; diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index 0d31d6605b..d4627605bb 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -2,6 +2,8 @@ TARGET = qminimal QT += core-private gui-private platformsupport-private +DEFINES += QT_NO_FOREACH + SOURCES = main.cpp \ qminimalintegration.cpp \ qminimalbackingstore.cpp diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 984d4456a0..558089dfce 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -67,7 +67,7 @@ static const char debugBackingStoreEnvironmentVariable[] = "QT_DEBUG_BACKINGSTOR static inline unsigned parseOptions(const QStringList ¶mList) { unsigned options = 0; - foreach (const QString ¶m, paramList) { + for (const QString ¶m : paramList) { if (param == QLatin1String("enable_fonts")) options |= QMinimalIntegration::EnableFonts; } diff --git a/src/plugins/platforms/offscreen/offscreen.pro b/src/plugins/platforms/offscreen/offscreen.pro index cc65449b04..fbaa853c41 100644 --- a/src/plugins/platforms/offscreen/offscreen.pro +++ b/src/plugins/platforms/offscreen/offscreen.pro @@ -2,6 +2,8 @@ TARGET = qoffscreen QT += core-private gui-private platformsupport-private +DEFINES += QT_NO_FOREACH + SOURCES = main.cpp \ qoffscreenintegration.cpp \ qoffscreenwindow.cpp \ diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp index a63aacdbfe..85422071aa 100644 --- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp +++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp @@ -59,9 +59,9 @@ public: void setPos(const QPoint &pos) Q_DECL_OVERRIDE { m_pos = pos; - QWindowList wl = QGuiApplication::topLevelWindows(); + const QWindowList wl = QGuiApplication::topLevelWindows(); QWindow *containing = 0; - foreach (QWindow *w, wl) { + for (QWindow *w : wl) { if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(pos)) { containing = w; break; @@ -104,9 +104,9 @@ QPixmap QOffscreenScreen::grabWindow(WId id, int x, int y, int width, int height QOffscreenWindow *window = QOffscreenWindow::windowForWinId(id); if (!window || window->window()->type() == Qt::Desktop) { - QWindowList wl = QGuiApplication::topLevelWindows(); + const QWindowList wl = QGuiApplication::topLevelWindows(); QWindow *containing = 0; - foreach (QWindow *w, wl) { + for (QWindow *w : wl) { if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(rect)) { containing = w; break; @@ -212,11 +212,10 @@ QOffscreenBackingStore *QOffscreenBackingStore::backingStoreForWinId(WId id) void QOffscreenBackingStore::clearHash() { - QList<WId> ids = m_windowAreaHash.keys(); - foreach (WId id, ids) { - QHash<WId, QOffscreenBackingStore *>::iterator it = m_backingStoreForWinIdHash.find(id); - if (it.value() == this) - m_backingStoreForWinIdHash.remove(id); + for (auto it = m_windowAreaHash.cbegin(), end = m_windowAreaHash.cend(); it != end; ++it) { + const auto it2 = qAsConst(m_backingStoreForWinIdHash).find(it.key()); + if (it2.value() == this) + m_backingStoreForWinIdHash.erase(it2); } m_windowAreaHash.clear(); } diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index 9a1428ac39..1817e15201 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -7,6 +7,8 @@ load(qt_plugin) QT += core-private gui-private platformsupport-private network +DEFINES += QT_NO_FOREACH + SOURCES = \ main.cpp \ qvncintegration.cpp \ diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index e87064e385..9f2d0c8a33 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -867,7 +867,7 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) quint16 length = getUShort(names + 8 + i*NameRecordSize); quint16 offset = getUShort(names + 10 + i*NameRecordSize); - if (DWORD(string_offset + offset + length) >= bytes) + if (DWORD(string_offset + offset + length) > bytes) continue; if ((platform_id == PlatformId_Microsoft @@ -890,7 +890,7 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes) QString strings[4]; for (int i = 0; i < 4; ++i) { - if (idStatus[0] == NotFound) + if (idStatus[i] == NotFound) continue; int id = ids[i]; quint16 length = getUShort(names + 8 + id * NameRecordSize); diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index b513d9ad7c..4d8966f934 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -122,7 +122,11 @@ static FontKeys &fontKeys() QSettings::NativeFormat); const QStringList allKeys = fontRegistry.allKeys(); const QString trueType = QStringLiteral("(TrueType)"); +#ifndef QT_NO_REGULAREXPRESSION const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+")); +#else + const QRegExp sizeListMatch(QLatin1String("\\s(\\d+,)+\\d+")); +#endif Q_ASSERT(sizeListMatch.isValid()); const int size = allKeys.size(); result.reserve(size); diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 18be3b0ce6..39a4eb81ca 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -364,8 +364,9 @@ void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEn glyphIndices.size(), glyphMetrics.data()); if (SUCCEEDED(hr)) { + qreal stretch = fontDef.stretch != QFont::AnyStretch ? fontDef.stretch / 100.0 : 1.0; for (int i = 0; i < glyphs->numGlyphs; ++i) - glyphs->advances[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth); + glyphs->advances[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth * stretch); if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) { for (int i = 0; i < glyphs->numGlyphs; ++i) glyphs->advances[i] = glyphs->advances[i].round(); @@ -448,7 +449,7 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g) width, height, advanceWidth, - advanceHeight); + 0); } else { qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__); } @@ -532,7 +533,7 @@ bool QWindowsFontEngineDirectWrite::supportsSubPixelPositions() const QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, - const QTransform &xform) + const QTransform &originalTransform) { UINT16 glyphIndex = t; FLOAT glyphAdvance = 0; @@ -551,6 +552,10 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t, glyphRun.bidiLevel = 0; glyphRun.glyphOffsets = &glyphOffset; + QTransform xform = originalTransform; + if (fontDef.stretch != 100) + xform.scale(fontDef.stretch / 100.0, 1.0); + DWRITE_MATRIX transform; transform.dx = subPixelPosition.toReal(); transform.dy = 0; @@ -807,10 +812,15 @@ QString QWindowsFontEngineDirectWrite::fontNameSubstitute(const QString &familyN glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph, QFixed subPixelPosition, - const QTransform &matrix, + const QTransform &originalTransform, GlyphFormat format) { Q_UNUSED(format); + + QTransform matrix = originalTransform; + if (fontDef.stretch != 100) + matrix.scale(fontDef.stretch / 100.0, 1.0); + glyph_metrics_t bbox = QFontEngine::boundingBox(glyph, matrix); // To get transformed advance UINT16 glyphIndex = glyph; diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index 6cc56372ec..7f9c9bd205 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -54,8 +54,9 @@ enum { debug = 0 }; static inline bool shellExecute(const QUrl &url) { - const QString nativeFilePath = - url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded); + const QString nativeFilePath = url.isLocalFile() && !url.hasFragment() && !url.hasQuery() + ? QDir::toNativeSeparators(url.toLocalFile()) + : url.toString(QUrl::FullyEncoded); const quintptr result = reinterpret_cast<quintptr>(ShellExecute(0, 0, reinterpret_cast<const wchar_t *>(nativeFilePath.utf16()), diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.cpp b/src/plugins/platforms/winrt/qwinrtclipboard.cpp index 2811f1f018..0a38b3df34 100644 --- a/src/plugins/platforms/winrt/qwinrtclipboard.cpp +++ b/src/plugins/platforms/winrt/qwinrtclipboard.cpp @@ -59,6 +59,7 @@ typedef IEventHandler<IInspectable *> ContentChangedHandler; QT_BEGIN_NAMESPACE QWinRTClipboard::QWinRTClipboard() + : m_mimeData(Q_NULLPTR) { #ifndef Q_OS_WINPHONE QEventDispatcherWinRT::runOnXamlThread([this]() { @@ -103,9 +104,16 @@ QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode) const wchar_t *textStr = result.GetRawBuffer(&size); QString text = QString::fromWCharArray(textStr, size); text.replace(QLatin1String("\r\n"), QLatin1String("\n")); - m_mimeData.setText(text); - return &m_mimeData; + if (m_mimeData) { + if (m_mimeData->text() == text) + return m_mimeData; + delete m_mimeData; + } + m_mimeData = new QMimeData(); + m_mimeData->setText(text); + + return m_mimeData; #else // Q_OS_WINPHONE return QPlatformClipboard::mimeData(mode); #endif // Q_OS_WINPHONE @@ -146,7 +154,13 @@ void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) return; #ifndef Q_OS_WINPHONE - const QString text = data->text(); + const bool newData = !m_mimeData || m_mimeData != data; + if (newData) { + if (m_mimeData) + delete m_mimeData; + m_mimeData = data; + } + const QString text = data ? data->text() : QString(); HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, text]() { HRESULT hr; ComPtr<IDataPackage> package; @@ -164,7 +178,6 @@ void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) return S_OK; }); RETURN_VOID_IF_FAILED("Could not set clipboard text."); - emitChanged(mode); #else // Q_OS_WINPHONE QPlatformClipboard::setMimeData(data, mode); #endif // Q_OS_WINPHONE diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.h b/src/plugins/platforms/winrt/qwinrtclipboard.h index f88a92956e..3e6ee109fd 100644 --- a/src/plugins/platforms/winrt/qwinrtclipboard.h +++ b/src/plugins/platforms/winrt/qwinrtclipboard.h @@ -73,7 +73,7 @@ private: #ifndef Q_OS_WINPHONE Microsoft::WRL::ComPtr<ABI::Windows::ApplicationModel::DataTransfer::IClipboardStatics> m_nativeClipBoard; #endif - QMimeData m_mimeData; + QMimeData *m_mimeData; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp index 3f400e1342..d69c63e9a4 100644 --- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp @@ -111,6 +111,9 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa Q_D(QWinRTMessageDialogHelper); QSharedPointer<QMessageDialogOptions> options = this->options(); + if (!options.data()) + return false; + const QString informativeText = options->informativeText(); const QString title = options->windowTitle(); const QString text = informativeText.isEmpty() ? options->text() : (options->text() + QLatin1Char('\n') + informativeText); diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index ad32e63cad..ad32c046df 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -763,10 +763,11 @@ void QWinRTScreen::addWindow(QWindow *window) { Q_D(QWinRTScreen); qCDebug(lcQpaWindows) << __FUNCTION__ << window; - if (window == topWindow()) + if (window == topWindow() || window->surfaceClass() == QSurface::Offscreen) return; d->visibleWindows.prepend(window); + updateWindowTitle(window->title()); QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason); handleExpose(); QWindowSystemInterface::flushWindowSystemEvents(); @@ -785,7 +786,7 @@ void QWinRTScreen::removeWindow(QWindow *window) if (!d->visibleWindows.removeAll(window)) return; if (wasTopWindow) - QWindowSystemInterface::handleWindowActivated(window, Qt::OtherFocusReason); + QWindowSystemInterface::handleWindowActivated(Q_NULLPTR, Qt::OtherFocusReason); handleExpose(); QWindowSystemInterface::flushWindowSystemEvents(); #if _MSC_VER >= 1900 && !defined(QT_NO_DRAGANDDROP) @@ -807,6 +808,8 @@ void QWinRTScreen::lower(QWindow *window) const bool wasTopWindow = window == topWindow(); if (wasTopWindow && d->visibleWindows.size() == 1) return; + if (window->surfaceClass() == QSurface::Offscreen) + return; d->visibleWindows.removeAll(window); d->visibleWindows.append(window); if (wasTopWindow) @@ -814,15 +817,10 @@ void QWinRTScreen::lower(QWindow *window) handleExpose(); } -void QWinRTScreen::updateWindowTitle() +void QWinRTScreen::updateWindowTitle(const QString &title) { Q_D(QWinRTScreen); - QWindow *window = topWindow(); - if (!window) - return; - - const QString title = window->title(); HStringReference titleRef(reinterpret_cast<LPCWSTR>(title.utf16()), title.length()); HRESULT hr = d->view->put_Title(titleRef.Get()); RETURN_VOID_IF_FAILED("Unable to set window title"); diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index 5cada9726d..0e753b748b 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -109,7 +109,7 @@ public: void raise(QWindow *window); void lower(QWindow *window); - void updateWindowTitle(); + void updateWindowTitle(const QString &title); ABI::Windows::UI::Core::ICoreWindow *coreWindow() const; ABI::Windows::UI::Xaml::IDependencyObject *canvas() const; diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index 606ca22bcd..5b82183d40 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -191,6 +191,8 @@ QWinRTWindow::~QWinRTWindow() }); RETURN_VOID_IF_FAILED("Failed to completely destroy window resources, likely because the application is shutting down"); + d->screen->removeWindow(window()); + if (!d->surface) return; @@ -282,7 +284,9 @@ void QWinRTWindow::setWindowTitle(const QString &title) { Q_D(QWinRTWindow); d->windowTitle = title; - d->screen->updateWindowTitle(); + + if (d->screen->topWindow() == window()) + d->screen->updateWindowTitle(title); } void QWinRTWindow::raise() diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri index 57c8f27d9c..a3813ef993 100644 --- a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri +++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri @@ -3,6 +3,8 @@ QT += core-private gui-private platformsupport-private xcb_qpa_lib-private INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD/../ +load(qt_build_paths) + # needed by Xcursor ... qtConfig(xcb-xlib) { DEFINES += XCB_USE_XLIB diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h index 719d2ace90..926e5e22df 100644 --- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h +++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h @@ -60,6 +60,7 @@ public: virtual bool initialize(QXcbConnection *connection) = 0; virtual bool supportsThreadedOpenGL() const { return false; } + virtual bool supportsSwitchableWidgetComposition() const { return true; } virtual bool handleXcbEvent(xcb_generic_event_t *event, uint responseType); virtual QXcbWindow *createWindow(QWindow *window) const = 0; diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro index 92e6c18fbe..6b3f9b171a 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro @@ -6,6 +6,8 @@ CONFIG += egl qtConfig(xcb-xlib): DEFINES += XCB_USE_XLIB +DEFINES += QT_NO_FOREACH + HEADERS += \ qxcbeglcontext.h \ qxcbeglintegration.h \ diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp index f97c01f390..77cbdd5fba 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp @@ -224,5 +224,26 @@ bool QXcbGlxIntegration::supportsThreadedOpenGL() const return QGLXContext::supportsThreading(); } +bool QXcbGlxIntegration::supportsSwitchableWidgetComposition() const +{ + static bool vendorChecked = false; + static bool isSwitchableWidgetCompositionAvailable = true; + if (!vendorChecked) { + vendorChecked = true; + Display *display = glXGetCurrentDisplay(); +#ifdef XCB_USE_XLIB + if (!display) + display = static_cast<Display *>(m_connection->xlib_display()); +#endif + const char *glxvendor = glXGetClientString(display, GLX_VENDOR); + if (glxvendor) { + if (!strcmp(glxvendor, "Parallels Inc")) + isSwitchableWidgetCompositionAvailable = false; + } + } + + return isSwitchableWidgetCompositionAvailable; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h index 77d3bc55e1..8f04db31b2 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h @@ -60,6 +60,7 @@ public: QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE; virtual bool supportsThreadedOpenGL() const Q_DECL_OVERRIDE; + virtual bool supportsSwitchableWidgetComposition() const Q_DECL_OVERRIDE; private: QXcbConnection *m_connection; diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro index 88c4144fd9..d82a1f2d17 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro @@ -4,6 +4,7 @@ include(../gl_integrations_plugin_base.pri) #should be removed from the sources DEFINES += XCB_USE_GLX XCB_USE_XLIB +DEFINES += QT_NO_FOREACH qtConfig(xcb-glx) { DEFINES += XCB_HAS_XCB_GLX diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 2d959688b3..d577d46b96 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -107,6 +107,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input") Q_LOGGING_CATEGORY(lcQpaXInputDevices, "qt.qpa.input.devices") +Q_LOGGING_CATEGORY(lcQpaXInputEvents, "qt.qpa.input.events") Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen") // this event type was added in libxcb 1.10, @@ -1119,7 +1120,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) // the rest we need to manage ourselves m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state); m_buttons |= translateMouseButton(ev->detail); - qCDebug(lcQpaXInput, "legacy mouse press, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons)); + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "legacy mouse press, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons)); HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent); } case XCB_BUTTON_RELEASE: { @@ -1127,15 +1129,17 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) m_keyboard->updateXKBStateFromCore(ev->state); m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state); m_buttons &= ~translateMouseButton(ev->detail); - qCDebug(lcQpaXInput, "legacy mouse release, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons)); + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "legacy mouse release, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons)); HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent); } case XCB_MOTION_NOTIFY: { xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t *)event; m_keyboard->updateXKBStateFromCore(ev->state); m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state); - qCDebug(lcQpaXInput, "legacy mouse move %d,%d button %d state %X", ev->event_x, ev->event_y, - ev->detail, static_cast<unsigned int>(m_buttons)); + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "legacy mouse move %d,%d button %d state %X", ev->event_x, ev->event_y, + ev->detail, static_cast<unsigned int>(m_buttons)); HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent); } @@ -1719,11 +1723,13 @@ void QXcbConnection::processXcbEvents() compressEvent(event, i, eventqueue)) continue; +#ifndef QT_NO_CLIPBOARD bool accepted = false; if (clipboard()->processIncr()) clipboard()->incrTransactionPeeker(event, accepted); if (accepted) continue; +#endif auto isWaitingFor = [=](PeekFunc peekFunc) { // These callbacks return true if the event is what they were diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 4d903ec8d3..dca32af9b1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -86,6 +86,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQpaXInput) Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputDevices) +Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputEvents) Q_DECLARE_LOGGING_CATEGORY(lcQpaScreen) class QXcbVirtualDesktop; diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index bda167bce9..1147fc82b2 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -562,8 +562,8 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) case XI_TouchBegin: case XI_TouchUpdate: case XI_TouchEnd: - if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) - qCDebug(lcQpaXInput, "XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event); @@ -620,8 +620,8 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo double value; if (!xi2GetValuatorValueIfSet(xiDeviceEvent, n, &value)) continue; - if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) - qCDebug(lcQpaXInput, " valuator %20s value %lf from range %lf -> %lf", + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, " valuator %20s value %lf from range %lf -> %lf", atomName(vci->label).constData(), value, vci->min, vci->max ); if (vci->label == atom(QXcbAtom::RelX)) { nx = valuatorNormalized(value, vci); @@ -751,8 +751,8 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo touchPoint.area = QRectF(x - w/2, y - h/2, w, h); touchPoint.normalPosition = QPointF(nx, ny); - if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) - qCDebug(lcQpaXInput) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition << + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition << " area " << touchPoint.area << " pressure " << touchPoint.pressure; QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, dev->touchPoints.values()); if (touchPoint.state == Qt::TouchPointReleased) @@ -883,8 +883,8 @@ void QXcbConnection::updateScrollingDevice(ScrollingDevice &scrollingDevice, int scrollingDevice.lastScrollPosition.setY(vci->value); } } - if (lcQpaXInput().isDebugEnabled() && lastScrollPosition != scrollingDevice.lastScrollPosition) - qCDebug(lcQpaXInput, "scrolling device %d moved from (%f, %f) to (%f, %f)", scrollingDevice.deviceId, + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled() && lastScrollPosition != scrollingDevice.lastScrollPosition)) + qCDebug(lcQpaXInputEvents, "scrolling device %d moved from (%f, %f) to (%f, %f)", scrollingDevice.deviceId, lastScrollPosition.x(), lastScrollPosition.y(), scrollingDevice.lastScrollPosition.x(), scrollingDevice.lastScrollPosition.y()); @@ -1117,9 +1117,10 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD } // TODO maybe have a hash of tabletData->deviceId to device data so we can // look up the tablet name here, and distinguish multiple tablets - qCDebug(lcQpaXInput, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", - tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], - ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool); + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", + tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], + ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool); } XFree(data); } @@ -1181,8 +1182,8 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD } } - if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) - qCDebug(lcQpaXInput, "XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf", tabletData->deviceId, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index fb006ec0f1..fbf3acc54b 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -194,8 +194,10 @@ void QXcbDrag::startDrag() init(); +#ifndef QT_NO_CLIPBOARD xcb_set_selection_owner(xcb_connection(), connection()->clipboard()->owner(), atom(QXcbAtom::XdndSelection), connection()->time()); +#endif QStringList fmts = QXcbMime::formatsHelper(drag()->mimeData()); for (int i = 0; i < fmts.size(); ++i) { @@ -205,10 +207,12 @@ void QXcbDrag::startDrag() drag_types.append(atoms.at(j)); } } +#ifndef QT_NO_CLIPBOARD if (drag_types.size() > 3) xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->clipboard()->owner(), atom(QXcbAtom::XdndTypelist), XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData()); +#endif setUseCompositing(current_virtual_desktop->compositingActive()); setScreen(current_virtual_desktop->screens().constFirst()->screen()); @@ -447,7 +451,11 @@ void QXcbDrag::move(const QPoint &globalPos) enter.window = target; enter.format = 32; enter.type = atom(QXcbAtom::XdndEnter); +#ifndef QT_NO_CLIPBOARD enter.data.data32[0] = connection()->clipboard()->owner(); +#else + enter.data.data32[0] = 0; +#endif enter.data.data32[1] = flags; enter.data.data32[2] = drag_types.size()>0 ? drag_types.at(0) : 0; enter.data.data32[3] = drag_types.size()>1 ? drag_types.at(1) : 0; @@ -476,7 +484,11 @@ void QXcbDrag::move(const QPoint &globalPos) move.window = target; move.format = 32; move.type = atom(QXcbAtom::XdndPosition); +#ifndef QT_NO_CLIPBOARD move.data.data32[0] = connection()->clipboard()->owner(); +#else + move.data.data32[0] = 0; +#endif move.data.data32[1] = 0; // flags move.data.data32[2] = (globalPos.x() << 16) + globalPos.y(); move.data.data32[3] = connection()->time(); @@ -505,7 +517,11 @@ void QXcbDrag::drop(const QPoint &globalPos) drop.window = current_target; drop.format = 32; drop.type = atom(QXcbAtom::XdndDrop); +#ifndef QT_NO_CLIPBOARD drop.data.data32[0] = connection()->clipboard()->owner(); +#else + drop.data.data32[0] = 0; +#endif drop.data.data32[1] = 0; // flags drop.data.data32[2] = connection()->time(); @@ -791,9 +807,11 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message // reset target_time = XCB_CURRENT_TIME; +#ifndef QT_NO_CLIPBOARD if (xdnd_dragsource == connection()->clipboard()->owner()) handle_xdnd_status(&response); else +#endif Q_XCB_CALL(xcb_send_event(xcb_connection(), false, current_proxy_target, XCB_EVENT_MASK_NO_EVENT, (const char *)&response)); } @@ -859,7 +877,11 @@ void QXcbDrag::handle_xdnd_status(const xcb_client_message_event_t *event) void QXcbDrag::handleStatus(const xcb_client_message_event_t *event) { - if (event->window != connection()->clipboard()->owner() || !drag()) + if ( +#ifndef QT_NO_CLIPBOARD + event->window != connection()->clipboard()->owner() || +#endif + !drag()) return; xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event); @@ -914,7 +936,11 @@ void QXcbDrag::send_leave() leave.window = current_target; leave.format = 32; leave.type = atom(QXcbAtom::XdndLeave); +#ifndef QT_NO_CLIPBOARD leave.data.data32[0] = connection()->clipboard()->owner(); +#else + leave.data.data32[0] = 0; +#endif leave.data.data32[1] = 0; // flags leave.data.data32[2] = 0; // x, y leave.data.data32[3] = 0; // w, h @@ -1003,8 +1029,10 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e void QXcbDrag::handleFinished(const xcb_client_message_event_t *event) { DEBUG("xdndHandleFinished"); +#ifndef QT_NO_CLIPBOARD if (event->window != connection()->clipboard()->owner()) return; +#endif const unsigned long *l = (const unsigned long *)event->data.data32; @@ -1284,11 +1312,13 @@ QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QVariant::Type r if (a == XCB_NONE) return result; +#ifndef QT_NO_CLIPBOARD if (c->clipboard()->getSelectionOwner(drag->atom(QXcbAtom::XdndSelection)) == XCB_NONE) return result; // should never happen? xcb_atom_t xdnd_selection = c->atom(QXcbAtom::XdndSelection); result = c->clipboard()->getSelection(xdnd_selection, a, xdnd_selection, drag->targetTime()); +#endif return mimeConvertToFormat(c, a, result, QLatin1String(format), requestedType, encoding); } diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 5a89113a4f..802f7b85ce 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -267,9 +267,14 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const case ForeignWindows: case SyncState: case RasterGLSurface: - case SwitchableWidgetComposition: return true; + case SwitchableWidgetComposition: + { + return m_connections.at(0)->glIntegration() + && m_connections.at(0)->glIntegration()->supportsSwitchableWidgetComposition(); + } + default: return QPlatformIntegration::hasCapability(cap); } } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index a8d401e15b..a3e8da7df8 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -364,6 +364,9 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic)); + if (function == QXcbWindowFunctions::setWmWindowRoleIdentifier()) + return QFunctionPointer(QXcbWindowFunctions::SetWmWindowRole(QXcbWindow::setWmWindowRoleStatic)); + if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier()) return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic)); diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index 802e4cfe08..8744fcba3e 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -40,6 +40,8 @@ #include "qxcbsessionmanager.h" +#ifndef QT_NO_SESSIONMANAGER + #include <qguiapplication.h> #include <qdatetime.h> #include <qfileinfo.h> @@ -491,3 +493,5 @@ void QXcbSessionManager::exitEventLoop() } #include "qxcbsessionmanager.moc" + +#endif diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.h b/src/plugins/platforms/xcb/qxcbsessionmanager.h index cba0ab91ad..a184282034 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.h +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.h @@ -52,6 +52,8 @@ #include <qpa/qplatformsessionmanager.h> +#ifndef QT_NO_SESSIONMANAGER + QT_BEGIN_NAMESPACE class QEventLoop; @@ -89,4 +91,6 @@ private: QT_END_NAMESPACE +#endif //QT_NO_SESSIONMANAGER + #endif //QXCBSESSIONMANAGER_H diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4084dbc1df..51390bfdae 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -258,6 +258,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) free_prop = true; } +#ifndef QT_NO_TEXTCODEC static const QTextCodec* mapper = QTextCodec::codecForLocale(); int errCode = 0; if (mapper) { @@ -281,6 +282,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) tp.nitems = qcs.length(); free_prop = false; } +#endif return &tp; } #endif // XCB_USE_XLIB @@ -306,6 +308,7 @@ static QWindow *childWindowAt(QWindow *win, const QPoint &p) } static const char *wm_window_type_property_id = "_q_xcb_wm_window_type"; +static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; QXcbWindow::QXcbWindow(QWindow *window) : QPlatformWindow(window) @@ -588,6 +591,11 @@ void QXcbWindow::create() setOpacity(opacity); if (window()->isTopLevel()) setWindowIcon(window()->icon()); + + if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)) { + QByteArray wmWindowRole = window()->property(wm_window_role_property_id).toByteArray(); + setWmWindowRole(wmWindowRole); + } } QXcbWindow::~QXcbWindow() @@ -1722,6 +1730,14 @@ void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text) static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text); } +void QXcbWindow::setWmWindowRoleStatic(QWindow *window, const QByteArray &role) +{ + if (window->handle()) + static_cast<QXcbWindow *>(window->handle())->setWmWindowRole(role); + else + window->setProperty(wm_window_role_property_id, role); +} + uint QXcbWindow::visualIdStatic(QWindow *window) { if (window && window->handle()) @@ -1887,6 +1903,13 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W xcb_flush(xcb_connection()); } +void QXcbWindow::setWmWindowRole(const QByteArray &role) +{ + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::WM_WINDOW_ROLE), XCB_ATOM_STRING, 8, + role.size(), role.constData())); +} + void QXcbWindow::setParentRelativeBackPixmapStatic(QWindow *window) { if (window->handle()) @@ -2415,7 +2438,7 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource } const char *sourceName = 0; - if (lcQpaXInput().isDebugEnabled()) { + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) { const QMetaObject *metaObject = qt_getEnumMetaObject(source); const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source))); sourceName = me.valueToKey(source); @@ -2423,17 +2446,20 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource switch (ev->evtype) { case XI_ButtonPress: - qCDebug(lcQpaXInput, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, true); handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_ButtonRelease: - qCDebug(lcQpaXInput, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, false); handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_Motion: - qCDebug(lcQpaXInput, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source); break; default: diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index e7190b1733..f62938ba8a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -151,10 +151,12 @@ public: void updateNetWmUserTime(xcb_timestamp_t timestamp); static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes); + static void setWmWindowRoleStatic(QWindow *window, const QByteArray &role); static uint visualIdStatic(QWindow *window); QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const; void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags); + void setWmWindowRole(const QByteArray &role); static void setWindowIconTextStatic(QWindow *window, const QString &text); diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro index 75684a769b..d7f150f276 100644 --- a/src/plugins/platforms/xcb/xcb-plugin.pro +++ b/src/plugins/platforms/xcb/xcb-plugin.pro @@ -2,6 +2,8 @@ TARGET = qxcb QT += core-private gui-private platformsupport-private xcb_qpa_lib-private +DEFINES += QT_NO_FOREACH + SOURCES = \ qxcbmain.cpp OTHER_FILES += xcb.json README diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index 942183877d..ec0fa68871 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -39,6 +39,8 @@ HEADERS = \ qxcbxsettings.h \ qxcbsystemtraytracker.h +load(qt_build_paths) + DEFINES += QT_BUILD_XCB_PLUGIN # needed by Xcursor ... qtConfig(xcb-xlib) { @@ -86,7 +88,11 @@ qtConfig(dbus-linked): \ # libxkbcommon !qtConfig(xkbcommon-system) { - include(../../../3rdparty/xkbcommon-x11.pri) + qtConfig(xkb) { + include(../../../3rdparty/xkbcommon-x11.pri) + } else { + include(../../../3rdparty/xkbcommon.pri) + } } else { QMAKE_USE += xkbcommon } diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index 308eee5404..42d3c1f193 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -171,7 +171,7 @@ QGtk3ColorDialogHelper::QGtk3ColorDialogHelper() connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); - g_signal_connect_swapped(d->gtkDialog(), "color-activated", G_CALLBACK(onColorChanged), this); + g_signal_connect_swapped(d->gtkDialog(), "notify::rgba", G_CALLBACK(onColorChanged), this); } QGtk3ColorDialogHelper::~QGtk3ColorDialogHelper() @@ -217,10 +217,7 @@ QColor QGtk3ColorDialogHelper::currentColor() const void QGtk3ColorDialogHelper::onAccepted() { - const QColor color = currentColor(); - emit currentColorChanged(color); emit accept(); - emit colorSelected(color); } void QGtk3ColorDialogHelper::onColorChanged(QGtk3ColorDialogHelper *dialog) @@ -247,6 +244,7 @@ QGtk3FileDialogHelper::QGtk3FileDialogHelper() g_signal_connect(GTK_FILE_CHOOSER(d->gtkDialog()), "selection-changed", G_CALLBACK(onSelectionChanged), this); g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "current-folder-changed", G_CALLBACK(onCurrentFolderChanged), this); + g_signal_connect_swapped(GTK_FILE_CHOOSER(d->gtkDialog()), "notify::filter", G_CALLBACK(onFilterChanged), this); } QGtk3FileDialogHelper::~QGtk3FileDialogHelper() @@ -358,15 +356,6 @@ QString QGtk3FileDialogHelper::selectedNameFilter() const void QGtk3FileDialogHelper::onAccepted() { emit accept(); - - QString filter = selectedNameFilter(); - if (filter.isEmpty()) - emit filterSelected(filter); - - QList<QUrl> files = selectedFiles(); - emit filesSelected(files); - if (files.count() == 1) - emit fileSelected(files.first()); } void QGtk3FileDialogHelper::onSelectionChanged(GtkDialog *gtkDialog, QGtk3FileDialogHelper *helper) @@ -385,6 +374,11 @@ void QGtk3FileDialogHelper::onCurrentFolderChanged(QGtk3FileDialogHelper *dialog emit dialog->directoryEntered(dialog->directory()); } +void QGtk3FileDialogHelper::onFilterChanged(QGtk3FileDialogHelper *dialog) +{ + emit dialog->filterSelected(dialog->selectedNameFilter()); +} + static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer<QFileDialogOptions> &options) { switch (options->fileMode()) { @@ -488,6 +482,8 @@ QGtk3FontDialogHelper::QGtk3FontDialogHelper() d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", 0))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); + + g_signal_connect_swapped(d->gtkDialog(), "notify::font", G_CALLBACK(onFontChanged), this); } QGtk3FontDialogHelper::~QGtk3FontDialogHelper() @@ -593,10 +589,12 @@ QFont QGtk3FontDialogHelper::currentFont() const void QGtk3FontDialogHelper::onAccepted() { - const QFont font = currentFont(); - emit currentFontChanged(font); emit accept(); - emit fontSelected(font); +} + +void QGtk3FontDialogHelper::onFontChanged(QGtk3FontDialogHelper *dialog) +{ + emit dialog->currentFontChanged(dialog->currentFont()); } void QGtk3FontDialogHelper::applyOptions() diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h index c852fd05f6..99add3bda3 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h @@ -107,6 +107,7 @@ private Q_SLOTS: private: static void onSelectionChanged(GtkDialog *dialog, QGtk3FileDialogHelper *helper); static void onCurrentFolderChanged(QGtk3FileDialogHelper *helper); + static void onFilterChanged(QGtk3FileDialogHelper *helper); void applyOptions(); void setNameFilters(const QStringList &filters); @@ -136,6 +137,7 @@ private Q_SLOTS: void onAccepted(); private: + static void onFontChanged(QGtk3FontDialogHelper *helper); void applyOptions(); QScopedPointer<QGtk3Dialog> d; |