diff options
Diffstat (limited to 'src/plugins')
27 files changed, 197 insertions, 811 deletions
diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index d6577e9d7f..03e94cfe6a 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -1,14 +1,12 @@ TARGET = qconnmanbearer -QT = core network-private dbus +QT = core network-private dbus linuxofono_support_private HEADERS += qconnmanservice_linux_p.h \ - ../linux_common/qofonoservice_linux_p.h \ qconnmanengine.h SOURCES += main.cpp \ qconnmanservice_linux.cpp \ - ../linux_common/qofonoservice_linux.cpp \ qconnmanengine.cpp OTHER_FILES += connman.json diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index eb79dbec1b..969eed45b1 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -54,7 +54,7 @@ #include <private/qbearerengine_impl_p.h> #include "qconnmanservice_linux_p.h" -#include "../linux_common/qofonoservice_linux_p.h" +#include <private/qofonoservice_linux_p.h> #include <QMap> #include <QVariant> diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp deleted file mode 100644 index 05f9b3ca17..0000000000 --- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QObject> -#include <QList> -#include <QtDBus/QtDBus> -#include <QtDBus/QDBusConnection> -#include <QtDBus/QDBusError> -#include <QtDBus/QDBusInterface> -#include <QtDBus/QDBusMessage> -#include <QtDBus/QDBusReply> -#include <QtDBus/QDBusPendingCallWatcher> -#include <QtDBus/QDBusObjectPath> -#include <QtDBus/QDBusPendingCall> - -#include "qofonoservice_linux_p.h" - -#ifndef QT_NO_DBUS - -QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item) -{ - argument.beginStructure(); - argument << item.path << item.properties; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &item) -{ - argument.beginStructure(); - argument >> item.path >> item.properties; - argument.endStructure(); - return argument; -} - -QT_BEGIN_NAMESPACE - -QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - OFONO_MANAGER_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - qDBusRegisterMetaType<ObjectPathProperties>(); - qDBusRegisterMetaType<PathPropertiesList>(); - - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - QLatin1String(OFONO_MANAGER_INTERFACE), - QLatin1String("ModemAdded"), - this,SLOT(modemAdded(QDBusObjectPath,QVariantMap))); - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - QLatin1String(OFONO_MANAGER_INTERFACE), - QLatin1String("ModemRemoved"), - this,SLOT(modemRemoved(QDBusObjectPath))); -} - -QOfonoManagerInterface::~QOfonoManagerInterface() -{ -} - -QStringList QOfonoManagerInterface::getModems() -{ - if (modemList.isEmpty()) { - QDBusPendingReply<PathPropertiesList> reply = call(QDBus::Block, QLatin1String("GetModems")); - reply.waitForFinished(); - if (!reply.isError()) { - const auto modems = reply.value(); - for (const ObjectPathProperties &modem : modems) - modemList << modem.path.path(); - } - } - - return modemList; -} - -QString QOfonoManagerInterface::currentModem() -{ - const QStringList modems = getModems(); - for (const QString &modem : modems) { - QOfonoModemInterface device(modem); - if (device.isPowered() && device.isOnline() - && device.interfaces().contains(QLatin1String("org.ofono.NetworkRegistration"))) - return modem; - } - return QString(); -} - -void QOfonoManagerInterface::modemAdded(const QDBusObjectPath &path, const QVariantMap &/*var*/) -{ - if (!modemList.contains(path.path())) { - modemList << path.path(); - Q_EMIT modemChanged(); - } -} - -void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path) -{ - if (modemList.contains(path.path())) { - modemList.removeOne(path.path()); - Q_EMIT modemChanged(); - } -} - - -QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_MODEM_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - path(), - OFONO_MODEM_INTERFACE, - QLatin1String("PropertyChanged"), - this,SLOT(propertyChanged(QString,QDBusVariant))); -} - -QOfonoModemInterface::~QOfonoModemInterface() -{ -} - -void QOfonoModemInterface::propertyChanged(const QString &name,const QDBusVariant &value) -{ - propertiesMap[name] = value.variant(); -} - -bool QOfonoModemInterface::isPowered() -{ - QVariant var = getProperty(QStringLiteral("Powered")); - return qdbus_cast<bool>(var); -} - -bool QOfonoModemInterface::isOnline() -{ - QVariant var = getProperty(QStringLiteral("Online")); - return qdbus_cast<bool>(var); -} - -QStringList QOfonoModemInterface::interfaces() -{ - const QVariant var = getProperty(QStringLiteral("Interfaces")); - return var.toStringList(); -} - -QVariantMap QOfonoModemInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties")); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -QVariant QOfonoModemInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) - var = map.value(property); - return var; -} - - -QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_NETWORK_REGISTRATION_INTERFACE, - QDBusConnection::systemBus(), parent) -{ -} - -QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface() -{ -} - -QString QOfonoNetworkRegistrationInterface::getTechnology() -{ - QVariant var = getProperty(QStringLiteral("Technology")); - return qdbus_cast<QString>(var); -} - -QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) - var = map.value(property); - return var; -} - -QVariantMap QOfonoNetworkRegistrationInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties")); - reply.waitForFinished(); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_DATA_CONNECTION_MANAGER_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - path(), - QLatin1String(OFONO_MODEM_INTERFACE), - QLatin1String("PropertyChanged"), - this,SLOT(propertyChanged(QString,QDBusVariant))); -} - -QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface() -{ -} - -QStringList QOfonoDataConnectionManagerInterface::contexts() -{ - if (contextList.isEmpty()) { - QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts")); - reply.waitForFinished(); - if (!reply.isError()) { - const auto contexts = reply.value(); - for (const ObjectPathProperties &context : contexts) - contextList << context.path.path(); - } - } - return contextList; -} - -PathPropertiesList QOfonoDataConnectionManagerInterface::contextsWithProperties() -{ - if (contextListProperties.isEmpty()) { - QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts")); - reply.waitForFinished(); - if (!reply.isError()) { - contextListProperties = reply.value(); - } - } - return contextListProperties; -} - -bool QOfonoDataConnectionManagerInterface::roamingAllowed() -{ - QVariant var = getProperty(QStringLiteral("RoamingAllowed")); - return qdbus_cast<bool>(var); -} - -QString QOfonoDataConnectionManagerInterface::bearer() -{ - QVariant var = getProperty(QStringLiteral("Bearer")); - return qdbus_cast<QString>(var); -} - -QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) -{ - return getProperties().value(property); -} - -QVariantMap &QOfonoDataConnectionManagerInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties")); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -void QOfonoDataConnectionManagerInterface::propertyChanged(const QString &name, const QDBusVariant &value) -{ - propertiesMap[name] = value.variant(); - if (name == QLatin1String("RoamingAllowed")) - Q_EMIT roamingAllowedChanged(value.variant().toBool()); -} - - -QOfonoConnectionContextInterface::QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_CONNECTION_CONTEXT_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - path(), - QLatin1String(OFONO_MODEM_INTERFACE), - QLatin1String("PropertyChanged"), - this,SLOT(propertyChanged(QString,QDBusVariant))); -} - -QOfonoConnectionContextInterface::~QOfonoConnectionContextInterface() -{ -} - -QVariantMap QOfonoConnectionContextInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply<QVariantMap> reply = call(QDBus::Block, QLatin1String("GetProperties")); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -void QOfonoConnectionContextInterface::propertyChanged(const QString &name, const QDBusVariant &value) -{ - propertiesMap[name] = value.variant(); -} - -QVariant QOfonoConnectionContextInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) - var = map.value(property); - return var; -} - -bool QOfonoConnectionContextInterface::active() -{ - QVariant var = getProperty(QStringLiteral("Active")); - return qdbus_cast<bool>(var); -} - -QString QOfonoConnectionContextInterface::accessPointName() -{ - QVariant var = getProperty(QStringLiteral("AccessPointName")); - return qdbus_cast<QString>(var); -} - -QString QOfonoConnectionContextInterface::name() -{ - QVariant var = getProperty(QStringLiteral("Name")); - return qdbus_cast<QString>(var); -} - -QT_END_NAMESPACE - -#endif // QT_NO_DBUS diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h deleted file mode 100644 index 62df5d4fa7..0000000000 --- a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOFONOSERVICE_H -#define QOFONOSERVICE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtDBus/QtDBus> -#include <QtDBus/QDBusConnection> -#include <QtDBus/QDBusError> -#include <QtDBus/QDBusInterface> -#include <QtDBus/QDBusMessage> -#include <QtDBus/QDBusReply> - -#include <QtDBus/QDBusPendingCallWatcher> -#include <QtDBus/QDBusObjectPath> -#include <QtDBus/QDBusContext> -#include <QMap> - -#ifndef QT_NO_DBUS - -#define OFONO_SERVICE "org.ofono" -#define OFONO_MANAGER_INTERFACE "org.ofono.Manager" -#define OFONO_MANAGER_PATH "/" - -#define OFONO_MODEM_INTERFACE "org.ofono.Modem" -#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration" -#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.ConnectionManager" -#define OFONO_CONNECTION_CONTEXT_INTERFACE "org.ofono.ConnectionContext" - -QT_BEGIN_NAMESPACE - -QT_END_NAMESPACE - -struct ObjectPathProperties -{ - QDBusObjectPath path; - QVariantMap properties; -}; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(ObjectPathProperties, Q_MOVABLE_TYPE); // QDBusObjectPath is movable, but cannot be - // marked as such until Qt 6 -QT_END_NAMESPACE - -typedef QVector<ObjectPathProperties> PathPropertiesList; -Q_DECLARE_METATYPE(ObjectPathProperties) -Q_DECLARE_METATYPE (PathPropertiesList) - -QT_BEGIN_NAMESPACE - -class QOfonoManagerInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - QOfonoManagerInterface( QObject *parent = nullptr); - ~QOfonoManagerInterface(); - - QStringList getModems(); - QString currentModem(); -signals: - void modemChanged(); -private: - QStringList modemList; -private slots: - void modemAdded(const QDBusObjectPath &path, const QVariantMap &var); - void modemRemoved(const QDBusObjectPath &path); -}; - -class QOfonoModemInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = nullptr); - ~QOfonoModemInterface(); - - bool isPowered(); - bool isOnline(); - QStringList interfaces(); -private: - QVariantMap getProperties(); - QVariantMap propertiesMap; - QVariant getProperty(const QString &); - void propertyChanged(const QString &, const QDBusVariant &value); -}; - - -class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = nullptr); - ~QOfonoNetworkRegistrationInterface(); - - QString getTechnology(); - -private: - QVariantMap getProperties(); - QVariant getProperty(const QString &); - QVariantMap propertiesMap; -Q_SIGNALS: - void propertyChanged(const QString &, const QDBusVariant &value); -}; - -class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = nullptr); - ~QOfonoDataConnectionManagerInterface(); - - QStringList contexts(); - PathPropertiesList contextsWithProperties(); - bool roamingAllowed(); - QVariant getProperty(const QString &); - QString bearer(); -Q_SIGNALS: - void roamingAllowedChanged(bool); -private: - QVariantMap &getProperties(); - QVariantMap propertiesMap; - QStringList contextList; - PathPropertiesList contextListProperties; -private Q_SLOTS: - void propertyChanged(const QString &, const QDBusVariant &value); -}; - -class QOfonoConnectionContextInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent = nullptr); - ~QOfonoConnectionContextInterface(); - - QVariant getProperty(const QString &); - bool active(); - QString accessPointName(); - QString name(); - -Q_SIGNALS: -private: - QVariantMap getProperties(); - QVariantMap propertiesMap; -private slots: - void propertyChanged(const QString &, const QDBusVariant &value); -}; - -QT_END_NAMESPACE - -#endif // QT_NO_DBUS - -#endif //QOFONOSERVICE_H diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro index 3fbad07ef5..3ca217f974 100644 --- a/src/plugins/bearer/networkmanager/networkmanager.pro +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -1,15 +1,13 @@ TARGET = qnmbearer -QT = core network-private dbus +QT = core network-private dbus linuxofono_support_private HEADERS += qnetworkmanagerservice.h \ - qnetworkmanagerengine.h \ - ../linux_common/qofonoservice_linux_p.h + qnetworkmanagerengine.h SOURCES += main.cpp \ qnetworkmanagerservice.cpp \ - qnetworkmanagerengine.cpp \ - ../linux_common/qofonoservice_linux.cpp + qnetworkmanagerengine.cpp OTHER_FILES += networkmanager.json diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index d686bc4e51..2fb5b2efbc 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -53,7 +53,6 @@ #include <QDBusInterface> #include <QDBusMessage> #include <QDBusReply> -#include "../linux_common/qofonoservice_linux_p.h" #ifndef QT_NO_DBUS diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index c6c5280eca..c624d6087d 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -55,7 +55,7 @@ #include "qnetworkmanagerservice.h" -#include "../linux_common/qofonoservice_linux_p.h" +#include <private/qofonoservice_linux_p.h> #include <QMap> #include <QVariant> diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 9cdc5de0e1..56885f2e23 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -195,20 +195,6 @@ namespace QtAndroidInput angleDelta); } - void releaseMouse(int x, int y) - { - m_ignoreMouseEvents = true; - QPoint globalPos(x,y); - QWindow *tlw = topLevelWindowAt(globalPos); - QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos; - - // Release left button - QWindowSystemInterface::handleMouseEvent(tlw, - localPos, - globalPos, - Qt::MouseButtons(Qt::NoButton)); - } - static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y) { QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext(); diff --git a/src/plugins/platforms/android/androidjniinput.h b/src/plugins/platforms/android/androidjniinput.h index 2e2470ae8f..cc3070c4aa 100644 --- a/src/plugins/platforms/android/androidjniinput.h +++ b/src/plugins/platforms/android/androidjniinput.h @@ -61,8 +61,6 @@ namespace QtAndroidInput void updateHandles(int handleCount, QPoint editMenuPos = QPoint(), uint32_t editButtons = 0, QPoint cursor = QPoint(), QPoint anchor = QPoint(), bool rtl = false); bool registerNatives(JNIEnv *env); - - void releaseMouse(int x, int y); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 5614d3b04f..e78c317863 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -827,9 +827,6 @@ void QAndroidInputContext::longPress(int x, int y) focusObjectStopComposing(); - // Release left button, otherwise the following events will cancel the menu popup - QtAndroidInput::releaseMouse(x, y); - const double pixelDensity = QGuiApplication::focusWindow() ? QHighDpiScaling::factor(QGuiApplication::focusWindow()) diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 00f5a1bf09..9b0a6b1b86 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -88,10 +88,13 @@ #include <qpa/qwindowsysteminterface.h> #include <qwindowdefs.h> +QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application"); +QT_END_NAMESPACE + QT_USE_NAMESPACE @implementation QCocoaApplicationDelegate { - bool startedQuit; NSObject <NSApplicationDelegate> *reflectionDelegate; bool inLaunch; } @@ -140,67 +143,30 @@ QT_USE_NAMESPACE return [[self.dockMenu retain] autorelease]; } -- (BOOL)canQuit -{ - [[NSApp mainMenu] cancelTracking]; - - bool handle_quit = true; - NSMenuItem *quitMenuItem = [[QCocoaMenuLoader sharedMenuLoader] quitMenuItem]; - if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty() - && [quitMenuItem isEnabled]) { - int visible = 0; - const QWindowList tlws = QGuiApplication::topLevelWindows(); - for (int i = 0; i < tlws.size(); ++i) { - if (tlws.at(i)->isVisible()) - ++visible; - } - handle_quit = (visible <= 1); - } - - if (handle_quit) { - QCloseEvent ev; - QGuiApplication::sendEvent(qGuiApp, &ev); - if (ev.isAccepted()) { - return YES; - } - } - - return NO; -} - // This function will only be called when NSApp is actually running. - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { if ([reflectionDelegate respondsToSelector:_cmd]) return [reflectionDelegate applicationShouldTerminate:sender]; - if ([self canQuit]) { - if (!startedQuit) { - startedQuit = true; - // Close open windows. This is done in order to deliver de-expose - // events while the event loop is still running. - const QWindowList topLevels = QGuiApplication::topLevelWindows(); - for (int i = 0; i < topLevels.size(); ++i) { - QWindow *topLevelWindow = topLevels.at(i); - // Already closed windows will not have a platform window, skip those - if (topLevelWindow->handle()) - QWindowSystemInterface::handleCloseEvent(topLevelWindow); - } - QWindowSystemInterface::flushWindowSystemEvents(); - - QGuiApplication::exit(0); - startedQuit = false; - } - } - if (QGuiApplicationPrivate::instance()->threadData->eventLoops.isEmpty()) { - // INVARIANT: No event loop is executing. This probably - // means that Qt is used as a plugin, or as a part of a native - // Cocoa application. In any case it should be fine to - // terminate now: + // No event loop is executing. This probably means that Qt is used as a plugin, + // or as a part of a native Cocoa application. In any case it should be fine to + // terminate now. + qCDebug(lcQpaApplication) << "No running event loops, terminating now"; return NSTerminateNow; } + if (!QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>()) { + qCDebug(lcQpaApplication) << "Application termination canceled"; + return NSTerminateCancel; + } + + // Even if the application termination was accepted by the application we can't + // return NSTerminateNow, as that would trigger AppKit to ultimately call exit(). + // We need to ensure that the runloop continues spinning so that we can return + // from our own event loop back to main(), and exit from there. + qCDebug(lcQpaApplication) << "Termination accepted, but returning to runloop for exit through main()"; return NSTerminateCancel; } diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index e87fc39c42..b3ce9e45dc 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -293,46 +293,42 @@ bool QCocoaEventDispatcher::hasPendingEvents() return qGlobalPostedEventsCount() || (qt_is_gui_used && !CFRunLoopIsWaiting(CFRunLoopGetMain())); } -static bool IsMouseOrKeyEvent( NSEvent* event ) +static bool isUserInputEvent(NSEvent* event) { - bool result = false; - - switch( [event type] ) - { - case NSEventTypeLeftMouseDown: - case NSEventTypeLeftMouseUp: - case NSEventTypeRightMouseDown: - case NSEventTypeRightMouseUp: - case NSEventTypeMouseMoved: // ?? - case NSEventTypeLeftMouseDragged: - case NSEventTypeRightMouseDragged: - case NSEventTypeMouseEntered: - case NSEventTypeMouseExited: - case NSEventTypeKeyDown: - case NSEventTypeKeyUp: - case NSEventTypeFlagsChanged: // key modifiers changed? - case NSEventTypeCursorUpdate: // ?? - case NSEventTypeScrollWheel: - case NSEventTypeTabletPoint: - case NSEventTypeTabletProximity: - case NSEventTypeOtherMouseDown: - case NSEventTypeOtherMouseUp: - case NSEventTypeOtherMouseDragged: + switch ([event type]) { + case NSEventTypeLeftMouseDown: + case NSEventTypeLeftMouseUp: + case NSEventTypeRightMouseDown: + case NSEventTypeRightMouseUp: + case NSEventTypeMouseMoved: // ?? + case NSEventTypeLeftMouseDragged: + case NSEventTypeRightMouseDragged: + case NSEventTypeMouseEntered: + case NSEventTypeMouseExited: + case NSEventTypeKeyDown: + case NSEventTypeKeyUp: + case NSEventTypeFlagsChanged: // key modifiers changed? + case NSEventTypeCursorUpdate: // ?? + case NSEventTypeScrollWheel: + case NSEventTypeTabletPoint: + case NSEventTypeTabletProximity: + case NSEventTypeOtherMouseDown: + case NSEventTypeOtherMouseUp: + case NSEventTypeOtherMouseDragged: #ifndef QT_NO_GESTURES - case NSEventTypeGesture: // touch events - case NSEventTypeMagnify: - case NSEventTypeSwipe: - case NSEventTypeRotate: - case NSEventTypeBeginGesture: - case NSEventTypeEndGesture: + case NSEventTypeGesture: // touch events + case NSEventTypeMagnify: + case NSEventTypeSwipe: + case NSEventTypeRotate: + case NSEventTypeBeginGesture: + case NSEventTypeEndGesture: #endif // QT_NO_GESTURES - result = true; + return true; break; - - default: + default: break; } - return result; + return false; } static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRunLoopMode) @@ -465,7 +461,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) dequeue: YES]; if (event) { - if (IsMouseOrKeyEvent(event)) { + if (isUserInputEvent(event)) { [event retain]; d->queuedUserInputEvents.append(event); continue; @@ -485,7 +481,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) if (event) { if (flags & QEventLoop::ExcludeUserInputEvents) { - if (IsMouseOrKeyEvent(event)) { + if (isUserInputEvent(event)) { [event retain]; d->queuedUserInputEvents.append(event); continue; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index bb309c0713..4210a4ed3f 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +class QCocoaWindow; + class QCocoaGLContext : public QPlatformOpenGLContext { public: @@ -76,12 +78,12 @@ private: static NSOpenGLPixelFormat *pixelFormatForSurfaceFormat(const QSurfaceFormat &format); bool setDrawable(QPlatformSurface *surface); + void prepareDrawable(QCocoaWindow *platformWindow); void updateSurfaceFormat(); NSOpenGLContext *m_context = nil; NSOpenGLContext *m_shareContext = nil; QSurfaceFormat m_format; - bool m_didCheckForSoftwareContext = false; QVarLengthArray<QMacNotificationObserver, 3> m_updateObservers; QAtomicInt m_needsUpdate = false; }; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index ba7d12ce30..b312e033cd 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -223,12 +223,10 @@ NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurface attrs << NSOpenGLPFAAllowOfflineRenderers; } - // FIXME: Pull this information out of the NSView - QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER"); - if (!useLayer.isEmpty() && useLayer.toInt() > 0) { - // Disable the software rendering fallback. This makes compositing - // OpenGL and raster NSViews using Core Animation layers possible. - attrs << NSOpenGLPFANoRecovery; + if (qGuiApp->testAttribute(Qt::AA_UseSoftwareOpenGL)) { + // kCGLRendererGenericFloatID is the modern software renderer on macOS, + // as opposed to kCGLRendererGenericID, which is deprecated. + attrs << NSOpenGLPFARendererID << kCGLRendererGenericFloatID; } attrs << 0; // 0-terminate array @@ -368,23 +366,6 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) [m_context makeCurrentContext]; if (surface->surface()->surfaceClass() == QSurface::Window) { - // Disable high-resolution surfaces when using the software renderer, which has the - // problem that the system silently falls back to a to using a low-resolution buffer - // when a high-resolution buffer is requested. This is not detectable using the NSWindow - // convertSizeToBacking and backingScaleFactor APIs. A typical result of this is that Qt - // will display a quarter of the window content when running in a virtual machine. - if (!m_didCheckForSoftwareContext) { - // FIXME: This ensures we check only once per context, - // but the context may be used for multiple surfaces. - m_didCheckForSoftwareContext = true; - - const GLubyte* renderer = glGetString(GL_RENDERER); - if (qstrcmp((const char *)renderer, "Apple Software Renderer") == 0) { - NSView *view = static_cast<QCocoaWindow *>(surface)->m_view; - [view setWantsBestResolutionOpenGLSurface:NO]; - } - } - if (m_needsUpdate.fetchAndStoreRelaxed(false)) update(); } @@ -413,11 +394,14 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface) } Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window); - QNSView *view = qnsview_cast(static_cast<QCocoaWindow *>(surface)->view()); + auto *cocoaWindow = static_cast<QCocoaWindow *>(surface); + QNSView *view = qnsview_cast(cocoaWindow->view()); if (view == m_context.view) return true; + prepareDrawable(cocoaWindow); + // Setting the drawable may happen on a separate thread as a result of // a call to makeCurrent, so we need to set up the observers before we // associate the view with the context. That way we will guarantee that @@ -460,6 +444,30 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface) return true; } +void QCocoaGLContext::prepareDrawable(QCocoaWindow *platformWindow) +{ + // We generally want high-DPI GL surfaces, unless the user has explicitly disabled them + bool prefersBestResolutionOpenGLSurface = qt_mac_resolveOption(YES, + platformWindow->window(), "_q_mac_wantsBestResolutionOpenGLSurface", + "QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE"); + + auto *view = platformWindow->view(); + + // The only case we have to opt out ourselves is when using the Apple software renderer + // in combination with surface-backed views, as these together do not support high-DPI. + if (prefersBestResolutionOpenGLSurface) { + int rendererID = 0; + [m_context getValues:&rendererID forParameter:NSOpenGLContextParameterCurrentRendererID]; + bool isSoftwareRenderer = (rendererID & kCGLRendererIDMatchingMask) == kCGLRendererGenericFloatID; + if (isSoftwareRenderer && !view.layer) { + qCInfo(lcQpaOpenGLContext) << "Disabling high resolution GL surface due to software renderer"; + prefersBestResolutionOpenGLSurface = false; + } + } + + view.wantsBestResolutionOpenGLSurface = prefersBestResolutionOpenGLSurface; +} + // NSOpenGLContext is not re-entrant. Even when using separate contexts per thread, // view, and window, calls into the API will still deadlock. For more information // see https://openradar.appspot.com/37064579 @@ -491,6 +499,21 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface) return; } + if (m_context.view.layer) { + // Flushing an NSOpenGLContext will hit the screen immediately, ignoring + // any Core Animation transactions in place. This may result in major + // visual artifacts if the flush happens out of sync with the size + // of the layer, view, and window reflected by other parts of the UI, + // e.g. if the application flushes in the resize event or a timer during + // window resizing, instead of in the expose event. + auto *cocoaWindow = static_cast<QCocoaWindow *>(surface); + if (cocoaWindow->geometry().size() != cocoaWindow->m_exposedRect.size()) { + qCInfo(lcQpaOpenGLContext) << "Window exposed size does not match geometry (yet)." + << "Skipping flush to avoid visual artifacts."; + return; + } + } + QMutexLocker locker(&s_reentrancyMutex); [m_context flushBuffer]; } diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h index 60243b79be..7ec9a2b5af 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.h +++ b/src/plugins/platforms/cocoa/qcocoascreen.h @@ -99,18 +99,18 @@ private: static void add(CGDirectDisplayID displayId); void remove(); - CGDirectDisplayID m_displayId = 0; + CGDirectDisplayID m_displayId = kCGNullDirectDisplay; QRect m_geometry; QRect m_availableGeometry; QDpi m_logicalDpi; - qreal m_refreshRate; - int m_depth; + qreal m_refreshRate = 0; + int m_depth = 0; QString m_name; QImage::Format m_format; QSizeF m_physicalSize; QCocoaCursor *m_cursor; - qreal m_devicePixelRatio; + qreal m_devicePixelRatio = 0; CVDisplayLinkRef m_displayLink = nullptr; dispatch_source_t m_displayLinkSource = nullptr; diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 392099d083..bd5c95b9d0 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -54,6 +54,23 @@ QT_BEGIN_NAMESPACE +namespace CoreGraphics { + Q_NAMESPACE + enum DisplayChange { + Moved = kCGDisplayMovedFlag, + SetMain = kCGDisplaySetMainFlag, + SetMode = kCGDisplaySetModeFlag, + Added = kCGDisplayAddFlag, + Removed = kCGDisplayRemoveFlag, + Enabled = kCGDisplayEnabledFlag, + Disabled = kCGDisplayDisabledFlag, + Mirrored = kCGDisplayMirrorFlag, + UnMirrored = kCGDisplayUnMirrorFlag, + DesktopShapeChanged = kCGDisplayDesktopShapeChangedFlag + }; + Q_ENUM_NS(DisplayChange) +} + void QCocoaScreen::initializeScreens() { uint32_t displayCount = 0; @@ -73,6 +90,10 @@ void QCocoaScreen::initializeScreens() Q_UNUSED(userInfo); + qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display reconfiguration" + << " (" << QFlags<CoreGraphics::DisplayChange>(flags) << ")" + << " for displayId=" << displayId; + QCocoaScreen *cocoaScreen = QCocoaScreen::get(displayId); if ((flags & kCGDisplayAddFlag) || !cocoaScreen) { @@ -93,22 +114,24 @@ void QCocoaScreen::initializeScreens() mainDisplay->updateProperties(); qCInfo(lcQpaScreen) << "Primary screen changed to" << mainDisplay; QWindowSystemInterface::handlePrimaryScreenChanged(mainDisplay); + if (cocoaScreen == mainDisplay) + return; // Already reconfigured } - if (cocoaScreen == mainDisplay) - return; // Already reconfigured - cocoaScreen->updateProperties(); - qCInfo(lcQpaScreen) << "Reconfigured" << cocoaScreen; + qCInfo(lcQpaScreen).nospace() << "Reconfigured " << + (primaryScreen() == cocoaScreen ? "primary " : "") + << cocoaScreen; } }, nullptr); } void QCocoaScreen::add(CGDirectDisplayID displayId) { + const bool isPrimary = CGDisplayIsMain(displayId); QCocoaScreen *cocoaScreen = new QCocoaScreen(displayId); - qCInfo(lcQpaScreen) << "Adding" << cocoaScreen; - QWindowSystemInterface::handleScreenAdded(cocoaScreen, CGDisplayIsMain(displayId)); + qCInfo(lcQpaScreen).nospace() << "Adding " << (isPrimary ? "new primary " : "") << cocoaScreen; + QWindowSystemInterface::handleScreenAdded(cocoaScreen, isPrimary); } QCocoaScreen::QCocoaScreen(CGDirectDisplayID displayId) @@ -127,7 +150,7 @@ void QCocoaScreen::cleanupScreens() void QCocoaScreen::remove() { - m_displayId = 0; // Prevent stale references during removal + m_displayId = kCGNullDirectDisplay; // Prevent stale references during removal // This may result in the application responding to QGuiApplication::screenRemoved // by moving the window to another screen, either by setGeometry, or by setScreen. @@ -140,6 +163,7 @@ void QCocoaScreen::remove() // QCocoaWindow::windowDidChangeScreen. At that point the window will appear to have // already changed its screen, but that's only true if comparing the Qt screens, // not when comparing the NSScreens. + qCInfo(lcQpaScreen).nospace() << "Removing " << (primaryScreen() == this ? "current primary " : "") << this; QWindowSystemInterface::handleScreenRemoved(this); } @@ -351,15 +375,6 @@ void QCocoaScreen::deliverUpdateRequests() // it on the main thread yet, because the processing of the update request is taking // too long, or because the update request was deferred due to window live resizing. qDeferredDebug(screenUpdates) << ", " << framesAheadOfDelivery << " frame(s) ahead"; - - // We skip the frame completely if we're live-resizing, to not put any extra - // strain on the main thread runloop. Otherwise we assume we should push frames - // as fast as possible, and hopefully the callback will be delivered on the - // main thread just when the previous finished. - if (qt_apple_sharedApplication().keyWindow.inLiveResize) { - qDeferredDebug(screenUpdates) << "; waiting for main thread to catch up"; - return; - } } qDeferredDebug(screenUpdates) << "; signaling dispatch source"; @@ -552,10 +567,10 @@ QPixmap QCocoaScreen::grabWindow(WId view, int x, int y, int width, int height) */ QCocoaScreen *QCocoaScreen::primaryScreen() { - auto screen = static_cast<QCocoaScreen *>(QGuiApplication::primaryScreen()->handle()); - Q_ASSERT_X(screen == get(CGMainDisplayID()), "QCocoaScreen", - "The application's primary screen should always be in sync with the main display"); - return screen; + // Note: The primary screen that Qt knows about may not match the current CGMainDisplayID() + // if macOS has not yet been able to inform us that the main display has changed, but we + // will update the primary screen accordingly once the reconfiguration callback comes in. + return static_cast<QCocoaScreen *>(QGuiApplication::primaryScreen()->handle()); } QList<QPlatformScreen*> QCocoaScreen::virtualSiblings() const @@ -597,7 +612,7 @@ NSScreen *QCocoaScreen::nativeScreen() const QCFType<CFUUIDRef> uuid = CGDisplayCreateUUIDFromDisplayID(m_displayId); for (NSScreen *screen in [NSScreen screens]) { - if (CGDisplayCreateUUIDFromDisplayID(screen.qt_displayId) == uuid) + if (QCFType<CFUUIDRef>(CGDisplayCreateUUIDFromDisplayID(screen.qt_displayId)) == uuid) return screen; } @@ -639,6 +654,7 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen) debug << ", geometry=" << screen->geometry(); debug << ", dpr=" << screen->devicePixelRatio(); debug << ", name=" << screen->name(); + debug << ", displayId=" << screen->m_displayId; debug << ", native=" << screen->nativeScreen(); } debug << ')'; @@ -646,6 +662,8 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen) } #endif // !QT_NO_DEBUG_STREAM +#include "qcocoascreen.moc" + QT_END_NAMESPACE @implementation NSScreen (QtExtras) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f212b3e3f0..21366b4f67 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1509,17 +1509,6 @@ bool QCocoaWindow::updatesWithDisplayLink() const void QCocoaWindow::deliverUpdateRequest() { - // Don't send update requests for views that need display, as the update - // request doesn't carry any information about dirty rects, so the app - // may end up painting a smaller region than required. (For some reason - // the layer and view's needsDisplay status isn't always in sync, even if - // the view is layer-backed, not layer-hosted, so we check both). - if (m_view.layer.needsDisplay || m_view.needsDisplay) { - qCDebug(lcQpaDrawing) << "View needs display, deferring update request for" << window(); - requestUpdate(); - return; - } - qCDebug(lcQpaDrawing) << "Delivering update request to" << window(); QPlatformWindow::deliverUpdateRequest(); } diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm index eb9286519d..2fd63fad67 100644 --- a/src/plugins/platforms/cocoa/qnsview_drawing.mm +++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm @@ -44,17 +44,6 @@ - (void)initDrawing { [self updateLayerBacking]; - - // Enable high-DPI OpenGL for retina displays. Enabling has the side - // effect that Cocoa will start calling glViewport(0, 0, width, height), - // overriding any glViewport calls in application code. This is usually not a - // problem, except if the application wants to have a "custom" viewport. - // (like the hellogl example) - if (m_platformWindow->window()->supportsOpenGL()) { - self.wantsBestResolutionOpenGLSurface = qt_mac_resolveOption(YES, m_platformWindow->window(), - "_q_mac_wantsBestResolutionOpenGLSurface", "QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE"); - // See also QCocoaGLContext::makeCurrent for software renderer workarounds. - } } - (BOOL)isOpaque diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index 58ad53a6e1..dcb9a85a3c 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -59,6 +59,8 @@ QMacPrintEngine::QMacPrintEngine(QPrinter::PrinterMode mode, const QString &devi QString id = deviceId; if (id.isEmpty()) id = QCocoaPrinterSupport().defaultPrintDeviceId(); + else + setProperty(QPrintEngine::PPK_PrinterName, deviceId); d->m_printDevice.reset(new QCocoaPrintDevice(id)); d->m_pageLayout.setPageSize(d->m_printDevice->defaultPageSize()); d->initialize(); diff --git a/src/plugins/platforms/haiku/qhaikuapplication.cpp b/src/plugins/platforms/haiku/qhaikuapplication.cpp index b75810c453..de4acdfd4a 100644 --- a/src/plugins/platforms/haiku/qhaikuapplication.cpp +++ b/src/plugins/platforms/haiku/qhaikuapplication.cpp @@ -42,6 +42,8 @@ #include <QCoreApplication> #include <QFileOpenEvent> +#include <qpa/qwindowsysteminterface.h> + #include <Entry.h> #include <Path.h> @@ -52,8 +54,7 @@ QHaikuApplication::QHaikuApplication(const char *signature) bool QHaikuApplication::QuitRequested() { - QEvent quitEvent(QEvent::Quit); - QCoreApplication::sendEvent(QCoreApplication::instance(), &quitEvent); + QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>(); return true; } diff --git a/src/plugins/platforms/wasm/wasm_shell.html b/src/plugins/platforms/wasm/wasm_shell.html index a118c217f3..d4bf632830 100644 --- a/src/plugins/platforms/wasm/wasm_shell.html +++ b/src/plugins/platforms/wasm/wasm_shell.html @@ -17,7 +17,7 @@ <body onload="init()"> <figure style="overflow:visible;" id="qtspinner"> <center style="margin-top:1.5em; line-height:150%"> - <img src="qtlogo.svg"; width=320; height=200; style="display:block"> </img> + <img src="qtlogo.svg" width="320" height="200" style="display:block"></img> <strong>Qt for WebAssembly: @APPNAME@</strong> <div id="qtstatus"></div> <noscript>JavaScript is disabled. Please enable JavaScript to use this application.</noscript> diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 437c9562ab..40f9652cbd 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -466,6 +466,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const result = int(scrollLines); return QVariant(result); } + case MouseDoubleClickDistance: + return GetSystemMetrics(SM_CXDOUBLECLK); default: break; } diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 1ce947165d..3d525598ca 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -354,6 +354,11 @@ bool QXcbDrag::findXdndAwareTarget(const QPoint &globalPos, xcb_window_t *target void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) { + // currentDrag() might be deleted while 'drag' is progressing + if (!currentDrag()) { + cancel(); + return; + } // The source sends XdndEnter and XdndPosition to the target. if (source_sameanswer.contains(globalPos) && source_sameanswer.isValid()) return; @@ -1076,7 +1081,8 @@ void QXcbDrag::cancel() send_leave(); // remove canceled object - currentDrag()->deleteLater(); + if (currentDrag()) + currentDrag()->deleteLater(); canceled = true; } diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index 2303ccf806..f880d4d722 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -42,6 +42,8 @@ #ifndef QT_NO_SESSIONMANAGER +#include <qpa/qwindowsysteminterface.h> + #include <qguiapplication.h> #include <qdatetime.h> #include <qfileinfo.h> @@ -289,8 +291,7 @@ static void sm_dieCallback(SmcConn smcConn, SmPointer /* clientData */) if (smcConn != smcConnection) return; resetSmState(); - QEvent quitEvent(QEvent::Quit); - QGuiApplication::sendEvent(qApp, &quitEvent); + QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>(); } static void sm_shutdownCancelledCallback(SmcConn smcConn, SmPointer clientData) diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 5bf23fdaed..e1ede4aec1 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -221,18 +221,18 @@ public: int disconnectCount; bool hasSQLFetchScroll; - bool isStmtHandleValid(); + bool isStmtHandleValid() const; void updateStmtHandleState(); }; -bool QODBCResultPrivate::isStmtHandleValid() +bool QODBCResultPrivate::isStmtHandleValid() const { - return disconnectCount == drv_d_func()->disconnectCount; + return drv_d_func() && disconnectCount == drv_d_func()->disconnectCount; } void QODBCResultPrivate::updateStmtHandleState() { - disconnectCount = drv_d_func()->disconnectCount; + disconnectCount = drv_d_func() ? drv_d_func()->disconnectCount : 0; } static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode = 0) @@ -975,7 +975,7 @@ QODBCResult::QODBCResult(const QODBCDriver *db) QODBCResult::~QODBCResult() { Q_D(QODBCResult); - if (d->hStmt && d->isStmtHandleValid() && driver()->isOpen()) { + if (d->hStmt && d->isStmtHandleValid() && driver() && driver()->isOpen()) { SQLRETURN r = SQLFreeHandle(SQL_HANDLE_STMT, d->hStmt); if (r != SQL_SUCCESS) qSqlWarning(QLatin1String("QODBCDriver: Unable to free statement handle ") diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index b85a1ac4c7..68313b7ff0 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1078,8 +1078,10 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin) return QPSQLDriver::Version10; case 11: return QPSQLDriver::Version11; + case 12: + return QPSQLDriver::Version12; default: - if (vMaj > 11) + if (vMaj > 12) return QPSQLDriver::UnknownLaterVersion; break; } @@ -1439,26 +1441,29 @@ QSqlRecord QPSQLDriver::record(const QString &tablename) const schema = stripDelimiters(schema, QSqlDriver::TableName); tbl = stripDelimiters(tbl, QSqlDriver::TableName); - QString stmt = QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, " - "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " - "pg_attrdef.adsrc " - "FROM pg_class, pg_attribute " - "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = " - "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) " - "WHERE %1 " - "AND pg_class.relname = '%2' " - "AND pg_attribute.attnum > 0 " - "AND pg_attribute.attrelid = pg_class.oid " - "AND pg_attribute.attisdropped = false " - "ORDER BY pg_attribute.attnum"); - if (schema.isEmpty()) - stmt = stmt.arg(QStringLiteral("pg_table_is_visible(pg_class.oid)")); - else - stmt = stmt.arg(QStringLiteral("pg_class.relnamespace = (SELECT oid FROM " - "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema)); + const QString adsrc = protocol() < Version8 + ? QStringLiteral("pg_attrdef.adsrc") + : QStringLiteral("pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid)"); + const QString nspname = schema.isEmpty() + ? QStringLiteral("pg_table_is_visible(pg_class.oid)") + : QStringLiteral("pg_class.relnamespace = (SELECT oid FROM " + "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema); + const QString stmt = + QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, " + "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " + "%1 " + "FROM pg_class, pg_attribute " + "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = " + "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) " + "WHERE %2 " + "AND pg_class.relname = '%3' " + "AND pg_attribute.attnum > 0 " + "AND pg_attribute.attrelid = pg_class.oid " + "AND pg_attribute.attisdropped = false " + "ORDER BY pg_attribute.attnum").arg(adsrc, nspname, tbl); QSqlQuery query(createResult()); - query.exec(stmt.arg(tbl)); + query.exec(stmt); while (query.next()) { int len = query.value(3).toInt(); int precision = query.value(4).toInt(); diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h index 99e0b5f60f..9ac1fb50d7 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql_p.h +++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h @@ -93,6 +93,7 @@ public: Version9_6 = 22, Version10 = 23, Version11 = 24, + Version12 = 25, UnknownLaterVersion = 100000 }; |