diff options
Diffstat (limited to 'src/platformsupport')
128 files changed, 675 insertions, 12856 deletions
diff --git a/src/platformsupport/.prev_CMakeLists.txt b/src/platformsupport/.prev_CMakeLists.txt deleted file mode 100644 index c43707948b..0000000000 --- a/src/platformsupport/.prev_CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Generated from platformsupport.pro. - -add_subdirectory(devicediscovery) -add_subdirectory(fbconvenience) -add_subdirectory(linuxofono) -if(QT_FEATURE_evdev OR QT_FEATURE_integrityhid OR QT_FEATURE_libinput OR QT_FEATURE_tslib OR QT_FEATURE_xkbcommon) - add_subdirectory(input) -endif() -if(QT_FEATURE_egl) - add_subdirectory(eglconvenience) -endif() -if(QT_FEATURE_opengl AND QT_FEATURE_xlib AND NOT QT_FEATURE_opengles2) - add_subdirectory(glxconvenience) -endif() -if(QT_FEATURE_kms) - add_subdirectory(kmsconvenience) -endif() -if(QT_FEATURE_accessibility AND QT_FEATURE_accessibility_atspi_bridge) - add_subdirectory(linuxaccessibility) -endif() diff --git a/src/platformsupport/CMakeLists.txt b/src/platformsupport/CMakeLists.txt index fd308c99fd..686c6213d2 100644 --- a/src/platformsupport/CMakeLists.txt +++ b/src/platformsupport/CMakeLists.txt @@ -1,24 +1,11 @@ -# Generated from platformsupport.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(devicediscovery) add_subdirectory(fbconvenience) -# special case begin -if (QT_FEATURE_dbus) - add_subdirectory(linuxofono) -endif() -# special case end if(QT_FEATURE_evdev OR QT_FEATURE_integrityhid OR QT_FEATURE_libinput OR QT_FEATURE_tslib OR QT_FEATURE_xkbcommon) add_subdirectory(input) endif() -if(QT_FEATURE_egl) - add_subdirectory(eglconvenience) -endif() -if(QT_FEATURE_opengl AND QT_FEATURE_xlib AND NOT QT_FEATURE_opengles2) - add_subdirectory(glxconvenience) -endif() if(QT_FEATURE_kms) add_subdirectory(kmsconvenience) endif() -if(QT_FEATURE_accessibility AND QT_FEATURE_accessibility_atspi_bridge) - add_subdirectory(linuxaccessibility) -endif() diff --git a/src/platformsupport/devicediscovery/.prev_CMakeLists.txt b/src/platformsupport/devicediscovery/.prev_CMakeLists.txt deleted file mode 100644 index 8ecabb4a1b..0000000000 --- a/src/platformsupport/devicediscovery/.prev_CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from devicediscovery.pro. - -##################################################################### -## DeviceDiscoverySupport Module: -##################################################################### - -qt_add_module(DeviceDiscoverySupport - STATIC - INTERNAL_MODULE - SOURCES - qdevicediscovery_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate -) - -#### Keys ignored in scope 1:.:.:devicediscovery.pro:<TRUE>: -# MODULE = "devicediscovery_support" -# QT_FOR_CONFIG = "gui-private" - -## Scopes: -##################################################################### - -qt_extend_target(DeviceDiscoverySupport CONDITION QT_FEATURE_libudev - SOURCES - qdevicediscovery_udev.cpp qdevicediscovery_udev_p.h - LIBRARIES - PkgConfig::Libudev -) - -qt_extend_target(DeviceDiscoverySupport CONDITION QT_FEATURE_evdev AND NOT QT_FEATURE_libudev - SOURCES - qdevicediscovery_static.cpp qdevicediscovery_static_p.h -) - -qt_extend_target(DeviceDiscoverySupport CONDITION NOT QT_FEATURE_evdev AND NOT QT_FEATURE_libudev - SOURCES - qdevicediscovery_dummy.cpp qdevicediscovery_dummy_p.h -) diff --git a/src/platformsupport/devicediscovery/CMakeLists.txt b/src/platformsupport/devicediscovery/CMakeLists.txt index 171db55f5b..19c35f6660 100644 --- a/src/platformsupport/devicediscovery/CMakeLists.txt +++ b/src/platformsupport/devicediscovery/CMakeLists.txt @@ -1,11 +1,12 @@ -# Generated from devicediscovery.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### -## DeviceDiscoverySupport Module: +## DeviceDiscoverySupportPrivate Module: ##################################################################### -qt_add_module(DeviceDiscoverySupport - CONFIG_MODULE_NAME devicediscovery_support # special case +qt_internal_add_module(DeviceDiscoverySupportPrivate + CONFIG_MODULE_NAME devicediscovery_support STATIC INTERNAL_MODULE SOURCES @@ -14,28 +15,25 @@ qt_add_module(DeviceDiscoverySupport QT_NO_CAST_FROM_ASCII PUBLIC_LIBRARIES Qt::CorePrivate + NO_GENERATE_CPP_EXPORTS ) -#### Keys ignored in scope 1:.:.:devicediscovery.pro:<TRUE>: -# MODULE = "devicediscovery_support" -# QT_FOR_CONFIG = "gui-private" - ## Scopes: ##################################################################### -qt_extend_target(DeviceDiscoverySupport CONDITION QT_FEATURE_libudev +qt_internal_extend_target(DeviceDiscoverySupportPrivate CONDITION QT_FEATURE_libudev SOURCES qdevicediscovery_udev.cpp qdevicediscovery_udev_p.h LIBRARIES PkgConfig::Libudev ) -qt_extend_target(DeviceDiscoverySupport CONDITION QT_FEATURE_evdev AND NOT QT_FEATURE_libudev +qt_internal_extend_target(DeviceDiscoverySupportPrivate CONDITION QT_FEATURE_evdev AND NOT QT_FEATURE_libudev SOURCES qdevicediscovery_static.cpp qdevicediscovery_static_p.h ) -qt_extend_target(DeviceDiscoverySupport CONDITION NOT QT_FEATURE_evdev AND NOT QT_FEATURE_libudev +qt_internal_extend_target(DeviceDiscoverySupportPrivate CONDITION NOT QT_FEATURE_evdev AND NOT QT_FEATURE_libudev SOURCES qdevicediscovery_dummy.cpp qdevicediscovery_dummy_p.h ) diff --git a/src/platformsupport/devicediscovery/devicediscovery.pro b/src/platformsupport/devicediscovery/devicediscovery.pro deleted file mode 100644 index 881ec4d41e..0000000000 --- a/src/platformsupport/devicediscovery/devicediscovery.pro +++ /dev/null @@ -1,24 +0,0 @@ -TARGET = QtDeviceDiscoverySupport -MODULE = devicediscovery_support - -QT = core-private -QT_FOR_CONFIG += gui-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII - -HEADERS += qdevicediscovery_p.h - -qtConfig(libudev) { - SOURCES += qdevicediscovery_udev.cpp - HEADERS += qdevicediscovery_udev_p.h - QMAKE_USE_PRIVATE += libudev -} else: qtConfig(evdev) { - SOURCES += qdevicediscovery_static.cpp - HEADERS += qdevicediscovery_static_p.h -} else { - SOURCES += qdevicediscovery_dummy.cpp - HEADERS += qdevicediscovery_dummy_p.h -} - -load(qt_module) diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp index a04b91b438..f94f7be3b2 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qdevicediscovery_dummy_p.h" diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h index fe669c8dec..9ac6fbe921 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QDEVICEDISCOVERY_DUMMY_H #define QDEVICEDISCOVERY_DUMMY_H @@ -60,7 +24,7 @@ class QDeviceDiscoveryDummy : public QDeviceDiscovery Q_OBJECT public: - QDeviceDiscoveryDummy(QDeviceTypes types, QObject *parent = 0); + QDeviceDiscoveryDummy(QDeviceTypes types, QObject *parent = nullptr); QStringList scanConnectedDevices() override; }; diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_p.h index f1f50e9708..59ce3cd889 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QDEVICEDISCOVERY_H #define QDEVICEDISCOVERY_H @@ -54,6 +18,7 @@ #include <QObject> #include <QSocketNotifier> #include <QStringList> +#include <private/qglobal_p.h> #define QT_EVDEV_DEVICE_PATH "/dev/input/" #define QT_EVDEV_DEVICE_PREFIX "event" diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp index a1575677f5..03a77aaae7 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qdevicediscovery_static_p.h" @@ -83,6 +47,8 @@ static bool testBit(long bit, const long *field) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcDD, "qt.qpa.input") QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent) @@ -107,7 +73,7 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices() dir.setPath(QString::fromLatin1(QT_EVDEV_DEVICE_PATH)); const auto deviceFiles = dir.entryList(); for (const QString &deviceFile : deviceFiles) { - QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile; + QString absoluteFilePath = dir.absolutePath() + u'/' + deviceFile; if (checkDeviceType(absoluteFilePath)) devices << absoluteFilePath; } @@ -118,7 +84,7 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices() dir.setPath(QString::fromLatin1(QT_DRM_DEVICE_PATH)); const auto deviceFiles = dir.entryList(); for (const QString &deviceFile : deviceFiles) { - QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile; + QString absoluteFilePath = dir.absolutePath() + u'/' + deviceFile; if (checkDeviceType(absoluteFilePath)) devices << absoluteFilePath; } @@ -139,7 +105,7 @@ bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device) qCDebug(lcDD) << "doing static device discovery for " << device; - if ((m_types & Device_DRM) && device.contains(QLatin1String(QT_DRM_DEVICE_PREFIX))) { + if ((m_types & Device_DRM) && device.contains(QT_DRM_DEVICE_PREFIX ""_L1)) { QT_CLOSE(fd); return true; } diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h index 93110c3c55..fb698c9022 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QDEVICEDISCOVERY_STATIC_H #define QDEVICEDISCOVERY_STATIC_H @@ -60,7 +24,7 @@ class QDeviceDiscoveryStatic : public QDeviceDiscovery Q_OBJECT public: - QDeviceDiscoveryStatic(QDeviceTypes types, QObject *parent = 0); + QDeviceDiscoveryStatic(QDeviceTypes types, QObject *parent = nullptr); QStringList scanConnectedDevices() override; private: diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp index 96af9a2b47..45043818a4 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qdevicediscovery_udev_p.h" @@ -54,13 +18,15 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcDD, "qt.qpa.input") QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent) { qCDebug(lcDD) << "udev device discovery for type" << types; - QDeviceDiscovery *helper = 0; + QDeviceDiscovery *helper = nullptr; struct udev *udev; udev = udev_new(); @@ -75,7 +41,7 @@ QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent) QDeviceDiscoveryUDev::QDeviceDiscoveryUDev(QDeviceTypes types, struct udev *udev, QObject *parent) : QDeviceDiscovery(types, parent), - m_udev(udev), m_udevMonitor(0), m_udevMonitorFileDescriptor(-1), m_udevSocketNotifier(0) + m_udev(udev) { if (!m_udev) return; @@ -140,9 +106,9 @@ QStringList QDeviceDiscoveryUDev::scanConnectedDevices() const char *syspath = udev_list_entry_get_name(entry); udev_device *udevice = udev_device_new_from_syspath(m_udev, syspath); QString candidate = QString::fromUtf8(udev_device_get_devnode(udevice)); - if ((m_types & Device_InputMask) && candidate.startsWith(QLatin1String(QT_EVDEV_DEVICE))) + if ((m_types & Device_InputMask) && candidate.startsWith(QT_EVDEV_DEVICE ""_L1)) devices << candidate; - if ((m_types & Device_VideoMask) && candidate.startsWith(QLatin1String(QT_DRM_DEVICE))) { + if ((m_types & Device_VideoMask) && candidate.startsWith(QT_DRM_DEVICE ""_L1)) { if (m_types & Device_DRM_PrimaryGPU) { udev_device *pci = udev_device_get_parent_with_subsystem_devtype(udevice, "pci", 0); if (pci) { @@ -186,9 +152,9 @@ void QDeviceDiscoveryUDev::handleUDevNotification() const char *subsystem; devNode = QString::fromUtf8(str); - if (devNode.startsWith(QLatin1String(QT_EVDEV_DEVICE))) + if (devNode.startsWith(QT_EVDEV_DEVICE ""_L1)) subsystem = "input"; - else if (devNode.startsWith(QLatin1String(QT_DRM_DEVICE))) + else if (devNode.startsWith(QT_DRM_DEVICE ""_L1)) subsystem = "drm"; else goto cleanup; @@ -220,7 +186,7 @@ bool QDeviceDiscoveryUDev::checkDeviceType(udev_device *dev) if ((m_types & Device_Keyboard) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 )) { const QString capabilities_key = QString::fromUtf8(udev_device_get_sysattr_value(dev, "capabilities/key")); - const auto val = QStringView{capabilities_key}.split(QLatin1Char(' '), Qt::SkipEmptyParts); + const auto val = QStringView{capabilities_key}.split(u' ', Qt::SkipEmptyParts); if (!val.isEmpty()) { bool ok; unsigned long long keys = val.last().toULongLong(&ok, 16); @@ -258,3 +224,5 @@ bool QDeviceDiscoveryUDev::checkDeviceType(udev_device *dev) } QT_END_NAMESPACE + +#include "moc_qdevicediscovery_udev_p.cpp" diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h index 82b475776d..3074877b5a 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QDEVICEDISCOVERY_UDEV_H #define QDEVICEDISCOVERY_UDEV_H @@ -68,16 +32,18 @@ public: private slots: void handleUDevNotification(); +protected: + struct udev *m_udev; + private: bool checkDeviceType(struct udev_device *dev); void startWatching(); void stopWatching(); - struct udev *m_udev; - struct udev_monitor *m_udevMonitor; - int m_udevMonitorFileDescriptor; - QSocketNotifier *m_udevSocketNotifier; + struct udev_monitor *m_udevMonitor = nullptr; + int m_udevMonitorFileDescriptor = -1; + QSocketNotifier *m_udevSocketNotifier = nullptr; }; QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/.prev_CMakeLists.txt b/src/platformsupport/eglconvenience/.prev_CMakeLists.txt deleted file mode 100644 index c00cc30d62..0000000000 --- a/src/platformsupport/eglconvenience/.prev_CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Generated from eglconvenience.pro. - -##################################################################### -## EglSupport Module: -##################################################################### - -qt_add_module(EglSupport - STATIC - INTERNAL_MODULE - SOURCES - qeglconvenience.cpp qeglconvenience_p.h - qeglstreamconvenience.cpp qeglstreamconvenience_p.h - qt_egl_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - PRECOMPILED_HEADER - "../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 1:.:.:eglconvenience.pro:<TRUE>: -# MODULE = "egl_support" - -## Scopes: -##################################################################### - -qt_extend_target(EglSupport CONDITION QT_FEATURE_opengl - SOURCES - qeglpbuffer.cpp qeglpbuffer_p.h - qeglplatformcontext.cpp qeglplatformcontext_p.h -) - -qt_extend_target(EglSupport CONDITION QT_FEATURE_egl_x11 - SOURCES - qxlibeglintegration.cpp qxlibeglintegration_p.h - LIBRARIES - X11::X11 -) - -qt_extend_target(EglSupport CONDITION NOT QT_FEATURE_egl_x11 - DEFINES - QT_EGL_NO_X11 -) - -qt_extend_target(EglSupport CONDITION QT_FEATURE_dlopen - PUBLIC_LIBRARIES - ${CMAKE_DL_LIBS} -) diff --git a/src/platformsupport/eglconvenience/CMakeLists.txt b/src/platformsupport/eglconvenience/CMakeLists.txt deleted file mode 100644 index 4b709161fd..0000000000 --- a/src/platformsupport/eglconvenience/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -# Generated from eglconvenience.pro. - -##################################################################### -## EglSupport Module: -##################################################################### - -qt_find_package(EGL) # special case - -qt_add_module(EglSupport - STATIC - INTERNAL_MODULE - SOURCES - qeglconvenience.cpp qeglconvenience_p.h - qeglstreamconvenience.cpp qeglstreamconvenience_p.h - qt_egl_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - EGL::EGL # special case - PRECOMPILED_HEADER - "../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 1:.:.:eglconvenience.pro:<TRUE>: -# MODULE = "egl_support" - -## Scopes: -##################################################################### - -qt_extend_target(EglSupport CONDITION QT_FEATURE_opengl - SOURCES - qeglpbuffer.cpp qeglpbuffer_p.h - qeglplatformcontext.cpp qeglplatformcontext_p.h -) - -qt_extend_target(EglSupport CONDITION QT_FEATURE_egl_x11 - SOURCES - qxlibeglintegration.cpp qxlibeglintegration_p.h - LIBRARIES - X11::X11 -) - -qt_extend_target(EglSupport CONDITION NOT QT_FEATURE_egl_x11 - DEFINES - QT_EGL_NO_X11 -) - -qt_extend_target(EglSupport CONDITION QT_FEATURE_dlopen - LIBRARIES - ${CMAKE_DL_LIBS} -) diff --git a/src/platformsupport/eglconvenience/eglconvenience.pro b/src/platformsupport/eglconvenience/eglconvenience.pro deleted file mode 100644 index e9ee52b53b..0000000000 --- a/src/platformsupport/eglconvenience/eglconvenience.pro +++ /dev/null @@ -1,43 +0,0 @@ -TARGET = QtEglSupport -MODULE = egl_support - -QT = core-private gui-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h - -HEADERS += \ - qeglconvenience_p.h \ - qeglstreamconvenience_p.h \ - qt_egl_p.h - -SOURCES += \ - qeglconvenience.cpp \ - qeglstreamconvenience.cpp - -qtConfig(opengl) { - HEADERS += \ - qeglplatformcontext_p.h \ - qeglpbuffer_p.h - - SOURCES += \ - qeglplatformcontext.cpp \ - qeglpbuffer.cpp -} - -qtConfig(egl_x11) { - HEADERS += \ - qxlibeglintegration_p.h - SOURCES += \ - qxlibeglintegration.cpp - QMAKE_USE_PRIVATE += xlib -} else { - # Avoid X11 header collision, use generic EGL native types - DEFINES += QT_EGL_NO_X11 -} -CONFIG += egl - -qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl - -load(qt_module) diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp deleted file mode 100644 index 5303d37cee..0000000000 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ /dev/null @@ -1,627 +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 <QByteArray> -#include <QOpenGLContext> - -#ifdef Q_OS_LINUX -#include <sys/ioctl.h> -#include <linux/fb.h> -#endif -#include <private/qmath_p.h> - -#include "qeglconvenience_p.h" - -#ifndef EGL_OPENGL_ES3_BIT_KHR -#define EGL_OPENGL_ES3_BIT_KHR 0x0040 -#endif - -QT_BEGIN_NAMESPACE - -QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format) -{ - int redSize = format.redBufferSize(); - int greenSize = format.greenBufferSize(); - int blueSize = format.blueBufferSize(); - int alphaSize = format.alphaBufferSize(); - int depthSize = format.depthBufferSize(); - int stencilSize = format.stencilBufferSize(); - int sampleCount = format.samples(); - - QVector<EGLint> configAttributes; - - // Map default, unspecified values (-1) to 0. This is important due to sorting rule #3 - // in section 3.4.1 of the spec and allows picking a potentially faster 16-bit config - // over 32-bit ones when there is no explicit request for the color channel sizes: - // - // The red/green/blue sizes have a sort priority of 3, so they are sorted by - // first. (unless a caveat like SLOW or NON_CONFORMANT is present) The sort order is - // Special and described as "by larger _total_ number of color bits.". So EGL will put - // 32-bit configs in the list before the 16-bit configs. However, the spec also goes - // on to say "If the requested number of bits in attrib_list for a particular - // component is 0, then the number of bits for that component is not considered". This - // part of the spec also seems to imply that setting the red/green/blue bits to zero - // means none of the components are considered and EGL disregards the entire sorting - // rule. It then looks to the next highest priority rule, which is - // EGL_BUFFER_SIZE. Despite the selection criteria being "AtLeast" for - // EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are put in the - // list before 32-bit configs. - // - // This also means that explicitly specifying a size like 565 will still result in - // having larger (888) configs first in the returned list. We need to handle this - // ourselves later by manually filtering the list, instead of just blindly taking the - // first config from it. - - configAttributes.append(EGL_RED_SIZE); - configAttributes.append(redSize > 0 ? redSize : 0); - - configAttributes.append(EGL_GREEN_SIZE); - configAttributes.append(greenSize > 0 ? greenSize : 0); - - configAttributes.append(EGL_BLUE_SIZE); - configAttributes.append(blueSize > 0 ? blueSize : 0); - - configAttributes.append(EGL_ALPHA_SIZE); - configAttributes.append(alphaSize > 0 ? alphaSize : 0); - - configAttributes.append(EGL_SAMPLES); - configAttributes.append(sampleCount > 0 ? sampleCount : 0); - - configAttributes.append(EGL_SAMPLE_BUFFERS); - configAttributes.append(sampleCount > 0); - - if (format.renderableType() != QSurfaceFormat::OpenVG) { - configAttributes.append(EGL_DEPTH_SIZE); - configAttributes.append(depthSize > 0 ? depthSize : 0); - - configAttributes.append(EGL_STENCIL_SIZE); - configAttributes.append(stencilSize > 0 ? stencilSize : 0); - } else { - // OpenVG needs alpha mask for clipping - configAttributes.append(EGL_ALPHA_MASK_SIZE); - configAttributes.append(8); - } - - return configAttributes; -} - -bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes) -{ - int i = -1; - // Reduce the complexity of a configuration request to ask for less - // because the previous request did not result in success. Returns - // true if the complexity was reduced, or false if no further - // reductions in complexity are possible. - - i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR); - if (i >= 0) { - configAttributes->remove(i,2); - } - -#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT - // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't - // find a config which supports pre-multiplied formats, remove the flag on the surface type: - - i = configAttributes->indexOf(EGL_SURFACE_TYPE); - if (i >= 0) { - EGLint surfaceType = configAttributes->at(i +1); - if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) { - surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT; - configAttributes->replace(i+1,surfaceType); - return true; - } - } -#endif - - // EGL chooses configs with the highest color depth over - // those with smaller (but faster) lower color depths. One - // way around this is to set EGL_BUFFER_SIZE to 16, which - // trumps the others. Of course, there may not be a 16-bit - // config available, so it's the first restraint we remove. - i = configAttributes->indexOf(EGL_BUFFER_SIZE); - if (i >= 0) { - if (configAttributes->at(i+1) == 16) { - configAttributes->remove(i,2); - return true; - } - } - - i = configAttributes->indexOf(EGL_SAMPLES); - if (i >= 0) { - EGLint value = configAttributes->value(i+1, 0); - if (value > 1) - configAttributes->replace(i+1, qMin(EGLint(16), value / 2)); - else - configAttributes->remove(i, 2); - return true; - } - - i = configAttributes->indexOf(EGL_SAMPLE_BUFFERS); - if (i >= 0) { - configAttributes->remove(i,2); - return true; - } - - i = configAttributes->indexOf(EGL_DEPTH_SIZE); - if (i >= 0) { - if (configAttributes->at(i + 1) >= 32) - configAttributes->replace(i + 1, 24); - else if (configAttributes->at(i + 1) > 1) - configAttributes->replace(i + 1, 1); - else - configAttributes->remove(i, 2); - return true; - } - - i = configAttributes->indexOf(EGL_ALPHA_SIZE); - if (i >= 0) { - configAttributes->remove(i,2); -#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB) - i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGBA); - if (i >= 0) { - configAttributes->replace(i,EGL_BIND_TO_TEXTURE_RGB); - configAttributes->replace(i+1,true); - - } -#endif - return true; - } - - i = configAttributes->indexOf(EGL_STENCIL_SIZE); - if (i >= 0) { - if (configAttributes->at(i + 1) > 1) - configAttributes->replace(i + 1, 1); - else - configAttributes->remove(i, 2); - return true; - } - -#ifdef EGL_BIND_TO_TEXTURE_RGB - i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGB); - if (i >= 0) { - configAttributes->remove(i,2); - return true; - } -#endif - - return false; -} - -QEglConfigChooser::QEglConfigChooser(EGLDisplay display) - : m_display(display) - , m_surfaceType(EGL_WINDOW_BIT) - , m_ignore(false) - , m_confAttrRed(0) - , m_confAttrGreen(0) - , m_confAttrBlue(0) - , m_confAttrAlpha(0) -{ -} - -QEglConfigChooser::~QEglConfigChooser() -{ -} - -EGLConfig QEglConfigChooser::chooseConfig() -{ - QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(m_format); - configureAttributes.append(EGL_SURFACE_TYPE); - configureAttributes.append(surfaceType()); - - configureAttributes.append(EGL_RENDERABLE_TYPE); - bool needsES2Plus = false; - switch (m_format.renderableType()) { - case QSurfaceFormat::OpenVG: - configureAttributes.append(EGL_OPENVG_BIT); - break; -#ifdef EGL_VERSION_1_4 - case QSurfaceFormat::DefaultRenderableType: -#ifndef QT_NO_OPENGL - if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) - configureAttributes.append(EGL_OPENGL_BIT); - else -#endif // QT_NO_OPENGL - needsES2Plus = true; - break; - case QSurfaceFormat::OpenGL: - configureAttributes.append(EGL_OPENGL_BIT); - break; -#endif - case QSurfaceFormat::OpenGLES: - if (m_format.majorVersion() == 1) { - configureAttributes.append(EGL_OPENGL_ES_BIT); - break; - } - Q_FALLTHROUGH(); - default: - needsES2Plus = true; - break; - } - if (needsES2Plus) { - if (m_format.majorVersion() >= 3 && q_hasEglExtension(display(), "EGL_KHR_create_context")) - configureAttributes.append(EGL_OPENGL_ES3_BIT_KHR); - else - configureAttributes.append(EGL_OPENGL_ES2_BIT); - } - configureAttributes.append(EGL_NONE); - - EGLConfig cfg = nullptr; - do { - // Get the number of matching configurations for this set of properties. - EGLint matching = 0; - if (!eglChooseConfig(display(), configureAttributes.constData(), nullptr, 0, &matching) || !matching) - continue; - - // Fetch all of the matching configurations and find the - // first that matches the pixel format we wanted. - int i = configureAttributes.indexOf(EGL_RED_SIZE); - m_confAttrRed = configureAttributes.at(i+1); - i = configureAttributes.indexOf(EGL_GREEN_SIZE); - m_confAttrGreen = configureAttributes.at(i+1); - i = configureAttributes.indexOf(EGL_BLUE_SIZE); - m_confAttrBlue = configureAttributes.at(i+1); - i = configureAttributes.indexOf(EGL_ALPHA_SIZE); - m_confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1); - - QVector<EGLConfig> configs(matching); - eglChooseConfig(display(), configureAttributes.constData(), configs.data(), configs.size(), &matching); - if (!cfg && matching > 0) - cfg = configs.first(); - - // Filter the list. Due to the EGL sorting rules configs with higher depth are - // placed first when the minimum color channel sizes have been specified (i.e. the - // QSurfaceFormat contains color sizes > 0). To prevent returning a 888 config - // when the QSurfaceFormat explicitly asked for 565, go through the returned - // configs and look for one that exactly matches the requested sizes. When no - // sizes have been given, take the first, which will be a config with the smaller - // (e.g. 16-bit) depth. - for (int i = 0; i < configs.size(); ++i) { - if (filterConfig(configs[i])) - return configs.at(i); - } - } while (q_reduceConfigAttributes(&configureAttributes)); - - if (!cfg) - qWarning("Cannot find EGLConfig, returning null config"); - return cfg; -} - -bool QEglConfigChooser::filterConfig(EGLConfig config) const -{ - // If we are fine with the highest depth (e.g. RGB888 configs) even when something - // smaller (565) was explicitly requested, do nothing. - if (m_ignore) - return true; - - EGLint red = 0; - EGLint green = 0; - EGLint blue = 0; - EGLint alpha = 0; - - // Compare only if a size was given. Otherwise just accept. - if (m_confAttrRed) - eglGetConfigAttrib(display(), config, EGL_RED_SIZE, &red); - if (m_confAttrGreen) - eglGetConfigAttrib(display(), config, EGL_GREEN_SIZE, &green); - if (m_confAttrBlue) - eglGetConfigAttrib(display(), config, EGL_BLUE_SIZE, &blue); - if (m_confAttrAlpha) - eglGetConfigAttrib(display(), config, EGL_ALPHA_SIZE, &alpha); - - return red == m_confAttrRed && green == m_confAttrGreen - && blue == m_confAttrBlue && alpha == m_confAttrAlpha; -} - -EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType) -{ - QEglConfigChooser chooser(display); - chooser.setSurfaceFormat(format); - chooser.setSurfaceType(surfaceType); - chooser.setIgnoreColorChannels(highestPixelFormat); - - return chooser.chooseConfig(); -} - -QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat) -{ - QSurfaceFormat format; - EGLint redSize = 0; - EGLint greenSize = 0; - EGLint blueSize = 0; - EGLint alphaSize = 0; - EGLint depthSize = 0; - EGLint stencilSize = 0; - EGLint sampleCount = 0; - EGLint renderableType = 0; - - eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); - eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); - eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); - eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); - eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); - eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); - eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); - eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType); - - if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT)) - format.setRenderableType(QSurfaceFormat::OpenVG); -#ifdef EGL_VERSION_1_4 - else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL - && (renderableType & EGL_OPENGL_BIT)) - format.setRenderableType(QSurfaceFormat::OpenGL); - else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType -#ifndef QT_NO_OPENGL - && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL -#endif - && (renderableType & EGL_OPENGL_BIT)) - format.setRenderableType(QSurfaceFormat::OpenGL); -#endif - else - format.setRenderableType(QSurfaceFormat::OpenGLES); - - format.setRedBufferSize(redSize); - format.setGreenBufferSize(greenSize); - format.setBlueBufferSize(blueSize); - format.setAlphaBufferSize(alphaSize); - format.setDepthBufferSize(depthSize); - format.setStencilBufferSize(stencilSize); - format.setSamples(sampleCount); - format.setStereo(false); // EGL doesn't support stereo buffers - format.setSwapInterval(referenceFormat.swapInterval()); - - // Clear the EGL error state because some of the above may - // have errored out because the attribute is not applicable - // to the surface type. Such errors don't matter. - eglGetError(); - - return format; -} - -bool q_hasEglExtension(EGLDisplay display, const char* extensionName) -{ - QList<QByteArray> extensions = - QByteArray(reinterpret_cast<const char *> - (eglQueryString(display, EGL_EXTENSIONS))).split(' '); - return extensions.contains(extensionName); -} - -struct AttrInfo { EGLint attr; const char *name; }; -static struct AttrInfo attrs[] = { - {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"}, - {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"}, - {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"}, - {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"}, - {EGL_RED_SIZE, "EGL_RED_SIZE"}, - {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"}, - {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"}, - {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"}, - {EGL_CONFIG_ID, "EGL_CONFIG_ID"}, - {EGL_LEVEL, "EGL_LEVEL"}, - {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"}, - {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"}, - {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"}, - {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"}, - {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"}, - {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"}, - {EGL_SAMPLES, "EGL_SAMPLES"}, - {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"}, - {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"}, - {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"}, - {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"}, - {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"}, - {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"}, - {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"}, - {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, - {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, - {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, - {-1, nullptr}}; - -void q_printEglConfig(EGLDisplay display, EGLConfig config) -{ - EGLint index; - for (index = 0; attrs[index].attr != -1; ++index) { - EGLint value; - if (eglGetConfigAttrib(display, config, attrs[index].attr, &value)) { - qDebug("\t%s: %d", attrs[index].name, (int)value); - } - } -} - -#ifdef Q_OS_UNIX - -QSizeF q_physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize) -{ -#ifndef Q_OS_LINUX - Q_UNUSED(framebufferDevice) -#endif - const int defaultPhysicalDpi = 100; - static QSizeF size; - - if (size.isEmpty()) { - // Note: in millimeters - int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH"); - int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT"); - - if (width && height) { - size.setWidth(width); - size.setHeight(height); - return size; - } - - int w = -1; - int h = -1; - QSize screenResolution; -#ifdef Q_OS_LINUX - struct fb_var_screeninfo vinfo; - - if (framebufferDevice != -1) { - if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) { - qWarning("eglconvenience: Could not query screen info"); - } else { - w = vinfo.width; - h = vinfo.height; - screenResolution = QSize(vinfo.xres, vinfo.yres); - } - } else -#endif - { - // Use the provided screen size, when available, since some platforms may have their own - // specific way to query it. Otherwise try querying it from the framebuffer. - screenResolution = screenSize.isEmpty() ? q_screenSizeFromFb(framebufferDevice) : screenSize; - } - - size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w)); - size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h)); - - if (w <= 0 || h <= 0) - qWarning("Unable to query physical screen size, defaulting to %d dpi.\n" - "To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH " - "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi); - } - - return size; -} - -QSize q_screenSizeFromFb(int framebufferDevice) -{ -#ifndef Q_OS_LINUX - Q_UNUSED(framebufferDevice) -#endif - const int defaultWidth = 800; - const int defaultHeight = 600; - static QSize size; - - if (size.isEmpty()) { - int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_WIDTH"); - int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_HEIGHT"); - - if (width && height) { - size.setWidth(width); - size.setHeight(height); - return size; - } - -#ifdef Q_OS_LINUX - struct fb_var_screeninfo vinfo; - int xres = -1; - int yres = -1; - - if (framebufferDevice != -1) { - if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) { - qWarning("eglconvenience: Could not read screen info"); - } else { - xres = vinfo.xres; - yres = vinfo.yres; - } - } - - size.setWidth(xres <= 0 ? defaultWidth : xres); - size.setHeight(yres <= 0 ? defaultHeight : yres); -#else - size.setWidth(defaultWidth); - size.setHeight(defaultHeight); -#endif - } - - return size; -} - -int q_screenDepthFromFb(int framebufferDevice) -{ -#ifndef Q_OS_LINUX - Q_UNUSED(framebufferDevice) -#endif - const int defaultDepth = 32; - static int depth = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DEPTH"); - - if (depth == 0) { -#ifdef Q_OS_LINUX - struct fb_var_screeninfo vinfo; - - if (framebufferDevice != -1) { - if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) - qWarning("eglconvenience: Could not query screen info"); - else - depth = vinfo.bits_per_pixel; - } - - if (depth <= 0) - depth = defaultDepth; -#else - depth = defaultDepth; -#endif - } - - return depth; -} - -qreal q_refreshRateFromFb(int framebufferDevice) -{ -#ifndef Q_OS_LINUX - Q_UNUSED(framebufferDevice) -#endif - - static qreal rate = 0; - -#ifdef Q_OS_LINUX - if (rate == 0) { - if (framebufferDevice != -1) { - struct fb_var_screeninfo vinfo; - if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) != -1) { - const quint64 quot = quint64(vinfo.left_margin + vinfo.right_margin + vinfo.xres + vinfo.hsync_len) - * quint64(vinfo.upper_margin + vinfo.lower_margin + vinfo.yres + vinfo.vsync_len) - * vinfo.pixclock; - if (quot) - rate = 1000000000000LLU / quot; - } else { - qWarning("eglconvenience: Could not query screen info"); - } - } - } -#endif - - if (rate == 0) - rate = 60; - - return rate; -} - -#endif // Q_OS_UNIX - -QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/qeglconvenience_p.h b/src/platformsupport/eglconvenience/qeglconvenience_p.h deleted file mode 100644 index ab2b813515..0000000000 --- a/src/platformsupport/eglconvenience/qeglconvenience_p.h +++ /dev/null @@ -1,111 +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 QEGLCONVENIENCE_H -#define QEGLCONVENIENCE_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 <QtGui/QSurfaceFormat> -#include <QtCore/QVector> -#include <QtCore/QSizeF> -#include <QtEglSupport/private/qt_egl_p.h> - -QT_BEGIN_NAMESPACE - -QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format); -bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes); -EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); -QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat = QSurfaceFormat()); -bool q_hasEglExtension(EGLDisplay display,const char* extensionName); -void q_printEglConfig(EGLDisplay display, EGLConfig config); - -#ifdef Q_OS_UNIX -QSizeF q_physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize = QSize()); -QSize q_screenSizeFromFb(int framebufferDevice); -int q_screenDepthFromFb(int framebufferDevice); -qreal q_refreshRateFromFb(int framebufferDevice); -#endif - -class QEglConfigChooser -{ -public: - QEglConfigChooser(EGLDisplay display); - virtual ~QEglConfigChooser(); - - EGLDisplay display() const { return m_display; } - - void setSurfaceType(EGLint surfaceType) { m_surfaceType = surfaceType; } - EGLint surfaceType() const { return m_surfaceType; } - - void setSurfaceFormat(const QSurfaceFormat &format) { m_format = format; } - QSurfaceFormat surfaceFormat() const { return m_format; } - - void setIgnoreColorChannels(bool ignore) { m_ignore = ignore; } - bool ignoreColorChannels() const { return m_ignore; } - - EGLConfig chooseConfig(); - -protected: - virtual bool filterConfig(EGLConfig config) const; - - QSurfaceFormat m_format; - EGLDisplay m_display; - EGLint m_surfaceType; - bool m_ignore; - - int m_confAttrRed; - int m_confAttrGreen; - int m_confAttrBlue; - int m_confAttrAlpha; -}; - - -QT_END_NAMESPACE - -#endif //QEGLCONVENIENCE_H diff --git a/src/platformsupport/eglconvenience/qeglpbuffer.cpp b/src/platformsupport/eglconvenience/qeglpbuffer.cpp deleted file mode 100644 index 15fc089778..0000000000 --- a/src/platformsupport/eglconvenience/qeglpbuffer.cpp +++ /dev/null @@ -1,108 +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 <QtGui/QOffscreenSurface> -#include "qeglpbuffer_p.h" -#include "qeglconvenience_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QEGLPbuffer - \brief A pbuffer-based implementation of QPlatformOffscreenSurface for EGL. - \since 5.2 - \internal - \ingroup qpa - - To use this implementation in the platform plugin simply - reimplement QPlatformIntegration::createPlatformOffscreenSurface() - and return a new instance of this class. -*/ - -QEGLPbuffer::QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface, - QEGLPlatformContext::Flags flags) - : QPlatformOffscreenSurface(offscreenSurface) - , m_format(format) - , m_display(display) - , m_pbuffer(EGL_NO_SURFACE) -{ - m_hasSurfaceless = !flags.testFlag(QEGLPlatformContext::NoSurfaceless) - && q_hasEglExtension(display, "EGL_KHR_surfaceless_context"); - - // Disable surfaceless contexts on Mesa for now. As of 10.6.0 and Intel at least, some - // operations (glReadPixels) are unable to work without a surface since they at some - // point temporarily unbind the current FBO and then later blow up in some seemingly - // safe operations, like setting the viewport, that apparently need access to the - // read/draw surface in the Intel backend. - const char *vendor = eglQueryString(display, EGL_VENDOR); // hard to check for GL_ strings here, so blacklist all Mesa - if (vendor && strstr(vendor, "Mesa")) - m_hasSurfaceless = false; - - if (m_hasSurfaceless) - return; - - EGLConfig config = q_configFromGLFormat(m_display, m_format, false, EGL_PBUFFER_BIT); - - if (config) { - const EGLint attributes[] = { - EGL_WIDTH, offscreenSurface->size().width(), - EGL_HEIGHT, offscreenSurface->size().height(), - EGL_LARGEST_PBUFFER, EGL_FALSE, - EGL_NONE - }; - - m_pbuffer = eglCreatePbufferSurface(m_display, config, attributes); - - if (m_pbuffer != EGL_NO_SURFACE) - m_format = q_glFormatFromConfig(m_display, config); - } -} - -QEGLPbuffer::~QEGLPbuffer() -{ - if (m_pbuffer != EGL_NO_SURFACE) - eglDestroySurface(m_display, m_pbuffer); -} - -bool QEGLPbuffer::isValid() const -{ - return m_pbuffer != EGL_NO_SURFACE || m_hasSurfaceless; -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/qeglpbuffer_p.h b/src/platformsupport/eglconvenience/qeglpbuffer_p.h deleted file mode 100644 index a137d0d328..0000000000 --- a/src/platformsupport/eglconvenience/qeglpbuffer_p.h +++ /dev/null @@ -1,80 +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 QEGLPBUFFER_H -#define QEGLPBUFFER_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 <qpa/qplatformoffscreensurface.h> -#include <QtEglSupport/private/qeglplatformcontext_p.h> - -QT_BEGIN_NAMESPACE - -class QEGLPbuffer : public QPlatformOffscreenSurface -{ -public: - QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface, - QEGLPlatformContext::Flags flags = { }); - ~QEGLPbuffer(); - - QSurfaceFormat format() const override { return m_format; } - bool isValid() const override; - - EGLSurface pbuffer() const { return m_pbuffer; } - -private: - QSurfaceFormat m_format; - EGLDisplay m_display; - EGLSurface m_pbuffer; - bool m_hasSurfaceless; -}; - -QT_END_NAMESPACE - -#endif // QEGLPBUFFER_H diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp deleted file mode 100644 index c82473ebbb..0000000000 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ /dev/null @@ -1,848 +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 "qeglplatformcontext_p.h" -#include "qeglconvenience_p.h" -#include "qeglpbuffer_p.h" -#include <qpa/qplatformwindow.h> -#include <QOpenGLContext> -#include <QDebug> - -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) -#include <QtCore/private/qjnihelpers_p.h> -#endif -#ifndef Q_OS_WIN -#include <dlfcn.h> -#endif - -QT_BEGIN_NAMESPACE - -/*! - \class QEGLPlatformContext - \brief An EGL context implementation. - \since 5.2 - \internal - \ingroup qpa - - Implement QPlatformOpenGLContext using EGL. To use it in platform - plugins a subclass must be created since - eglSurfaceForPlatformSurface() has to be reimplemented. This - function is used for mapping platform surfaces (windows) to EGL - surfaces and is necessary since different platform plugins may - have different ways of handling native windows (for example, a - plugin may choose not to back every platform window by a real EGL - surface). Other than that, no further customization is necessary. - */ - -// Constants from EGL_KHR_create_context -#ifndef EGL_CONTEXT_MINOR_VERSION_KHR -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#endif -#ifndef EGL_CONTEXT_FLAGS_KHR -#define EGL_CONTEXT_FLAGS_KHR 0x30FC -#endif -#ifndef EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#endif -#ifndef EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#endif -#ifndef EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#endif -#ifndef EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#endif -#ifndef EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#endif - -// Constants for OpenGL which are not available in the ES headers. -#ifndef GL_CONTEXT_FLAGS -#define GL_CONTEXT_FLAGS 0x821E -#endif -#ifndef GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#endif -#ifndef GL_CONTEXT_FLAG_DEBUG_BIT -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#endif -#ifndef GL_CONTEXT_PROFILE_MASK -#define GL_CONTEXT_PROFILE_MASK 0x9126 -#endif -#ifndef GL_CONTEXT_CORE_PROFILE_BIT -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#endif -#ifndef GL_CONTEXT_COMPATIBILITY_PROFILE_BIT -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#endif - -QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, - EGLConfig *config, Flags flags) - : m_eglDisplay(display) - , m_flags(flags) - , m_ownsContext(true) -{ - m_eglConfig = config ? *config : q_configFromGLFormat(display, format); - - m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig, format); - // m_format now has the renderableType() resolved (it cannot be Default anymore) - // but does not yet contain version, profile, options. - m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : nullptr; - - QVector<EGLint> contextAttrs; - contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - contextAttrs.append(format.majorVersion()); - const bool hasKHRCreateContext = q_hasEglExtension(m_eglDisplay, "EGL_KHR_create_context"); - if (hasKHRCreateContext) { - contextAttrs.append(EGL_CONTEXT_MINOR_VERSION_KHR); - contextAttrs.append(format.minorVersion()); - int flags = 0; - // The debug bit is supported both for OpenGL and OpenGL ES. - if (format.testOption(QSurfaceFormat::DebugContext)) - flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR; - // The fwdcompat bit is only for OpenGL 3.0+. - if (m_format.renderableType() == QSurfaceFormat::OpenGL - && format.majorVersion() >= 3 - && !format.testOption(QSurfaceFormat::DeprecatedFunctions)) - flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR; - if (flags) { - contextAttrs.append(EGL_CONTEXT_FLAGS_KHR); - contextAttrs.append(flags); - } - // Profiles are OpenGL only and mandatory in 3.2+. The value is silently ignored for < 3.2. - if (m_format.renderableType() == QSurfaceFormat::OpenGL) { - contextAttrs.append(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR); - contextAttrs.append(format.profile() == QSurfaceFormat::CoreProfile - ? EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR - : EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR); - } - } - - // Special Options for OpenVG surfaces - if (m_format.renderableType() == QSurfaceFormat::OpenVG) { - contextAttrs.append(EGL_ALPHA_MASK_SIZE); - contextAttrs.append(8); - } - - contextAttrs.append(EGL_NONE); - m_contextAttrs = contextAttrs; - - switch (m_format.renderableType()) { - case QSurfaceFormat::OpenVG: - m_api = EGL_OPENVG_API; - break; -#ifdef EGL_VERSION_1_4 - case QSurfaceFormat::OpenGL: - m_api = EGL_OPENGL_API; - break; -#endif // EGL_VERSION_1_4 - default: - m_api = EGL_OPENGL_ES_API; - break; - } - - eglBindAPI(m_api); - m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, m_shareContext, contextAttrs.constData()); - if (m_eglContext == EGL_NO_CONTEXT && m_shareContext != EGL_NO_CONTEXT) { - m_shareContext = nullptr; - m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, contextAttrs.constData()); - } - - if (m_eglContext == EGL_NO_CONTEXT) { - qWarning("QEGLPlatformContext: Failed to create context: %x", eglGetError()); - return; - } - - static const bool printConfig = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DEBUG"); - if (printConfig) { - qDebug() << "Created context for format" << format << "with config:"; - q_printEglConfig(m_eglDisplay, m_eglConfig); - } - - // Cannot just call updateFormatFromGL() since it relies on virtuals. Defer it to initialize(). -} - -void QEGLPlatformContext::adopt(EGLContext context, EGLDisplay display, QPlatformOpenGLContext *share) -{ - Q_ASSERT(!m_ownsContext); - - m_eglDisplay = display; - - // Figure out the EGLConfig. - EGLint value = 0; - eglQueryContext(m_eglDisplay, context, EGL_CONFIG_ID, &value); - EGLint n = 0; - EGLConfig cfg; - const EGLint attribs[] = { EGL_CONFIG_ID, value, EGL_NONE }; - if (eglChooseConfig(m_eglDisplay, attribs, &cfg, 1, &n) && n == 1) { - m_eglConfig = cfg; - m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig); - } else { - qWarning("QEGLPlatformContext: Failed to get framebuffer configuration for context"); - } - - // Fetch client API type. - value = 0; - eglQueryContext(m_eglDisplay, context, EGL_CONTEXT_CLIENT_TYPE, &value); - if (value == EGL_OPENGL_API || value == EGL_OPENGL_ES_API) { - // if EGL config supports both OpenGL and OpenGL ES render type, - // q_glFormatFromConfig() with the default "referenceFormat" parameter - // will always figure it out as OpenGL render type. - // We can override it to match user's real render type. - if (value == EGL_OPENGL_ES_API) - m_format.setRenderableType(QSurfaceFormat::OpenGLES); - m_api = value; - eglBindAPI(m_api); - } else { - qWarning("QEGLPlatformContext: Failed to get client API type"); - m_api = EGL_OPENGL_ES_API; - } - - m_eglContext = context; - m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : nullptr; - updateFormatFromGL(); -} - -void QEGLPlatformContext::initialize() -{ - if (m_eglContext != EGL_NO_CONTEXT) - updateFormatFromGL(); -} - -// Base implementation for pbuffers. Subclasses will handle the specialized cases for -// platforms without pbuffers. -EGLSurface QEGLPlatformContext::createTemporaryOffscreenSurface() -{ - // Make the context current to ensure the GL version query works. This needs a surface too. - const EGLint pbufferAttributes[] = { - EGL_WIDTH, 1, - EGL_HEIGHT, 1, - EGL_LARGEST_PBUFFER, EGL_FALSE, - EGL_NONE - }; - - // Cannot just pass m_eglConfig because it may not be suitable for pbuffers. Instead, - // do what QEGLPbuffer would do: request a config with the same attributes but with - // PBUFFER_BIT set. - EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT); - - return eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes); -} - -void QEGLPlatformContext::destroyTemporaryOffscreenSurface(EGLSurface surface) -{ - eglDestroySurface(m_eglDisplay, surface); -} - -void QEGLPlatformContext::runGLChecks() -{ - // Nothing to do here, subclasses may override in order to perform OpenGL - // queries needing a context. -} - -void QEGLPlatformContext::updateFormatFromGL() -{ -#ifndef QT_NO_OPENGL - // Have to save & restore to prevent QOpenGLContext::currentContext() from becoming - // inconsistent after QOpenGLContext::create(). - EGLDisplay prevDisplay = eglGetCurrentDisplay(); - if (prevDisplay == EGL_NO_DISPLAY) // when no context is current - prevDisplay = m_eglDisplay; - EGLContext prevContext = eglGetCurrentContext(); - EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW); - EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ); - - // Rely on the surfaceless extension, if available. This is beneficial since we can - // avoid creating an extra pbuffer surface which is apparently troublesome with some - // drivers (Mesa) when certain attributes are present (multisampling). - EGLSurface tempSurface = EGL_NO_SURFACE; - EGLContext tempContext = EGL_NO_CONTEXT; - if (m_flags.testFlag(NoSurfaceless) || !q_hasEglExtension(m_eglDisplay, "EGL_KHR_surfaceless_context")) - tempSurface = createTemporaryOffscreenSurface(); - - EGLBoolean ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext); - if (!ok) { - EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT); - tempContext = eglCreateContext(m_eglDisplay, config, nullptr, m_contextAttrs.constData()); - if (tempContext != EGL_NO_CONTEXT) - ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, tempContext); - } - if (ok) { - if (m_format.renderableType() == QSurfaceFormat::OpenGL - || m_format.renderableType() == QSurfaceFormat::OpenGLES) { - const GLubyte *s = glGetString(GL_VERSION); - if (s) { - QByteArray version = QByteArray(reinterpret_cast<const char *>(s)); - int major, minor; - if (QPlatformOpenGLContext::parseOpenGLVersion(version, major, minor)) { - m_format.setMajorVersion(major); - m_format.setMinorVersion(minor); - } - } - m_format.setProfile(QSurfaceFormat::NoProfile); - m_format.setOptions(QSurfaceFormat::FormatOptions()); - if (m_format.renderableType() == QSurfaceFormat::OpenGL) { - // Check profile and options. - if (m_format.majorVersion() < 3) { - m_format.setOption(QSurfaceFormat::DeprecatedFunctions); - } else { - GLint value = 0; - glGetIntegerv(GL_CONTEXT_FLAGS, &value); - if (!(value & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)) - m_format.setOption(QSurfaceFormat::DeprecatedFunctions); - if (value & GL_CONTEXT_FLAG_DEBUG_BIT) - m_format.setOption(QSurfaceFormat::DebugContext); - if (m_format.version() >= qMakePair(3, 2)) { - value = 0; - glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &value); - if (value & GL_CONTEXT_CORE_PROFILE_BIT) - m_format.setProfile(QSurfaceFormat::CoreProfile); - else if (value & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) - m_format.setProfile(QSurfaceFormat::CompatibilityProfile); - } - } - } - } - runGLChecks(); - eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext); - } else { - qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated (%x)", eglGetError()); - } - if (tempSurface != EGL_NO_SURFACE) - destroyTemporaryOffscreenSurface(tempSurface); - if (tempContext != EGL_NO_CONTEXT) - eglDestroyContext(m_eglDisplay, tempContext); -#endif // QT_NO_OPENGL -} - -bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface) -{ - Q_ASSERT(surface->surface()->supportsOpenGL()); - - eglBindAPI(m_api); - - EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface); - - // shortcut: on some GPUs, eglMakeCurrent is not a cheap operation - if (eglGetCurrentContext() == m_eglContext && - eglGetCurrentDisplay() == m_eglDisplay && - eglGetCurrentSurface(EGL_READ) == eglSurface && - eglGetCurrentSurface(EGL_DRAW) == eglSurface) { - return true; - } - - const bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext); - if (ok) { - if (!m_swapIntervalEnvChecked) { - m_swapIntervalEnvChecked = true; - if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_SWAPINTERVAL")) { - QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL"); - bool intervalOk; - const int swapInterval = swapIntervalString.toInt(&intervalOk); - if (intervalOk) - m_swapIntervalFromEnv = swapInterval; - } - } - const int requestedSwapInterval = m_swapIntervalFromEnv >= 0 - ? m_swapIntervalFromEnv - : surface->format().swapInterval(); - if (requestedSwapInterval >= 0 && m_swapInterval != requestedSwapInterval) { - m_swapInterval = requestedSwapInterval; - if (eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context - eglSwapInterval(eglDisplay(), m_swapInterval); - } - } else { - qWarning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError()); - } - - return ok; -} - -QEGLPlatformContext::~QEGLPlatformContext() -{ - if (m_ownsContext && m_eglContext != EGL_NO_CONTEXT) - eglDestroyContext(m_eglDisplay, m_eglContext); - - m_eglContext = EGL_NO_CONTEXT; -} - -void QEGLPlatformContext::doneCurrent() -{ - eglBindAPI(m_api); - bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (!ok) - qWarning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError()); -} - -void QEGLPlatformContext::swapBuffers(QPlatformSurface *surface) -{ - eglBindAPI(m_api); - EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface); - if (eglSurface != EGL_NO_SURFACE) { // skip if using surfaceless context - bool ok = eglSwapBuffers(m_eglDisplay, eglSurface); - if (!ok) - qWarning("QEGLPlatformContext: eglSwapBuffers failed: %x", eglGetError()); - } -} - -QFunctionPointer QEGLPlatformContext::getProcAddress(const char *procName) -{ - eglBindAPI(m_api); - QFunctionPointer proc = (QFunctionPointer) eglGetProcAddress(procName); -#if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY) - if (!proc) - proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName); -#elif !defined(QT_OPENGL_DYNAMIC) - // On systems without KHR_get_all_proc_addresses and without - // dynamic linking there still has to be a way to access the - // standard GLES functions. QOpenGL(Extra)Functions never makes - // direct GL API calls since Qt 5.7, so all such workarounds are - // expected to be handled in the platform plugin. - if (!proc) { - static struct StdFunc { - const char *name; - QFunctionPointer func; - } standardFuncs[] = { -#if QT_CONFIG(opengles2) - { "glBindTexture", (QFunctionPointer) ::glBindTexture }, - { "glBlendFunc", (QFunctionPointer) ::glBlendFunc }, - { "glClear", (QFunctionPointer) ::glClear }, - { "glClearColor", (QFunctionPointer) ::glClearColor }, - { "glClearStencil", (QFunctionPointer) ::glClearStencil }, - { "glColorMask", (QFunctionPointer) ::glColorMask }, - { "glCopyTexImage2D", (QFunctionPointer) ::glCopyTexImage2D }, - { "glCopyTexSubImage2D", (QFunctionPointer) ::glCopyTexSubImage2D }, - { "glCullFace", (QFunctionPointer) ::glCullFace }, - { "glDeleteTextures", (QFunctionPointer) ::glDeleteTextures }, - { "glDepthFunc", (QFunctionPointer) ::glDepthFunc }, - { "glDepthMask", (QFunctionPointer) ::glDepthMask }, - { "glDisable", (QFunctionPointer) ::glDisable }, - { "glDrawArrays", (QFunctionPointer) ::glDrawArrays }, - { "glDrawElements", (QFunctionPointer) ::glDrawElements }, - { "glEnable", (QFunctionPointer) ::glEnable }, - { "glFinish", (QFunctionPointer) ::glFinish }, - { "glFlush", (QFunctionPointer) ::glFlush }, - { "glFrontFace", (QFunctionPointer) ::glFrontFace }, - { "glGenTextures", (QFunctionPointer) ::glGenTextures }, - { "glGetBooleanv", (QFunctionPointer) ::glGetBooleanv }, - { "glGetError", (QFunctionPointer) ::glGetError }, - { "glGetFloatv", (QFunctionPointer) ::glGetFloatv }, - { "glGetIntegerv", (QFunctionPointer) ::glGetIntegerv }, - { "glGetString", (QFunctionPointer) ::glGetString }, - { "glGetTexParameterfv", (QFunctionPointer) ::glGetTexParameterfv }, - { "glGetTexParameteriv", (QFunctionPointer) ::glGetTexParameteriv }, - { "glHint", (QFunctionPointer) ::glHint }, - { "glIsEnabled", (QFunctionPointer) ::glIsEnabled }, - { "glIsTexture", (QFunctionPointer) ::glIsTexture }, - { "glLineWidth", (QFunctionPointer) ::glLineWidth }, - { "glPixelStorei", (QFunctionPointer) ::glPixelStorei }, - { "glPolygonOffset", (QFunctionPointer) ::glPolygonOffset }, - { "glReadPixels", (QFunctionPointer) ::glReadPixels }, - { "glScissor", (QFunctionPointer) ::glScissor }, - { "glStencilFunc", (QFunctionPointer) ::glStencilFunc }, - { "glStencilMask", (QFunctionPointer) ::glStencilMask }, - { "glStencilOp", (QFunctionPointer) ::glStencilOp }, - { "glTexImage2D", (QFunctionPointer) ::glTexImage2D }, - { "glTexParameterf", (QFunctionPointer) ::glTexParameterf }, - { "glTexParameterfv", (QFunctionPointer) ::glTexParameterfv }, - { "glTexParameteri", (QFunctionPointer) ::glTexParameteri }, - { "glTexParameteriv", (QFunctionPointer) ::glTexParameteriv }, - { "glTexSubImage2D", (QFunctionPointer) ::glTexSubImage2D }, - { "glViewport", (QFunctionPointer) ::glViewport }, - - { "glActiveTexture", (QFunctionPointer) ::glActiveTexture }, - { "glAttachShader", (QFunctionPointer) ::glAttachShader }, - { "glBindAttribLocation", (QFunctionPointer) ::glBindAttribLocation }, - { "glBindBuffer", (QFunctionPointer) ::glBindBuffer }, - { "glBindFramebuffer", (QFunctionPointer) ::glBindFramebuffer }, - { "glBindRenderbuffer", (QFunctionPointer) ::glBindRenderbuffer }, - { "glBlendColor", (QFunctionPointer) ::glBlendColor }, - { "glBlendEquation", (QFunctionPointer) ::glBlendEquation }, - { "glBlendEquationSeparate", (QFunctionPointer) ::glBlendEquationSeparate }, - { "glBlendFuncSeparate", (QFunctionPointer) ::glBlendFuncSeparate }, - { "glBufferData", (QFunctionPointer) ::glBufferData }, - { "glBufferSubData", (QFunctionPointer) ::glBufferSubData }, - { "glCheckFramebufferStatus", (QFunctionPointer) ::glCheckFramebufferStatus }, - { "glCompileShader", (QFunctionPointer) ::glCompileShader }, - { "glCompressedTexImage2D", (QFunctionPointer) ::glCompressedTexImage2D }, - { "glCompressedTexSubImage2D", (QFunctionPointer) ::glCompressedTexSubImage2D }, - { "glCreateProgram", (QFunctionPointer) ::glCreateProgram }, - { "glCreateShader", (QFunctionPointer) ::glCreateShader }, - { "glDeleteBuffers", (QFunctionPointer) ::glDeleteBuffers }, - { "glDeleteFramebuffers", (QFunctionPointer) ::glDeleteFramebuffers }, - { "glDeleteProgram", (QFunctionPointer) ::glDeleteProgram }, - { "glDeleteRenderbuffers", (QFunctionPointer) ::glDeleteRenderbuffers }, - { "glDeleteShader", (QFunctionPointer) ::glDeleteShader }, - { "glDetachShader", (QFunctionPointer) ::glDetachShader }, - { "glDisableVertexAttribArray", (QFunctionPointer) ::glDisableVertexAttribArray }, - { "glEnableVertexAttribArray", (QFunctionPointer) ::glEnableVertexAttribArray }, - { "glFramebufferRenderbuffer", (QFunctionPointer) ::glFramebufferRenderbuffer }, - { "glFramebufferTexture2D", (QFunctionPointer) ::glFramebufferTexture2D }, - { "glGenBuffers", (QFunctionPointer) ::glGenBuffers }, - { "glGenerateMipmap", (QFunctionPointer) ::glGenerateMipmap }, - { "glGenFramebuffers", (QFunctionPointer) ::glGenFramebuffers }, - { "glGenRenderbuffers", (QFunctionPointer) ::glGenRenderbuffers }, - { "glGetActiveAttrib", (QFunctionPointer) ::glGetActiveAttrib }, - { "glGetActiveUniform", (QFunctionPointer) ::glGetActiveUniform }, - { "glGetAttachedShaders", (QFunctionPointer) ::glGetAttachedShaders }, - { "glGetAttribLocation", (QFunctionPointer) ::glGetAttribLocation }, - { "glGetBufferParameteriv", (QFunctionPointer) ::glGetBufferParameteriv }, - { "glGetFramebufferAttachmentParameteriv", (QFunctionPointer) ::glGetFramebufferAttachmentParameteriv }, - { "glGetProgramiv", (QFunctionPointer) ::glGetProgramiv }, - { "glGetProgramInfoLog", (QFunctionPointer) ::glGetProgramInfoLog }, - { "glGetRenderbufferParameteriv", (QFunctionPointer) ::glGetRenderbufferParameteriv }, - { "glGetShaderiv", (QFunctionPointer) ::glGetShaderiv }, - { "glGetShaderInfoLog", (QFunctionPointer) ::glGetShaderInfoLog }, - { "glGetShaderPrecisionFormat", (QFunctionPointer) ::glGetShaderPrecisionFormat }, - { "glGetShaderSource", (QFunctionPointer) ::glGetShaderSource }, - { "glGetUniformfv", (QFunctionPointer) ::glGetUniformfv }, - { "glGetUniformiv", (QFunctionPointer) ::glGetUniformiv }, - { "glGetUniformLocation", (QFunctionPointer) ::glGetUniformLocation }, - { "glGetVertexAttribfv", (QFunctionPointer) ::glGetVertexAttribfv }, - { "glGetVertexAttribiv", (QFunctionPointer) ::glGetVertexAttribiv }, - { "glGetVertexAttribPointerv", (QFunctionPointer) ::glGetVertexAttribPointerv }, - { "glIsBuffer", (QFunctionPointer) ::glIsBuffer }, - { "glIsFramebuffer", (QFunctionPointer) ::glIsFramebuffer }, - { "glIsProgram", (QFunctionPointer) ::glIsProgram }, - { "glIsRenderbuffer", (QFunctionPointer) ::glIsRenderbuffer }, - { "glIsShader", (QFunctionPointer) ::glIsShader }, - { "glLinkProgram", (QFunctionPointer) ::glLinkProgram }, - { "glReleaseShaderCompiler", (QFunctionPointer) ::glReleaseShaderCompiler }, - { "glRenderbufferStorage", (QFunctionPointer) ::glRenderbufferStorage }, - { "glSampleCoverage", (QFunctionPointer) ::glSampleCoverage }, - { "glShaderBinary", (QFunctionPointer) ::glShaderBinary }, - { "glShaderSource", (QFunctionPointer) ::glShaderSource }, - { "glStencilFuncSeparate", (QFunctionPointer) ::glStencilFuncSeparate }, - { "glStencilMaskSeparate", (QFunctionPointer) ::glStencilMaskSeparate }, - { "glStencilOpSeparate", (QFunctionPointer) ::glStencilOpSeparate }, - { "glUniform1f", (QFunctionPointer) ::glUniform1f }, - { "glUniform1fv", (QFunctionPointer) ::glUniform1fv }, - { "glUniform1i", (QFunctionPointer) ::glUniform1i }, - { "glUniform1iv", (QFunctionPointer) ::glUniform1iv }, - { "glUniform2f", (QFunctionPointer) ::glUniform2f }, - { "glUniform2fv", (QFunctionPointer) ::glUniform2fv }, - { "glUniform2i", (QFunctionPointer) ::glUniform2i }, - { "glUniform2iv", (QFunctionPointer) ::glUniform2iv }, - { "glUniform3f", (QFunctionPointer) ::glUniform3f }, - { "glUniform3fv", (QFunctionPointer) ::glUniform3fv }, - { "glUniform3i", (QFunctionPointer) ::glUniform3i }, - { "glUniform3iv", (QFunctionPointer) ::glUniform3iv }, - { "glUniform4f", (QFunctionPointer) ::glUniform4f }, - { "glUniform4fv", (QFunctionPointer) ::glUniform4fv }, - { "glUniform4i", (QFunctionPointer) ::glUniform4i }, - { "glUniform4iv", (QFunctionPointer) ::glUniform4iv }, - { "glUniformMatrix2fv", (QFunctionPointer) ::glUniformMatrix2fv }, - { "glUniformMatrix3fv", (QFunctionPointer) ::glUniformMatrix3fv }, - { "glUniformMatrix4fv", (QFunctionPointer) ::glUniformMatrix4fv }, - { "glUseProgram", (QFunctionPointer) ::glUseProgram }, - { "glValidateProgram", (QFunctionPointer) ::glValidateProgram }, - { "glVertexAttrib1f", (QFunctionPointer) ::glVertexAttrib1f }, - { "glVertexAttrib1fv", (QFunctionPointer) ::glVertexAttrib1fv }, - { "glVertexAttrib2f", (QFunctionPointer) ::glVertexAttrib2f }, - { "glVertexAttrib2fv", (QFunctionPointer) ::glVertexAttrib2fv }, - { "glVertexAttrib3f", (QFunctionPointer) ::glVertexAttrib3f }, - { "glVertexAttrib3fv", (QFunctionPointer) ::glVertexAttrib3fv }, - { "glVertexAttrib4f", (QFunctionPointer) ::glVertexAttrib4f }, - { "glVertexAttrib4fv", (QFunctionPointer) ::glVertexAttrib4fv }, - { "glVertexAttribPointer", (QFunctionPointer) ::glVertexAttribPointer }, - - { "glClearDepthf", (QFunctionPointer) ::glClearDepthf }, - { "glDepthRangef", (QFunctionPointer) ::glDepthRangef }, -#endif // QT_CONFIG(opengles2) - -#if QT_CONFIG(opengles3) - { "glBeginQuery", (QFunctionPointer) ::glBeginQuery }, - { "glBeginTransformFeedback", (QFunctionPointer) ::glBeginTransformFeedback }, - { "glBindBufferBase", (QFunctionPointer) ::glBindBufferBase }, - { "glBindBufferRange", (QFunctionPointer) ::glBindBufferRange }, - { "glBindSampler", (QFunctionPointer) ::glBindSampler }, - { "glBindTransformFeedback", (QFunctionPointer) ::glBindTransformFeedback }, - { "glBindVertexArray", (QFunctionPointer) ::glBindVertexArray }, - { "glBlitFramebuffer", (QFunctionPointer) ::glBlitFramebuffer }, - { "glClearBufferfi", (QFunctionPointer) ::glClearBufferfi }, - { "glClearBufferfv", (QFunctionPointer) ::glClearBufferfv }, - { "glClearBufferiv", (QFunctionPointer) ::glClearBufferiv }, - { "glClearBufferuiv", (QFunctionPointer) ::glClearBufferuiv }, - { "glClientWaitSync", (QFunctionPointer) ::glClientWaitSync }, - { "glCompressedTexImage3D", (QFunctionPointer) ::glCompressedTexImage3D }, - { "glCompressedTexSubImage3D", (QFunctionPointer) ::glCompressedTexSubImage3D }, - { "glCopyBufferSubData", (QFunctionPointer) ::glCopyBufferSubData }, - { "glCopyTexSubImage3D", (QFunctionPointer) ::glCopyTexSubImage3D }, - { "glDeleteQueries", (QFunctionPointer) ::glDeleteQueries }, - { "glDeleteSamplers", (QFunctionPointer) ::glDeleteSamplers }, - { "glDeleteSync", (QFunctionPointer) ::glDeleteSync }, - { "glDeleteTransformFeedbacks", (QFunctionPointer) ::glDeleteTransformFeedbacks }, - { "glDeleteVertexArrays", (QFunctionPointer) ::glDeleteVertexArrays }, - { "glDrawArraysInstanced", (QFunctionPointer) ::glDrawArraysInstanced }, - { "glDrawBuffers", (QFunctionPointer) ::glDrawBuffers }, - { "glDrawElementsInstanced", (QFunctionPointer) ::glDrawElementsInstanced }, - { "glDrawRangeElements", (QFunctionPointer) ::glDrawRangeElements }, - { "glEndQuery", (QFunctionPointer) ::glEndQuery }, - { "glEndTransformFeedback", (QFunctionPointer) ::glEndTransformFeedback }, - { "glFenceSync", (QFunctionPointer) ::glFenceSync }, - { "glFlushMappedBufferRange", (QFunctionPointer) ::glFlushMappedBufferRange }, - { "glFramebufferTextureLayer", (QFunctionPointer) ::glFramebufferTextureLayer }, - { "glGenQueries", (QFunctionPointer) ::glGenQueries }, - { "glGenSamplers", (QFunctionPointer) ::glGenSamplers }, - { "glGenTransformFeedbacks", (QFunctionPointer) ::glGenTransformFeedbacks }, - { "glGenVertexArrays", (QFunctionPointer) ::glGenVertexArrays }, - { "glGetActiveUniformBlockName", (QFunctionPointer) ::glGetActiveUniformBlockName }, - { "glGetActiveUniformBlockiv", (QFunctionPointer) ::glGetActiveUniformBlockiv }, - { "glGetActiveUniformsiv", (QFunctionPointer) ::glGetActiveUniformsiv }, - { "glGetBufferParameteri64v", (QFunctionPointer) ::glGetBufferParameteri64v }, - { "glGetBufferPointerv", (QFunctionPointer) ::glGetBufferPointerv }, - { "glGetFragDataLocation", (QFunctionPointer) ::glGetFragDataLocation }, - { "glGetInteger64i_v", (QFunctionPointer) ::glGetInteger64i_v }, - { "glGetInteger64v", (QFunctionPointer) ::glGetInteger64v }, - { "glGetIntegeri_v", (QFunctionPointer) ::glGetIntegeri_v }, - { "glGetInternalformativ", (QFunctionPointer) ::glGetInternalformativ }, - { "glGetProgramBinary", (QFunctionPointer) ::glGetProgramBinary }, - { "glGetQueryObjectuiv", (QFunctionPointer) ::glGetQueryObjectuiv }, - { "glGetQueryiv", (QFunctionPointer) ::glGetQueryiv }, - { "glGetSamplerParameterfv", (QFunctionPointer) ::glGetSamplerParameterfv }, - { "glGetSamplerParameteriv", (QFunctionPointer) ::glGetSamplerParameteriv }, - { "glGetStringi", (QFunctionPointer) ::glGetStringi }, - { "glGetSynciv", (QFunctionPointer) ::glGetSynciv }, - { "glGetTransformFeedbackVarying", (QFunctionPointer) ::glGetTransformFeedbackVarying }, - { "glGetUniformBlockIndex", (QFunctionPointer) ::glGetUniformBlockIndex }, - { "glGetUniformIndices", (QFunctionPointer) ::glGetUniformIndices }, - { "glGetUniformuiv", (QFunctionPointer) ::glGetUniformuiv }, - { "glGetVertexAttribIiv", (QFunctionPointer) ::glGetVertexAttribIiv }, - { "glGetVertexAttribIuiv", (QFunctionPointer) ::glGetVertexAttribIuiv }, - { "glInvalidateFramebuffer", (QFunctionPointer) ::glInvalidateFramebuffer }, - { "glInvalidateSubFramebuffer", (QFunctionPointer) ::glInvalidateSubFramebuffer }, - { "glIsQuery", (QFunctionPointer) ::glIsQuery }, - { "glIsSampler", (QFunctionPointer) ::glIsSampler }, - { "glIsSync", (QFunctionPointer) ::glIsSync }, - { "glIsTransformFeedback", (QFunctionPointer) ::glIsTransformFeedback }, - { "glIsVertexArray", (QFunctionPointer) ::glIsVertexArray }, - { "glMapBufferRange", (QFunctionPointer) ::glMapBufferRange }, - { "glPauseTransformFeedback", (QFunctionPointer) ::glPauseTransformFeedback }, - { "glProgramBinary", (QFunctionPointer) ::glProgramBinary }, - { "glProgramParameteri", (QFunctionPointer) ::glProgramParameteri }, - { "glReadBuffer", (QFunctionPointer) ::glReadBuffer }, - { "glRenderbufferStorageMultisample", (QFunctionPointer) ::glRenderbufferStorageMultisample }, - { "glResumeTransformFeedback", (QFunctionPointer) ::glResumeTransformFeedback }, - { "glSamplerParameterf", (QFunctionPointer) ::glSamplerParameterf }, - { "glSamplerParameterfv", (QFunctionPointer) ::glSamplerParameterfv }, - { "glSamplerParameteri", (QFunctionPointer) ::glSamplerParameteri }, - { "glSamplerParameteriv", (QFunctionPointer) ::glSamplerParameteriv }, - { "glTexImage3D", (QFunctionPointer) ::glTexImage3D }, - { "glTexStorage2D", (QFunctionPointer) ::glTexStorage2D }, - { "glTexStorage3D", (QFunctionPointer) ::glTexStorage3D }, - { "glTexSubImage3D", (QFunctionPointer) ::glTexSubImage3D }, - { "glTransformFeedbackVaryings", (QFunctionPointer) ::glTransformFeedbackVaryings }, - { "glUniform1ui", (QFunctionPointer) ::glUniform1ui }, - { "glUniform1uiv", (QFunctionPointer) ::glUniform1uiv }, - { "glUniform2ui", (QFunctionPointer) ::glUniform2ui }, - { "glUniform2uiv", (QFunctionPointer) ::glUniform2uiv }, - { "glUniform3ui", (QFunctionPointer) ::glUniform3ui }, - { "glUniform3uiv", (QFunctionPointer) ::glUniform3uiv }, - { "glUniform4ui", (QFunctionPointer) ::glUniform4ui }, - { "glUniform4uiv", (QFunctionPointer) ::glUniform4uiv }, - { "glUniformBlockBinding", (QFunctionPointer) ::glUniformBlockBinding }, - { "glUniformMatrix2x3fv", (QFunctionPointer) ::glUniformMatrix2x3fv }, - { "glUniformMatrix2x4fv", (QFunctionPointer) ::glUniformMatrix2x4fv }, - { "glUniformMatrix3x2fv", (QFunctionPointer) ::glUniformMatrix3x2fv }, - { "glUniformMatrix3x4fv", (QFunctionPointer) ::glUniformMatrix3x4fv }, - { "glUniformMatrix4x2fv", (QFunctionPointer) ::glUniformMatrix4x2fv }, - { "glUniformMatrix4x3fv", (QFunctionPointer) ::glUniformMatrix4x3fv }, - { "glUnmapBuffer", (QFunctionPointer) ::glUnmapBuffer }, - { "glVertexAttribDivisor", (QFunctionPointer) ::glVertexAttribDivisor }, - { "glVertexAttribI4i", (QFunctionPointer) ::glVertexAttribI4i }, - { "glVertexAttribI4iv", (QFunctionPointer) ::glVertexAttribI4iv }, - { "glVertexAttribI4ui", (QFunctionPointer) ::glVertexAttribI4ui }, - { "glVertexAttribI4uiv", (QFunctionPointer) ::glVertexAttribI4uiv }, - { "glVertexAttribIPointer", (QFunctionPointer) ::glVertexAttribIPointer }, - { "glWaitSync", (QFunctionPointer) ::glWaitSync }, -#endif // QT_CONFIG(opengles3) - -#if QT_CONFIG(opengles31) - { "glActiveShaderProgram", (QFunctionPointer) ::glActiveShaderProgram }, - { "glBindImageTexture", (QFunctionPointer) ::glBindImageTexture }, - { "glBindProgramPipeline", (QFunctionPointer) ::glBindProgramPipeline }, - { "glBindVertexBuffer", (QFunctionPointer) ::glBindVertexBuffer }, - { "glCreateShaderProgramv", (QFunctionPointer) ::glCreateShaderProgramv }, - { "glDeleteProgramPipelines", (QFunctionPointer) ::glDeleteProgramPipelines }, - { "glDispatchCompute", (QFunctionPointer) ::glDispatchCompute }, - { "glDispatchComputeIndirect", (QFunctionPointer) ::glDispatchComputeIndirect }, - { "glDrawArraysIndirect", (QFunctionPointer) ::glDrawArraysIndirect }, - { "glDrawElementsIndirect", (QFunctionPointer) ::glDrawElementsIndirect }, - { "glFramebufferParameteri", (QFunctionPointer) ::glFramebufferParameteri }, - { "glGenProgramPipelines", (QFunctionPointer) ::glGenProgramPipelines }, - { "glGetBooleani_v", (QFunctionPointer) ::glGetBooleani_v }, - { "glGetFramebufferParameteriv", (QFunctionPointer) ::glGetFramebufferParameteriv }, - { "glGetMultisamplefv", (QFunctionPointer) ::glGetMultisamplefv }, - { "glGetProgramInterfaceiv", (QFunctionPointer) ::glGetProgramInterfaceiv }, - { "glGetProgramPipelineInfoLog", (QFunctionPointer) ::glGetProgramPipelineInfoLog }, - { "glGetProgramPipelineiv", (QFunctionPointer) ::glGetProgramPipelineiv }, - { "glGetProgramResourceIndex", (QFunctionPointer) ::glGetProgramResourceIndex }, - { "glGetProgramResourceLocation", (QFunctionPointer) ::glGetProgramResourceLocation }, - { "glGetProgramResourceName", (QFunctionPointer) ::glGetProgramResourceName }, - { "glGetProgramResourceiv", (QFunctionPointer) ::glGetProgramResourceiv }, - { "glGetTexLevelParameterfv", (QFunctionPointer) ::glGetTexLevelParameterfv }, - { "glGetTexLevelParameteriv", (QFunctionPointer) ::glGetTexLevelParameteriv }, - { "glIsProgramPipeline", (QFunctionPointer) ::glIsProgramPipeline }, - { "glMemoryBarrier", (QFunctionPointer) ::glMemoryBarrier }, - { "glMemoryBarrierByRegion", (QFunctionPointer) ::glMemoryBarrierByRegion }, - { "glProgramUniform1f", (QFunctionPointer) ::glProgramUniform1f }, - { "glProgramUniform1fv", (QFunctionPointer) ::glProgramUniform1fv }, - { "glProgramUniform1i", (QFunctionPointer) ::glProgramUniform1i }, - { "glProgramUniform1iv", (QFunctionPointer) ::glProgramUniform1iv }, - { "glProgramUniform1ui", (QFunctionPointer) ::glProgramUniform1ui }, - { "glProgramUniform1uiv", (QFunctionPointer) ::glProgramUniform1uiv }, - { "glProgramUniform2f", (QFunctionPointer) ::glProgramUniform2f }, - { "glProgramUniform2fv", (QFunctionPointer) ::glProgramUniform2fv }, - { "glProgramUniform2i", (QFunctionPointer) ::glProgramUniform2i }, - { "glProgramUniform2iv", (QFunctionPointer) ::glProgramUniform2iv }, - { "glProgramUniform2ui", (QFunctionPointer) ::glProgramUniform2ui }, - { "glProgramUniform2uiv", (QFunctionPointer) ::glProgramUniform2uiv }, - { "glProgramUniform3f", (QFunctionPointer) ::glProgramUniform3f }, - { "glProgramUniform3fv", (QFunctionPointer) ::glProgramUniform3fv }, - { "glProgramUniform3i", (QFunctionPointer) ::glProgramUniform3i }, - { "glProgramUniform3iv", (QFunctionPointer) ::glProgramUniform3iv }, - { "glProgramUniform3ui", (QFunctionPointer) ::glProgramUniform3ui }, - { "glProgramUniform3uiv", (QFunctionPointer) ::glProgramUniform3uiv }, - { "glProgramUniform4f", (QFunctionPointer) ::glProgramUniform4f }, - { "glProgramUniform4fv", (QFunctionPointer) ::glProgramUniform4fv }, - { "glProgramUniform4i", (QFunctionPointer) ::glProgramUniform4i }, - { "glProgramUniform4iv", (QFunctionPointer) ::glProgramUniform4iv }, - { "glProgramUniform4ui", (QFunctionPointer) ::glProgramUniform4ui }, - { "glProgramUniform4uiv", (QFunctionPointer) ::glProgramUniform4uiv }, - { "glProgramUniformMatrix2fv", (QFunctionPointer) ::glProgramUniformMatrix2fv }, - { "glProgramUniformMatrix2x3fv", (QFunctionPointer) ::glProgramUniformMatrix2x3fv }, - { "glProgramUniformMatrix2x4fv", (QFunctionPointer) ::glProgramUniformMatrix2x4fv }, - { "glProgramUniformMatrix3fv", (QFunctionPointer) ::glProgramUniformMatrix3fv }, - { "glProgramUniformMatrix3x2fv", (QFunctionPointer) ::glProgramUniformMatrix3x2fv }, - { "glProgramUniformMatrix3x4fv", (QFunctionPointer) ::glProgramUniformMatrix3x4fv }, - { "glProgramUniformMatrix4fv", (QFunctionPointer) ::glProgramUniformMatrix4fv }, - { "glProgramUniformMatrix4x2fv", (QFunctionPointer) ::glProgramUniformMatrix4x2fv }, - { "glProgramUniformMatrix4x3fv", (QFunctionPointer) ::glProgramUniformMatrix4x3fv }, - { "glSampleMaski", (QFunctionPointer) ::glSampleMaski }, - { "glTexStorage2DMultisample", (QFunctionPointer) ::glTexStorage2DMultisample }, - { "glUseProgramStages", (QFunctionPointer) ::glUseProgramStages }, - { "glValidateProgramPipeline", (QFunctionPointer) ::glValidateProgramPipeline }, - { "glVertexAttribBinding", (QFunctionPointer) ::glVertexAttribBinding }, - { "glVertexAttribFormat", (QFunctionPointer) ::glVertexAttribFormat }, - { "glVertexAttribIFormat", (QFunctionPointer) ::glVertexAttribIFormat }, - { "glVertexBindingDivisor", (QFunctionPointer) ::glVertexBindingDivisor }, -#endif // QT_CONFIG(opengles31) - -#if QT_CONFIG(opengles32) - { "glBlendBarrier", (QFunctionPointer) ::glBlendBarrier }, - { "glCopyImageSubData", (QFunctionPointer) ::glCopyImageSubData }, - { "glDebugMessageControl", (QFunctionPointer) ::glDebugMessageControl }, - { "glDebugMessageInsert", (QFunctionPointer) ::glDebugMessageInsert }, - { "glDebugMessageCallback", (QFunctionPointer) ::glDebugMessageCallback }, - { "glGetDebugMessageLog", (QFunctionPointer) ::glGetDebugMessageLog }, - { "glPushDebugGroup", (QFunctionPointer) ::glPushDebugGroup }, - { "glPopDebugGroup", (QFunctionPointer) ::glPopDebugGroup }, - { "glObjectLabel", (QFunctionPointer) ::glObjectLabel }, - { "glGetObjectLabel", (QFunctionPointer) ::glGetObjectLabel }, - { "glObjectPtrLabel", (QFunctionPointer) ::glObjectPtrLabel }, - { "glGetObjectPtrLabel", (QFunctionPointer) ::glGetObjectPtrLabel }, - { "glGetPointerv", (QFunctionPointer) ::glGetPointerv }, - { "glEnablei", (QFunctionPointer) ::glEnablei }, - { "glDisablei", (QFunctionPointer) ::glDisablei }, - { "glBlendEquationi", (QFunctionPointer) ::glBlendEquationi }, - { "glBlendEquationSeparatei", (QFunctionPointer) ::glBlendEquationSeparatei }, - { "glBlendFunci", (QFunctionPointer) ::glBlendFunci }, - { "glBlendFuncSeparatei", (QFunctionPointer) ::glBlendFuncSeparatei }, - { "glColorMaski", (QFunctionPointer) ::glColorMaski }, - { "glIsEnabledi", (QFunctionPointer) ::glIsEnabledi }, - { "glDrawElementsBaseVertex", (QFunctionPointer) ::glDrawElementsBaseVertex }, - { "glDrawRangeElementsBaseVertex", (QFunctionPointer) ::glDrawRangeElementsBaseVertex }, - { "glDrawElementsInstancedBaseVertex", (QFunctionPointer) ::glDrawElementsInstancedBaseVertex }, - { "glFramebufferTexture", (QFunctionPointer) ::glFramebufferTexture }, - { "glPrimitiveBoundingBox", (QFunctionPointer) ::glPrimitiveBoundingBox }, - { "glGetGraphicsResetStatus", (QFunctionPointer) ::glGetGraphicsResetStatus }, - { "glReadnPixels", (QFunctionPointer) ::glReadnPixels }, - { "glGetnUniformfv", (QFunctionPointer) ::glGetnUniformfv }, - { "glGetnUniformiv", (QFunctionPointer) ::glGetnUniformiv }, - { "glGetnUniformuiv", (QFunctionPointer) ::glGetnUniformuiv }, - { "glMinSampleShading", (QFunctionPointer) ::glMinSampleShading }, - { "glPatchParameteri", (QFunctionPointer) ::glPatchParameteri }, - { "glTexParameterIiv", (QFunctionPointer) ::glTexParameterIiv }, - { "glTexParameterIuiv", (QFunctionPointer) ::glTexParameterIuiv }, - { "glGetTexParameterIiv", (QFunctionPointer) ::glGetTexParameterIiv }, - { "glGetTexParameterIuiv", (QFunctionPointer) ::glGetTexParameterIuiv }, - { "glSamplerParameterIiv", (QFunctionPointer) ::glSamplerParameterIiv }, - { "glSamplerParameterIuiv", (QFunctionPointer) ::glSamplerParameterIuiv }, - { "glGetSamplerParameterIiv", (QFunctionPointer) ::glGetSamplerParameterIiv }, - { "glGetSamplerParameterIuiv", (QFunctionPointer) ::glGetSamplerParameterIuiv }, - { "glTexBuffer", (QFunctionPointer) ::glTexBuffer }, - { "glTexBufferRange", (QFunctionPointer) ::glTexBufferRange }, - { "glTexStorage3DMultisample", (QFunctionPointer) ::glTexStorage3DMultisample }, -#endif // QT_CONFIG(opengles32) - }; - - for (size_t i = 0; i < sizeof(standardFuncs) / sizeof(StdFunc); ++i) { - if (!qstrcmp(procName, standardFuncs[i].name)) { - proc = standardFuncs[i].func; - break; - } - } - } -#endif - - return proc; -} - -QSurfaceFormat QEGLPlatformContext::format() const -{ - return m_format; -} - -EGLContext QEGLPlatformContext::eglContext() const -{ - return m_eglContext; -} - -EGLDisplay QEGLPlatformContext::eglDisplay() const -{ - return m_eglDisplay; -} - -EGLConfig QEGLPlatformContext::eglConfig() const -{ - return m_eglConfig; -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h deleted file mode 100644 index 610588568e..0000000000 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ /dev/null @@ -1,145 +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 QEGLPLATFORMCONTEXT_H -#define QEGLPLATFORMCONTEXT_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 <QtCore/qtextstream.h> -#include <qpa/qplatformwindow.h> -#include <qpa/qplatformopenglcontext.h> -#include <QtCore/QVariant> -#include <QtEglSupport/private/qt_egl_p.h> -#include <QtGui/private/qopenglcontext_p.h> - -QT_BEGIN_NAMESPACE - -class QEGLPlatformContext : public QPlatformOpenGLContext, - public QPlatformInterface::QEGLContext -{ -public: - enum Flag { - NoSurfaceless = 0x01 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, - EGLConfig *config = nullptr, Flags flags = { }); - - template <typename T> - static QOpenGLContext *createFrom(EGLContext context, EGLDisplay contextDisplay, - EGLDisplay platformDisplay, QOpenGLContext *shareContext) - { - if (!context) - return nullptr; - - // A context belonging to a given EGLDisplay cannot be used with another one - if (contextDisplay != platformDisplay) { - qWarning("QEGLPlatformContext: Cannot adopt context from different display"); - return nullptr; - } - - QPlatformOpenGLContext *shareHandle = shareContext ? shareContext->handle() : nullptr; - - auto *resultingContext = new QOpenGLContext; - auto *contextPrivate = QOpenGLContextPrivate::get(resultingContext); - auto *platformContext = new T; - platformContext->adopt(context, contextDisplay, shareHandle); - contextPrivate->adopt(platformContext); - return resultingContext; - } - - ~QEGLPlatformContext(); - - void initialize() override; - bool makeCurrent(QPlatformSurface *surface) override; - void doneCurrent() override; - void swapBuffers(QPlatformSurface *surface) override; - QFunctionPointer getProcAddress(const char *procName) override; - - QSurfaceFormat format() const override; - bool isSharing() const override { return m_shareContext != EGL_NO_CONTEXT; } - bool isValid() const override { return m_eglContext != EGL_NO_CONTEXT; } - - EGLContext nativeContext() const override { return eglContext(); } - - EGLContext eglContext() const; - EGLDisplay eglDisplay() const; - EGLConfig eglConfig() const; - -protected: - QEGLPlatformContext() {} // For adoption - virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0; - virtual EGLSurface createTemporaryOffscreenSurface(); - virtual void destroyTemporaryOffscreenSurface(EGLSurface surface); - virtual void runGLChecks(); - -private: - void adopt(EGLContext context, EGLDisplay display, QPlatformOpenGLContext *shareContext); - void updateFormatFromGL(); - - EGLContext m_eglContext; - EGLContext m_shareContext; - EGLDisplay m_eglDisplay; - EGLConfig m_eglConfig; - QSurfaceFormat m_format; - EGLenum m_api; - int m_swapInterval = -1; - bool m_swapIntervalEnvChecked = false; - int m_swapIntervalFromEnv = -1; - Flags m_flags; - bool m_ownsContext = false; - QVector<EGLint> m_contextAttrs; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QEGLPlatformContext::Flags) - -QT_END_NAMESPACE - -#endif //QEGLPLATFORMCONTEXT_H diff --git a/src/platformsupport/eglconvenience/qeglstreamconvenience.cpp b/src/platformsupport/eglconvenience/qeglstreamconvenience.cpp deleted file mode 100644 index 5c336f0553..0000000000 --- a/src/platformsupport/eglconvenience/qeglstreamconvenience.cpp +++ /dev/null @@ -1,123 +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 "qeglstreamconvenience_p.h" -#include <string.h> - -QT_BEGIN_NAMESPACE - -QEGLStreamConvenience::QEGLStreamConvenience() - : initialized(false), - has_egl_platform_device(false), - has_egl_device_base(false), - has_egl_stream(false), - has_egl_stream_producer_eglsurface(false), - has_egl_stream_consumer_egloutput(false), - has_egl_output_drm(false), - has_egl_output_base(false), - has_egl_stream_cross_process_fd(false), - has_egl_stream_consumer_gltexture(false) -{ - const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); - if (!extensions) { - qWarning("Failed to query EGL extensions"); - return; - } - - query_devices = reinterpret_cast<PFNEGLQUERYDEVICESEXTPROC>(eglGetProcAddress("eglQueryDevicesEXT")); - query_device_string = reinterpret_cast<PFNEGLQUERYDEVICESTRINGEXTPROC>(eglGetProcAddress("eglQueryDeviceStringEXT")); - get_platform_display = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT")); - - has_egl_device_base = strstr(extensions, "EGL_EXT_device_base"); - has_egl_platform_device = strstr(extensions, "EGL_EXT_platform_device"); -} - -void QEGLStreamConvenience::initialize(EGLDisplay dpy) -{ - if (initialized) - return; - - if (!eglBindAPI(EGL_OPENGL_ES_API)) { - qWarning("Failed to bind OpenGL ES API"); - return; - } - - const char *extensions = eglQueryString(dpy, EGL_EXTENSIONS); - if (!extensions) { - qWarning("Failed to query EGL extensions"); - return; - } - - create_stream = reinterpret_cast<PFNEGLCREATESTREAMKHRPROC>(eglGetProcAddress("eglCreateStreamKHR")); - destroy_stream = reinterpret_cast<PFNEGLDESTROYSTREAMKHRPROC>(eglGetProcAddress("eglDestroyStreamKHR")); - stream_attrib = reinterpret_cast<PFNEGLSTREAMATTRIBKHRPROC>(eglGetProcAddress("eglStreamAttribKHR")); - query_stream = reinterpret_cast<PFNEGLQUERYSTREAMKHRPROC>(eglGetProcAddress("eglQueryStreamKHR")); - query_stream_u64 = reinterpret_cast<PFNEGLQUERYSTREAMU64KHRPROC>(eglGetProcAddress("eglQueryStreamu64KHR")); - create_stream_producer_surface = reinterpret_cast<PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC>(eglGetProcAddress("eglCreateStreamProducerSurfaceKHR")); - stream_consumer_output = reinterpret_cast<PFNEGLSTREAMCONSUMEROUTPUTEXTPROC>(eglGetProcAddress("eglStreamConsumerOutputEXT")); - get_output_layers = reinterpret_cast<PFNEGLGETOUTPUTLAYERSEXTPROC>(eglGetProcAddress("eglGetOutputLayersEXT")); - get_output_ports = reinterpret_cast<PFNEGLGETOUTPUTPORTSEXTPROC>(eglGetProcAddress("eglGetOutputPortsEXT")); - output_layer_attrib = reinterpret_cast<PFNEGLOUTPUTLAYERATTRIBEXTPROC>(eglGetProcAddress("eglOutputLayerAttribEXT")); - query_output_layer_attrib = reinterpret_cast<PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC>(eglGetProcAddress("eglQueryOutputLayerAttribEXT")); - query_output_layer_string = reinterpret_cast<PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC>(eglGetProcAddress("eglQueryOutputLayerStringEXT")); - query_output_port_attrib = reinterpret_cast<PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC>(eglGetProcAddress("eglQueryOutputPortAttribEXT")); - query_output_port_string = reinterpret_cast<PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC>(eglGetProcAddress("eglQueryOutputPortStringEXT")); - get_stream_file_descriptor = reinterpret_cast<PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC>(eglGetProcAddress("eglGetStreamFileDescriptorKHR")); - create_stream_from_file_descriptor = reinterpret_cast<PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC>(eglGetProcAddress("eglCreateStreamFromFileDescriptorKHR")); - stream_consumer_gltexture = reinterpret_cast<PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC>(eglGetProcAddress("eglStreamConsumerGLTextureExternalKHR")); - stream_consumer_acquire = reinterpret_cast<PFNEGLSTREAMCONSUMERACQUIREKHRPROC>(eglGetProcAddress("eglStreamConsumerAcquireKHR")); - stream_consumer_release = reinterpret_cast<PFNEGLSTREAMCONSUMERRELEASEKHRPROC>(eglGetProcAddress("eglStreamConsumerReleaseKHR")); - create_stream_attrib_nv = reinterpret_cast<PFNEGLCREATESTREAMATTRIBNVPROC>(eglGetProcAddress("eglCreateStreamAttribNV")); - set_stream_attrib_nv = reinterpret_cast<PFNEGLSETSTREAMATTRIBNVPROC>(eglGetProcAddress("eglSetStreamAttribNV")); - query_stream_attrib_nv = reinterpret_cast<PFNEGLQUERYSTREAMATTRIBNVPROC>(eglGetProcAddress("eglQueryStreamAttribNV")); - acquire_stream_attrib_nv = reinterpret_cast<PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC>(eglGetProcAddress("eglStreamConsumerAcquireAttribNV")); - release_stream_attrib_nv = reinterpret_cast<PFNEGLSTREAMCONSUMERRELEASEATTRIBNVPROC>(eglGetProcAddress("eglStreamConsumerReleaseAttribNV")); - - has_egl_stream = strstr(extensions, "EGL_KHR_stream"); - has_egl_stream_producer_eglsurface = strstr(extensions, "EGL_KHR_stream_producer_eglsurface"); - has_egl_stream_consumer_egloutput = strstr(extensions, "EGL_EXT_stream_consumer_egloutput"); - has_egl_output_drm = strstr(extensions, "EGL_EXT_output_drm"); - has_egl_output_base = strstr(extensions, "EGL_EXT_output_base"); - has_egl_stream_cross_process_fd = strstr(extensions, "EGL_KHR_stream_cross_process_fd"); - has_egl_stream_consumer_gltexture = strstr(extensions, "EGL_KHR_stream_consumer_gltexture"); - - initialized = true; -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/qeglstreamconvenience_p.h b/src/platformsupport/eglconvenience/qeglstreamconvenience_p.h deleted file mode 100644 index c3d3070210..0000000000 --- a/src/platformsupport/eglconvenience/qeglstreamconvenience_p.h +++ /dev/null @@ -1,210 +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 QEGLSTREAMCONVENIENCE_H -#define QEGLSTREAMCONVENIENCE_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 <qglobal.h> -#include <QtEglSupport/private/qt_egl_p.h> - -// This provides runtime EGLDevice/Output/Stream support even when eglext.h in -// the sysroot is not up-to-date. - -#ifndef EGL_VERSION_1_5 -typedef intptr_t EGLAttrib; -#endif - -#ifndef EGL_EXT_platform_base -typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); -#endif - -#ifndef EGL_EXT_device_base -typedef void *EGLDeviceEXT; -#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); -typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); -#endif - -#ifndef EGL_EXT_output_base -typedef void *EGLOutputLayerEXT; -typedef void *EGLOutputPortEXT; -#define EGL_NO_OUTPUT_LAYER_EXT ((EGLOutputLayerEXT)0) -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); -typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); -typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); -#endif - -#ifndef EGL_KHR_stream -typedef void *EGLStreamKHR; -typedef quint64 EGLuint64KHR; -#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) -#define EGL_STREAM_STATE_KHR 0x3214 -#define EGL_STREAM_STATE_CREATED_KHR 0x3215 -#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 -#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 -#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 -#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 -#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A -#define EGL_BAD_STREAM_KHR 0x321B -#define EGL_BAD_STATE_KHR 0x321C -typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); -#endif - -#ifndef EGL_KHR_stream_fifo -#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC -#endif - -#ifndef EGL_KHR_stream_producer_eglsurface -#define EGL_STREAM_BIT_KHR 0x0800 -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); -#endif - -#ifndef EGL_KHR_stream_cross_process_fd -typedef int EGLNativeFileDescriptorKHR; -#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) -typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); -#endif - -#ifndef EGL_KHR_stream_consumer_gltexture -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -#endif - -#ifndef EGL_EXT_stream_consumer_egloutput -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); -#endif - -#ifndef EGL_EXT_platform_device -#define EGL_PLATFORM_DEVICE_EXT 0x313F -#endif - -#ifndef EGL_EXT_device_drm -#define EGL_DRM_DEVICE_FILE_EXT 0x3233 -#endif - -#ifndef EGL_EXT_output_drm -#define EGL_DRM_CRTC_EXT 0x3234 -#define EGL_DRM_PLANE_EXT 0x3235 -#endif - -#ifndef EGL_PLATFORM_X11_KHR -#define EGL_PLATFORM_X11_KHR 0x31D5 -#endif - -#ifndef EGL_NV_stream_attrib -typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBNVPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); -#endif - -QT_BEGIN_NAMESPACE - -class QEGLStreamConvenience -{ -public: - QEGLStreamConvenience(); - void initialize(EGLDisplay dpy); - - PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display; - PFNEGLQUERYDEVICESEXTPROC query_devices; - PFNEGLQUERYDEVICESTRINGEXTPROC query_device_string; - PFNEGLCREATESTREAMKHRPROC create_stream; - PFNEGLCREATESTREAMATTRIBNVPROC create_stream_attrib_nv; - PFNEGLSETSTREAMATTRIBNVPROC set_stream_attrib_nv; - PFNEGLQUERYSTREAMATTRIBNVPROC query_stream_attrib_nv; - PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC acquire_stream_attrib_nv; - PFNEGLSTREAMCONSUMERRELEASEATTRIBNVPROC release_stream_attrib_nv; - PFNEGLDESTROYSTREAMKHRPROC destroy_stream; - PFNEGLSTREAMATTRIBKHRPROC stream_attrib; - PFNEGLQUERYSTREAMKHRPROC query_stream; - PFNEGLQUERYSTREAMU64KHRPROC query_stream_u64; - PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC create_stream_producer_surface; - PFNEGLSTREAMCONSUMEROUTPUTEXTPROC stream_consumer_output; - PFNEGLGETOUTPUTLAYERSEXTPROC get_output_layers; - PFNEGLGETOUTPUTPORTSEXTPROC get_output_ports; - PFNEGLOUTPUTLAYERATTRIBEXTPROC output_layer_attrib; - PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC query_output_layer_attrib; - PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC query_output_layer_string; - PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC query_output_port_attrib; - PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC query_output_port_string; - PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC get_stream_file_descriptor; - PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC create_stream_from_file_descriptor; - PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC stream_consumer_gltexture; - PFNEGLSTREAMCONSUMERACQUIREKHRPROC stream_consumer_acquire; - PFNEGLSTREAMCONSUMERRELEASEKHRPROC stream_consumer_release; - - bool initialized; - - bool has_egl_platform_device; - bool has_egl_device_base; - bool has_egl_stream; - bool has_egl_stream_producer_eglsurface; - bool has_egl_stream_consumer_egloutput; - bool has_egl_output_drm; - bool has_egl_output_base; - bool has_egl_stream_cross_process_fd; - bool has_egl_stream_consumer_gltexture; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/platformsupport/eglconvenience/qt_egl_p.h b/src/platformsupport/eglconvenience/qt_egl_p.h deleted file mode 100644 index bf37d07fd8..0000000000 --- a/src/platformsupport/eglconvenience/qt_egl_p.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 QT_EGL_P_H -#define QT_EGL_P_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. -// - -#ifdef QT_EGL_NO_X11 -# ifndef EGL_NO_X11 -# define EGL_NO_X11 -# endif -# ifndef MESA_EGL_NO_X11_HEADERS -# define MESA_EGL_NO_X11_HEADERS // MESA -# endif -# if !defined(Q_OS_INTEGRITY) -# define WIN_INTERFACE_CUSTOM // NV -# endif // Q_OS_INTEGRITY -#endif // QT_EGL_NO_X11 - -#ifdef QT_EGL_WAYLAND -# define WAYLAND // NV -#endif // QT_EGL_WAYLAND - -#include <EGL/egl.h> -#include <EGL/eglext.h> - -#include <stdint.h> - -QT_BEGIN_NAMESPACE - -namespace QtInternal { - -template <class FromType, class ToType> -struct QtEglConverter -{ - static inline ToType convert(FromType v) - { return v; } -}; - -template <> -struct QtEglConverter<uint32_t, uintptr_t> -{ - static inline uintptr_t convert(uint32_t v) - { return v; } -}; - -#if QT_POINTER_SIZE > 4 -template <> -struct QtEglConverter<uintptr_t, uint32_t> -{ - static inline uint32_t convert(uintptr_t v) - { return uint32_t(v); } -}; -#endif - -template <> -struct QtEglConverter<uint32_t, void *> -{ - static inline void *convert(uint32_t v) - { return reinterpret_cast<void *>(uintptr_t(v)); } -}; - -template <> -struct QtEglConverter<void *, uint32_t> -{ - static inline uint32_t convert(void *v) - { return uintptr_t(v); } -}; - -} // QtInternal - -template <class ToType, class FromType> -static inline ToType qt_egl_cast(FromType from) -{ return QtInternal::QtEglConverter<FromType, ToType>::convert(from); } - -QT_END_NAMESPACE - -#endif // QT_EGL_P_H diff --git a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp b/src/platformsupport/eglconvenience/qxlibeglintegration.cpp deleted file mode 100644 index ac743e1e38..0000000000 --- a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp +++ /dev/null @@ -1,162 +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 <QLoggingCategory> -#include "qxlibeglintegration_p.h" - -Q_LOGGING_CATEGORY(lcXlibEglDebug, "qt.egl.xlib.debug") - -VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config) -{ - VisualID visualId = 0; - EGLint eglValue = 0; - - EGLint configRedSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize); - - EGLint configGreenSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &configGreenSize); - - EGLint configBlueSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &configBlueSize); - - EGLint configAlphaSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_ALPHA_SIZE, &configAlphaSize); - - eglGetConfigAttrib(eglDisplay, config, EGL_CONFIG_ID, &eglValue); - int configId = eglValue; - - // See if EGL provided a valid VisualID: - eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue); - visualId = (VisualID)eglValue; - if (visualId) { - // EGL has suggested a visual id, so get the rest of the visual info for that id: - XVisualInfo visualInfoTemplate; - memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - visualInfoTemplate.visualid = visualId; - - XVisualInfo *chosenVisualInfo; - int matchingCount = 0; - chosenVisualInfo = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &matchingCount); - if (chosenVisualInfo) { - // Skip size checks if implementation supports non-matching visual - // and config (QTBUG-9444). - if (q_hasEglExtension(eglDisplay,"EGL_NV_post_convert_rounding")) { - XFree(chosenVisualInfo); - return visualId; - } - // Skip also for i.MX6 where 565 visuals are suggested for the default 444 configs and it works just fine. - const char *vendor = eglQueryString(eglDisplay, EGL_VENDOR); - if (vendor && strstr(vendor, "Vivante")) { - XFree(chosenVisualInfo); - return visualId; - } - - int visualRedSize = qPopulationCount(chosenVisualInfo->red_mask); - int visualGreenSize = qPopulationCount(chosenVisualInfo->green_mask); - int visualBlueSize = qPopulationCount(chosenVisualInfo->blue_mask); - int visualAlphaSize = chosenVisualInfo->depth - visualRedSize - visualBlueSize - visualGreenSize; - - const bool visualMatchesConfig = visualRedSize >= configRedSize - && visualGreenSize >= configGreenSize - && visualBlueSize >= configBlueSize - && visualAlphaSize >= configAlphaSize; - - // In some cases EGL tends to suggest a 24-bit visual for 8888 - // configs. In such a case we have to fall back to XGetVisualInfo. - if (!visualMatchesConfig) { - visualId = 0; - qCDebug(lcXlibEglDebug, - "EGL suggested using X Visual ID %d (%d %d %d %d depth %d) for EGL config %d" - "(%d %d %d %d), but this is incompatible", - (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, visualAlphaSize, chosenVisualInfo->depth, - configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize); - } - } else { - qCDebug(lcXlibEglDebug, "EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID", - (int)visualId, configId); - visualId = 0; - } - XFree(chosenVisualInfo); - } - else - qCDebug(lcXlibEglDebug, "EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId); - - if (visualId) { - qCDebug(lcXlibEglDebug, configAlphaSize > 0 - ? "Using ARGB Visual ID %d provided by EGL for config %d" - : "Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId); - return visualId; - } - - // Finally, try to use XGetVisualInfo and only use the bit depths to match on: - if (!visualId) { - XVisualInfo visualInfoTemplate; - memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - XVisualInfo *matchingVisuals; - int matchingCount = 0; - - visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize; - matchingVisuals = XGetVisualInfo(display, - VisualDepthMask, - &visualInfoTemplate, - &matchingCount); - if (!matchingVisuals) { - // Try again without taking the alpha channel into account: - visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize; - matchingVisuals = XGetVisualInfo(display, - VisualDepthMask, - &visualInfoTemplate, - &matchingCount); - } - - if (matchingVisuals) { - visualId = matchingVisuals[0].visualid; - XFree(matchingVisuals); - } - } - - if (visualId) { - qCDebug(lcXlibEglDebug, "Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId); - return visualId; - } - - qWarning("Unable to find an X11 visual which matches EGL config %d", configId); - return (VisualID)0; -} diff --git a/src/platformsupport/eglconvenience/qxlibeglintegration_p.h b/src/platformsupport/eglconvenience/qxlibeglintegration_p.h deleted file mode 100644 index 899b217146..0000000000 --- a/src/platformsupport/eglconvenience/qxlibeglintegration_p.h +++ /dev/null @@ -1,65 +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 QTESTLITEEGLINTEGRATION_H -#define QTESTLITEEGLINTEGRATION_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 "qeglconvenience_p.h" -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -class QXlibEglIntegration -{ -public: - static VisualID getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config); -}; - -#endif // QTESTLITEEGLINTEGRATION_H diff --git a/src/platformsupport/fbconvenience/CMakeLists.txt b/src/platformsupport/fbconvenience/CMakeLists.txt index 804b2c15ec..7bd7daec0d 100644 --- a/src/platformsupport/fbconvenience/CMakeLists.txt +++ b/src/platformsupport/fbconvenience/CMakeLists.txt @@ -1,10 +1,12 @@ -# Generated from fbconvenience.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### -## FbSupport Module: +## FbSupportPrivate Module: ##################################################################### -qt_add_module(FbSupport +qt_internal_add_module(FbSupportPrivate + CONFIG_MODULE_NAME fb_support STATIC INTERNAL_MODULE SOURCES @@ -20,7 +22,5 @@ qt_add_module(FbSupport Qt::GuiPrivate PRECOMPILED_HEADER "../../corelib/global/qt_pch.h" + NO_GENERATE_CPP_EXPORTS ) - -#### Keys ignored in scope 1:.:.:fbconvenience.pro:<TRUE>: -# MODULE = "fb_support" diff --git a/src/platformsupport/fbconvenience/fbconvenience.pro b/src/platformsupport/fbconvenience/fbconvenience.pro deleted file mode 100644 index 3775906470..0000000000 --- a/src/platformsupport/fbconvenience/fbconvenience.pro +++ /dev/null @@ -1,24 +0,0 @@ -TARGET = QtFbSupport -MODULE = fb_support - -QT = core-private gui-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h - -SOURCES += \ - qfbscreen.cpp \ - qfbbackingstore.cpp \ - qfbwindow.cpp \ - qfbcursor.cpp \ - qfbvthandler.cpp - -HEADERS += \ - qfbscreen_p.h \ - qfbbackingstore_p.h \ - qfbwindow_p.h \ - qfbcursor_p.h \ - qfbvthandler_p.h - -load(qt_module) diff --git a/src/platformsupport/fbconvenience/qfbbackingstore.cpp b/src/platformsupport/fbconvenience/qfbbackingstore.cpp index e2d94406a4..8443c77dd3 100644 --- a/src/platformsupport/fbconvenience/qfbbackingstore.cpp +++ b/src/platformsupport/fbconvenience/qfbbackingstore.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qfbbackingstore_p.h" #include "qfbwindow_p.h" diff --git a/src/platformsupport/fbconvenience/qfbbackingstore_p.h b/src/platformsupport/fbconvenience/qfbbackingstore_p.h index c4762c9327..ead06bf55f 100644 --- a/src/platformsupport/fbconvenience/qfbbackingstore_p.h +++ b/src/platformsupport/fbconvenience/qfbbackingstore_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFBBACKINGSTORE_P_H #define QFBBACKINGSTORE_P_H @@ -53,6 +17,7 @@ #include <qpa/qplatformbackingstore.h> #include <QtCore/QMutex> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE diff --git a/src/platformsupport/fbconvenience/qfbcursor.cpp b/src/platformsupport/fbconvenience/qfbcursor.cpp index a300e3efcb..9f7e964760 100644 --- a/src/platformsupport/fbconvenience/qfbcursor.cpp +++ b/src/platformsupport/fbconvenience/qfbcursor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qfbcursor_p.h" #include "qfbscreen_p.h" @@ -69,7 +33,7 @@ QFbCursor::QFbCursor(QFbScreen *screen) if (!mVisible) return; - mCursorImage = new QPlatformCursorImage(0, 0, 0, 0, 0, 0); + mCursorImage.reset(new QPlatformCursorImage(0, 0, 0, 0, 0, 0)); setCursor(Qt::ArrowCursor); mDeviceListener = new QFbCursorDeviceListener(this); @@ -210,3 +174,5 @@ void QFbCursor::updateMouseStatus() } QT_END_NAMESPACE + +#include "moc_qfbcursor_p.cpp" diff --git a/src/platformsupport/fbconvenience/qfbcursor_p.h b/src/platformsupport/fbconvenience/qfbcursor_p.h index cc36a2411b..a118440ac9 100644 --- a/src/platformsupport/fbconvenience/qfbcursor_p.h +++ b/src/platformsupport/fbconvenience/qfbcursor_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFBCURSOR_P_H #define QFBCURSOR_P_H @@ -113,7 +77,7 @@ private: QRect mPrevRect; // last place the cursor was drawn bool mDirty; bool mOnScreen; - QPlatformCursorImage *mCursorImage; + QScopedPointer<QPlatformCursorImage> mCursorImage; QFbCursorDeviceListener *mDeviceListener; QPoint m_pos; }; diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index 76984dfe5c..85e2f57198 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qfbscreen_p.h" #include "qfbcursor_p.h" @@ -99,7 +63,7 @@ void QFbScreen::addWindow(QFbWindow *window) } setDirty(window->geometry()); QWindow *w = topWindow(); - QWindowSystemInterface::handleWindowActivated(w); + QWindowSystemInterface::handleFocusWindowChanged(w); topWindowChanged(w); } @@ -108,7 +72,7 @@ void QFbScreen::removeWindow(QFbWindow *window) mWindowStack.removeOne(window); setDirty(window->geometry()); QWindow *w = topWindow(); - QWindowSystemInterface::handleWindowActivated(w); + QWindowSystemInterface::handleFocusWindowChanged(w); topWindowChanged(w); } @@ -120,7 +84,7 @@ void QFbScreen::raise(QFbWindow *window) mWindowStack.move(index, 0); setDirty(window->geometry()); QWindow *w = topWindow(); - QWindowSystemInterface::handleWindowActivated(w); + QWindowSystemInterface::handleFocusWindowChanged(w); topWindowChanged(w); } @@ -132,7 +96,7 @@ void QFbScreen::lower(QFbWindow *window) mWindowStack.move(index, mWindowStack.size() - 1); setDirty(window->geometry()); QWindow *w = topWindow(); - QWindowSystemInterface::handleWindowActivated(w); + QWindowSystemInterface::handleFocusWindowChanged(w); topWindowChanged(w); } @@ -156,7 +120,7 @@ QWindow *QFbScreen::topLevelAt(const QPoint & p) const int QFbScreen::windowCount() const { - return mWindowStack.count(); + return mWindowStack.size(); } void QFbScreen::setDirty(const QRect &rect) @@ -246,7 +210,7 @@ QRegion QFbScreen::doRedraw() QFbWindow *QFbScreen::windowForId(WId wid) const { - for (int i = 0; i < mWindowStack.count(); ++i) { + for (int i = 0; i < mWindowStack.size(); ++i) { if (mWindowStack[i]->winId() == wid) return mWindowStack[i]; } @@ -259,3 +223,5 @@ QFbScreen::Flags QFbScreen::flags() const } QT_END_NAMESPACE + +#include "moc_qfbscreen_p.cpp" diff --git a/src/platformsupport/fbconvenience/qfbscreen_p.h b/src/platformsupport/fbconvenience/qfbscreen_p.h index eed615de36..82dd98fcf6 100644 --- a/src/platformsupport/fbconvenience/qfbscreen_p.h +++ b/src/platformsupport/fbconvenience/qfbscreen_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFBSCREEN_P_H #define QFBSCREEN_P_H diff --git a/src/platformsupport/fbconvenience/qfbvthandler.cpp b/src/platformsupport/fbconvenience/qfbvthandler.cpp index 8aab0bada4..0d835331d6 100644 --- a/src/platformsupport/fbconvenience/qfbvthandler.cpp +++ b/src/platformsupport/fbconvenience/qfbvthandler.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qfbvthandler_p.h" #include <QtCore/QSocketNotifier> @@ -210,3 +174,5 @@ void QFbVtHandler::handleInt() } QT_END_NAMESPACE + +#include "moc_qfbvthandler_p.cpp" diff --git a/src/platformsupport/fbconvenience/qfbvthandler_p.h b/src/platformsupport/fbconvenience/qfbvthandler_p.h index d565ec3632..8a1fb37a67 100644 --- a/src/platformsupport/fbconvenience/qfbvthandler_p.h +++ b/src/platformsupport/fbconvenience/qfbvthandler_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFBVTHANDLER_H #define QFBVTHANDLER_H diff --git a/src/platformsupport/fbconvenience/qfbwindow.cpp b/src/platformsupport/fbconvenience/qfbwindow.cpp index 9f5f87d9d6..54716cc497 100644 --- a/src/platformsupport/fbconvenience/qfbwindow.cpp +++ b/src/platformsupport/fbconvenience/qfbwindow.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qfbwindow_p.h" #include "qfbscreen_p.h" @@ -45,7 +9,7 @@ QT_BEGIN_NAMESPACE -static QBasicAtomicInt winIdGenerator = Q_BASIC_ATOMIC_INITIALIZER(0); +Q_CONSTINIT static QBasicAtomicInt winIdGenerator = Q_BASIC_ATOMIC_INITIALIZER(0); QFbWindow::QFbWindow(QWindow *window) : QPlatformWindow(window), mBackingStore(0), mWindowState(Qt::WindowNoState) @@ -138,14 +102,14 @@ void QFbWindow::lower() void QFbWindow::repaint(const QRegion ®ion) { const QRect currentGeometry = geometry(); - const QRect dirtyClient = region.boundingRect(); - const QRect dirtyRegion = dirtyClient.translated(currentGeometry.topLeft()); const QRect oldGeometryLocal = mOldGeometry; mOldGeometry = currentGeometry; // If this is a move, redraw the previous location if (oldGeometryLocal != currentGeometry) platformScreen()->setDirty(oldGeometryLocal); - platformScreen()->setDirty(dirtyRegion); + auto topLeft = currentGeometry.topLeft(); + for (auto rect : region) + platformScreen()->setDirty(rect.translated(topLeft)); } QT_END_NAMESPACE diff --git a/src/platformsupport/fbconvenience/qfbwindow_p.h b/src/platformsupport/fbconvenience/qfbwindow_p.h index 76b34ce041..8367a10bce 100644 --- a/src/platformsupport/fbconvenience/qfbwindow_p.h +++ b/src/platformsupport/fbconvenience/qfbwindow_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFBWINDOW_P_H #define QFBWINDOW_P_H @@ -52,6 +16,7 @@ // #include <qpa/qplatformwindow.h> +#include <private/qglobal_p.h> QT_BEGIN_NAMESPACE diff --git a/src/platformsupport/glxconvenience/.prev_CMakeLists.txt b/src/platformsupport/glxconvenience/.prev_CMakeLists.txt deleted file mode 100644 index d3d2c87910..0000000000 --- a/src/platformsupport/glxconvenience/.prev_CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Generated from glxconvenience.pro. - -##################################################################### -## GlxSupport Module: -##################################################################### - -qt_add_module(GlxSupport - STATIC - INTERNAL_MODULE - SOURCES - qglxconvenience.cpp qglxconvenience_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - X11::X11 -) - -#### Keys ignored in scope 1:.:.:glxconvenience.pro:<TRUE>: -# MODULE = "glx_support" diff --git a/src/platformsupport/glxconvenience/CMakeLists.txt b/src/platformsupport/glxconvenience/CMakeLists.txt deleted file mode 100644 index 00d2e6c754..0000000000 --- a/src/platformsupport/glxconvenience/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Generated from glxconvenience.pro. - -qt_find_package(X11) # special case - -##################################################################### -## GlxSupport Module: -##################################################################### - -qt_add_module(GlxSupport - STATIC - INTERNAL_MODULE - SOURCES - qglxconvenience.cpp qglxconvenience_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - X11::X11 -) - -#### Keys ignored in scope 1:.:.:glxconvenience.pro:<TRUE>: -# MODULE = "glx_support" diff --git a/src/platformsupport/glxconvenience/glxconvenience.pro b/src/platformsupport/glxconvenience/glxconvenience.pro deleted file mode 100644 index 1b9cf79080..0000000000 --- a/src/platformsupport/glxconvenience/glxconvenience.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = QtGlxSupport -MODULE = glx_support - -QT = core-private gui-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII - -QMAKE_USE += xlib - -HEADERS += qglxconvenience_p.h -SOURCES += qglxconvenience.cpp - -load(qt_module) diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp deleted file mode 100644 index 823adf52ea..0000000000 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ /dev/null @@ -1,463 +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$ -** -****************************************************************************/ - -// We have to include this before the X11 headers dragged in by -// qglxconvenience_p.h. -#include <QtCore/QByteArray> -#include <QtCore/QScopedPointer> - -#include <QtCore/qmetatype.h> -#include <QtCore/qtextstream.h> -#include "qglxconvenience_p.h" - -#include <QtCore/QLoggingCategory> -#include <QtCore/QVector> -#include <QtCore/QVarLengthArray> - -#include <GL/glxext.h> - -Q_LOGGING_CATEGORY(lcGlx, "qt.glx") - -enum { - XFocusOut = FocusOut, - XFocusIn = FocusIn, - XKeyPress = KeyPress, - XKeyRelease = KeyRelease, - XNone = None, - XRevertToParent = RevertToParent, - XGrayScale = GrayScale, - XCursorShape = CursorShape -}; -#undef FocusOut -#undef FocusIn -#undef KeyPress -#undef KeyRelease -#undef None -#undef RevertToParent -#undef GrayScale -#undef CursorShape - -#ifdef FontChange -#undef FontChange -#endif - -#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 -#endif - -QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit, int flags) -{ - QVector<int> spec; - - spec << GLX_LEVEL - << 0 - - << GLX_RENDER_TYPE - << GLX_RGBA_BIT - - << GLX_RED_SIZE - << qMax(1, format.redBufferSize()) - - << GLX_GREEN_SIZE - << qMax(1, format.greenBufferSize()) - - << GLX_BLUE_SIZE - << qMax(1, format.blueBufferSize()) - - << GLX_ALPHA_SIZE - << qMax(0, format.alphaBufferSize()); - - if (format.swapBehavior() != QSurfaceFormat::SingleBuffer) - spec << GLX_DOUBLEBUFFER - << True; - - if (format.stereo()) - spec << GLX_STEREO - << True; - - if (format.depthBufferSize() != -1) - spec << GLX_DEPTH_SIZE - << format.depthBufferSize(); - - if (format.stencilBufferSize() != -1) - spec << GLX_STENCIL_SIZE - << format.stencilBufferSize(); - - if (format.samples() > 1) - spec << GLX_SAMPLE_BUFFERS_ARB - << 1 - << GLX_SAMPLES_ARB - << format.samples(); - - if ((flags & QGLX_SUPPORTS_SRGB) && format.colorSpace() == QSurfaceFormat::sRGBColorSpace) - spec << GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB - << True; - - spec << GLX_DRAWABLE_TYPE - << drawableBit - - << XNone; - - return spec; -} - -namespace { -struct QXcbSoftwareOpenGLEnforcer { - QXcbSoftwareOpenGLEnforcer() { - // Allow forcing LIBGL_ALWAYS_SOFTWARE for Qt 5 applications only. - // This is most useful with drivers that only support OpenGL 1. - // We need OpenGL 2, but the user probably doesn't want - // LIBGL_ALWAYS_SOFTWARE in OpenGL 1 apps. - - if (!checkedForceSoftwareOpenGL) { - // If LIBGL_ALWAYS_SOFTWARE is already set, don't mess with it. - // We want to unset LIBGL_ALWAYS_SOFTWARE at the end so it does not - // get inherited by other processes, of course only if it wasn't - // already set before. - if (!qEnvironmentVariableIsEmpty("QT_XCB_FORCE_SOFTWARE_OPENGL") - && !qEnvironmentVariableIsSet("LIBGL_ALWAYS_SOFTWARE")) - forceSoftwareOpenGL = true; - - checkedForceSoftwareOpenGL = true; - } - - if (forceSoftwareOpenGL) - qputenv("LIBGL_ALWAYS_SOFTWARE", QByteArrayLiteral("1")); - } - - ~QXcbSoftwareOpenGLEnforcer() { - // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it - if (forceSoftwareOpenGL) - qunsetenv("LIBGL_ALWAYS_SOFTWARE"); - } - - static bool checkedForceSoftwareOpenGL; - static bool forceSoftwareOpenGL; -}; - -bool QXcbSoftwareOpenGLEnforcer::checkedForceSoftwareOpenGL = false; -bool QXcbSoftwareOpenGLEnforcer::forceSoftwareOpenGL = false; - -template <class T> -struct QXlibScopedPointerDeleter { - static inline void cleanup(T *pointer) { - if (pointer) - XFree(pointer); - } -}; - -template <class T> -using QXlibPointer = QScopedPointer<T, QXlibScopedPointerDeleter<T>>; - -template <class T> -using QXlibArrayPointer = QScopedArrayPointer<T, QXlibScopedPointerDeleter<T>>; -} - -GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format, bool highestPixelFormat, int drawableBit, int flags) -{ - QXcbSoftwareOpenGLEnforcer softwareOpenGLEnforcer; - - GLXFBConfig config = nullptr; - - do { - const QVector<int> spec = qglx_buildSpec(format, drawableBit, flags); - - int confcount = 0; - QXlibArrayPointer<GLXFBConfig> configs(glXChooseFBConfig(display, screen, spec.constData(), &confcount)); - - if (!config && confcount > 0) { - config = configs[0]; - if (highestPixelFormat && !format.hasAlpha()) - break; - } - - const int requestedRed = qMax(0, format.redBufferSize()); - const int requestedGreen = qMax(0, format.greenBufferSize()); - const int requestedBlue = qMax(0, format.blueBufferSize()); - const int requestedAlpha = qMax(0, format.alphaBufferSize()); - - GLXFBConfig compatibleCandidate = nullptr; - for (int i = 0; i < confcount; i++) { - GLXFBConfig candidate = configs[i]; - - if ((flags & QGLX_SUPPORTS_SRGB) && format.colorSpace() == QSurfaceFormat::sRGBColorSpace) { - int srgbCapable = 0; - glXGetFBConfigAttrib(display, candidate, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable); - if (!srgbCapable) - continue; - } - - QXlibPointer<XVisualInfo> visual(glXGetVisualFromFBConfig(display, candidate)); - if (!visual) - continue; - int actualRed; - int actualGreen; - int actualBlue; - int actualAlpha; - glXGetFBConfigAttrib(display, candidate, GLX_RED_SIZE, &actualRed); - glXGetFBConfigAttrib(display, candidate, GLX_GREEN_SIZE, &actualGreen); - glXGetFBConfigAttrib(display, candidate, GLX_BLUE_SIZE, &actualBlue); - glXGetFBConfigAttrib(display, candidate, GLX_ALPHA_SIZE, &actualAlpha); - // Sometimes the visuals don't have a depth that includes the alpha channel. - actualAlpha = qMin(actualAlpha, visual->depth - actualRed - actualGreen - actualBlue); - - if (requestedRed && actualRed < requestedRed) - continue; - if (requestedGreen && actualGreen < requestedGreen) - continue; - if (requestedBlue && actualBlue < requestedBlue) - continue; - if (requestedAlpha && actualAlpha < requestedAlpha) - continue; - if (!compatibleCandidate) // Only pick up the first compatible one offered by the server - compatibleCandidate = candidate; - - if (requestedRed && actualRed != requestedRed) - continue; - if (requestedGreen && actualGreen != requestedGreen) - continue; - if (requestedBlue && actualBlue != requestedBlue) - continue; - if (requestedAlpha && actualAlpha != requestedAlpha) - continue; - - return candidate; - } - if (compatibleCandidate) { - qCDebug(lcGlx) << "qglx_findConfig: Found non-matching but compatible FBConfig"; - return compatibleCandidate; - } - } while (qglx_reduceFormat(&format)); - - if (!config) - qCWarning(lcGlx) << "qglx_findConfig: Failed to finding matching FBConfig for" << format; - - return config; -} - -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *format, int drawableBit, int flags) -{ - Q_ASSERT(format); - - XVisualInfo *visualInfo = nullptr; - - GLXFBConfig config = qglx_findConfig(display, screen, *format, false, drawableBit, flags); - if (config) - visualInfo = glXGetVisualFromFBConfig(display, config); - - if (visualInfo) { - qglx_surfaceFormatFromGLXFBConfig(format, display, config, flags); - return visualInfo; - } - - // attempt to fall back to glXChooseVisual - do { - QVector<int> attribs = qglx_buildSpec(*format, drawableBit, flags); - visualInfo = glXChooseVisual(display, screen, attribs.data()); - - if (visualInfo) { - qglx_surfaceFormatFromVisualInfo(format, display, visualInfo, flags); - return visualInfo; - } - } while (qglx_reduceFormat(format)); - - return visualInfo; -} - -void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display, GLXFBConfig config, int flags) -{ - int redSize = 0; - int greenSize = 0; - int blueSize = 0; - int alphaSize = 0; - int depthSize = 0; - int stencilSize = 0; - int sampleBuffers = 0; - int sampleCount = 0; - int stereo = 0; - int srgbCapable = 0; - - glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); - glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); - glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); - glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); - glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); - glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); - glXGetFBConfigAttrib(display, config, GLX_SAMPLE_BUFFERS_ARB, &sampleBuffers); - glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); - if (flags & QGLX_SUPPORTS_SRGB) - glXGetFBConfigAttrib(display, config, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable); - - format->setRedBufferSize(redSize); - format->setGreenBufferSize(greenSize); - format->setBlueBufferSize(blueSize); - format->setAlphaBufferSize(alphaSize); - format->setDepthBufferSize(depthSize); - format->setStencilBufferSize(stencilSize); - if (sampleBuffers) { - glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); - format->setSamples(sampleCount); - } - format->setColorSpace(srgbCapable ? QSurfaceFormat::sRGBColorSpace : QSurfaceFormat::DefaultColorSpace); - - format->setStereo(stereo); -} - -void qglx_surfaceFormatFromVisualInfo(QSurfaceFormat *format, Display *display, XVisualInfo *visualInfo, int flags) -{ - int redSize = 0; - int greenSize = 0; - int blueSize = 0; - int alphaSize = 0; - int depthSize = 0; - int stencilSize = 0; - int sampleBuffers = 0; - int sampleCount = 0; - int stereo = 0; - int srgbCapable = 0; - - glXGetConfig(display, visualInfo, GLX_RED_SIZE, &redSize); - glXGetConfig(display, visualInfo, GLX_GREEN_SIZE, &greenSize); - glXGetConfig(display, visualInfo, GLX_BLUE_SIZE, &blueSize); - glXGetConfig(display, visualInfo, GLX_ALPHA_SIZE, &alphaSize); - glXGetConfig(display, visualInfo, GLX_DEPTH_SIZE, &depthSize); - glXGetConfig(display, visualInfo, GLX_STENCIL_SIZE, &stencilSize); - glXGetConfig(display, visualInfo, GLX_SAMPLE_BUFFERS_ARB, &sampleBuffers); - glXGetConfig(display, visualInfo, GLX_STEREO, &stereo); - if (flags & QGLX_SUPPORTS_SRGB) - glXGetConfig(display, visualInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable); - - format->setRedBufferSize(redSize); - format->setGreenBufferSize(greenSize); - format->setBlueBufferSize(blueSize); - format->setAlphaBufferSize(alphaSize); - format->setDepthBufferSize(depthSize); - format->setStencilBufferSize(stencilSize); - if (sampleBuffers) { - glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB, &sampleCount); - format->setSamples(sampleCount); - } - format->setColorSpace(srgbCapable ? QSurfaceFormat::sRGBColorSpace : QSurfaceFormat::DefaultColorSpace); - - format->setStereo(stereo); -} - -bool qglx_reduceFormat(QSurfaceFormat *format) -{ - Q_ASSERT(format); - if (std::max(std::max(format->redBufferSize(), format->greenBufferSize()), format->blueBufferSize()) > 8) { - if (format->alphaBufferSize() > 2) { - // First try to match 10 10 10 2 - format->setAlphaBufferSize(2); - return true; - } - - format->setRedBufferSize(std::min(format->redBufferSize(), 8)); - format->setGreenBufferSize(std::min(format->greenBufferSize(), 8)); - format->setBlueBufferSize(std::min(format->blueBufferSize(), 8)); - return true; - } - - if (format->redBufferSize() > 1) { - format->setRedBufferSize(1); - return true; - } - - if (format->greenBufferSize() > 1) { - format->setGreenBufferSize(1); - return true; - } - - if (format->blueBufferSize() > 1) { - format->setBlueBufferSize(1); - return true; - } - - if (format->swapBehavior() != QSurfaceFormat::SingleBuffer){ - format->setSwapBehavior(QSurfaceFormat::SingleBuffer); - return true; - } - - if (format->samples() > 1) { - format->setSamples(qMin(16, format->samples() / 2)); - return true; - } - - if (format->depthBufferSize() >= 32) { - format->setDepthBufferSize(24); - return true; - } - - if (format->depthBufferSize() > 1) { - format->setDepthBufferSize(1); - return true; - } - - if (format->depthBufferSize() > 0) { - format->setDepthBufferSize(0); - return true; - } - - if (format->hasAlpha()) { - format->setAlphaBufferSize(0); - return true; - } - - if (format->stencilBufferSize() > 1) { - format->setStencilBufferSize(1); - return true; - } - - if (format->stencilBufferSize() > 0) { - format->setStencilBufferSize(0); - return true; - } - - if (format->stereo()) { - format->setStereo(false); - return true; - } - - if (format->colorSpace() == QSurfaceFormat::sRGBColorSpace) { - format->setColorSpace(QSurfaceFormat::DefaultColorSpace); - return true; - } - - return false; -} diff --git a/src/platformsupport/glxconvenience/qglxconvenience_p.h b/src/platformsupport/glxconvenience/qglxconvenience_p.h deleted file mode 100644 index f9647bfd9a..0000000000 --- a/src/platformsupport/glxconvenience/qglxconvenience_p.h +++ /dev/null @@ -1,72 +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 QGLXCONVENIENCE_H -#define QGLXCONVENIENCE_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 <QSurfaceFormat> -#include <QVector> - -#include <X11/Xlib.h> -#include <GL/glx.h> - -enum QGlxFlags -{ - QGLX_SUPPORTS_SRGB = 0x01 -}; - -QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit = GLX_WINDOW_BIT, int flags = 0); -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *format, int drawableBit = GLX_WINDOW_BIT, int flags = 0); -GLXFBConfig qglx_findConfig(Display *display, int screen, QSurfaceFormat format, bool highestPixelFormat = false, int drawableBit = GLX_WINDOW_BIT, int flags = 0); -void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display, GLXFBConfig config, int flags = 0); -void qglx_surfaceFormatFromVisualInfo(QSurfaceFormat *format, Display *display, XVisualInfo *visualInfo, int flags = 0); -bool qglx_reduceFormat(QSurfaceFormat *format); - -#endif // QGLXCONVENIENCE_H diff --git a/src/platformsupport/input/.prev_CMakeLists.txt b/src/platformsupport/input/.prev_CMakeLists.txt deleted file mode 100644 index f8c05e9f97..0000000000 --- a/src/platformsupport/input/.prev_CMakeLists.txt +++ /dev/null @@ -1,102 +0,0 @@ -# Generated from input.pro. - -##################################################################### -## InputSupport Module: -##################################################################### - -qt_add_module(InputSupport - STATIC - INTERNAL_MODULE - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::DeviceDiscoverySupportPrivate - Qt::GuiPrivate - PRECOMPILED_HEADER - "../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 3:.:.:input-support.pro:<TRUE>: -# MODULE = "input_support" - -## Scopes: -##################################################################### - -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev - SOURCES - evdevkeyboard/qevdevkeyboard_defaultmap_p.h - evdevkeyboard/qevdevkeyboardhandler.cpp evdevkeyboard/qevdevkeyboardhandler_p.h - evdevkeyboard/qevdevkeyboardmanager.cpp evdevkeyboard/qevdevkeyboardmanager_p.h - evdevmouse/qevdevmousehandler.cpp evdevmouse/qevdevmousehandler_p.h - evdevmouse/qevdevmousemanager.cpp evdevmouse/qevdevmousemanager_p.h - evdevtouch/qevdevtouchhandler.cpp evdevtouch/qevdevtouchhandler_p.h - evdevtouch/qevdevtouchmanager.cpp evdevtouch/qevdevtouchmanager_p.h - INCLUDE_DIRECTORIES - evdevtouch/../shared -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_tabletevent - SOURCES - evdevtablet/qevdevtablethandler.cpp evdevtablet/qevdevtablethandler_p.h - evdevtablet/qevdevtabletmanager.cpp evdevtablet/qevdevtabletmanager_p.h -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_libudev AND QT_FEATURE_tabletevent - LIBRARIES - PkgConfig::Libudev -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_libudev - LIBRARIES - PkgConfig::Libudev -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_mtdev - LIBRARIES - PkgConfig::Mtdev -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_tslib - SOURCES - tslib/qtslib.cpp tslib/qtslib_p.h - PUBLIC_LIBRARIES - PkgConfig::Tslib -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_libinput - SOURCES - libinput/qlibinputhandler.cpp libinput/qlibinputhandler_p.h - libinput/qlibinputkeyboard.cpp libinput/qlibinputkeyboard_p.h - libinput/qlibinputpointer.cpp libinput/qlibinputpointer_p.h - libinput/qlibinputtouch.cpp libinput/qlibinputtouch_p.h - INCLUDE_DIRECTORIES - libinput/../shared - LIBRARIES - Libinput::Libinput - PkgConfig::Libudev -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_libinput AND QT_FEATURE_xkbcommon - LIBRARIES - XKB::XKB - PUBLIC_LIBRARIES - Qt::XkbCommonSupportPrivate -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev OR QT_FEATURE_libinput - SOURCES - shared/devicehandlerlist_p.h - shared/qevdevutil.cpp shared/qevdevutil_p.h - shared/qtouchoutputmapping.cpp shared/qtouchoutputmapping_p.h -) - -qt_extend_target(InputSupport CONDITION QT_FEATURE_integrityhid - SOURCES - integrityhid/qintegrityhidmanager.cpp integrityhid/qintegrityhidmanager.h - LIBRARIES - integrityhid -) -if(QT_FEATURE_xkbcommon) - add_subdirectory(xkbcommon) -endif() diff --git a/src/platformsupport/input/CMakeLists.txt b/src/platformsupport/input/CMakeLists.txt index 7ab93df062..b7ff09d827 100644 --- a/src/platformsupport/input/CMakeLists.txt +++ b/src/platformsupport/input/CMakeLists.txt @@ -1,15 +1,17 @@ -# Generated from input.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -qt_find_package(Libinput) # special case -qt_find_package(XKB) # special case -qt_find_package(Tslib) # special case -qt_find_package(Mtdev) # special case +qt_find_package(Libinput) +qt_find_package(XKB) +qt_find_package(Tslib) +qt_find_package(Mtdev) ##################################################################### -## InputSupport Module: +## InputSupportPrivate Module: ##################################################################### -qt_add_module(InputSupport +qt_internal_add_module(InputSupportPrivate + CONFIG_MODULE_NAME input_support STATIC INTERNAL_MODULE DEFINES @@ -20,15 +22,13 @@ qt_add_module(InputSupport Qt::GuiPrivate PRECOMPILED_HEADER "../../corelib/global/qt_pch.h" + NO_GENERATE_CPP_EXPORTS ) -#### Keys ignored in scope 3:.:.:input-support.pro:<TRUE>: -# MODULE = "input_support" - ## Scopes: ##################################################################### -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_evdev SOURCES evdevkeyboard/qevdevkeyboard_defaultmap_p.h evdevkeyboard/qevdevkeyboardhandler.cpp evdevkeyboard/qevdevkeyboardhandler_p.h @@ -36,40 +36,41 @@ qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev evdevmouse/qevdevmousehandler.cpp evdevmouse/qevdevmousehandler_p.h evdevmouse/qevdevmousemanager.cpp evdevmouse/qevdevmousemanager_p.h evdevtouch/qevdevtouchhandler.cpp evdevtouch/qevdevtouchhandler_p.h + evdevtouch/qevdevtouchfilter_p.h evdevtouch/qevdevtouchmanager.cpp evdevtouch/qevdevtouchmanager_p.h INCLUDE_DIRECTORIES evdevtouch/../shared ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_tabletevent +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_evdev AND QT_FEATURE_tabletevent SOURCES evdevtablet/qevdevtablethandler.cpp evdevtablet/qevdevtablethandler_p.h evdevtablet/qevdevtabletmanager.cpp evdevtablet/qevdevtabletmanager_p.h ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_libudev AND QT_FEATURE_tabletevent +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_evdev AND QT_FEATURE_libudev AND QT_FEATURE_tabletevent LIBRARIES PkgConfig::Libudev ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_libudev +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_evdev AND QT_FEATURE_libudev LIBRARIES PkgConfig::Libudev ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev AND QT_FEATURE_mtdev +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_evdev AND QT_FEATURE_mtdev LIBRARIES PkgConfig::Mtdev ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_tslib +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_tslib SOURCES tslib/qtslib.cpp tslib/qtslib_p.h PUBLIC_LIBRARIES PkgConfig::Tslib ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_libinput +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_libinput SOURCES libinput/qlibinputhandler.cpp libinput/qlibinputhandler_p.h libinput/qlibinputkeyboard.cpp libinput/qlibinputkeyboard_p.h @@ -82,26 +83,21 @@ qt_extend_target(InputSupport CONDITION QT_FEATURE_libinput PkgConfig::Libudev ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_libinput AND QT_FEATURE_xkbcommon +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_libinput AND QT_FEATURE_xkbcommon LIBRARIES XKB::XKB - PUBLIC_LIBRARIES - Qt::XkbCommonSupportPrivate ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_evdev OR QT_FEATURE_libinput +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_evdev OR QT_FEATURE_libinput SOURCES shared/devicehandlerlist_p.h shared/qevdevutil.cpp shared/qevdevutil_p.h - shared/qtouchoutputmapping.cpp shared/qtouchoutputmapping_p.h + shared/qoutputmapping.cpp shared/qoutputmapping_p.h ) -qt_extend_target(InputSupport CONDITION QT_FEATURE_integrityhid +qt_internal_extend_target(InputSupportPrivate CONDITION QT_FEATURE_integrityhid SOURCES integrityhid/qintegrityhidmanager.cpp integrityhid/qintegrityhidmanager.h LIBRARIES integrityhid ) -if(QT_FEATURE_xkbcommon) - add_subdirectory(xkbcommon) -endif() diff --git a/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri b/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri deleted file mode 100644 index 445f230fa5..0000000000 --- a/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS += \ - $$PWD/qevdevkeyboard_defaultmap_p.h \ - $$PWD/qevdevkeyboardhandler_p.h \ - $$PWD/qevdevkeyboardmanager_p.h - -SOURCES += \ - $$PWD/qevdevkeyboardhandler.cpp \ - $$PWD/qevdevkeyboardmanager.cpp - -qtConfig(libudev): \ - QMAKE_USE_PRIVATE += libudev diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h index 17bf0fb797..02ed8463e3 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVKEYBOARDHANDLER_DEFAULTMAP_P_H #define QEVDEVKEYBOARDHANDLER_DEFAULTMAP_P_H @@ -52,6 +16,7 @@ // #include "qnamespace.h" +#include "private/qglobal_p.h" #ifdef Q_OS_FREEBSD #include <dev/evdev/input.h> #else diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index d951688b4f..48fba79958 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -1,43 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevkeyboardhandler_p.h" +#include "qoutputmapping_p.h" #include <qplatformdefs.h> @@ -68,6 +33,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(qLcEvdevKey, "qt.qpa.input") Q_LOGGING_CATEGORY(qLcEvdevKeyMap, "qt.qpa.input.keymap") @@ -89,7 +56,7 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer { qCDebug(qLcEvdevKey) << "Create keyboard handler with for device" << device; - setObjectName(QLatin1String("LinuxInput Keyboard Handler")); + setObjectName("LinuxInput Keyboard Handler"_L1); memset(m_locks, 0, sizeof(m_locks)); @@ -120,25 +87,29 @@ std::unique_ptr<QEvdevKeyboardHandler> QEvdevKeyboardHandler::create(const QStri bool enableCompose = false; int grab = 0; - const auto args = QStringView{specification}.split(QLatin1Char(':')); + const auto args = QStringView{specification}.split(u':'); for (const auto &arg : args) { - if (arg.startsWith(QLatin1String("keymap="))) + if (arg.startsWith("keymap="_L1)) keymapFile = arg.mid(7).toString(); - else if (arg == QLatin1String("disable-zap")) + else if (arg == "disable-zap"_L1) disableZap = true; - else if (arg == QLatin1String("enable-compose")) + else if (arg == "enable-compose"_L1) enableCompose = true; - else if (arg.startsWith(QLatin1String("repeat-delay="))) + else if (arg.startsWith("repeat-delay="_L1)) repeatDelay = arg.mid(13).toInt(); - else if (arg.startsWith(QLatin1String("repeat-rate="))) + else if (arg.startsWith("repeat-rate="_L1)) repeatRate = arg.mid(12).toInt(); - else if (arg.startsWith(QLatin1String("grab="))) + else if (arg.startsWith("grab="_L1)) grab = arg.mid(5).toInt(); } qCDebug(qLcEvdevKey, "Opening keyboard at %ls", qUtf16Printable(device)); - QFdContainer fd(qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0)); + QFdContainer fd(qt_safe_open(device.toLocal8Bit().constData(), O_RDWR | O_NDELAY, 0)); + if (fd.get() < 0) { + qCDebug(qLcEvdevKey, "Keyboard device could not be opened as read-write, trying read-only"); + fd.reset(qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0)); + } if (fd.get() >= 0) { ::ioctl(fd.get(), EVIOCGRAB, grab); if (repeatDelay > 0 && repeatRate > 0) { @@ -240,7 +211,11 @@ void QEvdevKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtc if (!autoRepeat) QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(QEvdevKeyboardHandler::toQtModifiers(m_modifiers)); - QWindowSystemInterface::handleExtendedKeyEvent(0, (isPress ? QEvent::KeyPress : QEvent::KeyRelease), + QWindow *window = nullptr; +#ifdef Q_OS_WEBOS + window = QOutputMapping::get()->windowForDeviceNode(m_device); +#endif + QWindowSystemInterface::handleExtendedKeyEvent(window, (isPress ? QEvent::KeyPress : QEvent::KeyRelease), qtcode, modifiers, nativecode + 8, 0, int(modifiers), (unicode != 0xffff ) ? QString(QChar(unicode)) : QString(), autoRepeat); } @@ -250,8 +225,8 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint KeycodeAction result = None; bool first_press = pressed && !autorepeat; - const QEvdevKeyboardMap::Mapping *map_plain = 0; - const QEvdevKeyboardMap::Mapping *map_withmod = 0; + const QEvdevKeyboardMap::Mapping *map_plain = nullptr; + const QEvdevKeyboardMap::Mapping *map_withmod = nullptr; quint8 modifiers = m_modifiers; diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index f92a2bf704..1d991e2ba5 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVKEYBOARDHANDLER_P_H #define QEVDEVKEYBOARDHANDLER_P_H @@ -54,6 +18,7 @@ #include <qobject.h> #include <QTimer> #include <QDataStream> +#include <private/qglobal_p.h> #include <memory> @@ -136,13 +101,14 @@ class QFdContainer int m_fd; Q_DISABLE_COPY_MOVE(QFdContainer); public: - explicit QFdContainer(int fd = -1) noexcept : m_fd(fd) {} + Q_NODISCARD_CTOR explicit QFdContainer(int fd = -1) noexcept : m_fd(fd) {} ~QFdContainer() { reset(); } int get() const noexcept { return m_fd; } int release() noexcept { int result = m_fd; m_fd = -1; return result; } void reset() noexcept; + void reset(int fd) { reset(); m_fd = fd; } }; class QEvdevKeyboardHandler : public QObject diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index 7080245d3b..43717c4e81 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevkeyboardmanager_p.h" @@ -50,6 +14,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_DECLARE_LOGGING_CATEGORY(qLcEvdevKey) QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent) @@ -67,7 +33,7 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & m_spec = std::move(parsed.spec); // add all keyboards for devices specified in the argument list - for (const QString &device : qAsConst(parsed.devices)) + for (const QString &device : std::as_const(parsed.devices)) addKeyboard(device); if (parsed.devices.isEmpty()) { @@ -124,9 +90,9 @@ void QEvdevKeyboardManager::loadKeymap(const QString &file) // Restore the default, which is either the built-in keymap or // the one given in the plugin spec. QString keymapFromSpec; - const auto specs = QStringView{m_spec}.split(QLatin1Char(':')); + const auto specs = QStringView{m_spec}.split(u':'); for (const auto &arg : specs) { - if (arg.startsWith(QLatin1String("keymap="))) + if (arg.startsWith("keymap="_L1)) keymapFromSpec = arg.mid(7).toString(); } for (const auto &keyboard : m_keyboards) { diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h index d91da330c3..d3f75f8367 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVKEYBOARDMANAGER_P_H #define QEVDEVKEYBOARDMANAGER_P_H diff --git a/src/platformsupport/input/evdevmouse/evdevmouse.pri b/src/platformsupport/input/evdevmouse/evdevmouse.pri deleted file mode 100644 index a8c9c663f3..0000000000 --- a/src/platformsupport/input/evdevmouse/evdevmouse.pri +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS += \ - $$PWD/qevdevmousehandler_p.h \ - $$PWD/qevdevmousemanager_p.h - -SOURCES += \ - $$PWD/qevdevmousehandler.cpp \ - $$PWD/qevdevmousemanager.cpp - -qtConfig(libudev): \ - QMAKE_USE_PRIVATE += libudev - diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index 5d6f20bd1a..8d98cb1e8c 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevmousehandler_p.h" @@ -64,6 +28,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(qLcEvdevMouse, "qt.qpa.input") std::unique_ptr<QEvdevMouseHandler> QEvdevMouseHandler::create(const QString &device, const QString &specification) @@ -75,15 +41,15 @@ std::unique_ptr<QEvdevMouseHandler> QEvdevMouseHandler::create(const QString &de int grab = 0; bool abs = false; - const auto args = QStringView{specification}.split(QLatin1Char(':')); + const auto args = QStringView{specification}.split(u':'); for (const auto &arg : args) { - if (arg == QLatin1String("nocompress")) + if (arg == "nocompress"_L1) compression = false; - else if (arg.startsWith(QLatin1String("dejitter="))) + else if (arg.startsWith("dejitter="_L1)) jitterLimit = arg.mid(9).toInt(); - else if (arg.startsWith(QLatin1String("grab="))) + else if (arg.startsWith("grab="_L1)) grab = arg.mid(5).toInt(); - else if (arg == QLatin1String("abs")) + else if (arg == "abs"_L1) abs = true; } @@ -101,7 +67,7 @@ std::unique_ptr<QEvdevMouseHandler> QEvdevMouseHandler::create(const QString &de QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit) : m_device(device), m_fd(fd), m_abs(abs), m_compression(compression) { - setObjectName(QLatin1String("Evdev Mouse Handler")); + setObjectName("Evdev Mouse Handler"_L1); m_jitterLimitSquared = jitterLimit * jitterLimit; @@ -204,7 +170,10 @@ void QEvdevMouseHandler::sendMouseEvent() m_prevInvalid = false; } - emit handleMouseEvent(x, y, m_abs, m_buttons, m_button, m_eventType); + if (m_eventType == QEvent::MouseMove) + emit handleMouseEvent(x, y, m_abs, m_buttons, Qt::NoButton, m_eventType); + else + emit handleMouseEvent(x, y, m_abs, m_buttons, m_button, m_eventType); m_prevx = m_x; m_prevy = m_y; @@ -216,7 +185,6 @@ void QEvdevMouseHandler::readMouseData() int n = 0; bool posChanged = false, btnChanged = false; bool pendingMouseEvent = false; - int eventCompressCount = 0; forever { int result = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n); @@ -323,7 +291,6 @@ void QEvdevMouseHandler::readMouseData() posChanged = false; if (m_compression) { pendingMouseEvent = true; - eventCompressCount++; } else { sendMouseEvent(); } @@ -341,3 +308,5 @@ void QEvdevMouseHandler::readMouseData() } QT_END_NAMESPACE + +#include "moc_qevdevmousehandler_p.cpp" diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 8fcf49200b..a49ff10256 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVMOUSEHANDLER_P_H #define QEVDEVMOUSEHANDLER_P_H @@ -55,6 +19,7 @@ #include <QString> #include <QPoint> #include <QEvent> +#include <private/qglobal_p.h> #include <memory> diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index 108d03fac6..55b127ef17 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevmousemanager_p.h" @@ -53,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_DECLARE_LOGGING_CATEGORY(qLcEvdevMouse) QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent) @@ -68,16 +34,16 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif auto parsed = QEvdevUtil::parseSpecification(spec); m_spec = std::move(parsed.spec); - for (const auto &arg : qAsConst(parsed.args)) { - if (arg.startsWith(QLatin1String("xoffset="))) { + for (const auto &arg : std::as_const(parsed.args)) { + if (arg.startsWith("xoffset="_L1)) { m_xoffset = arg.mid(8).toInt(); - } else if (arg.startsWith(QLatin1String("yoffset="))) { + } else if (arg.startsWith("yoffset="_L1)) { m_yoffset = arg.mid(8).toInt(); } } // add all mice for devices specified in the argument list - for (const QString &device : qAsConst(parsed.devices)) + for (const QString &device : std::as_const(parsed.devices)) addMouse(device); if (parsed.devices.isEmpty()) { @@ -96,7 +62,7 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif } QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager(); - connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [this](const QPoint &pos) { + connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, this, [this](const QPoint &pos) { m_x = pos.x(); m_y = pos.y(); clampPosition(); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h index f5c32ed8b5..5467513cd4 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVMOUSEMANAGER_P_H #define QEVDEVMOUSEMANAGER_P_H diff --git a/src/platformsupport/input/evdevtablet/evdevtablet.pri b/src/platformsupport/input/evdevtablet/evdevtablet.pri deleted file mode 100644 index ea1712ad2f..0000000000 --- a/src/platformsupport/input/evdevtablet/evdevtablet.pri +++ /dev/null @@ -1,10 +0,0 @@ -HEADERS += \ - $$PWD/qevdevtablethandler_p.h \ - $$PWD/qevdevtabletmanager_p.h - -SOURCES += \ - $$PWD/qevdevtablethandler.cpp \ - $$PWD/qevdevtabletmanager.cpp - -qtConfig(libudev): \ - QMAKE_USE_PRIVATE += libudev diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp index 7ed068c5cc..109ab0f212 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevtablethandler_p.h" @@ -54,6 +18,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(qLcEvdevTablet, "qt.qpa.input") class QEvdevTabletData @@ -169,9 +135,9 @@ void QEvdevTabletData::report() QEvdevTabletHandler::QEvdevTabletHandler(const QString &device, const QString &spec, QObject *parent) : QObject(parent), m_fd(-1), m_device(device), m_notifier(0), d(0) { - Q_UNUSED(spec) + Q_UNUSED(spec); - setObjectName(QLatin1String("Evdev Tablet Handler")); + setObjectName("Evdev Tablet Handler"_L1); qCDebug(qLcEvdevTablet, "evdevtablet: using %ls", qUtf16Printable(device)); diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h index b83bb21258..205d629397 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVTABLETHANDLER_P_H #define QEVDEVTABLETHANDLER_P_H diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp index d9888c5b97..a270f9700d 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevtabletmanager_p.h" #include "qevdevtablethandler_p.h" @@ -48,7 +12,6 @@ #include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h> #include <private/qguiapplication_p.h> #include <private/qinputdevicemanager_p_p.h> -#include <private/qmemory_p.h> QT_BEGIN_NAMESPACE @@ -70,7 +33,7 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec auto parsed = QEvdevUtil::parseSpecification(spec); m_spec = std::move(parsed.spec); - for (const QString &device : qAsConst(parsed.devices)) + for (const QString &device : std::as_const(parsed.devices)) addDevice(device); // when no devices specified, use device discovery to scan and monitor @@ -96,7 +59,7 @@ QEvdevTabletManager::~QEvdevTabletManager() void QEvdevTabletManager::addDevice(const QString &deviceNode) { qCDebug(qLcEvdevTablet, "Adding device at %ls", qUtf16Printable(deviceNode)); - auto handler = qt_make_unique<QEvdevTabletHandlerThread>(deviceNode, m_spec); + auto handler = std::make_unique<QEvdevTabletHandlerThread>(deviceNode, m_spec); if (handler) { m_activeDevices.add(deviceNode, std::move(handler)); updateDeviceCount(); diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h index bb18ffba04..08bc2cfaa4 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVTABLETMANAGER_P_H #define QEVDEVTABLETMANAGER_P_H diff --git a/src/platformsupport/input/evdevtouch/evdevtouch.pri b/src/platformsupport/input/evdevtouch/evdevtouch.pri deleted file mode 100644 index 0ad236e882..0000000000 --- a/src/platformsupport/input/evdevtouch/evdevtouch.pri +++ /dev/null @@ -1,16 +0,0 @@ -HEADERS += \ - $$PWD/qevdevtouchhandler_p.h \ - $$PWD/qevdevtouchmanager_p.h - -SOURCES += \ - $$PWD/qevdevtouchhandler.cpp \ - $$PWD/qevdevtouchmanager.cpp - -INCLUDEPATH += $$PWD/../shared - -qtConfig(libudev): \ - QMAKE_USE_PRIVATE += libudev - -qtConfig(mtdev) { - QMAKE_USE_PRIVATE += mtdev -} diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchfilter_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchfilter_p.h index ff6085d725..9d181dc651 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchfilter_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchfilter_p.h @@ -1,43 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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 <qglobal.h> +// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include <private/qglobal_p.h> // // W A R N I N G diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 5a964c0a17..1b0da6297b 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -1,45 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevtouchhandler_p.h" -#include "qtouchoutputmapping_p.h" +#include "qoutputmapping_p.h" #include <QStringList> #include <QHash> #include <QSocketNotifier> @@ -49,6 +13,9 @@ #include <QtGui/qpointingdevice.h> #include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qpointingdevice_p.h> + +#include <QtCore/qpointer.h> #include <mutex> @@ -76,6 +43,8 @@ extern "C" { QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input") Q_LOGGING_CATEGORY(qLcEvents, "qt.qpa.input.events") @@ -126,8 +95,7 @@ public: int y = 0; int maj = -1; int pressure = 0; - Qt::TouchPointState state = Qt::TouchPointPressed; - QTouchEvent::TouchPoint::InfoFlags flags; + QEventPoint::State state = QEventPoint::State::Pressed; }; QHash<int, Contact> m_contacts; // The key is a tracking id for type A, slot number for type B. QHash<int, Contact> m_lastContacts; @@ -138,7 +106,7 @@ public: double m_lastTimeStamp; int findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist); - void addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates); + void addTouchPoint(const Contact &contact, QEventPoint::States *combinedStates); void reportPoints(); void loadMultiScreenMappings(); @@ -184,12 +152,12 @@ QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, co m_filtered(false), m_prediction(0) { for (const QString &arg : args) { - if (arg == QStringLiteral("force_window")) + if (arg == u"force_window") m_forceToActiveWindow = true; - else if (arg == QStringLiteral("filtered")) + else if (arg == u"filtered") m_filtered = true; - else if (arg.startsWith(QStringLiteral("prediction="))) - m_prediction = arg.mid(11).toInt(); + else if (const QStringView prefix = u"prediction="; arg.startsWith(prefix)) + m_prediction = QStringView(arg).mid(prefix.size()).toInt(); } } @@ -209,15 +177,15 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const , m_mtdev(nullptr) #endif { - setObjectName(QLatin1String("Evdev Touch Handler")); + setObjectName("Evdev Touch Handler"_L1); - const QStringList args = spec.split(QLatin1Char(':')); + const QStringList args = spec.split(u':'); int rotationAngle = 0; bool invertx = false; bool inverty = false; - for (int i = 0; i < args.count(); ++i) { - if (args.at(i).startsWith(QLatin1String("rotate"))) { - QString rotateArg = args.at(i).section(QLatin1Char('='), 1, 1); + for (int i = 0; i < args.size(); ++i) { + if (args.at(i).startsWith("rotate"_L1)) { + QString rotateArg = args.at(i).section(u'=', 1, 1); bool ok; uint argValue = rotateArg.toUInt(&ok); if (ok) { @@ -226,13 +194,14 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const case 180: case 270: rotationAngle = argValue; + break; default: break; } } - } else if (args.at(i) == QLatin1String("invertx")) { + } else if (args.at(i) == "invertx"_L1) { invertx = true; - } else if (args.at(i) == QLatin1String("inverty")) { + } else if (args.at(i) == "inverty"_L1) { inverty = true; } } @@ -255,6 +224,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const if (mtdeverr) { qWarning("evdevtouch: mtdev_open failed: %d", mtdeverr); QT_CLOSE(m_fd); + free(m_mtdev); return; } #endif @@ -322,7 +292,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const } // Fix up the coordinate ranges for am335x in case the kernel driver does not have them fixed. - if (d->hw_name == QLatin1String("ti-tsc")) { + if (d->hw_name == "ti-tsc"_L1) { if (d->hw_range_x_min == 0 && d->hw_range_x_max == 4095) { d->hw_range_x_min = 165; d->hw_range_x_max = 4016; @@ -350,9 +320,9 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const if (inverty) d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5); - QTouchOutputMapping mapping; - if (mapping.load()) { - d->m_screenName = mapping.screenNameForDeviceNode(d->deviceNode); + QOutputMapping *mapping = QOutputMapping::get(); + if (mapping->load()) { + d->m_screenName = mapping->screenNameForDeviceNode(d->deviceNode); if (!d->m_screenName.isEmpty()) qCDebug(qLcEvdevTouch, "evdevtouch: Mapping device %ls to screen %ls", qUtf16Printable(d->deviceNode), qUtf16Printable(d->m_screenName)); @@ -465,20 +435,61 @@ void QEvdevTouchScreenHandler::registerPointingDevice() m_device = new QPointingDevice(d->hw_name, id++, QInputDevice::DeviceType::TouchScreen, QPointingDevice::PointerType::Finger, caps, 16, 0); + + auto geom = d->screenGeometry(); + if (!geom.isNull()) + QPointingDevicePrivate::get(m_device)->setAvailableVirtualGeometry(geom); + QWindowSystemInterface::registerInputDevice(m_device); } +/*! \internal + + QEvdevTouchScreenHandler::unregisterPointingDevice can be called by several cases. + + First of all, the case that an application is terminated, and destroy all input devices + immediately to unregister in this case. + + Secondly, the case that removing a device without touch events for the device while the + application is still running. In this case, the destructor of QEvdevTouchScreenHandler from + the connection with QDeviceDiscovery::deviceRemoved in QEvdevTouchManager calls this method. + And this method moves a device into the main thread and then deletes it later but there is no + touch events for the device so that the device would be deleted in appropriate time. + + Finally, this case is similar as the second one but with touch events, that is, a device is + removed while touch events are given to the device and the application is still running. + In this case, this method is called by readData with ENODEV error and the destructor of + QEvdevTouchScreenHandler. So in order to prevent accessing the device which is already nullptr, + check the nullity of a device first. And as same as the second case, move the device into the + main thread and then delete it later. But in this case, cannot guarantee which event is + handled first since the list or queue where posting QDeferredDeleteEvent and appending touch + events are different. + If touch events are handled first, there is no problem because the device which is used for + these events is registered. However if QDeferredDeleteEvent for deleting the device is + handled first, this may cause a crash due to using unregistered device when processing touch + events later. In order to prevent processing such touch events, check a device which is used + for touch events is registered when processing touch events. + + see QGuiApplicationPrivate::processTouchEvent(). + */ void QEvdevTouchScreenHandler::unregisterPointingDevice() { - delete m_device; + if (!m_device) + return; + + if (QGuiApplication::instance()) { + m_device->moveToThread(QGuiApplication::instance()->thread()); + m_device->deleteLater(); + } else { + delete m_device; + } m_device = nullptr; } -void QEvdevTouchScreenData::addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates) +void QEvdevTouchScreenData::addTouchPoint(const Contact &contact, QEventPoint::States *combinedStates) { QWindowSystemInterface::TouchPoint tp; tp.id = contact.trackingId; - tp.flags = contact.flags; tp.state = contact.state; *combinedStates |= tp.state; @@ -509,8 +520,8 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) m_contacts[m_currentSlot].x = m_currentData.x; if (m_typeB) { m_contacts[m_currentSlot].x = m_currentData.x; - if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary) - m_contacts[m_currentSlot].state = Qt::TouchPointMoved; + if (m_contacts[m_currentSlot].state == QEventPoint::State::Stationary) + m_contacts[m_currentSlot].state = QEventPoint::State::Updated; } } else if (data->code == ABS_MT_POSITION_Y || (m_singleTouch && data->code == ABS_Y)) { m_currentData.y = qBound(hw_range_y_min, data->value, hw_range_y_max); @@ -518,23 +529,23 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) m_contacts[m_currentSlot].y = m_currentData.y; if (m_typeB) { m_contacts[m_currentSlot].y = m_currentData.y; - if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary) - m_contacts[m_currentSlot].state = Qt::TouchPointMoved; + if (m_contacts[m_currentSlot].state == QEventPoint::State::Stationary) + m_contacts[m_currentSlot].state = QEventPoint::State::Updated; } } else if (data->code == ABS_MT_TRACKING_ID) { m_currentData.trackingId = data->value; if (m_typeB) { if (m_currentData.trackingId == -1) { - m_contacts[m_currentSlot].state = Qt::TouchPointReleased; + m_contacts[m_currentSlot].state = QEventPoint::State::Released; } else { - m_contacts[m_currentSlot].state = Qt::TouchPointPressed; + m_contacts[m_currentSlot].state = QEventPoint::State::Pressed; m_contacts[m_currentSlot].trackingId = m_currentData.trackingId; } } } else if (data->code == ABS_MT_TOUCH_MAJOR) { m_currentData.maj = data->value; if (data->value == 0) - m_currentData.state = Qt::TouchPointReleased; + m_currentData.state = QEventPoint::State::Released; if (m_typeB) m_contacts[m_currentSlot].maj = m_currentData.maj; } else if (data->code == ABS_PRESSURE || data->code == ABS_MT_PRESSURE) { @@ -550,14 +561,14 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) } else if (data->type == EV_KEY && !m_typeB) { if (data->code == BTN_TOUCH && data->value == 0) - m_contacts[m_currentSlot].state = Qt::TouchPointReleased; + m_contacts[m_currentSlot].state = QEventPoint::State::Released; } else if (data->type == EV_SYN && data->code == SYN_MT_REPORT && m_lastEventType != EV_SYN) { // If there is no tracking id, one will be generated later. // Until that use a temporary key. int key = m_currentData.trackingId; if (key == -1) - key = m_contacts.count(); + key = m_contacts.size(); m_contacts.insert(key, m_currentData); m_currentData = Contact(); @@ -578,31 +589,33 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) m_lastTouchPoints = m_touchPoints; m_touchPoints.clear(); - Qt::TouchPointStates combinedStates; + QEventPoint::States combinedStates; bool hasPressure = false; for (auto it = m_contacts.begin(), end = m_contacts.end(); it != end; /*erasing*/) { Contact &contact(it.value()); - if (!contact.state) + if (!contact.state) { + ++it; continue; + } int key = m_typeB ? it.key() : contact.trackingId; if (!m_typeB && m_lastContacts.contains(key)) { const Contact &prev(m_lastContacts.value(key)); - if (contact.state == Qt::TouchPointReleased) { + if (contact.state == QEventPoint::State::Released) { // Copy over the previous values for released points, just in case. contact.x = prev.x; contact.y = prev.y; contact.maj = prev.maj; } else { contact.state = (prev.x == contact.x && prev.y == contact.y) - ? Qt::TouchPointStationary : Qt::TouchPointMoved; + ? QEventPoint::State::Stationary : QEventPoint::State::Updated; } } // Avoid reporting a contact in released state more than once. - if (!m_typeB && contact.state == Qt::TouchPointReleased + if (!m_typeB && contact.state == QEventPoint::State::Released && !m_lastContacts.contains(key)) { it = m_contacts.erase(it); continue; @@ -621,12 +634,12 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) int key = m_typeB ? it.key() : contact.trackingId; if (m_typeB) { if (contact.trackingId != m_contacts[key].trackingId && contact.state) { - contact.state = Qt::TouchPointReleased; + contact.state = QEventPoint::State::Released; addTouchPoint(contact, &combinedStates); } } else { if (!m_contacts.contains(key)) { - contact.state = Qt::TouchPointReleased; + contact.state = QEventPoint::State::Released; addTouchPoint(contact, &combinedStates); } } @@ -636,18 +649,20 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) for (auto it = m_contacts.begin(), end = m_contacts.end(); it != end; /*erasing*/) { Contact &contact(it.value()); - if (!contact.state) + if (!contact.state) { + ++it; continue; + } - if (contact.state == Qt::TouchPointReleased) { + if (contact.state == QEventPoint::State::Released) { if (m_typeB) { - contact.state = static_cast<Qt::TouchPointState>(0); + contact.state = QEventPoint::State::Unknown; } else { it = m_contacts.erase(it); continue; } } else { - contact.state = Qt::TouchPointStationary; + contact.state = QEventPoint::State::Stationary; } ++it; } @@ -657,7 +672,7 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) m_contacts.clear(); - if (!m_touchPoints.isEmpty() && (hasPressure || combinedStates != Qt::TouchPointStationary)) + if (!m_touchPoints.isEmpty() && (hasPressure || combinedStates != QEventPoint::State::Stationary)) reportPoints(); } @@ -721,7 +736,7 @@ QRect QEvdevTouchScreenData::screenGeometry() const { if (m_forceToActiveWindow) { QWindow *win = QGuiApplication::focusWindow(); - return win ? QHighDpi::toNativePixels(win->geometry(), win) : QRect(); + return win ? QHighDpi::toNativeWindowGeometry(win->geometry(), win) : QRect(); } // Now it becomes tricky. Traditionally we picked the primaryScreen() @@ -729,7 +744,7 @@ QRect QEvdevTouchScreenData::screenGeometry() const // suddenly it was all broken. // // For now we only support the display configuration of the KMS/DRM - // backends of eglfs. See QTouchOutputMapping. + // backends of eglfs. See QOutputMapping. // // The good news it that once winRect refers to the correct screen // geometry in the full virtual desktop space, there is nothing else @@ -748,7 +763,7 @@ QRect QEvdevTouchScreenData::screenGeometry() const if (m_screen) screen = m_screen; } - return QHighDpi::toNativePixels(screen->geometry(), screen); + return screen ? QHighDpi::toNativePixels(screen->geometry(), screen) : QRect(); } void QEvdevTouchScreenData::reportPoints() @@ -762,7 +777,7 @@ void QEvdevTouchScreenData::reportPoints() // Map the coordinates based on the normalized position. QPA expects 'area' // to be in screen coordinates. - const int pointCount = m_touchPoints.count(); + const int pointCount = m_touchPoints.size(); for (int i = 0; i < pointCount; ++i) { QWindowSystemInterface::TouchPoint &tp(m_touchPoints[i]); @@ -780,7 +795,7 @@ void QEvdevTouchScreenData::reportPoints() // Calculate normalized pressure. if (!hw_pressure_min && !hw_pressure_max) - tp.pressure = tp.state == Qt::TouchPointReleased ? 0 : 1; + tp.pressure = tp.state == QEventPoint::State::Released ? 0 : 1; else tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min); @@ -889,7 +904,7 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() } else { // Update our estimate for the touch rate. We're making the assumption - // that this value will be mostly accurate with the occational bump, + // that this value will be mostly accurate with the occasional bump, // so we're weighting the existing value high compared to the update. const double ratio = 0.9; m_touchRate = sqrt(m_touchRate * m_touchRate * ratio + touchDelta * touchDelta * (1.0 - ratio)); @@ -927,8 +942,8 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() f.y.initialize(pos.y(), velocity.y()); // Make sure the first instance of a touch point we send has the // 'pressed' state. - if (tp.state != Qt::TouchPointPressed) - tp.state = Qt::TouchPointPressed; + if (tp.state != QEventPoint::State::Pressed) + tp.state = QEventPoint::State::Pressed; } tp.velocity = QVector2D(f.x.velocity() * winRect.width(), f.y.velocity() * winRect.height()); @@ -950,14 +965,14 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() f.touchPoint = tp; // Don't store the point for future reference if it is a release. - if (tp.state != Qt::TouchPointReleased) + if (tp.state != QEventPoint::State::Released) filteredPoints[tp.id] = f; } for (QHash<int, FilteredTouchPoint>::const_iterator it = m_filteredPoints.constBegin(), end = m_filteredPoints.constEnd(); it != end; ++it) { const FilteredTouchPoint &f = it.value(); QWindowSystemInterface::TouchPoint tp = f.touchPoint; - tp.state = Qt::TouchPointReleased; + tp.state = QEventPoint::State::Released; tp.velocity = QVector2D(); points.append(tp); } @@ -971,3 +986,5 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() QT_END_NAMESPACE + +#include "moc_qevdevtouchhandler_p.cpp" diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h index 3ad2602811..b7b058e8b2 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVTOUCHHANDLER_P_H #define QEVDEVTOUCHHANDLER_P_H @@ -57,6 +21,7 @@ #include <QObject> #include <QString> #include <QList> +#include <QHash> #include <QThread> #include <QtCore/private/qthread_p.h> #include <qpa/qwindowsysteminterface.h> diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index a1226ac66a..f2a652c254 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevtouchmanager_p.h" #include "qevdevtouchhandler_p.h" @@ -48,7 +12,6 @@ #include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h> #include <private/qguiapplication_p.h> #include <private/qinputdevicemanager_p_p.h> -#include <private/qmemory_p.h> QT_BEGIN_NAMESPACE @@ -70,7 +33,7 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif auto parsed = QEvdevUtil::parseSpecification(spec); m_spec = std::move(parsed.spec); - for (const QString &device : qAsConst(parsed.devices)) + for (const QString &device : std::as_const(parsed.devices)) addDevice(device); // when no devices specified, use device discovery to scan and monitor @@ -96,7 +59,7 @@ QEvdevTouchManager::~QEvdevTouchManager() void QEvdevTouchManager::addDevice(const QString &deviceNode) { qCDebug(qLcEvdevTouch, "evdevtouch: Adding device at %ls", qUtf16Printable(deviceNode)); - auto handler = qt_make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec); + auto handler = std::make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec); if (handler) { connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount); m_activeDevices.add(deviceNode, std::move(handler)); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h index 94ee05d900..0bbc87ac0b 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVTOUCHMANAGER_P_H #define QEVDEVTOUCHMANAGER_P_H diff --git a/src/platformsupport/input/input-support.pro b/src/platformsupport/input/input-support.pro deleted file mode 100644 index 3d39210b9e..0000000000 --- a/src/platformsupport/input/input-support.pro +++ /dev/null @@ -1,35 +0,0 @@ -TARGET = QtInputSupport -MODULE = input_support - -QT = core-private gui-private devicediscovery_support-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h - -qtConfig(evdev) { - include($$PWD/evdevmouse/evdevmouse.pri) - include($$PWD/evdevkeyboard/evdevkeyboard.pri) - include($$PWD/evdevtouch/evdevtouch.pri) - qtConfig(tabletevent) { - include($$PWD/evdevtablet/evdevtablet.pri) - } -} - -qtConfig(tslib) { - include($$PWD/tslib/tslib.pri) -} - -qtConfig(libinput) { - include($$PWD/libinput/libinput.pri) -} - -qtConfig(evdev)|qtConfig(libinput) { - include($$PWD/shared/shared.pri) -} - -qtConfig(integrityhid) { - include($$PWD/integrityhid/integrityhid.pri) -} - -load(qt_module) diff --git a/src/platformsupport/input/input.pro b/src/platformsupport/input/input.pro deleted file mode 100644 index 138c04dea3..0000000000 --- a/src/platformsupport/input/input.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -QT_FOR_CONFIG += gui-private - -qtConfig(xkbcommon): SUBDIRS += xkbcommon - -SUBDIRS += input-support.pro ### FIXME - QTBUG-52657 - -CONFIG += ordered diff --git a/src/platformsupport/input/integrityhid/integrityhid.pri b/src/platformsupport/input/integrityhid/integrityhid.pri deleted file mode 100644 index 0a6240c422..0000000000 --- a/src/platformsupport/input/integrityhid/integrityhid.pri +++ /dev/null @@ -1,7 +0,0 @@ -HEADERS += \ - $$PWD/qintegrityhidmanager.h - -SOURCES += \ - $$PWD/qintegrityhidmanager.cpp - -QMAKE_USE_PRIVATE += integrityhid diff --git a/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp b/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp index e472693077..86036d579d 100644 --- a/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp +++ b/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Green Hills Software -** 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$ -** -****************************************************************************/ +// Copyright (C) 2015 Green Hills Software +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qintegrityhidmanager.h" #include <QList> diff --git a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h index e46cb75dc1..228d9ea5f3 100644 --- a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h +++ b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Green Hills Software -** 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$ -** -****************************************************************************/ +// Copyright (C) 2015 Green Hills Software +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QINTEGRITYHIDMANAGER_P_H #define QINTEGRITYHIDMANAGER_P_H diff --git a/src/platformsupport/input/libinput/libinput.pri b/src/platformsupport/input/libinput/libinput.pri deleted file mode 100644 index f80b5f41d9..0000000000 --- a/src/platformsupport/input/libinput/libinput.pri +++ /dev/null @@ -1,20 +0,0 @@ -HEADERS += \ - $$PWD/qlibinputhandler_p.h \ - $$PWD/qlibinputpointer_p.h \ - $$PWD/qlibinputkeyboard_p.h \ - $$PWD/qlibinputtouch_p.h - -SOURCES += \ - $$PWD/qlibinputhandler.cpp \ - $$PWD/qlibinputpointer.cpp \ - $$PWD/qlibinputkeyboard.cpp \ - $$PWD/qlibinputtouch.cpp - -QMAKE_USE_PRIVATE += libudev libinput - -INCLUDEPATH += $$PWD/../shared - -qtConfig(xkbcommon): { - QMAKE_USE_PRIVATE += xkbcommon - QT += xkbcommon_support-private -} diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index 95dfb46d16..ef45533f1a 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qlibinputhandler_p.h" #include "qlibinputpointer_p.h" @@ -115,7 +79,7 @@ QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec) m_touch.reset(new QLibInputTouch); QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager(); - connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [this](const QPoint &pos) { + connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, this, [this](const QPoint &pos) { m_pointer->setPos(pos); }); @@ -208,7 +172,11 @@ void QLibInputHandler::processEvent(libinput_event *ev) case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: m_pointer->processAbsMotion(libinput_event_get_pointer_event(ev)); break; +#if QT_CONFIG(libinput_hires_wheel_support) + case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL: +#else case LIBINPUT_EVENT_POINTER_AXIS: +#endif m_pointer->processAxis(libinput_event_get_pointer_event(ev)); break; case LIBINPUT_EVENT_KEYBOARD_KEY: diff --git a/src/platformsupport/input/libinput/qlibinputhandler_p.h b/src/platformsupport/input/libinput/qlibinputhandler_p.h index ac7a267a4d..ca7926bae6 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler_p.h +++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLIBINPUTHANDLER_P_H #define QLIBINPUTHANDLER_P_H @@ -43,6 +7,7 @@ #include <QtCore/QObject> #include <QtCore/QScopedPointer> #include <QtCore/QMap> +#include <QtCore/private/qglobal_p.h> // // W A R N I N G diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp index 4961d8d530..25939cd510 100644 --- a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp +++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qlibinputkeyboard_p.h" #include <QtCore/QLoggingCategory> @@ -46,7 +10,7 @@ #if QT_CONFIG(xkbcommon) #include <xkbcommon/xkbcommon-keysyms.h> #include <xkbcommon/xkbcommon-names.h> -#include <QtXkbCommonSupport/private/qxkbcommon_p.h> +#include <QtGui/private/qxkbcommon_p.h> #endif QT_BEGIN_NAMESPACE @@ -115,7 +79,7 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e) xkb_state_update_key(m_state, keycode, pressed ? XKB_KEY_DOWN : XKB_KEY_UP); - Qt::KeyboardModifiers modifiersAfterStateChange = QXkbCommon::modifiers(m_state); + Qt::KeyboardModifiers modifiersAfterStateChange = QXkbCommon::modifiers(m_state, sym); QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(modifiersAfterStateChange); QWindowSystemInterface::handleExtendedKeyEvent(nullptr, diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h index 7521902e02..fecbca34aa 100644 --- a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h +++ b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLIBINPUTKEYBOARD_P_H #define QLIBINPUTKEYBOARD_P_H diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index db9e81b5df..03351397b5 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer.cpp +++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qlibinputpointer_p.h" #include <libinput.h> @@ -133,16 +97,28 @@ void QLibInputPointer::processAxis(libinput_event_pointer *e) angleDelta.setX(qRound(value)); #else if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) { +#if QT_CONFIG(libinput_hires_wheel_support) + value = libinput_event_pointer_get_scroll_value_v120(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); +#else value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); +#endif angleDelta.setY(qRound(value)); } if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) { +#if QT_CONFIG(libinput_hires_wheel_support) + value = libinput_event_pointer_get_scroll_value_v120(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); +#else value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); +#endif angleDelta.setX(qRound(value)); } #endif - const int factor = 8; - angleDelta *= -factor; +#if QT_CONFIG(libinput_hires_wheel_support) + const int factor = -1; +#else + const int factor = -8; +#endif + angleDelta *= factor; Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers(); QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods); } diff --git a/src/platformsupport/input/libinput/qlibinputpointer_p.h b/src/platformsupport/input/libinput/qlibinputpointer_p.h index 55d4a5f919..f1709eaa34 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer_p.h +++ b/src/platformsupport/input/libinput/qlibinputpointer_p.h @@ -1,46 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLIBINPUTPOINTER_P_H #define QLIBINPUTPOINTER_P_H #include <QtCore/QPoint> +#include <QtCore/private/qglobal_p.h> // // W A R N I N G diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index c1df7e4c7a..e3a483dc84 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -1,44 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qlibinputtouch_p.h" -#include "qtouchoutputmapping_p.h" +#include "qoutputmapping_p.h" #include <libinput.h> #include <QtGui/QGuiApplication> #include <QtGui/QPointingDevice> @@ -50,12 +14,13 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(qLcLibInput) +Q_LOGGING_CATEGORY(qLcLibInputEvents, "qt.qpa.input.events") QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t slot) { const int id = qMax(0, slot); - for (int i = 0; i < m_points.count(); ++i) + for (int i = 0; i < m_points.size(); ++i) if (m_points.at(i).id == id) return &m_points[i]; @@ -68,9 +33,8 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e return &m_devState[dev]; } -QPointF QLibInputTouch::getPos(libinput_event_touch *e) +QRect QLibInputTouch::screenGeometry(DeviceState *state) { - DeviceState *state = deviceState(e); QScreen *screen = QGuiApplication::primaryScreen(); if (!state->m_screenName.isEmpty()) { if (!m_screen) { @@ -85,12 +49,45 @@ QPointF QLibInputTouch::getPos(libinput_event_touch *e) if (m_screen) screen = m_screen; } - const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); + return screen ? QHighDpi::toNativePixels(screen->geometry(), screen) : QRect(); +} + +QPointF QLibInputTouch::getPos(libinput_event_touch *e) +{ + DeviceState *state = deviceState(e); + QRect geom = screenGeometry(state); const double x = libinput_event_touch_get_x_transformed(e, geom.width()); const double y = libinput_event_touch_get_y_transformed(e, geom.height()); return geom.topLeft() + QPointF(x, y); } +static void setMatrix(libinput_device *dev) +{ + if (libinput_device_config_calibration_has_matrix(dev)) { + QByteArray env = qgetenv("QT_QPA_LIBINPUT_TOUCH_MATRIX"); + env = env.simplified(); + if (env.size()) { + float matrix[6]; + QList<QByteArray> list = env.split(' '); + if (list.length() != 6) { + qCWarning(qLcLibInput, "matrix length %lld wrong, should be 6", list.length()); + return; + } + for (int i = 0; i < 6; i++) { + bool ok = true; + matrix[i] = list[i].toFloat(&ok); + if (!ok) { + qCWarning(qLcLibInput, "Invalid matrix entry %d %s ", i, list[i].constData()); + return; + } + } + if (libinput_device_config_calibration_set_matrix(dev, matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS) + qCWarning(qLcLibInput, "Failed to set libinput calibration matrix "); + } + } else { + qCWarning(qLcLibInput, "Touch device doesn't support matrix"); + } +} void QLibInputTouch::registerDevice(libinput_device *dev) { struct udev_device *udev_device; @@ -101,20 +98,28 @@ void QLibInputTouch::registerDevice(libinput_device *dev) qCDebug(qLcLibInput, "libinput: registerDevice %s - %s", qPrintable(devNode), qPrintable(devName)); - QTouchOutputMapping mapping; - if (mapping.load()) { - m_devState[dev].m_screenName = mapping.screenNameForDeviceNode(devNode); - if (!m_devState[dev].m_screenName.isEmpty()) - qCDebug(qLcLibInput, "libinput: Mapping device %s to screen %s", - qPrintable(devNode), qPrintable(m_devState[dev].m_screenName)); + QOutputMapping *mapping = QOutputMapping::get(); + QRect geom; + if (mapping->load()) { + m_devState[dev].m_screenName = mapping->screenNameForDeviceNode(devNode); + if (!m_devState[dev].m_screenName.isEmpty()) { + geom = screenGeometry(&m_devState[dev]); + qCDebug(qLcLibInput) << "libinput: Mapping device" << devNode + << "to screen" << m_devState[dev].m_screenName + << "with geometry" << geom; + } } QPointingDevice *&td = m_devState[dev].m_touchDevice; td = new QPointingDevice(devName, udev_device_get_devnum(udev_device), QInputDevice::DeviceType::TouchScreen, QPointingDevice::PointerType::Finger, QPointingDevice::Capability::Position | QPointingDevice::Capability::Area, 16, 0); - QPointingDevicePrivate::get(td)->busId = QString::fromLocal8Bit(udev_device_get_syspath(udev_device)); // TODO is that the best to choose? + auto devPriv = QPointingDevicePrivate::get(td); + devPriv->busId = QString::fromLocal8Bit(udev_device_get_syspath(udev_device)); // TODO is that the best to choose? + if (!geom.isNull()) + devPriv->setAvailableVirtualGeometry(geom); QWindowSystemInterface::registerInputDevice(td); + setMatrix(dev); } void QLibInputTouch::unregisterDevice(libinput_device *dev) @@ -133,10 +138,11 @@ void QLibInputTouch::processTouchDown(libinput_event_touch *e) } else { QWindowSystemInterface::TouchPoint newTp; newTp.id = qMax(0, slot); - newTp.state = Qt::TouchPointPressed; + newTp.state = QEventPoint::State::Pressed; newTp.area = QRect(0, 0, 8, 8); newTp.area.moveCenter(getPos(e)); state->m_points.append(newTp); + qCDebug(qLcLibInputEvents) << "touch down" << newTp; } } @@ -146,16 +152,17 @@ void QLibInputTouch::processTouchMotion(libinput_event_touch *e) DeviceState *state = deviceState(e); QWindowSystemInterface::TouchPoint *tp = state->point(slot); if (tp) { - Qt::TouchPointState tmpState = Qt::TouchPointMoved; + QEventPoint::State tmpState = QEventPoint::State::Updated; const QPointF p = getPos(e); if (tp->area.center() == p) - tmpState = Qt::TouchPointStationary; + tmpState = QEventPoint::State::Stationary; else tp->area.moveCenter(p); // 'down' may be followed by 'motion' within the same "frame". // Handle this by compressing and keeping the Pressed state until the 'frame'. - if (tp->state != Qt::TouchPointPressed && tp->state != Qt::TouchPointReleased) + if (tp->state != QEventPoint::State::Pressed && tp->state != QEventPoint::State::Released) tp->state = tmpState; + qCDebug(qLcLibInputEvents) << "touch move" << tp; } else { qWarning("Inconsistent touch state (got 'motion' without 'down')"); } @@ -167,13 +174,16 @@ void QLibInputTouch::processTouchUp(libinput_event_touch *e) DeviceState *state = deviceState(e); QWindowSystemInterface::TouchPoint *tp = state->point(slot); if (tp) { - tp->state = Qt::TouchPointReleased; + tp->state = QEventPoint::State::Released; // There may not be a Frame event after the last Up. Work this around. - Qt::TouchPointStates s; - for (int i = 0; i < state->m_points.count(); ++i) + QEventPoint::States s; + for (int i = 0; i < state->m_points.size(); ++i) s |= state->m_points.at(i).state; - if (s == Qt::TouchPointReleased) + qCDebug(qLcLibInputEvents) << "touch up" << s << tp; + if (s == QEventPoint::State::Released) processTouchFrame(e); + else + qCDebug(qLcLibInputEvents, "waiting for all points to be released"); } else { qWarning("Inconsistent touch state (got 'up' without 'down')"); } @@ -182,6 +192,7 @@ void QLibInputTouch::processTouchUp(libinput_event_touch *e) void QLibInputTouch::processTouchCancel(libinput_event_touch *e) { DeviceState *state = deviceState(e); + qCDebug(qLcLibInputEvents) << "touch cancel" << state->m_points; if (state->m_touchDevice) QWindowSystemInterface::handleTouchCancelEvent(nullptr, state->m_touchDevice, QGuiApplication::keyboardModifiers()); else @@ -195,18 +206,19 @@ void QLibInputTouch::processTouchFrame(libinput_event_touch *e) qWarning("TouchFrame without registered device"); return; } + qCDebug(qLcLibInputEvents) << "touch frame" << state->m_points; if (state->m_points.isEmpty()) return; QWindowSystemInterface::handleTouchEvent(nullptr, state->m_touchDevice, state->m_points, QGuiApplication::keyboardModifiers()); - for (int i = 0; i < state->m_points.count(); ++i) { + for (int i = 0; i < state->m_points.size(); ++i) { QWindowSystemInterface::TouchPoint &tp(state->m_points[i]); - if (tp.state == Qt::TouchPointReleased) + if (tp.state == QEventPoint::State::Released) state->m_points.removeAt(i--); - else if (tp.state == Qt::TouchPointPressed) - tp.state = Qt::TouchPointStationary; + else if (tp.state == QEventPoint::State::Pressed) + tp.state = QEventPoint::State::Stationary; } } diff --git a/src/platformsupport/input/libinput/qlibinputtouch_p.h b/src/platformsupport/input/libinput/qlibinputtouch_p.h index 175e96f583..174795b140 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch_p.h +++ b/src/platformsupport/input/libinput/qlibinputtouch_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLIBINPUTTOUCH_P_H #define QLIBINPUTTOUCH_P_H @@ -44,6 +8,7 @@ #include <QtCore/QList> #include <QtCore/QPointer> #include <qpa/qwindowsysteminterface.h> +#include <private/qglobal_p.h> // // W A R N I N G @@ -83,6 +48,7 @@ private: }; DeviceState *deviceState(libinput_event_touch *e); + QRect screenGeometry(DeviceState *state); QPointF getPos(libinput_event_touch *e); QHash<libinput_device *, DeviceState> m_devState; diff --git a/src/platformsupport/input/shared/devicehandlerlist_p.h b/src/platformsupport/input/shared/devicehandlerlist_p.h index 97794d4d7d..facd1946a5 100644 --- a/src/platformsupport/input/shared/devicehandlerlist_p.h +++ b/src/platformsupport/input/shared/devicehandlerlist_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTINPUTSUPPORT_DEVICEHANDLERLIST_P_H #define QTINPUTSUPPORT_DEVICEHANDLERLIST_P_H @@ -52,6 +16,7 @@ // #include <QString> +#include <private/qglobal_p.h> #include <vector> #include <memory> diff --git a/src/platformsupport/input/shared/qevdevutil.cpp b/src/platformsupport/input/shared/qevdevutil.cpp index 4cecb27a64..c1ebb9ada0 100644 --- a/src/platformsupport/input/shared/qevdevutil.cpp +++ b/src/platformsupport/input/shared/qevdevutil.cpp @@ -1,61 +1,27 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qevdevutil_p.h" QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace QEvdevUtil { ParsedSpecification parseSpecification(const QString &specification) { ParsedSpecification result; - result.args = QStringView{specification}.split(QLatin1Char(':')); + result.args = QStringView{specification}.split(u':'); - for (const auto &arg : qAsConst(result.args)) { - if (arg.startsWith(QLatin1String("/dev/"))) { + for (const auto &arg : std::as_const(result.args)) { + if (arg.startsWith("/dev/"_L1)) { // if device is specified try to use it result.devices.append(arg.toString()); } else { // build new specification without /dev/ elements - result.spec += arg + QLatin1Char(':'); + result.spec += arg + u':'; } } diff --git a/src/platformsupport/input/shared/qevdevutil_p.h b/src/platformsupport/input/shared/qevdevutil_p.h index d5576f66cd..8533b93783 100644 --- a/src/platformsupport/input/shared/qevdevutil_p.h +++ b/src/platformsupport/input/shared/qevdevutil_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QEVDEVUTIL_P_H #define QEVDEVUTIL_P_H @@ -51,10 +15,11 @@ // We mean it. // +#include <QList> #include <QString> #include <QStringList> -#include <QVector> #include <QStringView> +#include <private/qglobal_p.h> QT_BEGIN_NAMESPACE @@ -64,7 +29,7 @@ struct ParsedSpecification { QString spec; QStringList devices; - QVector<QStringView> args; + QList<QStringView> args; }; ParsedSpecification parseSpecification(const QString &specification); diff --git a/src/platformsupport/input/shared/qoutputmapping.cpp b/src/platformsupport/input/shared/qoutputmapping.cpp new file mode 100644 index 0000000000..c8683958d3 --- /dev/null +++ b/src/platformsupport/input/shared/qoutputmapping.cpp @@ -0,0 +1,95 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qoutputmapping_p.h" +#include <QFile> +#include <QFileInfo> +#include <QVariantMap> +#include <QJsonDocument> +#include <QJsonObject> +#include <QJsonArray> + +QT_BEGIN_NAMESPACE + +using namespace Qt::StringLiterals; + +static QOutputMapping *s_outputMapping = nullptr; + +QOutputMapping *QOutputMapping::get() +{ + if (!s_outputMapping) + s_outputMapping = new QDefaultOutputMapping; + + return s_outputMapping; +} + +bool QOutputMapping::load() +{ + return false; +} + +QString QOutputMapping::screenNameForDeviceNode(const QString &deviceNode) +{ + Q_UNUSED(deviceNode); + return QString(); +} + +#ifdef Q_OS_WEBOS +QWindow *QOutputMapping::windowForDeviceNode(const QString &deviceNode) +{ + Q_UNUSED(deviceNode); + return nullptr; +} + +void QOutputMapping::set(QOutputMapping *mapping) +{ + if (s_outputMapping) + delete s_outputMapping; + + s_outputMapping = mapping; +} +#endif // Q_OS_WEBOS + +bool QDefaultOutputMapping::load() +{ + static QByteArray configFile = qgetenv("QT_QPA_EGLFS_KMS_CONFIG"); + if (configFile.isEmpty()) + return false; + + QFile file(QString::fromUtf8(configFile)); + if (!file.open(QFile::ReadOnly)) { + qWarning("touch input support: Failed to open %s", configFile.constData()); + return false; + } + + const QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); + if (!doc.isObject()) { + qWarning("touch input support: Failed to parse %s", configFile.constData()); + return false; + } + + // What we are interested is the virtualIndex and touchDevice properties for + // each element in the outputs array. + const QJsonArray outputs = doc.object().value("outputs"_L1).toArray(); + for (int i = 0; i < outputs.size(); ++i) { + const QVariantMap output = outputs.at(i).toObject().toVariantMap(); + if (!output.contains(QStringLiteral("touchDevice"))) + continue; + if (!output.contains(QStringLiteral("name"))) { + qWarning("evdevtouch: Output %d specifies touchDevice but not name, this is wrong", i); + continue; + } + QFileInfo deviceNode(output.value(QStringLiteral("touchDevice")).toString()); + const QString &screenName = output.value(QStringLiteral("name")).toString(); + m_screenTable.insert(deviceNode.canonicalFilePath(), screenName); + } + + return true; +} + +QString QDefaultOutputMapping::screenNameForDeviceNode(const QString &deviceNode) +{ + return m_screenTable.value(deviceNode); +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/input/shared/qoutputmapping_p.h b/src/platformsupport/input/shared/qoutputmapping_p.h new file mode 100644 index 0000000000..b11364188d --- /dev/null +++ b/src/platformsupport/input/shared/qoutputmapping_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOUTPUTMAPPING_P_H +#define QOUTPUTMAPPING_P_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 <QString> +#include <QHash> +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QWindow; + +class QOutputMapping +{ +public: + virtual ~QOutputMapping() {} + + static QOutputMapping *get(); + virtual bool load(); + virtual QString screenNameForDeviceNode(const QString &deviceNode); + +#ifdef Q_OS_WEBOS + virtual QWindow *windowForDeviceNode(const QString &deviceNode); + static void set(QOutputMapping *mapping); +#endif +}; + +class QDefaultOutputMapping : public QOutputMapping +{ +public: + bool load() override; + QString screenNameForDeviceNode(const QString &deviceNode) override; + +private: + QHash<QString, QString> m_screenTable; +}; + +QT_END_NAMESPACE + +#endif // QOUTPUTMAPPING_P_H diff --git a/src/platformsupport/input/shared/qtouchoutputmapping.cpp b/src/platformsupport/input/shared/qtouchoutputmapping.cpp deleted file mode 100644 index 0a1afd4739..0000000000 --- a/src/platformsupport/input/shared/qtouchoutputmapping.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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 "qtouchoutputmapping_p.h" -#include <QFile> -#include <QVariantMap> -#include <QJsonDocument> -#include <QJsonObject> -#include <QJsonArray> - -QT_BEGIN_NAMESPACE - -bool QTouchOutputMapping::load() -{ - static QByteArray configFile = qgetenv("QT_QPA_EGLFS_KMS_CONFIG"); - if (configFile.isEmpty()) - return false; - - QFile file(QString::fromUtf8(configFile)); - if (!file.open(QFile::ReadOnly)) { - qWarning("touch input support: Failed to open %s", configFile.constData()); - return false; - } - - const QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); - if (!doc.isObject()) { - qWarning("touch input support: Failed to parse %s", configFile.constData()); - return false; - } - - // What we are interested is the virtualIndex and touchDevice properties for - // each element in the outputs array. - const QJsonArray outputs = doc.object().value(QLatin1String("outputs")).toArray(); - for (int i = 0; i < outputs.size(); ++i) { - const QVariantMap output = outputs.at(i).toObject().toVariantMap(); - if (!output.contains(QStringLiteral("touchDevice"))) - continue; - if (!output.contains(QStringLiteral("name"))) { - qWarning("evdevtouch: Output %d specifies touchDevice but not name, this is wrong", i); - continue; - } - const QString &deviceNode = output.value(QStringLiteral("touchDevice")).toString(); - const QString &screenName = output.value(QStringLiteral("name")).toString(); - m_screenTable.insert(deviceNode, screenName); - } - - return true; -} - -QString QTouchOutputMapping::screenNameForDeviceNode(const QString &deviceNode) -{ - return m_screenTable.value(deviceNode); -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/input/shared/qtouchoutputmapping_p.h b/src/platformsupport/input/shared/qtouchoutputmapping_p.h deleted file mode 100644 index 94d4dbc3b1..0000000000 --- a/src/platformsupport/input/shared/qtouchoutputmapping_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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 QTOUCHOUTPUTMAPPING_P_H -#define QTOUCHOUTPUTMAPPING_P_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 <QString> -#include <QHash> - -QT_BEGIN_NAMESPACE - -class QTouchOutputMapping -{ -public: - bool load(); - QString screenNameForDeviceNode(const QString &deviceNode); - -private: - QHash<QString, QString> m_screenTable; -}; - -QT_END_NAMESPACE - -#endif // QTOUCHOUTPUTMAPPING_P_H diff --git a/src/platformsupport/input/shared/shared.pri b/src/platformsupport/input/shared/shared.pri deleted file mode 100644 index c29d11e7d6..0000000000 --- a/src/platformsupport/input/shared/shared.pri +++ /dev/null @@ -1,8 +0,0 @@ -HEADERS += \ - $$PWD/devicehandlerlist_p.h \ - $$PWD/qevdevutil_p.h \ - $$PWD/qtouchoutputmapping_p.h - -SOURCES += \ - $$PWD/qevdevutil.cpp \ - $$PWD/qtouchoutputmapping.cpp diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp index e105f5ea98..a84cc90dc2 100644 --- a/src/platformsupport/input/tslib/qtslib.cpp +++ b/src/platformsupport/input/tslib/qtslib.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtslib_p.h" @@ -51,16 +15,18 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(qLcTsLib, "qt.qpa.input") QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, const QString &specification, QObject *parent) : QObject(parent), - m_rawMode(!key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive)) + m_rawMode(!key.compare("TslibRaw"_L1, Qt::CaseInsensitive)) { qCDebug(qLcTsLib) << "Initializing tslib plugin" << key << specification; - setObjectName(QLatin1String("TSLib Mouse Handler")); + setObjectName("TSLib Mouse Handler"_L1); m_dev = ts_setup(nullptr, 1); if (!m_dev) { @@ -113,9 +79,12 @@ void QTsLibMouseHandler::readMouseData() } QPoint pos(x, y); - QWindowSystemInterface::handleMouseEvent(nullptr, pos, pos, - pressed ? Qt::LeftButton : Qt::NoButton, - Qt::NoButton, QEvent::None); + Qt::MouseButton button = pressed ^ m_pressed ? Qt::LeftButton : Qt::NoButton; + Qt::MouseButtons state = pressed ? Qt::LeftButton : Qt::NoButton; + QEvent::Type type = pressed ? (m_pressed ? QEvent::MouseMove : QEvent::MouseButtonPress) + : QEvent::MouseButtonRelease; + + QWindowSystemInterface::handleMouseEvent(nullptr, pos, pos, state, button, type); m_x = x; m_y = y; @@ -124,3 +93,5 @@ void QTsLibMouseHandler::readMouseData() } QT_END_NAMESPACE + +#include "moc_qtslib_p.cpp" diff --git a/src/platformsupport/input/tslib/qtslib_p.h b/src/platformsupport/input/tslib/qtslib_p.h index ffd60cd0e3..03514a6d5d 100644 --- a/src/platformsupport/input/tslib/qtslib_p.h +++ b/src/platformsupport/input/tslib/qtslib_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins module 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTSLIB_H #define QTSLIB_H @@ -52,6 +16,7 @@ // #include <QObject> +#include <private/qglobal_p.h> struct tsdev; @@ -64,7 +29,7 @@ class QTsLibMouseHandler : public QObject Q_OBJECT public: - QTsLibMouseHandler(const QString &key, const QString &specification, QObject *parent = 0); + QTsLibMouseHandler(const QString &key, const QString &specification, QObject *parent = nullptr); ~QTsLibMouseHandler(); private slots: diff --git a/src/platformsupport/input/tslib/tslib.pri b/src/platformsupport/input/tslib/tslib.pri deleted file mode 100644 index 9efd126e13..0000000000 --- a/src/platformsupport/input/tslib/tslib.pri +++ /dev/null @@ -1,7 +0,0 @@ -HEADERS += \ - $$PWD/qtslib_p.h - -SOURCES += \ - $$PWD/qtslib.cpp - -QMAKE_USE += tslib diff --git a/src/platformsupport/input/xkbcommon/CMakeLists.txt b/src/platformsupport/input/xkbcommon/CMakeLists.txt deleted file mode 100644 index 86d132d912..0000000000 --- a/src/platformsupport/input/xkbcommon/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Generated from xkbcommon.pro. - -##################################################################### -## XkbCommonSupport Module: -##################################################################### - -qt_add_module(XkbCommonSupport - STATIC - INTERNAL_MODULE - SOURCES - qxkbcommon.cpp qxkbcommon_p.h - qxkbcommon_3rdparty.cpp - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - XKB::XKB - PRECOMPILED_HEADER - "../../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 1:.:.:xkbcommon.pro:<TRUE>: -# MODULE = "xkbcommon_support" - -## Scopes: -##################################################################### - -qt_extend_target(XkbCommonSupport CONDITION CLANG AND NOT ICC - COMPILE_OPTIONS - -ftemplate-depth=1024 -) diff --git a/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/src/platformsupport/input/xkbcommon/qxkbcommon.cpp deleted file mode 100644 index 877c5d848f..0000000000 --- a/src/platformsupport/input/xkbcommon/qxkbcommon.cpp +++ /dev/null @@ -1,828 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "qxkbcommon_p.h" - -#include <private/qmakearray_p.h> - -#include <QtCore/QMetaMethod> -#include <QtGui/QKeyEvent> -#include <QtGui/private/qguiapplication_p.h> - -#include <qpa/qplatforminputcontext.h> -#include <qpa/qplatformintegration.h> - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcXkbcommon, "qt.xkbcommon") - -static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers, - xkb_state *state, xkb_keycode_t code, - bool superAsMeta, bool hyperAsMeta); - -typedef struct xkb2qt -{ - unsigned int xkb; - unsigned int qt; - - constexpr bool operator <=(const xkb2qt &that) const noexcept - { - return xkb <= that.xkb; - } - - constexpr bool operator <(const xkb2qt &that) const noexcept - { - return xkb < that.xkb; - } -} xkb2qt_t; - -template<std::size_t Xkb, std::size_t Qt> -struct Xkb2Qt -{ - using Type = xkb2qt_t; - static constexpr Type data() noexcept { return Type{Xkb, Qt}; } -}; - -static constexpr const auto KeyTbl = qMakeArray( - QSortedData< - // misc keys - - Xkb2Qt<XKB_KEY_Escape, Qt::Key_Escape>, - Xkb2Qt<XKB_KEY_Tab, Qt::Key_Tab>, - Xkb2Qt<XKB_KEY_ISO_Left_Tab, Qt::Key_Backtab>, - Xkb2Qt<XKB_KEY_BackSpace, Qt::Key_Backspace>, - Xkb2Qt<XKB_KEY_Return, Qt::Key_Return>, - Xkb2Qt<XKB_KEY_Insert, Qt::Key_Insert>, - Xkb2Qt<XKB_KEY_Delete, Qt::Key_Delete>, - Xkb2Qt<XKB_KEY_Clear, Qt::Key_Delete>, - Xkb2Qt<XKB_KEY_Pause, Qt::Key_Pause>, - Xkb2Qt<XKB_KEY_Print, Qt::Key_Print>, - Xkb2Qt<0x1005FF60, Qt::Key_SysReq>, // hardcoded Sun SysReq - Xkb2Qt<0x1007ff00, Qt::Key_SysReq>, // hardcoded X386 SysReq - - // cursor movement - - Xkb2Qt<XKB_KEY_Home, Qt::Key_Home>, - Xkb2Qt<XKB_KEY_End, Qt::Key_End>, - Xkb2Qt<XKB_KEY_Left, Qt::Key_Left>, - Xkb2Qt<XKB_KEY_Up, Qt::Key_Up>, - Xkb2Qt<XKB_KEY_Right, Qt::Key_Right>, - Xkb2Qt<XKB_KEY_Down, Qt::Key_Down>, - Xkb2Qt<XKB_KEY_Prior, Qt::Key_PageUp>, - Xkb2Qt<XKB_KEY_Next, Qt::Key_PageDown>, - - // modifiers - - Xkb2Qt<XKB_KEY_Shift_L, Qt::Key_Shift>, - Xkb2Qt<XKB_KEY_Shift_R, Qt::Key_Shift>, - Xkb2Qt<XKB_KEY_Shift_Lock, Qt::Key_Shift>, - Xkb2Qt<XKB_KEY_Control_L, Qt::Key_Control>, - Xkb2Qt<XKB_KEY_Control_R, Qt::Key_Control>, - Xkb2Qt<XKB_KEY_Meta_L, Qt::Key_Meta>, - Xkb2Qt<XKB_KEY_Meta_R, Qt::Key_Meta>, - Xkb2Qt<XKB_KEY_Alt_L, Qt::Key_Alt>, - Xkb2Qt<XKB_KEY_Alt_R, Qt::Key_Alt>, - Xkb2Qt<XKB_KEY_Caps_Lock, Qt::Key_CapsLock>, - Xkb2Qt<XKB_KEY_Num_Lock, Qt::Key_NumLock>, - Xkb2Qt<XKB_KEY_Scroll_Lock, Qt::Key_ScrollLock>, - Xkb2Qt<XKB_KEY_Super_L, Qt::Key_Super_L>, - Xkb2Qt<XKB_KEY_Super_R, Qt::Key_Super_R>, - Xkb2Qt<XKB_KEY_Menu, Qt::Key_Menu>, - Xkb2Qt<XKB_KEY_Hyper_L, Qt::Key_Hyper_L>, - Xkb2Qt<XKB_KEY_Hyper_R, Qt::Key_Hyper_R>, - Xkb2Qt<XKB_KEY_Help, Qt::Key_Help>, - Xkb2Qt<0x1000FF74, Qt::Key_Backtab>, // hardcoded HP backtab - Xkb2Qt<0x1005FF10, Qt::Key_F11>, // hardcoded Sun F36 (labeled F11) - Xkb2Qt<0x1005FF11, Qt::Key_F12>, // hardcoded Sun F37 (labeled F12) - - // numeric and function keypad keys - - Xkb2Qt<XKB_KEY_KP_Space, Qt::Key_Space>, - Xkb2Qt<XKB_KEY_KP_Tab, Qt::Key_Tab>, - Xkb2Qt<XKB_KEY_KP_Enter, Qt::Key_Enter>, - Xkb2Qt<XKB_KEY_KP_Home, Qt::Key_Home>, - Xkb2Qt<XKB_KEY_KP_Left, Qt::Key_Left>, - Xkb2Qt<XKB_KEY_KP_Up, Qt::Key_Up>, - Xkb2Qt<XKB_KEY_KP_Right, Qt::Key_Right>, - Xkb2Qt<XKB_KEY_KP_Down, Qt::Key_Down>, - Xkb2Qt<XKB_KEY_KP_Prior, Qt::Key_PageUp>, - Xkb2Qt<XKB_KEY_KP_Next, Qt::Key_PageDown>, - Xkb2Qt<XKB_KEY_KP_End, Qt::Key_End>, - Xkb2Qt<XKB_KEY_KP_Begin, Qt::Key_Clear>, - Xkb2Qt<XKB_KEY_KP_Insert, Qt::Key_Insert>, - Xkb2Qt<XKB_KEY_KP_Delete, Qt::Key_Delete>, - Xkb2Qt<XKB_KEY_KP_Equal, Qt::Key_Equal>, - Xkb2Qt<XKB_KEY_KP_Multiply, Qt::Key_Asterisk>, - Xkb2Qt<XKB_KEY_KP_Add, Qt::Key_Plus>, - Xkb2Qt<XKB_KEY_KP_Separator, Qt::Key_Comma>, - Xkb2Qt<XKB_KEY_KP_Subtract, Qt::Key_Minus>, - Xkb2Qt<XKB_KEY_KP_Decimal, Qt::Key_Period>, - Xkb2Qt<XKB_KEY_KP_Divide, Qt::Key_Slash>, - - // special non-XF86 function keys - - Xkb2Qt<XKB_KEY_Undo, Qt::Key_Undo>, - Xkb2Qt<XKB_KEY_Redo, Qt::Key_Redo>, - Xkb2Qt<XKB_KEY_Find, Qt::Key_Find>, - Xkb2Qt<XKB_KEY_Cancel, Qt::Key_Cancel>, - - // International input method support keys - - // International & multi-key character composition - Xkb2Qt<XKB_KEY_ISO_Level3_Shift, Qt::Key_AltGr>, - Xkb2Qt<XKB_KEY_Multi_key, Qt::Key_Multi_key>, - Xkb2Qt<XKB_KEY_Codeinput, Qt::Key_Codeinput>, - Xkb2Qt<XKB_KEY_SingleCandidate, Qt::Key_SingleCandidate>, - Xkb2Qt<XKB_KEY_MultipleCandidate, Qt::Key_MultipleCandidate>, - Xkb2Qt<XKB_KEY_PreviousCandidate, Qt::Key_PreviousCandidate>, - - // Misc Functions - Xkb2Qt<XKB_KEY_Mode_switch, Qt::Key_Mode_switch>, - Xkb2Qt<XKB_KEY_script_switch, Qt::Key_Mode_switch>, - - // Japanese keyboard support - Xkb2Qt<XKB_KEY_Kanji, Qt::Key_Kanji>, - Xkb2Qt<XKB_KEY_Muhenkan, Qt::Key_Muhenkan>, - //Xkb2Qt<XKB_KEY_Henkan_Mode, Qt::Key_Henkan_Mode>, - Xkb2Qt<XKB_KEY_Henkan_Mode, Qt::Key_Henkan>, - Xkb2Qt<XKB_KEY_Henkan, Qt::Key_Henkan>, - Xkb2Qt<XKB_KEY_Romaji, Qt::Key_Romaji>, - Xkb2Qt<XKB_KEY_Hiragana, Qt::Key_Hiragana>, - Xkb2Qt<XKB_KEY_Katakana, Qt::Key_Katakana>, - Xkb2Qt<XKB_KEY_Hiragana_Katakana, Qt::Key_Hiragana_Katakana>, - Xkb2Qt<XKB_KEY_Zenkaku, Qt::Key_Zenkaku>, - Xkb2Qt<XKB_KEY_Hankaku, Qt::Key_Hankaku>, - Xkb2Qt<XKB_KEY_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku>, - Xkb2Qt<XKB_KEY_Touroku, Qt::Key_Touroku>, - Xkb2Qt<XKB_KEY_Massyo, Qt::Key_Massyo>, - Xkb2Qt<XKB_KEY_Kana_Lock, Qt::Key_Kana_Lock>, - Xkb2Qt<XKB_KEY_Kana_Shift, Qt::Key_Kana_Shift>, - Xkb2Qt<XKB_KEY_Eisu_Shift, Qt::Key_Eisu_Shift>, - Xkb2Qt<XKB_KEY_Eisu_toggle, Qt::Key_Eisu_toggle>, - //Xkb2Qt<XKB_KEY_Kanji_Bangou, Qt::Key_Kanji_Bangou>, - //Xkb2Qt<XKB_KEY_Zen_Koho, Qt::Key_Zen_Koho>, - //Xkb2Qt<XKB_KEY_Mae_Koho, Qt::Key_Mae_Koho>, - Xkb2Qt<XKB_KEY_Kanji_Bangou, Qt::Key_Codeinput>, - Xkb2Qt<XKB_KEY_Zen_Koho, Qt::Key_MultipleCandidate>, - Xkb2Qt<XKB_KEY_Mae_Koho, Qt::Key_PreviousCandidate>, - - // Korean keyboard support - Xkb2Qt<XKB_KEY_Hangul, Qt::Key_Hangul>, - Xkb2Qt<XKB_KEY_Hangul_Start, Qt::Key_Hangul_Start>, - Xkb2Qt<XKB_KEY_Hangul_End, Qt::Key_Hangul_End>, - Xkb2Qt<XKB_KEY_Hangul_Hanja, Qt::Key_Hangul_Hanja>, - Xkb2Qt<XKB_KEY_Hangul_Jamo, Qt::Key_Hangul_Jamo>, - Xkb2Qt<XKB_KEY_Hangul_Romaja, Qt::Key_Hangul_Romaja>, - //Xkb2Qt<XKB_KEY_Hangul_Codeinput, Qt::Key_Hangul_Codeinput>, - Xkb2Qt<XKB_KEY_Hangul_Codeinput, Qt::Key_Codeinput>, - Xkb2Qt<XKB_KEY_Hangul_Jeonja, Qt::Key_Hangul_Jeonja>, - Xkb2Qt<XKB_KEY_Hangul_Banja, Qt::Key_Hangul_Banja>, - Xkb2Qt<XKB_KEY_Hangul_PreHanja, Qt::Key_Hangul_PreHanja>, - Xkb2Qt<XKB_KEY_Hangul_PostHanja, Qt::Key_Hangul_PostHanja>, - //Xkb2Qt<XKB_KEY_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate>, - //Xkb2Qt<XKB_KEY_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate>, - //Xkb2Qt<XKB_KEY_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate>, - Xkb2Qt<XKB_KEY_Hangul_SingleCandidate, Qt::Key_SingleCandidate>, - Xkb2Qt<XKB_KEY_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate>, - Xkb2Qt<XKB_KEY_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate>, - Xkb2Qt<XKB_KEY_Hangul_Special, Qt::Key_Hangul_Special>, - //Xkb2Qt<XKB_KEY_Hangul_switch, Qt::Key_Hangul_switch>, - Xkb2Qt<XKB_KEY_Hangul_switch, Qt::Key_Mode_switch>, - - // dead keys - Xkb2Qt<XKB_KEY_dead_grave, Qt::Key_Dead_Grave>, - Xkb2Qt<XKB_KEY_dead_acute, Qt::Key_Dead_Acute>, - Xkb2Qt<XKB_KEY_dead_circumflex, Qt::Key_Dead_Circumflex>, - Xkb2Qt<XKB_KEY_dead_tilde, Qt::Key_Dead_Tilde>, - Xkb2Qt<XKB_KEY_dead_macron, Qt::Key_Dead_Macron>, - Xkb2Qt<XKB_KEY_dead_breve, Qt::Key_Dead_Breve>, - Xkb2Qt<XKB_KEY_dead_abovedot, Qt::Key_Dead_Abovedot>, - Xkb2Qt<XKB_KEY_dead_diaeresis, Qt::Key_Dead_Diaeresis>, - Xkb2Qt<XKB_KEY_dead_abovering, Qt::Key_Dead_Abovering>, - Xkb2Qt<XKB_KEY_dead_doubleacute, Qt::Key_Dead_Doubleacute>, - Xkb2Qt<XKB_KEY_dead_caron, Qt::Key_Dead_Caron>, - Xkb2Qt<XKB_KEY_dead_cedilla, Qt::Key_Dead_Cedilla>, - Xkb2Qt<XKB_KEY_dead_ogonek, Qt::Key_Dead_Ogonek>, - Xkb2Qt<XKB_KEY_dead_iota, Qt::Key_Dead_Iota>, - Xkb2Qt<XKB_KEY_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound>, - Xkb2Qt<XKB_KEY_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound>, - Xkb2Qt<XKB_KEY_dead_belowdot, Qt::Key_Dead_Belowdot>, - Xkb2Qt<XKB_KEY_dead_hook, Qt::Key_Dead_Hook>, - Xkb2Qt<XKB_KEY_dead_horn, Qt::Key_Dead_Horn>, - Xkb2Qt<XKB_KEY_dead_stroke, Qt::Key_Dead_Stroke>, - Xkb2Qt<XKB_KEY_dead_abovecomma, Qt::Key_Dead_Abovecomma>, - Xkb2Qt<XKB_KEY_dead_abovereversedcomma, Qt::Key_Dead_Abovereversedcomma>, - Xkb2Qt<XKB_KEY_dead_doublegrave, Qt::Key_Dead_Doublegrave>, - Xkb2Qt<XKB_KEY_dead_belowring, Qt::Key_Dead_Belowring>, - Xkb2Qt<XKB_KEY_dead_belowmacron, Qt::Key_Dead_Belowmacron>, - Xkb2Qt<XKB_KEY_dead_belowcircumflex, Qt::Key_Dead_Belowcircumflex>, - Xkb2Qt<XKB_KEY_dead_belowtilde, Qt::Key_Dead_Belowtilde>, - Xkb2Qt<XKB_KEY_dead_belowbreve, Qt::Key_Dead_Belowbreve>, - Xkb2Qt<XKB_KEY_dead_belowdiaeresis, Qt::Key_Dead_Belowdiaeresis>, - Xkb2Qt<XKB_KEY_dead_invertedbreve, Qt::Key_Dead_Invertedbreve>, - Xkb2Qt<XKB_KEY_dead_belowcomma, Qt::Key_Dead_Belowcomma>, - Xkb2Qt<XKB_KEY_dead_currency, Qt::Key_Dead_Currency>, - Xkb2Qt<XKB_KEY_dead_a, Qt::Key_Dead_a>, - Xkb2Qt<XKB_KEY_dead_A, Qt::Key_Dead_A>, - Xkb2Qt<XKB_KEY_dead_e, Qt::Key_Dead_e>, - Xkb2Qt<XKB_KEY_dead_E, Qt::Key_Dead_E>, - Xkb2Qt<XKB_KEY_dead_i, Qt::Key_Dead_i>, - Xkb2Qt<XKB_KEY_dead_I, Qt::Key_Dead_I>, - Xkb2Qt<XKB_KEY_dead_o, Qt::Key_Dead_o>, - Xkb2Qt<XKB_KEY_dead_O, Qt::Key_Dead_O>, - Xkb2Qt<XKB_KEY_dead_u, Qt::Key_Dead_u>, - Xkb2Qt<XKB_KEY_dead_U, Qt::Key_Dead_U>, - Xkb2Qt<XKB_KEY_dead_small_schwa, Qt::Key_Dead_Small_Schwa>, - Xkb2Qt<XKB_KEY_dead_capital_schwa, Qt::Key_Dead_Capital_Schwa>, - Xkb2Qt<XKB_KEY_dead_greek, Qt::Key_Dead_Greek>, - Xkb2Qt<XKB_KEY_dead_lowline, Qt::Key_Dead_Lowline>, - Xkb2Qt<XKB_KEY_dead_aboveverticalline, Qt::Key_Dead_Aboveverticalline>, - Xkb2Qt<XKB_KEY_dead_belowverticalline, Qt::Key_Dead_Belowverticalline>, - Xkb2Qt<XKB_KEY_dead_longsolidusoverlay, Qt::Key_Dead_Longsolidusoverlay>, - - // Special keys from X.org - This include multimedia keys, - // wireless/bluetooth/uwb keys, special launcher keys, etc. - Xkb2Qt<XKB_KEY_XF86Back, Qt::Key_Back>, - Xkb2Qt<XKB_KEY_XF86Forward, Qt::Key_Forward>, - Xkb2Qt<XKB_KEY_XF86Stop, Qt::Key_Stop>, - Xkb2Qt<XKB_KEY_XF86Refresh, Qt::Key_Refresh>, - Xkb2Qt<XKB_KEY_XF86Favorites, Qt::Key_Favorites>, - Xkb2Qt<XKB_KEY_XF86AudioMedia, Qt::Key_LaunchMedia>, - Xkb2Qt<XKB_KEY_XF86OpenURL, Qt::Key_OpenUrl>, - Xkb2Qt<XKB_KEY_XF86HomePage, Qt::Key_HomePage>, - Xkb2Qt<XKB_KEY_XF86Search, Qt::Key_Search>, - Xkb2Qt<XKB_KEY_XF86AudioLowerVolume, Qt::Key_VolumeDown>, - Xkb2Qt<XKB_KEY_XF86AudioMute, Qt::Key_VolumeMute>, - Xkb2Qt<XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp>, - Xkb2Qt<XKB_KEY_XF86AudioPlay, Qt::Key_MediaPlay>, - Xkb2Qt<XKB_KEY_XF86AudioStop, Qt::Key_MediaStop>, - Xkb2Qt<XKB_KEY_XF86AudioPrev, Qt::Key_MediaPrevious>, - Xkb2Qt<XKB_KEY_XF86AudioNext, Qt::Key_MediaNext>, - Xkb2Qt<XKB_KEY_XF86AudioRecord, Qt::Key_MediaRecord>, - Xkb2Qt<XKB_KEY_XF86AudioPause, Qt::Key_MediaPause>, - Xkb2Qt<XKB_KEY_XF86Mail, Qt::Key_LaunchMail>, - Xkb2Qt<XKB_KEY_XF86MyComputer, Qt::Key_Launch0>, // ### Qt 6: remap properly - Xkb2Qt<XKB_KEY_XF86Calculator, Qt::Key_Launch1>, - Xkb2Qt<XKB_KEY_XF86Memo, Qt::Key_Memo>, - Xkb2Qt<XKB_KEY_XF86ToDoList, Qt::Key_ToDoList>, - Xkb2Qt<XKB_KEY_XF86Calendar, Qt::Key_Calendar>, - Xkb2Qt<XKB_KEY_XF86PowerDown, Qt::Key_PowerDown>, - Xkb2Qt<XKB_KEY_XF86ContrastAdjust, Qt::Key_ContrastAdjust>, - Xkb2Qt<XKB_KEY_XF86Standby, Qt::Key_Standby>, - Xkb2Qt<XKB_KEY_XF86MonBrightnessUp, Qt::Key_MonBrightnessUp>, - Xkb2Qt<XKB_KEY_XF86MonBrightnessDown, Qt::Key_MonBrightnessDown>, - Xkb2Qt<XKB_KEY_XF86KbdLightOnOff, Qt::Key_KeyboardLightOnOff>, - Xkb2Qt<XKB_KEY_XF86KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp>, - Xkb2Qt<XKB_KEY_XF86KbdBrightnessDown, Qt::Key_KeyboardBrightnessDown>, - Xkb2Qt<XKB_KEY_XF86PowerOff, Qt::Key_PowerOff>, - Xkb2Qt<XKB_KEY_XF86WakeUp, Qt::Key_WakeUp>, - Xkb2Qt<XKB_KEY_XF86Eject, Qt::Key_Eject>, - Xkb2Qt<XKB_KEY_XF86ScreenSaver, Qt::Key_ScreenSaver>, - Xkb2Qt<XKB_KEY_XF86WWW, Qt::Key_WWW>, - Xkb2Qt<XKB_KEY_XF86Sleep, Qt::Key_Sleep>, - Xkb2Qt<XKB_KEY_XF86LightBulb, Qt::Key_LightBulb>, - Xkb2Qt<XKB_KEY_XF86Shop, Qt::Key_Shop>, - Xkb2Qt<XKB_KEY_XF86History, Qt::Key_History>, - Xkb2Qt<XKB_KEY_XF86AddFavorite, Qt::Key_AddFavorite>, - Xkb2Qt<XKB_KEY_XF86HotLinks, Qt::Key_HotLinks>, - Xkb2Qt<XKB_KEY_XF86BrightnessAdjust, Qt::Key_BrightnessAdjust>, - Xkb2Qt<XKB_KEY_XF86Finance, Qt::Key_Finance>, - Xkb2Qt<XKB_KEY_XF86Community, Qt::Key_Community>, - Xkb2Qt<XKB_KEY_XF86AudioRewind, Qt::Key_AudioRewind>, - Xkb2Qt<XKB_KEY_XF86BackForward, Qt::Key_BackForward>, - Xkb2Qt<XKB_KEY_XF86ApplicationLeft, Qt::Key_ApplicationLeft>, - Xkb2Qt<XKB_KEY_XF86ApplicationRight, Qt::Key_ApplicationRight>, - Xkb2Qt<XKB_KEY_XF86Book, Qt::Key_Book>, - Xkb2Qt<XKB_KEY_XF86CD, Qt::Key_CD>, - Xkb2Qt<XKB_KEY_XF86Calculater, Qt::Key_Calculator>, - Xkb2Qt<XKB_KEY_XF86Clear, Qt::Key_Clear>, - Xkb2Qt<XKB_KEY_XF86ClearGrab, Qt::Key_ClearGrab>, - Xkb2Qt<XKB_KEY_XF86Close, Qt::Key_Close>, - Xkb2Qt<XKB_KEY_XF86Copy, Qt::Key_Copy>, - Xkb2Qt<XKB_KEY_XF86Cut, Qt::Key_Cut>, - Xkb2Qt<XKB_KEY_XF86Display, Qt::Key_Display>, - Xkb2Qt<XKB_KEY_XF86DOS, Qt::Key_DOS>, - Xkb2Qt<XKB_KEY_XF86Documents, Qt::Key_Documents>, - Xkb2Qt<XKB_KEY_XF86Excel, Qt::Key_Excel>, - Xkb2Qt<XKB_KEY_XF86Explorer, Qt::Key_Explorer>, - Xkb2Qt<XKB_KEY_XF86Game, Qt::Key_Game>, - Xkb2Qt<XKB_KEY_XF86Go, Qt::Key_Go>, - Xkb2Qt<XKB_KEY_XF86iTouch, Qt::Key_iTouch>, - Xkb2Qt<XKB_KEY_XF86LogOff, Qt::Key_LogOff>, - Xkb2Qt<XKB_KEY_XF86Market, Qt::Key_Market>, - Xkb2Qt<XKB_KEY_XF86Meeting, Qt::Key_Meeting>, - Xkb2Qt<XKB_KEY_XF86MenuKB, Qt::Key_MenuKB>, - Xkb2Qt<XKB_KEY_XF86MenuPB, Qt::Key_MenuPB>, - Xkb2Qt<XKB_KEY_XF86MySites, Qt::Key_MySites>, - Xkb2Qt<XKB_KEY_XF86New, Qt::Key_New>, - Xkb2Qt<XKB_KEY_XF86News, Qt::Key_News>, - Xkb2Qt<XKB_KEY_XF86OfficeHome, Qt::Key_OfficeHome>, - Xkb2Qt<XKB_KEY_XF86Open, Qt::Key_Open>, - Xkb2Qt<XKB_KEY_XF86Option, Qt::Key_Option>, - Xkb2Qt<XKB_KEY_XF86Paste, Qt::Key_Paste>, - Xkb2Qt<XKB_KEY_XF86Phone, Qt::Key_Phone>, - Xkb2Qt<XKB_KEY_XF86Reply, Qt::Key_Reply>, - Xkb2Qt<XKB_KEY_XF86Reload, Qt::Key_Reload>, - Xkb2Qt<XKB_KEY_XF86RotateWindows, Qt::Key_RotateWindows>, - Xkb2Qt<XKB_KEY_XF86RotationPB, Qt::Key_RotationPB>, - Xkb2Qt<XKB_KEY_XF86RotationKB, Qt::Key_RotationKB>, - Xkb2Qt<XKB_KEY_XF86Save, Qt::Key_Save>, - Xkb2Qt<XKB_KEY_XF86Send, Qt::Key_Send>, - Xkb2Qt<XKB_KEY_XF86Spell, Qt::Key_Spell>, - Xkb2Qt<XKB_KEY_XF86SplitScreen, Qt::Key_SplitScreen>, - Xkb2Qt<XKB_KEY_XF86Support, Qt::Key_Support>, - Xkb2Qt<XKB_KEY_XF86TaskPane, Qt::Key_TaskPane>, - Xkb2Qt<XKB_KEY_XF86Terminal, Qt::Key_Terminal>, - Xkb2Qt<XKB_KEY_XF86Tools, Qt::Key_Tools>, - Xkb2Qt<XKB_KEY_XF86Travel, Qt::Key_Travel>, - Xkb2Qt<XKB_KEY_XF86Video, Qt::Key_Video>, - Xkb2Qt<XKB_KEY_XF86Word, Qt::Key_Word>, - Xkb2Qt<XKB_KEY_XF86Xfer, Qt::Key_Xfer>, - Xkb2Qt<XKB_KEY_XF86ZoomIn, Qt::Key_ZoomIn>, - Xkb2Qt<XKB_KEY_XF86ZoomOut, Qt::Key_ZoomOut>, - Xkb2Qt<XKB_KEY_XF86Away, Qt::Key_Away>, - Xkb2Qt<XKB_KEY_XF86Messenger, Qt::Key_Messenger>, - Xkb2Qt<XKB_KEY_XF86WebCam, Qt::Key_WebCam>, - Xkb2Qt<XKB_KEY_XF86MailForward, Qt::Key_MailForward>, - Xkb2Qt<XKB_KEY_XF86Pictures, Qt::Key_Pictures>, - Xkb2Qt<XKB_KEY_XF86Music, Qt::Key_Music>, - Xkb2Qt<XKB_KEY_XF86Battery, Qt::Key_Battery>, - Xkb2Qt<XKB_KEY_XF86Bluetooth, Qt::Key_Bluetooth>, - Xkb2Qt<XKB_KEY_XF86WLAN, Qt::Key_WLAN>, - Xkb2Qt<XKB_KEY_XF86UWB, Qt::Key_UWB>, - Xkb2Qt<XKB_KEY_XF86AudioForward, Qt::Key_AudioForward>, - Xkb2Qt<XKB_KEY_XF86AudioRepeat, Qt::Key_AudioRepeat>, - Xkb2Qt<XKB_KEY_XF86AudioRandomPlay, Qt::Key_AudioRandomPlay>, - Xkb2Qt<XKB_KEY_XF86Subtitle, Qt::Key_Subtitle>, - Xkb2Qt<XKB_KEY_XF86AudioCycleTrack, Qt::Key_AudioCycleTrack>, - Xkb2Qt<XKB_KEY_XF86Time, Qt::Key_Time>, - Xkb2Qt<XKB_KEY_XF86Select, Qt::Key_Select>, - Xkb2Qt<XKB_KEY_XF86View, Qt::Key_View>, - Xkb2Qt<XKB_KEY_XF86TopMenu, Qt::Key_TopMenu>, - Xkb2Qt<XKB_KEY_XF86Red, Qt::Key_Red>, - Xkb2Qt<XKB_KEY_XF86Green, Qt::Key_Green>, - Xkb2Qt<XKB_KEY_XF86Yellow, Qt::Key_Yellow>, - Xkb2Qt<XKB_KEY_XF86Blue, Qt::Key_Blue>, - Xkb2Qt<XKB_KEY_XF86Bluetooth, Qt::Key_Bluetooth>, - Xkb2Qt<XKB_KEY_XF86Suspend, Qt::Key_Suspend>, - Xkb2Qt<XKB_KEY_XF86Hibernate, Qt::Key_Hibernate>, - Xkb2Qt<XKB_KEY_XF86TouchpadToggle, Qt::Key_TouchpadToggle>, - Xkb2Qt<XKB_KEY_XF86TouchpadOn, Qt::Key_TouchpadOn>, - Xkb2Qt<XKB_KEY_XF86TouchpadOff, Qt::Key_TouchpadOff>, - Xkb2Qt<XKB_KEY_XF86AudioMicMute, Qt::Key_MicMute>, - Xkb2Qt<XKB_KEY_XF86Launch0, Qt::Key_Launch2>, // ### Qt 6: remap properly - Xkb2Qt<XKB_KEY_XF86Launch1, Qt::Key_Launch3>, - Xkb2Qt<XKB_KEY_XF86Launch2, Qt::Key_Launch4>, - Xkb2Qt<XKB_KEY_XF86Launch3, Qt::Key_Launch5>, - Xkb2Qt<XKB_KEY_XF86Launch4, Qt::Key_Launch6>, - Xkb2Qt<XKB_KEY_XF86Launch5, Qt::Key_Launch7>, - Xkb2Qt<XKB_KEY_XF86Launch6, Qt::Key_Launch8>, - Xkb2Qt<XKB_KEY_XF86Launch7, Qt::Key_Launch9>, - Xkb2Qt<XKB_KEY_XF86Launch8, Qt::Key_LaunchA>, - Xkb2Qt<XKB_KEY_XF86Launch9, Qt::Key_LaunchB>, - Xkb2Qt<XKB_KEY_XF86LaunchA, Qt::Key_LaunchC>, - Xkb2Qt<XKB_KEY_XF86LaunchB, Qt::Key_LaunchD>, - Xkb2Qt<XKB_KEY_XF86LaunchC, Qt::Key_LaunchE>, - Xkb2Qt<XKB_KEY_XF86LaunchD, Qt::Key_LaunchF>, - Xkb2Qt<XKB_KEY_XF86LaunchE, Qt::Key_LaunchG>, - Xkb2Qt<XKB_KEY_XF86LaunchF, Qt::Key_LaunchH> - >::Data{} -); - -xkb_keysym_t QXkbCommon::qxkbcommon_xkb_keysym_to_upper(xkb_keysym_t ks) -{ - xkb_keysym_t lower, upper; - - xkbcommon_XConvertCase(ks, &lower, &upper); - - return upper; -} - -QString QXkbCommon::lookupString(struct xkb_state *state, xkb_keycode_t code) -{ - QVarLengthArray<char, 32> chars(32); - const int size = xkb_state_key_get_utf8(state, code, chars.data(), chars.size()); - if (Q_UNLIKELY(size + 1 > chars.size())) { // +1 for NUL - chars.resize(size + 1); - xkb_state_key_get_utf8(state, code, chars.data(), chars.size()); - } - return QString::fromUtf8(chars.constData(), size); -} - -QString QXkbCommon::lookupStringNoKeysymTransformations(xkb_keysym_t keysym) -{ - QVarLengthArray<char, 32> chars(32); - const int size = xkb_keysym_to_utf8(keysym, chars.data(), chars.size()); - if (size == 0) - return QString(); // the keysym does not have a Unicode representation - - if (Q_UNLIKELY(size > chars.size())) { - chars.resize(size); - xkb_keysym_to_utf8(keysym, chars.data(), chars.size()); - } - return QString::fromUtf8(chars.constData(), size - 1); -} - -QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event) -{ - QVector<xkb_keysym_t> keysyms; - int qtKey = event->key(); - - if (qtKey >= Qt::Key_F1 && qtKey <= Qt::Key_F35) { - keysyms.append(XKB_KEY_F1 + (qtKey - Qt::Key_F1)); - } else if (event->modifiers() & Qt::KeypadModifier) { - if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9) - keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0)); - } else if (isLatin(qtKey) && event->text().isUpper()) { - keysyms.append(qtKey); - } - - if (!keysyms.isEmpty()) - return keysyms; - - // check if we have a direct mapping - auto it = std::find_if(KeyTbl.cbegin(), KeyTbl.cend(), [&qtKey](xkb2qt_t elem) { - return elem.qt == static_cast<uint>(qtKey); - }); - if (it != KeyTbl.end()) { - keysyms.append(it->xkb); - return keysyms; - } - - QVector<uint> ucs4; - if (event->text().isEmpty()) - ucs4.append(qtKey); - else - ucs4 = event->text().toUcs4(); - - // From libxkbcommon keysym-utf.c: - // "We allow to represent any UCS character in the range U-00000000 to - // U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff." - for (uint utf32 : qAsConst(ucs4)) - keysyms.append(utf32 | 0x01000000); - - return keysyms; -} - -int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers) -{ - return keysymToQtKey(keysym, modifiers, nullptr, 0); -} - -int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers, - xkb_state *state, xkb_keycode_t code, - bool superAsMeta, bool hyperAsMeta) -{ - // Note 1: All standard key sequences on linux (as defined in platform theme) - // that use a latin character also contain a control modifier, which is why - // checking for Qt::ControlModifier is sufficient here. It is possible to - // override QPlatformTheme::keyBindings() and provide custom sequences for - // QKeySequence::StandardKey. Custom sequences probably should respect this - // convention (alternatively, we could test against other modifiers here). - // Note 2: The possibleKeys() shorcut mechanism is not affected by this value - // adjustment and does its own thing. - if (modifiers & Qt::ControlModifier) { - // With standard shortcuts we should prefer a latin character, this is - // for checks like "some qkeyevent == QKeySequence::Copy" to work even - // when using for example 'russian' keyboard layout. - if (!QXkbCommon::isLatin(keysym)) { - xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code); - if (latinKeysym != XKB_KEY_NoSymbol) - keysym = latinKeysym; - } - } - - return keysymToQtKey_internal(keysym, modifiers, state, code, superAsMeta, hyperAsMeta); -} - -static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers, - xkb_state *state, xkb_keycode_t code, - bool superAsMeta, bool hyperAsMeta) -{ - int qtKey = 0; - - // lookup from direct mapping - if (keysym >= XKB_KEY_F1 && keysym <= XKB_KEY_F35) { - // function keys - qtKey = Qt::Key_F1 + (keysym - XKB_KEY_F1); - } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) { - // numeric keypad keys - qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0); - } else if (QXkbCommon::isLatin(keysym)) { - qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym); - } else { - // check if we have a direct mapping - xkb2qt_t searchKey{keysym, 0}; - auto it = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey); - if (it != KeyTbl.end() && !(searchKey < *it)) - qtKey = it->qt; - } - - if (qtKey) - return qtKey; - - // lookup from unicode - QString text; - if (!state || modifiers & Qt::ControlModifier) { - // Control modifier changes the text to ASCII control character, therefore we - // can't use this text to map keysym to a qt key. We can use the same keysym - // (it is not affectd by transformation) to obtain untransformed text. For details - // see "Appendix A. Default Symbol Transformations" in the XKB specification. - text = QXkbCommon::lookupStringNoKeysymTransformations(keysym); - } else { - text = QXkbCommon::lookupString(state, code); - } - if (!text.isEmpty()) { - if (text.unicode()->isDigit()) { - // Ensures that also non-latin digits are mapped to corresponding qt keys, - // e.g CTRL + Û² (arabic two), is mapped to CTRL + Qt::Key_2. - qtKey = Qt::Key_0 + text.unicode()->digitValue(); - } else { - qtKey = text.unicode()->toUpper().unicode(); - } - } - - // translate Super/Hyper keys to Meta if we're using them as the MetaModifier - if (superAsMeta && (qtKey == Qt::Key_Super_L || qtKey == Qt::Key_Super_R)) - qtKey = Qt::Key_Meta; - if (hyperAsMeta && (qtKey == Qt::Key_Hyper_L || qtKey == Qt::Key_Hyper_R)) - qtKey = Qt::Key_Meta; - - return qtKey; -} - -Qt::KeyboardModifiers QXkbCommon::modifiers(struct xkb_state *state) -{ - Qt::KeyboardModifiers modifiers = Qt::NoModifier; - - if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL, XKB_STATE_MODS_EFFECTIVE) > 0) - modifiers |= Qt::ControlModifier; - if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT, XKB_STATE_MODS_EFFECTIVE) > 0) - modifiers |= Qt::AltModifier; - if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_SHIFT, XKB_STATE_MODS_EFFECTIVE) > 0) - modifiers |= Qt::ShiftModifier; - if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_LOGO, XKB_STATE_MODS_EFFECTIVE) > 0) - modifiers |= Qt::MetaModifier; - - return modifiers; -} - -// Possible modifier states. -static const Qt::KeyboardModifiers ModsTbl[] = { - Qt::NoModifier, // 0 - Qt::ShiftModifier, // 1 - Qt::ControlModifier, // 2 - Qt::ControlModifier | Qt::ShiftModifier, // 3 - Qt::AltModifier, // 4 - Qt::AltModifier | Qt::ShiftModifier, // 5 - Qt::AltModifier | Qt::ControlModifier, // 6 - Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier, // 7 - Qt::NoModifier // Fall-back to raw Key_*, for non-latin1 kb layouts -}; - -QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event, - bool superAsMeta, bool hyperAsMeta) -{ - QList<int> result; - quint32 keycode = event->nativeScanCode(); - Qt::KeyboardModifiers modifiers = event->modifiers(); - xkb_keymap *keymap = xkb_state_get_keymap(state); - // turn off the modifier bits which doesn't participate in shortcuts - Qt::KeyboardModifiers notNeeded = Qt::KeypadModifier | Qt::GroupSwitchModifier; - modifiers &= ~notNeeded; - // create a fresh kb state and test against the relevant modifier combinations - ScopedXKBState scopedXkbQueryState(xkb_state_new(keymap)); - xkb_state *queryState = scopedXkbQueryState.get(); - if (!queryState) { - qCWarning(lcXkbcommon) << Q_FUNC_INFO << "failed to compile xkb keymap"; - return result; - } - // get kb state from the master state and update the temporary state - xkb_layout_index_t lockedLayout = xkb_state_serialize_layout(state, XKB_STATE_LAYOUT_LOCKED); - xkb_mod_mask_t latchedMods = xkb_state_serialize_mods(state, XKB_STATE_MODS_LATCHED); - xkb_mod_mask_t lockedMods = xkb_state_serialize_mods(state, XKB_STATE_MODS_LOCKED); - xkb_mod_mask_t depressedMods = xkb_state_serialize_mods(state, XKB_STATE_MODS_DEPRESSED); - xkb_state_update_mask(queryState, depressedMods, latchedMods, lockedMods, 0, 0, lockedLayout); - // handle shortcuts for level three and above - xkb_layout_index_t layoutIndex = xkb_state_key_get_layout(queryState, keycode); - xkb_level_index_t levelIndex = 0; - if (layoutIndex != XKB_LAYOUT_INVALID) { - levelIndex = xkb_state_key_get_level(queryState, keycode, layoutIndex); - if (levelIndex == XKB_LEVEL_INVALID) - levelIndex = 0; - } - if (levelIndex <= 1) - xkb_state_update_mask(queryState, 0, latchedMods, lockedMods, 0, 0, lockedLayout); - - xkb_keysym_t sym = xkb_state_key_get_one_sym(queryState, keycode); - if (sym == XKB_KEY_NoSymbol) - return result; - - int baseQtKey = keysymToQtKey_internal(sym, modifiers, queryState, keycode, superAsMeta, hyperAsMeta); - if (baseQtKey) - result += (baseQtKey + modifiers); - - xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(keymap, "Shift"); - xkb_mod_index_t altMod = xkb_keymap_mod_get_index(keymap, "Alt"); - xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(keymap, "Control"); - xkb_mod_index_t metaMod = xkb_keymap_mod_get_index(keymap, "Meta"); - - Q_ASSERT(shiftMod < 32); - Q_ASSERT(altMod < 32); - Q_ASSERT(controlMod < 32); - - xkb_mod_mask_t depressed; - int qtKey = 0; - // obtain a list of possible shortcuts for the given key event - for (uint i = 1; i < sizeof(ModsTbl) / sizeof(*ModsTbl) ; ++i) { - Qt::KeyboardModifiers neededMods = ModsTbl[i]; - if ((modifiers & neededMods) == neededMods) { - if (i == 8) { - if (isLatin(baseQtKey)) - continue; - // add a latin key as a fall back key - sym = lookupLatinKeysym(state, keycode); - } else { - depressed = 0; - if (neededMods & Qt::AltModifier) - depressed |= (1 << altMod); - if (neededMods & Qt::ShiftModifier) - depressed |= (1 << shiftMod); - if (neededMods & Qt::ControlModifier) - depressed |= (1 << controlMod); - if (metaMod < 32 && neededMods & Qt::MetaModifier) - depressed |= (1 << metaMod); - xkb_state_update_mask(queryState, depressed, latchedMods, lockedMods, 0, 0, lockedLayout); - sym = xkb_state_key_get_one_sym(queryState, keycode); - } - if (sym == XKB_KEY_NoSymbol) - continue; - - Qt::KeyboardModifiers mods = modifiers & ~neededMods; - qtKey = keysymToQtKey_internal(sym, mods, queryState, keycode, superAsMeta, hyperAsMeta); - if (!qtKey || qtKey == baseQtKey) - continue; - - // catch only more specific shortcuts, i.e. Ctrl+Shift+= also generates Ctrl++ and +, - // but Ctrl++ is more specific than +, so we should skip the last one - bool ambiguous = false; - for (int shortcut : qAsConst(result)) { - if (int(shortcut & ~Qt::KeyboardModifierMask) == qtKey && (shortcut & mods) == mods) { - ambiguous = true; - break; - } - } - if (ambiguous) - continue; - - result += (qtKey + mods); - } - } - - return result; -} - -void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap) -{ - const xkb_layout_index_t layoutCount = xkb_keymap_num_layouts(keymap); - const xkb_keycode_t minKeycode = xkb_keymap_min_keycode(keymap); - const xkb_keycode_t maxKeycode = xkb_keymap_max_keycode(keymap); - - const xkb_keysym_t *keysyms = nullptr; - int nrLatinKeys = 0; - for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) { - for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) { - xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms); - if (keysyms && isLatin(keysyms[0])) - nrLatinKeys++; - if (nrLatinKeys > 10) // arbitrarily chosen threshold - return; - } - } - // This means that lookupLatinKeysym() will not find anything and latin - // key shortcuts might not work. This is a bug in the affected desktop - // environment. Usually can be solved via system settings by adding e.g. 'us' - // layout to the list of seleced layouts, or by using command line, "setxkbmap - // -layout rus,en". The position of latin key based layout in the list of the - // selected layouts is irrelevant. Properly functioning desktop environments - // handle this behind the scenes, even if no latin key based layout has been - // explicitly listed in the selected layouts. - qCDebug(lcXkbcommon, "no keyboard layouts with latin keys present"); -} - -xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode) -{ - xkb_layout_index_t layout; - xkb_keysym_t sym = XKB_KEY_NoSymbol; - xkb_keymap *keymap = xkb_state_get_keymap(state); - const xkb_layout_index_t layoutCount = xkb_keymap_num_layouts_for_key(keymap, keycode); - const xkb_layout_index_t currentLayout = xkb_state_key_get_layout(state, keycode); - // Look at user layouts in the order in which they are defined in system - // settings to find a latin keysym. - for (layout = 0; layout < layoutCount; ++layout) { - if (layout == currentLayout) - continue; - const xkb_keysym_t *syms = nullptr; - xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout); - if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1) - continue; - if (isLatin(syms[0])) { - sym = syms[0]; - break; - } - } - - if (sym == XKB_KEY_NoSymbol) - return sym; - - xkb_mod_mask_t latchedMods = xkb_state_serialize_mods(state, XKB_STATE_MODS_LATCHED); - xkb_mod_mask_t lockedMods = xkb_state_serialize_mods(state, XKB_STATE_MODS_LOCKED); - - // Check for uniqueness, consider the following setup: - // setxkbmap -layout us,ru,us -variant dvorak,, -option 'grp:ctrl_alt_toggle' (set 'ru' as active). - // In this setup, the user would expect to trigger a ctrl+q shortcut by pressing ctrl+<physical x key>, - // because "US dvorak" is higher up in the layout settings list. This check verifies that an obtained - // 'sym' can not be acquired by any other layout higher up in the user's layout list. If it can be acquired - // then the obtained key is not unique. This prevents ctrl+<physical q key> from generating a ctrl+q - // shortcut in the above described setup. We don't want ctrl+<physical x key> and ctrl+<physical q key> to - // generate the same shortcut event in this case. - const xkb_keycode_t minKeycode = xkb_keymap_min_keycode(keymap); - const xkb_keycode_t maxKeycode = xkb_keymap_max_keycode(keymap); - ScopedXKBState queryState(xkb_state_new(keymap)); - for (xkb_layout_index_t prevLayout = 0; prevLayout < layout; ++prevLayout) { - xkb_state_update_mask(queryState.get(), 0, latchedMods, lockedMods, 0, 0, prevLayout); - for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) { - xkb_keysym_t prevSym = xkb_state_key_get_one_sym(queryState.get(), code); - if (prevSym == sym) { - sym = XKB_KEY_NoSymbol; - break; - } - } - } - - return sym; -} - -void QXkbCommon::setXkbContext(QPlatformInputContext *inputContext, struct xkb_context *context) -{ - if (!inputContext || !context) - return; - - const char *const inputContextClassName = "QComposeInputContext"; - const char *const normalizedSignature = "setXkbContext(xkb_context*)"; - - if (inputContext->objectName() != QLatin1String(inputContextClassName)) - return; - - static const QMetaMethod setXkbContext = [&]() { - int methodIndex = inputContext->metaObject()->indexOfMethod(normalizedSignature); - QMetaMethod method = inputContext->metaObject()->method(methodIndex); - Q_ASSERT(method.isValid()); - if (!method.isValid()) - qCWarning(lcXkbcommon) << normalizedSignature << "not found on" << inputContextClassName; - return method; - }(); - - if (!setXkbContext.isValid()) - return; - - setXkbContext.invoke(inputContext, Qt::DirectConnection, Q_ARG(struct xkb_context*, context)); -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/input/xkbcommon/qxkbcommon_3rdparty.cpp b/src/platformsupport/input/xkbcommon/qxkbcommon_3rdparty.cpp deleted file mode 100644 index 08f43b3b72..0000000000 --- a/src/platformsupport/input/xkbcommon/qxkbcommon_3rdparty.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ - -/* Copyright 1985, 1987, 1990, 1998 The Open Group - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the names of the authors or their - institutions shall not be used in advertising or otherwise to promote the - sale, use or other dealings in this Software without prior written - authorization from the authors. - - - - Copyright © 2009 Dan Nicholson - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice (including the next - paragraph) shall be included in all copies or substantial portions of the - Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. -*/ - -/* - XConvertCase was copied from src/3rdparty/xkbcommon/src/keysym.c - The following code modifications were applied: - - XConvertCase() was renamed to xkbcommon_XConvertCase(), to not confuse it - with Xlib's XConvertCase(). - - UCSConvertCase() was renamed to qt_UCSConvertCase() and function's body was - replaced to use Qt APIs for doing case conversion, which should give us better - results instead of using the less complete version from keysym.c -*/ - -#include "qxkbcommon_p.h" - -#include <QtCore/QChar> - -static void qt_UCSConvertCase(uint32_t code, xkb_keysym_t *lower, xkb_keysym_t *upper) -{ - *lower = QChar::toLower(code); - *upper = QChar::toUpper(code); -} - -void QXkbCommon::xkbcommon_XConvertCase(xkb_keysym_t sym, xkb_keysym_t *lower, xkb_keysym_t *upper) -{ - /* Latin 1 keysym */ - if (sym < 0x100) { - qt_UCSConvertCase(sym, lower, upper); - return; - } - - /* Unicode keysym */ - if ((sym & 0xff000000) == 0x01000000) { - qt_UCSConvertCase((sym & 0x00ffffff), lower, upper); - *upper |= 0x01000000; - *lower |= 0x01000000; - return; - } - - /* Legacy keysym */ - - *lower = sym; - *upper = sym; - - switch (sym >> 8) { - case 1: /* Latin 2 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym == XKB_KEY_Aogonek) - *lower = XKB_KEY_aogonek; - else if (sym >= XKB_KEY_Lstroke && sym <= XKB_KEY_Sacute) - *lower += (XKB_KEY_lstroke - XKB_KEY_Lstroke); - else if (sym >= XKB_KEY_Scaron && sym <= XKB_KEY_Zacute) - *lower += (XKB_KEY_scaron - XKB_KEY_Scaron); - else if (sym >= XKB_KEY_Zcaron && sym <= XKB_KEY_Zabovedot) - *lower += (XKB_KEY_zcaron - XKB_KEY_Zcaron); - else if (sym == XKB_KEY_aogonek) - *upper = XKB_KEY_Aogonek; - else if (sym >= XKB_KEY_lstroke && sym <= XKB_KEY_sacute) - *upper -= (XKB_KEY_lstroke - XKB_KEY_Lstroke); - else if (sym >= XKB_KEY_scaron && sym <= XKB_KEY_zacute) - *upper -= (XKB_KEY_scaron - XKB_KEY_Scaron); - else if (sym >= XKB_KEY_zcaron && sym <= XKB_KEY_zabovedot) - *upper -= (XKB_KEY_zcaron - XKB_KEY_Zcaron); - else if (sym >= XKB_KEY_Racute && sym <= XKB_KEY_Tcedilla) - *lower += (XKB_KEY_racute - XKB_KEY_Racute); - else if (sym >= XKB_KEY_racute && sym <= XKB_KEY_tcedilla) - *upper -= (XKB_KEY_racute - XKB_KEY_Racute); - break; - case 2: /* Latin 3 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XKB_KEY_Hstroke && sym <= XKB_KEY_Hcircumflex) - *lower += (XKB_KEY_hstroke - XKB_KEY_Hstroke); - else if (sym >= XKB_KEY_Gbreve && sym <= XKB_KEY_Jcircumflex) - *lower += (XKB_KEY_gbreve - XKB_KEY_Gbreve); - else if (sym >= XKB_KEY_hstroke && sym <= XKB_KEY_hcircumflex) - *upper -= (XKB_KEY_hstroke - XKB_KEY_Hstroke); - else if (sym >= XKB_KEY_gbreve && sym <= XKB_KEY_jcircumflex) - *upper -= (XKB_KEY_gbreve - XKB_KEY_Gbreve); - else if (sym >= XKB_KEY_Cabovedot && sym <= XKB_KEY_Scircumflex) - *lower += (XKB_KEY_cabovedot - XKB_KEY_Cabovedot); - else if (sym >= XKB_KEY_cabovedot && sym <= XKB_KEY_scircumflex) - *upper -= (XKB_KEY_cabovedot - XKB_KEY_Cabovedot); - break; - case 3: /* Latin 4 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XKB_KEY_Rcedilla && sym <= XKB_KEY_Tslash) - *lower += (XKB_KEY_rcedilla - XKB_KEY_Rcedilla); - else if (sym >= XKB_KEY_rcedilla && sym <= XKB_KEY_tslash) - *upper -= (XKB_KEY_rcedilla - XKB_KEY_Rcedilla); - else if (sym == XKB_KEY_ENG) - *lower = XKB_KEY_eng; - else if (sym == XKB_KEY_eng) - *upper = XKB_KEY_ENG; - else if (sym >= XKB_KEY_Amacron && sym <= XKB_KEY_Umacron) - *lower += (XKB_KEY_amacron - XKB_KEY_Amacron); - else if (sym >= XKB_KEY_amacron && sym <= XKB_KEY_umacron) - *upper -= (XKB_KEY_amacron - XKB_KEY_Amacron); - break; - case 6: /* Cyrillic */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XKB_KEY_Serbian_DJE && sym <= XKB_KEY_Serbian_DZE) - *lower -= (XKB_KEY_Serbian_DJE - XKB_KEY_Serbian_dje); - else if (sym >= XKB_KEY_Serbian_dje && sym <= XKB_KEY_Serbian_dze) - *upper += (XKB_KEY_Serbian_DJE - XKB_KEY_Serbian_dje); - else if (sym >= XKB_KEY_Cyrillic_YU && sym <= XKB_KEY_Cyrillic_HARDSIGN) - *lower -= (XKB_KEY_Cyrillic_YU - XKB_KEY_Cyrillic_yu); - else if (sym >= XKB_KEY_Cyrillic_yu && sym <= XKB_KEY_Cyrillic_hardsign) - *upper += (XKB_KEY_Cyrillic_YU - XKB_KEY_Cyrillic_yu); - break; - case 7: /* Greek */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XKB_KEY_Greek_ALPHAaccent && sym <= XKB_KEY_Greek_OMEGAaccent) - *lower += (XKB_KEY_Greek_alphaaccent - XKB_KEY_Greek_ALPHAaccent); - else if (sym >= XKB_KEY_Greek_alphaaccent && sym <= XKB_KEY_Greek_omegaaccent && - sym != XKB_KEY_Greek_iotaaccentdieresis && - sym != XKB_KEY_Greek_upsilonaccentdieresis) - *upper -= (XKB_KEY_Greek_alphaaccent - XKB_KEY_Greek_ALPHAaccent); - else if (sym >= XKB_KEY_Greek_ALPHA && sym <= XKB_KEY_Greek_OMEGA) - *lower += (XKB_KEY_Greek_alpha - XKB_KEY_Greek_ALPHA); - else if (sym >= XKB_KEY_Greek_alpha && sym <= XKB_KEY_Greek_omega && - sym != XKB_KEY_Greek_finalsmallsigma) - *upper -= (XKB_KEY_Greek_alpha - XKB_KEY_Greek_ALPHA); - break; - case 0x13: /* Latin 9 */ - if (sym == XKB_KEY_OE) - *lower = XKB_KEY_oe; - else if (sym == XKB_KEY_oe) - *upper = XKB_KEY_OE; - else if (sym == XKB_KEY_Ydiaeresis) - *lower = XKB_KEY_ydiaeresis; - break; - } -} diff --git a/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/src/platformsupport/input/xkbcommon/qxkbcommon_p.h deleted file mode 100644 index 561eae03db..0000000000 --- a/src/platformsupport/input/xkbcommon/qxkbcommon_p.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 QXKBCOMMON_P_H -#define QXKBCOMMON_P_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 <QtCore/QString> -#include <QtCore/QVector> -#include <QtCore/QLoggingCategory> -#include <QtCore/QList> - -#include <xkbcommon/xkbcommon.h> - -#include <memory> - -QT_BEGIN_NAMESPACE - -Q_DECLARE_LOGGING_CATEGORY(lcXkbcommon) - -class QEvent; -class QKeyEvent; -class QPlatformInputContext; - -class QXkbCommon -{ -public: - static QString lookupString(struct xkb_state *state, xkb_keycode_t code); - static QString lookupStringNoKeysymTransformations(xkb_keysym_t keysym); - - static QVector<xkb_keysym_t> toKeysym(QKeyEvent *event); - - static int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers); - static int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers, - xkb_state *state, xkb_keycode_t code, - bool superAsMeta = false, bool hyperAsMeta = false); - - // xkbcommon_* API is part of libxkbcommon internals, with modifications as - // desribed in the header of the implementation file. - static void xkbcommon_XConvertCase(xkb_keysym_t sym, xkb_keysym_t *lower, xkb_keysym_t *upper); - static xkb_keysym_t qxkbcommon_xkb_keysym_to_upper(xkb_keysym_t ks); - - static Qt::KeyboardModifiers modifiers(struct xkb_state *state); - - static QList<int> possibleKeys(xkb_state *state, const QKeyEvent *event, - bool superAsMeta = false, bool hyperAsMeta = false); - - static void verifyHasLatinLayout(xkb_keymap *keymap); - static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode); - - static bool isLatin(xkb_keysym_t sym) { - return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z')); - } - static bool isKeypad(xkb_keysym_t sym) { - return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9; - } - - static void setXkbContext(QPlatformInputContext *inputContext, struct xkb_context *context); - - struct XKBStateDeleter { - void operator()(struct xkb_state *state) const { return xkb_state_unref(state); } - }; - struct XKBKeymapDeleter { - void operator()(struct xkb_keymap *keymap) const { return xkb_keymap_unref(keymap); } - }; - struct XKBContextDeleter { - void operator()(struct xkb_context *context) const { return xkb_context_unref(context); } - }; - using ScopedXKBState = std::unique_ptr<struct xkb_state, XKBStateDeleter>; - using ScopedXKBKeymap = std::unique_ptr<struct xkb_keymap, XKBKeymapDeleter>; - using ScopedXKBContext = std::unique_ptr<struct xkb_context, XKBContextDeleter>; -}; - -QT_END_NAMESPACE - -#endif // QXKBCOMMON_P_H diff --git a/src/platformsupport/input/xkbcommon/xkbcommon.pro b/src/platformsupport/input/xkbcommon/xkbcommon.pro deleted file mode 100644 index 22b16ae44a..0000000000 --- a/src/platformsupport/input/xkbcommon/xkbcommon.pro +++ /dev/null @@ -1,23 +0,0 @@ -TARGET = QtXkbCommonSupport -MODULE = xkbcommon_support - -QT = core-private gui-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../../corelib/global/qt_pch.h - -QMAKE_USE += xkbcommon - -HEADERS += \ - qxkbcommon_p.h - -SOURCES += \ - qxkbcommon.cpp \ - qxkbcommon_3rdparty.cpp - -# qxkbcommon.cpp::KeyTbl has more than 256 levels of expansion and older -# Clang uses that as a limit (it's 1024 in current versions). -clang:!intel_icc: QMAKE_CXXFLAGS += -ftemplate-depth=1024 - -load(qt_module) diff --git a/src/platformsupport/kmsconvenience/.prev_CMakeLists.txt b/src/platformsupport/kmsconvenience/.prev_CMakeLists.txt deleted file mode 100644 index 5b0fd00566..0000000000 --- a/src/platformsupport/kmsconvenience/.prev_CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Generated from kmsconvenience.pro. - -##################################################################### -## KmsSupport Module: -##################################################################### - -qt_add_module(KmsSupport - STATIC - INTERNAL_MODULE - SOURCES - qkmsdevice.cpp qkmsdevice_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Libdrm::Libdrm - Qt::CorePrivate - Qt::GuiPrivate -) - -#### Keys ignored in scope 1:.:.:kmsconvenience.pro:<TRUE>: -# MODULE = "kms_support" diff --git a/src/platformsupport/kmsconvenience/CMakeLists.txt b/src/platformsupport/kmsconvenience/CMakeLists.txt index 8001ee27de..9cd4eb1d33 100644 --- a/src/platformsupport/kmsconvenience/CMakeLists.txt +++ b/src/platformsupport/kmsconvenience/CMakeLists.txt @@ -1,12 +1,14 @@ -# Generated from kmsconvenience.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -qt_find_package(Libdrm) # special case +qt_find_package(Libdrm) ##################################################################### -## KmsSupport Module: +## KmsSupportPrivate Module: ##################################################################### -qt_add_module(KmsSupport +qt_internal_add_module(KmsSupportPrivate + CONFIG_MODULE_NAME kms_support STATIC INTERNAL_MODULE SOURCES @@ -17,7 +19,5 @@ qt_add_module(KmsSupport Libdrm::Libdrm Qt::CorePrivate Qt::GuiPrivate + NO_GENERATE_CPP_EXPORTS ) - -#### Keys ignored in scope 1:.:.:kmsconvenience.pro:<TRUE>: -# MODULE = "kms_support" diff --git a/src/platformsupport/kmsconvenience/kmsconvenience.pro b/src/platformsupport/kmsconvenience/kmsconvenience.pro deleted file mode 100644 index 0c5a20a239..0000000000 --- a/src/platformsupport/kmsconvenience/kmsconvenience.pro +++ /dev/null @@ -1,19 +0,0 @@ -TARGET = QtKmsSupport -MODULE = kms_support - -QT = core-private gui-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII - -HEADERS += \ - qkmsdevice_p.h - -SOURCES += \ - qkmsdevice.cpp - -QMAKE_USE += drm - -LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD - -load(qt_module) diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 8cd7f9b368..421e9f05c0 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -1,43 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Pelagicore AG -** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2016 Pelagicore AG +// Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qkmsdevice_p.h" @@ -53,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(qLcKmsDebug, "qt.qpa.eglfs.kms") enum OutputConfiguration { @@ -234,7 +200,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, if (userConnectorConfig.contains(QStringLiteral("virtualPos"))) { const QByteArray vpos = userConnectorConfig.value(QStringLiteral("virtualPos")).toByteArray(); const QByteArrayList vposComp = vpos.split(','); - if (vposComp.count() == 2) + if (vposComp.size() == 2) vinfo->virtualPos = QPoint(vposComp[0].trimmed().toInt(), vposComp[1].trimmed().toInt()); } if (userConnectorConfig.value(QStringLiteral("primary")).toBool()) @@ -318,7 +284,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, if (current < 0 && crtc_mode.clock != 0) { modes << crtc_mode; - current = mode.size() - 1; + current = modes.size() - 1; } if (configuration == OutputConfigCurrent) @@ -462,7 +428,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, if (plane.possibleCrtcs & (1 << output.crtc_index)) { output.available_planes.append(plane); planeListStr.append(QString::number(plane.id)); - planeListStr.append(QLatin1Char(' ')); + planeListStr.append(u' '); // Choose the first primary plane that is not already assigned to // another screen's associated crtc. @@ -471,7 +437,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } } qCDebug(qLcKmsDebug, "Output %s can use %d planes: %s", - connectorName.constData(), output.available_planes.count(), qPrintable(planeListStr)); + connectorName.constData(), int(output.available_planes.size()), qPrintable(planeListStr)); // This is for the EGLDevice/EGLStream backend. On some of those devices one // may want to target a pre-configured plane. It is probably useless for @@ -509,10 +475,10 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_KMS_PLANES_FOR_CRTCS")) { const QString val = qEnvironmentVariable("QT_QPA_EGLFS_KMS_PLANES_FOR_CRTCS"); qCDebug(qLcKmsDebug, "crtc_id:plane_id override list: %s", qPrintable(val)); - const QStringList crtcPlanePairs = val.split(QLatin1Char(':')); + const QStringList crtcPlanePairs = val.split(u':'); for (const QString &crtcPlanePair : crtcPlanePairs) { - const QStringList values = crtcPlanePair.split(QLatin1Char(',')); - if (values.count() == 2 && uint(values[0].toInt()) == output.crtc_id) { + const QStringList values = crtcPlanePair.split(u','); + if (values.size() == 2 && uint(values[0].toInt()) == output.crtc_id) { uint planeId = values[1].toInt(); for (QKmsPlane &kmsplane : m_planes) { if (kmsplane.id == planeId) { @@ -664,7 +630,7 @@ void QKmsDevice::createScreens() discoverPlanes(); - QVector<OrderedScreen> screens; + QList<OrderedScreen> screens; int wantedConnectorIndex = -1; bool ok; @@ -702,7 +668,7 @@ void QKmsDevice::createScreens() // The final list of screens is available, so do the second phase setup. // Hook up clone sources and targets. for (const OrderedScreen &orderedScreen : screens) { - QVector<QPlatformScreen *> screensCloningThisScreen; + QList<QPlatformScreen *> screensCloningThisScreen; for (const OrderedScreen &s : screens) { if (s.vinfo.output.clone_source == orderedScreen.vinfo.output.name) screensCloningThisScreen.append(s.screen); @@ -727,7 +693,7 @@ void QKmsDevice::createScreens() // Figure out the virtual desktop and register the screens to QPA/QGuiApplication. QPoint pos(0, 0); QList<QPlatformScreen *> siblings; - QVector<QPoint> virtualPositions; + QList<QPoint> virtualPositions; int primarySiblingIdx = -1; for (const OrderedScreen &orderedScreen : screens) { @@ -750,10 +716,11 @@ void QKmsDevice::createScreens() // virtualIndex. This is not only handy but also required since for instance // evdevtouch relies on it when performing touch device - screen mapping. if (!m_screenConfig->separateScreens()) { + qCDebug(qLcKmsDebug) << " virtual position is" << virtualPos; siblings.append(s); virtualPositions.append(virtualPos); if (orderedScreen.vinfo.isPrimary) - primarySiblingIdx = siblings.count() - 1; + primarySiblingIdx = siblings.size() - 1; } else { registerScreen(s, orderedScreen.vinfo.isPrimary, virtualPos, QList<QPlatformScreen *>() << s); } @@ -761,7 +728,7 @@ void QKmsDevice::createScreens() if (!m_screenConfig->separateScreens()) { // enable the virtual desktop - for (int i = 0; i < siblings.count(); ++i) + for (int i = 0; i < siblings.size(); ++i) registerScreen(siblings[i], i == primarySiblingIdx, virtualPositions[i], siblings); } } @@ -775,7 +742,7 @@ QPlatformScreen *QKmsDevice::createHeadlessScreen() // not all subclasses support screen cloning void QKmsDevice::registerScreenCloning(QPlatformScreen *screen, QPlatformScreen *screenThisScreenClones, - const QVector<QPlatformScreen *> &screensCloningThisScreen) + const QList<QPlatformScreen *> &screensCloningThisScreen) { Q_UNUSED(screen); Q_UNUSED(screenThisScreenClones); @@ -1011,7 +978,7 @@ void QKmsDevice::parseCrtcProperties(uint32_t crtcId, QKmsOutput *output) } enumerateProperties(objProps, [output](drmModePropertyPtr prop, quint64 value) { - Q_UNUSED(value) + Q_UNUSED(value); if (!strcasecmp(prop->name, "mode_id")) output->modeIdPropertyId = prop->prop_id; else if (!strcasecmp(prop->name, "active")) @@ -1033,7 +1000,6 @@ QKmsScreenConfig::QKmsScreenConfig() , m_pbuffers(false) , m_virtualDesktopLayout(VirtualDesktopLayoutHorizontal) { - loadConfig(); } void QKmsScreenConfig::loadConfig() @@ -1063,7 +1029,7 @@ void QKmsScreenConfig::loadConfig() const QJsonObject object = doc.object(); - const QString headlessStr = object.value(QLatin1String("headless")).toString(); + const QString headlessStr = object.value("headless"_L1).toString(); const QByteArray headless = headlessStr.toUtf8(); QSize headlessSize; if (sscanf(headless.constData(), "%dx%d", &headlessSize.rwidth(), &headlessSize.rheight()) == 2) { @@ -1073,22 +1039,22 @@ void QKmsScreenConfig::loadConfig() m_headless = false; } - m_hwCursor = object.value(QLatin1String("hwcursor")).toBool(m_hwCursor); - m_pbuffers = object.value(QLatin1String("pbuffers")).toBool(m_pbuffers); - m_devicePath = object.value(QLatin1String("device")).toString(); - m_separateScreens = object.value(QLatin1String("separateScreens")).toBool(m_separateScreens); + m_hwCursor = object.value("hwcursor"_L1).toBool(m_hwCursor); + m_pbuffers = object.value("pbuffers"_L1).toBool(m_pbuffers); + m_devicePath = object.value("device"_L1).toString(); + m_separateScreens = object.value("separateScreens"_L1).toBool(m_separateScreens); - const QString vdOriString = object.value(QLatin1String("virtualDesktopLayout")).toString(); + const QString vdOriString = object.value("virtualDesktopLayout"_L1).toString(); if (!vdOriString.isEmpty()) { - if (vdOriString == QLatin1String("horizontal")) + if (vdOriString == "horizontal"_L1) m_virtualDesktopLayout = VirtualDesktopLayoutHorizontal; - else if (vdOriString == QLatin1String("vertical")) + else if (vdOriString == "vertical"_L1) m_virtualDesktopLayout = VirtualDesktopLayoutVertical; else qCWarning(qLcKmsDebug) << "Unknown virtualDesktopOrientation value" << vdOriString; } - const QJsonArray outputs = object.value(QLatin1String("outputs")).toArray(); + const QJsonArray outputs = object.value("outputs"_L1).toArray(); for (int i = 0; i < outputs.size(); i++) { const QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap(); diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index 55a590cfce..050d836cb1 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -1,43 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Pelagicore AG -** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Pelagicore AG +// Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QKMSDEVICE_P_H #define QKMSDEVICE_P_H @@ -66,7 +30,7 @@ #include <functional> // In less fortunate cases one may need to build on a system with dev headers -// from the dark ages. Let's pull a GL and define the missing stuff outselves. +// from the dark ages. Let's pull a GL and define the missing stuff ourselves. #ifndef DRM_PLANE_TYPE_OVERLAY #define DRM_PLANE_TYPE_OVERLAY 0 @@ -111,6 +75,7 @@ public: }; QKmsScreenConfig(); + virtual ~QKmsScreenConfig() {} QString devicePath() const { return m_devicePath; } @@ -122,10 +87,9 @@ public: VirtualDesktopLayout virtualDesktopLayout() const { return m_virtualDesktopLayout; } QMap<QString, QVariantMap> outputSettings() const { return m_outputSettings; } + virtual void loadConfig(); -private: - void loadConfig(); - +protected: QString m_devicePath; bool m_headless; QSize m_headlessSize; @@ -163,7 +127,7 @@ struct QKmsPlane int possibleCrtcs = 0; - QVector<uint32_t> supportedFormats; + QList<uint32_t> supportedFormats; Rotations initialRotation = Rotation0; Rotations availableRotations = Rotation0; @@ -207,7 +171,7 @@ struct QKmsOutput uint32_t drm_format = DRM_FORMAT_XRGB8888; bool drm_format_requested_by_user = false; QString clone_source; - QVector<QKmsPlane> available_planes; + QList<QKmsPlane> available_planes; struct QKmsPlane *eglfs_plane = nullptr; QSize size; uint32_t crtcIdPropertyId = 0; @@ -258,7 +222,7 @@ protected: virtual QPlatformScreen *createHeadlessScreen(); virtual void registerScreenCloning(QPlatformScreen *screen, QPlatformScreen *screenThisScreenClones, - const QVector<QPlatformScreen *> &screensCloningThisScreen); + const QList<QPlatformScreen *> &screensCloningThisScreen); virtual void registerScreen(QPlatformScreen *screen, bool isPrimary, const QPoint &virtualPos, @@ -292,7 +256,7 @@ protected: #endif quint32 m_crtc_allocator; - QVector<QKmsPlane> m_planes; + QList<QKmsPlane> m_planes; private: Q_DISABLE_COPY(QKmsDevice) diff --git a/src/platformsupport/linuxaccessibility/.prev_CMakeLists.txt b/src/platformsupport/linuxaccessibility/.prev_CMakeLists.txt deleted file mode 100644 index 38d3d2831f..0000000000 --- a/src/platformsupport/linuxaccessibility/.prev_CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Generated from linuxaccessibility.pro. - -##################################################################### -## LinuxAccessibilitySupport Module: -##################################################################### - -qt_add_module(LinuxAccessibilitySupport - STATIC - INTERNAL_MODULE - SOURCES - application.cpp application_p.h - atspiadaptor.cpp atspiadaptor_p.h - bridge.cpp bridge_p.h - cache.cpp cache_p.h - constant_mappings.cpp constant_mappings_p.h - dbusconnection.cpp dbusconnection_p.h - struct_marshallers.cpp struct_marshallers_p.h - DBUS_ADAPTOR_SOURCES - dbusxml/Cache.xml - dbusxml/DeviceEventController.xml - DBUS_ADAPTOR_FLAGS - "-i" "struct_marshallers_p.h" - DBUS_INTERFACE_SOURCES - dbusxml/Bus.xml - dbusxml/Socket.xml - DBUS_INTERFACE_FLAGS - "-i" "struct_marshallers_p.h" - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - PkgConfig::ATSPI2_nolink - Qt::AccessibilitySupportPrivate - Qt::CorePrivate - Qt::DBus - Qt::GuiPrivate - PRECOMPILED_HEADER - "../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 1:.:.:linuxaccessibility.pro:<TRUE>: -# MODULE = "linuxaccessibility_support" diff --git a/src/platformsupport/linuxaccessibility/CMakeLists.txt b/src/platformsupport/linuxaccessibility/CMakeLists.txt deleted file mode 100644 index 0e1a7a9d16..0000000000 --- a/src/platformsupport/linuxaccessibility/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Generated from linuxaccessibility.pro. - -qt_find_package(ATSPI2) # special case - -##################################################################### -## LinuxAccessibilitySupport Module: -##################################################################### - -qt_add_module(LinuxAccessibilitySupport - STATIC - INTERNAL_MODULE - SOURCES - application.cpp application_p.h - atspiadaptor.cpp atspiadaptor_p.h - bridge.cpp bridge_p.h - cache.cpp cache_p.h - constant_mappings.cpp constant_mappings_p.h - dbusconnection.cpp dbusconnection_p.h - struct_marshallers.cpp struct_marshallers_p.h - DBUS_ADAPTOR_SOURCES - dbusxml/Cache.xml - dbusxml/DeviceEventController.xml - DBUS_ADAPTOR_FLAGS - "-i" "struct_marshallers_p.h" - DBUS_INTERFACE_SOURCES - dbusxml/Bus.xml - dbusxml/Socket.xml - DBUS_INTERFACE_FLAGS - "-i" "struct_marshallers_p.h" - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - PkgConfig::ATSPI2_nolink - Qt::CorePrivate - Qt::DBus - Qt::GuiPrivate - PRECOMPILED_HEADER - "../../corelib/global/qt_pch.h" -) - -#### Keys ignored in scope 1:.:.:linuxaccessibility.pro:<TRUE>: -# MODULE = "linuxaccessibility_support" diff --git a/src/platformsupport/linuxaccessibility/application.cpp b/src/platformsupport/linuxaccessibility/application.cpp deleted file mode 100644 index 7852e407ad..0000000000 --- a/src/platformsupport/linuxaccessibility/application.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "application_p.h" - -#include <QtCore/qcoreapplication.h> -#include <QtDBus/qdbuspendingreply.h> -#include <qdebug.h> - -#ifndef QT_NO_ACCESSIBILITY -#include "deviceeventcontroller_adaptor.h" -#include "atspi/atspi-constants.h" - -//#define KEYBOARD_DEBUG - -QT_BEGIN_NAMESPACE - -/*! - \class QSpiApplicationAdaptor - \internal - - \brief QSpiApplicationAdaptor - - QSpiApplicationAdaptor -*/ - -QSpiApplicationAdaptor::QSpiApplicationAdaptor(const QDBusConnection &connection, QObject *parent) - : QObject(parent), dbusConnection(connection), inCapsLock(false) -{ -} - -enum QSpiKeyEventType { - QSPI_KEY_EVENT_PRESS, - QSPI_KEY_EVENT_RELEASE, - QSPI_KEY_EVENT_LAST_DEFINED -}; - -void QSpiApplicationAdaptor::sendEvents(bool active) -{ - if (active) { - qApp->installEventFilter(this); - } else { - qApp->removeEventFilter(this); - } -} - - -bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) -{ - if (!event->spontaneous()) - return false; - - switch (event->type()) { - case QEvent::WindowActivate: - emit windowActivated(target, true); - break; - case QEvent::WindowDeactivate: - emit windowActivated(target, false); - break; - case QEvent::KeyPress: - case QEvent::KeyRelease: { - QKeyEvent *keyEvent = static_cast <QKeyEvent *>(event); - QSpiDeviceEvent de; - - if (event->type() == QEvent::KeyPress) - de.type = QSPI_KEY_EVENT_PRESS; - else - de.type = QSPI_KEY_EVENT_RELEASE; - - de.id = keyEvent->nativeVirtualKey(); - de.hardwareCode = keyEvent->nativeScanCode(); - - de.timestamp = QDateTime::currentMSecsSinceEpoch(); - - if (keyEvent->key() == Qt::Key_Tab) - de.text = QStringLiteral("Tab"); - else if (keyEvent->key() == Qt::Key_Backtab) - de.text = QStringLiteral("Backtab"); - else if (keyEvent->key() == Qt::Key_Control) - de.text = QStringLiteral("Control_L"); - else if (keyEvent->key() == Qt::Key_Left) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Left") : QStringLiteral("Left"); - else if (keyEvent->key() == Qt::Key_Right) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Right") : QStringLiteral("Right"); - else if (keyEvent->key() == Qt::Key_Up) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Up") : QStringLiteral("Up"); - else if (keyEvent->key() == Qt::Key_Down) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Down") : QStringLiteral("Down"); - else if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) - de.text = QStringLiteral("Return"); - else if (keyEvent->key() == Qt::Key_Backspace) - de.text = QStringLiteral("BackSpace"); - else if (keyEvent->key() == Qt::Key_Delete) - de.text = QStringLiteral("Delete"); - else if (keyEvent->key() == Qt::Key_PageUp) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Page_Up") : QStringLiteral("Page_Up"); - else if (keyEvent->key() == Qt::Key_PageDown) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Page_Up") : QStringLiteral("Page_Down"); - else if (keyEvent->key() == Qt::Key_Home) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Home") : QStringLiteral("Home"); - else if (keyEvent->key() == Qt::Key_End) - de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_End") : QStringLiteral("End"); - else if (keyEvent->key() == Qt::Key_Clear && (keyEvent->modifiers() & Qt::KeypadModifier)) - de.text = QStringLiteral("KP_Begin"); // Key pad 5 - else if (keyEvent->key() == Qt::Key_Escape) - de.text = QStringLiteral("Escape"); - else if (keyEvent->key() == Qt::Key_Space) - de.text = QStringLiteral("space"); - else if (keyEvent->key() == Qt::Key_CapsLock) { - de.text = QStringLiteral("Caps_Lock"); - if (event->type() == QEvent::KeyPress) - inCapsLock = true; - else - inCapsLock = false; - } else if (keyEvent->key() == Qt::Key_NumLock) - de.text = QStringLiteral("Num_Lock"); - else if (keyEvent->key() == Qt::Key_Insert) - de.text = QStringLiteral("Insert"); - else - de.text = keyEvent->text(); - - // This is a bit dubious, Gnome uses some gtk function here. - // Long term the spec will hopefully change to just use keycodes. - de.isText = !de.text.isEmpty(); - - de.modifiers = 0; - if (!inCapsLock && keyEvent->modifiers() & Qt::ShiftModifier) - de.modifiers |= 1 << ATSPI_MODIFIER_SHIFT; - if (inCapsLock && (keyEvent->key() != Qt::Key_CapsLock)) - de.modifiers |= 1 << ATSPI_MODIFIER_SHIFTLOCK; - if ((keyEvent->modifiers() & Qt::ControlModifier) && (keyEvent->key() != Qt::Key_Control)) - de.modifiers |= 1 << ATSPI_MODIFIER_CONTROL; - if ((keyEvent->modifiers() & Qt::AltModifier) && (keyEvent->key() != Qt::Key_Alt)) - de.modifiers |= 1 << ATSPI_MODIFIER_ALT; - if ((keyEvent->modifiers() & Qt::MetaModifier) && (keyEvent->key() != Qt::Key_Meta)) - de.modifiers |= 1 << ATSPI_MODIFIER_META; - -#ifdef KEYBOARD_DEBUG - qDebug() << "Key event text:" << event->type() << de.text - << "native virtual key:" << de.id - << "hardware code/scancode:" << de.hardwareCode - << "modifiers:" << de.modifiers - << "text:" << de.text; -#endif - - QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.a11y.atspi.Registry"), - QStringLiteral("/org/a11y/atspi/registry/deviceeventcontroller"), - QStringLiteral("org.a11y.atspi.DeviceEventController"), QStringLiteral("NotifyListenersSync")); - m.setArguments(QVariantList() << QVariant::fromValue(de)); - - // FIXME: this is critical, the timeout should probably be pretty low to allow normal processing - int timeout = 100; - bool sent = dbusConnection.callWithCallback(m, this, SLOT(notifyKeyboardListenerCallback(QDBusMessage)), - SLOT(notifyKeyboardListenerError(QDBusError,QDBusMessage)), timeout); - if (sent) { - //queue the event and send it after callback - keyEvents.enqueue(QPair<QPointer<QObject>, QKeyEvent*> (QPointer<QObject>(target), copyKeyEvent(keyEvent))); - return true; - } - } - default: - break; - } - return false; -} - -QKeyEvent* QSpiApplicationAdaptor::copyKeyEvent(QKeyEvent* old) -{ - return new QKeyEvent(old->type(), old->key(), old->modifiers(), - old->nativeScanCode(), old->nativeVirtualKey(), old->nativeModifiers(), - old->text(), old->isAutoRepeat(), old->count()); -} - -void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage& message) -{ - if (!keyEvents.length()) { - qWarning("QSpiApplication::notifyKeyboardListenerCallback with no queued key called"); - return; - } - Q_ASSERT(message.arguments().length() == 1); - if (message.arguments().at(0).toBool() == true) { - QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); - delete event.second; - } else { - QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); - if (event.first) - QCoreApplication::postEvent(event.first.data(), event.second); - } -} - -void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& /*message*/) -{ - qWarning() << "QSpiApplication::keyEventError " << error.name() << error.message(); - while (!keyEvents.isEmpty()) { - QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); - if (event.first) - QCoreApplication::postEvent(event.first.data(), event.second); - } -} - -QT_END_NAMESPACE - -#endif //QT_NO_ACCESSIBILITY diff --git a/src/platformsupport/linuxaccessibility/application_p.h b/src/platformsupport/linuxaccessibility/application_p.h deleted file mode 100644 index 6a8786dc07..0000000000 --- a/src/platformsupport/linuxaccessibility/application_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 Q_SPI_APPLICATION_H -#define Q_SPI_APPLICATION_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 <QtGui/private/qtguiglobal_p.h> -#include <QtCore/QPointer> -#include <QtCore/QQueue> -#include <QtDBus/QDBusConnection> -#include <QtGui/QAccessibleInterface> -Q_MOC_INCLUDE(<QtDBus/QDBusMessage>) - -QT_REQUIRE_CONFIG(accessibility); - -QT_BEGIN_NAMESPACE - -/* - * Used for the root object. - * - * Uses the root object reference and reports its parent as the desktop object. - */ -class QSpiApplicationAdaptor :public QObject -{ - Q_OBJECT - -public: - QSpiApplicationAdaptor(const QDBusConnection &connection, QObject *parent); - virtual ~QSpiApplicationAdaptor() {} - void sendEvents(bool active); - -Q_SIGNALS: - void windowActivated(QObject* window, bool active); - -protected: - bool eventFilter(QObject *obj, QEvent *event) override; - -private Q_SLOTS: - void notifyKeyboardListenerCallback(const QDBusMessage& message); - void notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& message); - -private: - static QKeyEvent* copyKeyEvent(QKeyEvent*); - - QQueue<QPair<QPointer<QObject>, QKeyEvent*> > keyEvents; - QDBusConnection dbusConnection; - bool inCapsLock; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp deleted file mode 100644 index c4ff9a211b..0000000000 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ /dev/null @@ -1,2482 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "atspiadaptor_p.h" - -#include <QtGui/qwindow.h> -#include <QtGui/qguiapplication.h> -#include <qdbusmessage.h> -#include <qdbusreply.h> -#include <qclipboard.h> - -#include <QtCore/qloggingcategory.h> - -#ifndef QT_NO_ACCESSIBILITY -#include "socket_interface.h" -#include "constant_mappings_p.h" -#include <QtGui/private/qaccessiblebridgeutils_p.h> - -#include "application_p.h" -/*! - \class AtSpiAdaptor - \internal - - \brief AtSpiAdaptor is the main class to forward between QAccessibleInterface and AT-SPI DBus - - AtSpiAdaptor implements the functions specified in all at-spi interfaces. - It sends notifications coming from Qt via dbus and listens to incoming dbus requests. -*/ - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcAccessibilityAtspi, "qt.accessibility.atspi") -Q_LOGGING_CATEGORY(lcAccessibilityAtspiCreation, "qt.accessibility.atspi.creation") - -AtSpiAdaptor::AtSpiAdaptor(DBusConnection *connection, QObject *parent) - : QDBusVirtualObject(parent), m_dbus(connection) - , sendFocus(0) - , sendObject(0) - , sendObject_active_descendant_changed(0) - , sendObject_attributes_changed(0) - , sendObject_bounds_changed(0) - , sendObject_children_changed(0) -// , sendObject_children_changed_add(0) -// , sendObject_children_changed_remove(0) - , sendObject_column_deleted(0) - , sendObject_column_inserted(0) - , sendObject_column_reordered(0) - , sendObject_link_selected(0) - , sendObject_model_changed(0) - , sendObject_property_change(0) - , sendObject_property_change_accessible_description(0) - , sendObject_property_change_accessible_name(0) - , sendObject_property_change_accessible_parent(0) - , sendObject_property_change_accessible_role(0) - , sendObject_property_change_accessible_table_caption(0) - , sendObject_property_change_accessible_table_column_description(0) - , sendObject_property_change_accessible_table_column_header(0) - , sendObject_property_change_accessible_table_row_description(0) - , sendObject_property_change_accessible_table_row_header(0) - , sendObject_property_change_accessible_table_summary(0) - , sendObject_property_change_accessible_value(0) - , sendObject_row_deleted(0) - , sendObject_row_inserted(0) - , sendObject_row_reordered(0) - , sendObject_selection_changed(0) - , sendObject_state_changed(0) - , sendObject_text_attributes_changed(0) - , sendObject_text_bounds_changed(0) - , sendObject_text_caret_moved(0) - , sendObject_text_changed(0) -// , sendObject_text_changed_delete(0) -// , sendObject_text_changed_insert(0) - , sendObject_text_selection_changed(0) - , sendObject_value_changed(0) - , sendObject_visible_data_changed(0) - , sendWindow(0) - , sendWindow_activate(0) - , sendWindow_close(0) - , sendWindow_create(0) - , sendWindow_deactivate(0) -// , sendWindow_desktop_create(0) -// , sendWindow_desktop_destroy(0) - , sendWindow_lower(0) - , sendWindow_maximize(0) - , sendWindow_minimize(0) - , sendWindow_move(0) - , sendWindow_raise(0) - , sendWindow_reparent(0) - , sendWindow_resize(0) - , sendWindow_restore(0) - , sendWindow_restyle(0) - , sendWindow_shade(0) - , sendWindow_unshade(0) -{ - m_applicationAdaptor = new QSpiApplicationAdaptor(m_dbus->connection(), this); - connect(m_applicationAdaptor, SIGNAL(windowActivated(QObject*,bool)), this, SLOT(windowActivated(QObject*,bool))); - - updateEventListeners(); - bool success = m_dbus->connection().connect(QLatin1String("org.a11y.atspi.Registry"), QLatin1String("/org/a11y/atspi/registry"), - QLatin1String("org.a11y.atspi.Registry"), QLatin1String("EventListenerRegistered"), this, - SLOT(eventListenerRegistered(QString,QString))); - success = success && m_dbus->connection().connect(QLatin1String("org.a11y.atspi.Registry"), QLatin1String("/org/a11y/atspi/registry"), - QLatin1String("org.a11y.atspi.Registry"), QLatin1String("EventListenerDeregistered"), this, - SLOT(eventListenerDeregistered(QString,QString))); -} - -AtSpiAdaptor::~AtSpiAdaptor() -{ -} - -/*! - Provide DBus introspection. - */ -QString AtSpiAdaptor::introspect(const QString &path) const -{ - static const QLatin1String accessibleIntrospection( - " <interface name=\"org.a11y.atspi.Accessible\">\n" - " <property access=\"read\" type=\"s\" name=\"Name\"/>\n" - " <property access=\"read\" type=\"s\" name=\"Description\"/>\n" - " <property access=\"read\" type=\"(so)\" name=\"Parent\">\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n" - " </property>\n" - " <property access=\"read\" type=\"i\" name=\"ChildCount\"/>\n" - " <method name=\"GetChildAtIndex\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"(so)\"/>\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetChildren\">\n" - " <arg direction=\"out\" type=\"a(so)\"/>\n" - " <annotation value=\"QSpiObjectReferenceArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetIndexInParent\">\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetRelationSet\">\n" - " <arg direction=\"out\" type=\"a(ua(so))\"/>\n" - " <annotation value=\"QSpiRelationArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetRole\">\n" - " <arg direction=\"out\" type=\"u\"/>\n" - " </method>\n" - " <method name=\"GetRoleName\">\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetLocalizedRoleName\">\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetState\">\n" - " <arg direction=\"out\" type=\"au\"/>\n" - " <annotation value=\"QSpiUIntList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetAttributes\">\n" - " <arg direction=\"out\" type=\"a{ss}\"/>\n" - " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetApplication\">\n" - " <arg direction=\"out\" type=\"(so)\"/>\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " </interface>\n" - ); - - static const QLatin1String actionIntrospection( - " <interface name=\"org.a11y.atspi.Action\">\n" - " <property access=\"read\" type=\"i\" name=\"NActions\"/>\n" - " <method name=\"GetDescription\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetName\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetKeyBinding\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetActions\">\n" - " <arg direction=\"out\" type=\"a(sss)\" name=\"index\"/>\n" - " <annotation value=\"QSpiActionArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"DoAction\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " </interface>\n" - ); - - static const QLatin1String applicationIntrospection( - " <interface name=\"org.a11y.atspi.Application\">\n" - " <property access=\"read\" type=\"s\" name=\"ToolkitName\"/>\n" - " <property access=\"read\" type=\"s\" name=\"Version\"/>\n" - " <property access=\"readwrite\" type=\"i\" name=\"Id\"/>\n" - " <method name=\"GetLocale\">\n" - " <arg direction=\"in\" type=\"u\" name=\"lctype\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetApplicationBusAddress\">\n" - " <arg direction=\"out\" type=\"s\" name=\"address\"/>\n" - " </method>\n" - " </interface>\n" - ); - - static const QLatin1String componentIntrospection( - " <interface name=\"org.a11y.atspi.Component\">\n" - " <method name=\"Contains\">\n" - " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"GetAccessibleAtPoint\">\n" - " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n" - " <arg direction=\"out\" type=\"(so)\"/>\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetExtents\">\n" - " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n" - " <arg direction=\"out\" type=\"(iiii)\"/>\n" - " <annotation value=\"QSpiRect\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetPosition\">\n" - " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"y\"/>\n" - " </method>\n" - " <method name=\"GetSize\">\n" - " <arg direction=\"out\" type=\"i\" name=\"width\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"height\"/>\n" - " </method>\n" - " <method name=\"GetLayer\">\n" - " <arg direction=\"out\" type=\"u\"/>\n" - " </method>\n" - " <method name=\"GetMDIZOrder\">\n" - " <arg direction=\"out\" type=\"n\"/>\n" - " </method>\n" - " <method name=\"GrabFocus\">\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"GetAlpha\">\n" - " <arg direction=\"out\" type=\"d\"/>\n" - " </method>\n" - " <method name=\"SetExtents\">\n" - " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"width\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"height\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"SetPosition\">\n" - " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"SetSize\">\n" - " <arg direction=\"in\" type=\"i\" name=\"width\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"height\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " </interface>\n" - ); - - static const QLatin1String editableTextIntrospection( - " <interface name=\"org.a11y.atspi.EditableText\">\n" - " <method name=\"SetTextContents\">\n" - " <arg direction=\"in\" type=\"s\" name=\"newContents\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"InsertText\">\n" - " <arg direction=\"in\" type=\"i\" name=\"position\"/>\n" - " <arg direction=\"in\" type=\"s\" name=\"text\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"length\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"CopyText\">\n" - " <arg direction=\"in\" type=\"i\" name=\"startPos\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"endPos\"/>\n" - " </method>\n" - " <method name=\"CutText\">\n" - " <arg direction=\"in\" type=\"i\" name=\"startPos\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"endPos\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"DeleteText\">\n" - " <arg direction=\"in\" type=\"i\" name=\"startPos\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"endPos\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"PasteText\">\n" - " <arg direction=\"in\" type=\"i\" name=\"position\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " </interface>\n" - ); - - static const QLatin1String tableIntrospection( - " <interface name=\"org.a11y.atspi.Table\">\n" - " <property access=\"read\" type=\"i\" name=\"NRows\"/>\n" - " <property access=\"read\" type=\"i\" name=\"NColumns\"/>\n" - " <property access=\"read\" type=\"(so)\" name=\"Caption\">\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n" - " </property>\n" - " <property access=\"read\" type=\"(so)\" name=\"Summary\">\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n" - " </property>\n" - " <property access=\"read\" type=\"i\" name=\"NSelectedRows\"/>\n" - " <property access=\"read\" type=\"i\" name=\"NSelectedColumns\"/>\n" - " <method name=\"GetAccessibleAt\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"(so)\"/>\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetIndexAt\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetRowAtIndex\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetColumnAtIndex\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetRowDescription\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetColumnDescription\">\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"GetRowExtentAt\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetColumnExtentAt\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetRowHeader\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"out\" type=\"(so)\"/>\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetColumnHeader\">\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"(so)\"/>\n" - " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetSelectedRows\">\n" - " <arg direction=\"out\" type=\"ai\"/>\n" - " <annotation value=\"QSpiIntList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetSelectedColumns\">\n" - " <arg direction=\"out\" type=\"ai\"/>\n" - " <annotation value=\"QSpiIntList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"IsRowSelected\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"IsColumnSelected\">\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"IsSelected\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"AddRowSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"AddColumnSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"RemoveRowSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"RemoveColumnSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"GetRowColumnExtentsAtIndex\">\n" - " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"row\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"col\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"row_extents\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"col_extents\"/>\n" - " <arg direction=\"out\" type=\"b\" name=\"is_selected\"/>\n" - " </method>\n" - " </interface>\n" - ); - - static const QLatin1String textIntrospection( - " <interface name=\"org.a11y.atspi.Text\">\n" - " <property access=\"read\" type=\"i\" name=\"CharacterCount\"/>\n" - " <property access=\"read\" type=\"i\" name=\"CaretOffset\"/>\n" - " <method name=\"GetText\">\n" - " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " </method>\n" - " <method name=\"SetCaretOffset\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"GetTextBeforeOffset\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"type\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n" - " </method>\n" - " <method name=\"GetTextAtOffset\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"type\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n" - " </method>\n" - " <method name=\"GetTextAfterOffset\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"type\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n" - " </method>\n" - " <method name=\"GetCharacterAtOffset\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetAttributeValue\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"in\" type=\"s\" name=\"attributeName\"/>\n" - " <arg direction=\"out\" type=\"s\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n" - " <arg direction=\"out\" type=\"b\" name=\"defined\"/>\n" - " </method>\n" - " <method name=\"GetAttributes\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"out\" type=\"a{ss}\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n" - " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetDefaultAttributes\">\n" - " <arg direction=\"out\" type=\"a{ss}\"/>\n" - " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetCharacterExtents\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"width\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"height\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n" - " </method>\n" - " <method name=\"GetOffsetAtPoint\">\n" - " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " </method>\n" - " <method name=\"GetNSelections\">\n" - " <arg direction=\"out\" type=\"i\"/>\n" - " <method name=\"GetSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"selectionNum\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n" - " </method>\n" - " <method name=\"AddSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"RemoveSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"selectionNum\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"SetSelection\">\n" - " <arg direction=\"in\" type=\"i\" name=\"selectionNum\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n" - " <arg direction=\"out\" type=\"b\"/>\n" - " </method>\n" - " <method name=\"GetRangeExtents\">\n" - " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"width\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"height\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n" - " </method>\n" - " <method name=\"GetBoundedRanges\">\n" - " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"width\"/>\n" - " <arg direction=\"in\" type=\"i\" name=\"height\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"xClipType\"/>\n" - " <arg direction=\"in\" type=\"u\" name=\"yClipType\"/>\n" - " <arg direction=\"out\" type=\"a(iisv)\"/>\n" - " <annotation value=\"QSpiRangeList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetAttributeRun\">\n" - " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n" - " <arg direction=\"in\" type=\"b\" name=\"includeDefaults\"/>\n" - " <arg direction=\"out\" type=\"a{ss}\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n" - " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n" - " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " <method name=\"GetDefaultAttributeSet\">\n" - " <arg direction=\"out\" type=\"a{ss}\"/>\n" - " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" - " </method>\n" - " </interface>\n" - ); - - static const QLatin1String valueIntrospection( - " <interface name=\"org.a11y.atspi.Value\">\n" - " <property access=\"read\" type=\"d\" name=\"MinimumValue\"/>\n" - " <property access=\"read\" type=\"d\" name=\"MaximumValue\"/>\n" - " <property access=\"read\" type=\"d\" name=\"MinimumIncrement\"/>\n" - " <property access=\"readwrite\" type=\"d\" name=\"CurrentValue\"/>\n" - " <method name=\"SetCurrentValue\">\n" - " <arg direction=\"in\" type=\"d\" name=\"value\"/>\n" - " </method>\n" - " </interface>\n" - ); - - QAccessibleInterface * interface = interfaceFromPath(path); - if (!interface) { - qCDebug(lcAccessibilityAtspi) << "WARNING Qt AtSpiAdaptor: Could not find accessible on path: " << path; - return QString(); - } - - QStringList interfaces = accessibleInterfaces(interface); - - QString xml; - xml.append(accessibleIntrospection); - - if (interfaces.contains(QLatin1String(ATSPI_DBUS_INTERFACE_COMPONENT))) - xml.append(componentIntrospection); - if (interfaces.contains(QLatin1String(ATSPI_DBUS_INTERFACE_TEXT))) - xml.append(textIntrospection); - if (interfaces.contains(QLatin1String(ATSPI_DBUS_INTERFACE_EDITABLE_TEXT))) - xml.append(editableTextIntrospection); - if (interfaces.contains(QLatin1String(ATSPI_DBUS_INTERFACE_ACTION))) - xml.append(actionIntrospection); - if (interfaces.contains(QLatin1String(ATSPI_DBUS_INTERFACE_TABLE))) - xml.append(tableIntrospection); - if (interfaces.contains(QLatin1String(ATSPI_DBUS_INTERFACE_VALUE))) - xml.append(valueIntrospection); - if (path == QLatin1String(QSPI_OBJECT_PATH_ROOT)) - xml.append(applicationIntrospection); - - return xml; -} - -void AtSpiAdaptor::setBitFlag(const QString &flag) -{ - Q_ASSERT(flag.size()); - - // assume we don't get nonsense - look at first letter only - switch (flag.at(0).toLower().toLatin1()) { - case 'o': { - if (flag.size() <= 8) { // Object:: - sendObject = 1; - } else { // Object:Foo:Bar - QString right = flag.mid(7); - if (false) { - } else if (right.startsWith(QLatin1String("ActiveDescendantChanged"))) { - sendObject_active_descendant_changed = 1; - } else if (right.startsWith(QLatin1String("AttributesChanged"))) { - sendObject_attributes_changed = 1; - } else if (right.startsWith(QLatin1String("BoundsChanged"))) { - sendObject_bounds_changed = 1; - } else if (right.startsWith(QLatin1String("ChildrenChanged"))) { - sendObject_children_changed = 1; - } else if (right.startsWith(QLatin1String("ColumnDeleted"))) { - sendObject_column_deleted = 1; - } else if (right.startsWith(QLatin1String("ColumnInserted"))) { - sendObject_column_inserted = 1; - } else if (right.startsWith(QLatin1String("ColumnReordered"))) { - sendObject_column_reordered = 1; - } else if (right.startsWith(QLatin1String("LinkSelected"))) { - sendObject_link_selected = 1; - } else if (right.startsWith(QLatin1String("ModelChanged"))) { - sendObject_model_changed = 1; - } else if (right.startsWith(QLatin1String("PropertyChange"))) { - if (right == QLatin1String("PropertyChange:AccessibleDescription")) { - sendObject_property_change_accessible_description = 1; - } else if (right == QLatin1String("PropertyChange:AccessibleName")) { - sendObject_property_change_accessible_name = 1; - } else if (right == QLatin1String("PropertyChange:AccessibleParent")) { - sendObject_property_change_accessible_parent = 1; - } else if (right == QLatin1String("PropertyChange:AccessibleRole")) { - sendObject_property_change_accessible_role = 1; - } else if (right == QLatin1String("PropertyChange:TableCaption")) { - sendObject_property_change_accessible_table_caption = 1; - } else if (right == QLatin1String("PropertyChange:TableColumnDescription")) { - sendObject_property_change_accessible_table_column_description = 1; - } else if (right == QLatin1String("PropertyChange:TableColumnHeader")) { - sendObject_property_change_accessible_table_column_header = 1; - } else if (right == QLatin1String("PropertyChange:TableRowDescription")) { - sendObject_property_change_accessible_table_row_description = 1; - } else if (right == QLatin1String("PropertyChange:TableRowHeader")) { - sendObject_property_change_accessible_table_row_header = 1; - } else if (right == QLatin1String("PropertyChange:TableSummary")) { - sendObject_property_change_accessible_table_summary = 1; - } else if (right == QLatin1String("PropertyChange:AccessibleValue")) { - sendObject_property_change_accessible_value = 1; - } else { - sendObject_property_change = 1; - } - } else if (right.startsWith(QLatin1String("RowDeleted"))) { - sendObject_row_deleted = 1; - } else if (right.startsWith(QLatin1String("RowInserted"))) { - sendObject_row_inserted = 1; - } else if (right.startsWith(QLatin1String("RowReordered"))) { - sendObject_row_reordered = 1; - } else if (right.startsWith(QLatin1String("SelectionChanged"))) { - sendObject_selection_changed = 1; - } else if (right.startsWith(QLatin1String("StateChanged"))) { - sendObject_state_changed = 1; - } else if (right.startsWith(QLatin1String("TextAttributesChanged"))) { - sendObject_text_attributes_changed = 1; - } else if (right.startsWith(QLatin1String("TextBoundsChanged"))) { - sendObject_text_bounds_changed = 1; - } else if (right.startsWith(QLatin1String("TextCaretMoved"))) { - sendObject_text_caret_moved = 1; - } else if (right.startsWith(QLatin1String("TextChanged"))) { - sendObject_text_changed = 1; - } else if (right.startsWith(QLatin1String("TextSelectionChanged"))) { - sendObject_text_selection_changed = 1; - } else if (right.startsWith(QLatin1String("ValueChanged"))) { - sendObject_value_changed = 1; - } else if (right.startsWith(QLatin1String("VisibleDataChanged")) - || right.startsWith(QLatin1String("VisibledataChanged"))) { // typo in libatspi - sendObject_visible_data_changed = 1; - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: subscription string not handled:" << flag; - } - } - break; - } - case 'w': { // window - if (flag.size() <= 8) { - sendWindow = 1; - } else { // object:Foo:Bar - QString right = flag.mid(7); - if (false) { - } else if (right.startsWith(QLatin1String("Activate"))) { - sendWindow_activate = 1; - } else if (right.startsWith(QLatin1String("Close"))) { - sendWindow_close= 1; - } else if (right.startsWith(QLatin1String("Create"))) { - sendWindow_create = 1; - } else if (right.startsWith(QLatin1String("Deactivate"))) { - sendWindow_deactivate = 1; - } else if (right.startsWith(QLatin1String("Lower"))) { - sendWindow_lower = 1; - } else if (right.startsWith(QLatin1String("Maximize"))) { - sendWindow_maximize = 1; - } else if (right.startsWith(QLatin1String("Minimize"))) { - sendWindow_minimize = 1; - } else if (right.startsWith(QLatin1String("Move"))) { - sendWindow_move = 1; - } else if (right.startsWith(QLatin1String("Raise"))) { - sendWindow_raise = 1; - } else if (right.startsWith(QLatin1String("Reparent"))) { - sendWindow_reparent = 1; - } else if (right.startsWith(QLatin1String("Resize"))) { - sendWindow_resize = 1; - } else if (right.startsWith(QLatin1String("Restore"))) { - sendWindow_restore = 1; - } else if (right.startsWith(QLatin1String("Restyle"))) { - sendWindow_restyle = 1; - } else if (right.startsWith(QLatin1String("Shade"))) { - sendWindow_shade = 1; - } else if (right.startsWith(QLatin1String("Unshade"))) { - sendWindow_unshade = 1; - } else if (right.startsWith(QLatin1String("DesktopCreate"))) { - // ignore this one - } else if (right.startsWith(QLatin1String("DesktopDestroy"))) { - // ignore this one - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: subscription string not handled:" << flag; - } - } - break; - } - case 'f': { - sendFocus = 1; - break; - } - case 'd': { // document is not implemented - break; - } - case 't': { // terminal is not implemented - break; - } - case 'm': { // mouse* is handled in a different way by the gnome atspi stack - break; - } - default: - qCDebug(lcAccessibilityAtspi) << "WARNING: subscription string not handled:" << flag; - } -} - -/*! - Checks via dbus which events should be sent. - */ -void AtSpiAdaptor::updateEventListeners() -{ - QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String("org.a11y.atspi.Registry"), - QLatin1String("/org/a11y/atspi/registry"), - QLatin1String("org.a11y.atspi.Registry"), QLatin1String("GetRegisteredEvents")); - QDBusReply<QSpiEventListenerArray> listenersReply = m_dbus->connection().call(m); - if (listenersReply.isValid()) { - const QSpiEventListenerArray evList = listenersReply.value(); - for (const QSpiEventListener &ev : evList) - setBitFlag(ev.eventName); - m_applicationAdaptor->sendEvents(!evList.isEmpty()); - } else { - qCDebug(lcAccessibilityAtspi) << "Could not query active accessibility event listeners."; - } -} - -void AtSpiAdaptor::eventListenerDeregistered(const QString &/*bus*/, const QString &/*path*/) -{ -// qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::eventListenerDeregistered: " << bus << path; - updateEventListeners(); -} - -void AtSpiAdaptor::eventListenerRegistered(const QString &/*bus*/, const QString &/*path*/) -{ -// qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::eventListenerRegistered: " << bus << path; - updateEventListeners(); -} - -/*! - This slot needs to get called when a \a window has be activated or deactivated (become focused). - When \a active is true, the window just received focus, otherwise it lost the focus. - */ -void AtSpiAdaptor::windowActivated(QObject* window, bool active) -{ - if (!(sendWindow || sendWindow_activate)) - return; - - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window); - Q_ASSERT(iface); - Q_ASSERT(!active || iface->isValid()); - - QString windowTitle; - // in dtor it may be invalid - if (iface->isValid()) - windowTitle = iface->text(QAccessible::Name); - - QDBusVariant data; - data.setVariant(windowTitle); - - QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(data)); - - QString status = active ? QLatin1String("Activate") : QLatin1String("Deactivate"); - QString path = pathForObject(window); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_WINDOW), status, args); - - QVariantList stateArgs = packDBusSignalArguments(QLatin1String("active"), active ? 1 : 0, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("StateChanged"), stateArgs); -} - -QVariantList AtSpiAdaptor::packDBusSignalArguments(const QString &type, int data1, int data2, const QVariant &variantData) const -{ - QVariantList arguments; - arguments << type << data1 << data2 << variantData - << QVariant::fromValue(QSpiObjectReference(m_dbus->connection(), QDBusObjectPath(QSPI_OBJECT_PATH_ROOT))); - return arguments; -} - -QVariant AtSpiAdaptor::variantForPath(const QString &path) const -{ - QDBusVariant data; - data.setVariant(QVariant::fromValue(QSpiObjectReference(m_dbus->connection(), QDBusObjectPath(path)))); - return QVariant::fromValue(data); -} - -bool AtSpiAdaptor::sendDBusSignal(const QString &path, const QString &interface, const QString &signalName, const QVariantList &arguments) const -{ - QDBusMessage message = QDBusMessage::createSignal(path, interface, signalName); - message.setArguments(arguments); - return m_dbus->connection().send(message); -} - -QAccessibleInterface *AtSpiAdaptor::interfaceFromPath(const QString& dbusPath) const -{ - if (dbusPath == QLatin1String(QSPI_OBJECT_PATH_ROOT)) - return QAccessible::queryAccessibleInterface(qApp); - - QStringList parts = dbusPath.split(QLatin1Char('/')); - if (parts.size() != 6) { - qCDebug(lcAccessibilityAtspi) << "invalid path: " << dbusPath; - return 0; - } - - QString objectString = parts.at(5); - QAccessible::Id id = objectString.toUInt(); - - // The id is always in the range [INT_MAX+1, UINT_MAX] - if ((int)id >= 0) - qCWarning(lcAccessibilityAtspi) << "No accessible object found for id: " << id; - - return QAccessible::accessibleInterface(id); -} - -void AtSpiAdaptor::notifyStateChange(QAccessibleInterface *interface, const QString &state, int value) -{ - QString path = pathForInterface(interface); - QVariantList stateArgs = packDBusSignalArguments(state, value, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("StateChanged"), stateArgs); -} - - -/*! - This function gets called when Qt notifies about accessibility updates. -*/ -void AtSpiAdaptor::notify(QAccessibleEvent *event) -{ - switch (event->type()) { - case QAccessible::ObjectCreated: - if (sendObject || sendObject_children_changed) - notifyAboutCreation(event->accessibleInterface()); - break; - case QAccessible::ObjectShow: { - if (sendObject || sendObject_state_changed) { - notifyStateChange(event->accessibleInterface(), QLatin1String("showing"), 1); - } - break; - } - case QAccessible::ObjectHide: { - if (sendObject || sendObject_state_changed) { - notifyStateChange(event->accessibleInterface(), QLatin1String("showing"), 0); - } - break; - } - case QAccessible::ObjectDestroyed: { - if (sendObject || sendObject_state_changed) - notifyAboutDestruction(event->accessibleInterface()); - break; - } - case QAccessible::ObjectReorder: { - if (sendObject || sendObject_children_changed) - childrenChanged(event->accessibleInterface()); - break; - } - case QAccessible::NameChanged: { - if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) { - QString path = pathForInterface(event->accessibleInterface()); - QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("PropertyChange"), args); - } - break; - } - case QAccessible::DescriptionChanged: { - if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) { - QString path = pathForInterface(event->accessibleInterface()); - QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("PropertyChange"), args); - } - break; - } - case QAccessible::Focus: { - if (sendFocus || sendObject || sendObject_state_changed) - sendFocusChanged(event->accessibleInterface()); - break; - } - case QAccessible::TextInserted: - case QAccessible::TextRemoved: - case QAccessible::TextUpdated: { - if (sendObject || sendObject_text_changed) { - QAccessibleInterface * iface = event->accessibleInterface(); - if (!iface || !iface->textInterface()) { - qCDebug(lcAccessibilityAtspi) << "Received text event for invalid interface."; - return; - } - QString path = pathForInterface(iface); - - int changePosition = 0; - int cursorPosition = 0; - QString textRemoved; - QString textInserted; - - if (event->type() == QAccessible::TextInserted) { - QAccessibleTextInsertEvent *textEvent = static_cast<QAccessibleTextInsertEvent*>(event); - textInserted = textEvent->textInserted(); - changePosition = textEvent->changePosition(); - cursorPosition = textEvent->cursorPosition(); - } else if (event->type() == QAccessible::TextRemoved) { - QAccessibleTextRemoveEvent *textEvent = static_cast<QAccessibleTextRemoveEvent*>(event); - textRemoved = textEvent->textRemoved(); - changePosition = textEvent->changePosition(); - cursorPosition = textEvent->cursorPosition(); - } else if (event->type() == QAccessible::TextUpdated) { - QAccessibleTextUpdateEvent *textEvent = static_cast<QAccessibleTextUpdateEvent*>(event); - textInserted = textEvent->textInserted(); - textRemoved = textEvent->textRemoved(); - changePosition = textEvent->changePosition(); - cursorPosition = textEvent->cursorPosition(); - } - - QDBusVariant data; - - if (!textRemoved.isEmpty()) { - data.setVariant(QVariant::fromValue(textRemoved)); - QVariantList args = packDBusSignalArguments(QLatin1String("delete"), changePosition, textRemoved.length(), QVariant::fromValue(data)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("TextChanged"), args); - } - - if (!textInserted.isEmpty()) { - data.setVariant(QVariant::fromValue(textInserted)); - QVariantList args = packDBusSignalArguments(QLatin1String("insert"), changePosition, textInserted.length(), QVariant::fromValue(data)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("TextChanged"), args); - } - - // send a cursor update - Q_UNUSED(cursorPosition) -// QDBusVariant cursorData; -// cursorData.setVariant(QVariant::fromValue(cursorPosition)); -// QVariantList args = packDBusSignalArguments(QString(), cursorPosition, 0, QVariant::fromValue(cursorData)); -// sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), -// QLatin1String("TextCaretMoved"), args); - } - break; - } - case QAccessible::TextCaretMoved: { - if (sendObject || sendObject_text_caret_moved) { - QAccessibleInterface * iface = event->accessibleInterface(); - if (!iface || !iface->textInterface()) { - qCWarning(lcAccessibilityAtspi) << "Sending TextCaretMoved from object that does not implement text interface: " << iface; - return; - } - - QString path = pathForInterface(iface); - QDBusVariant cursorData; - int pos = iface->textInterface()->cursorPosition(); - cursorData.setVariant(QVariant::fromValue(pos)); - QVariantList args = packDBusSignalArguments(QString(), pos, 0, QVariant::fromValue(cursorData)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("TextCaretMoved"), args); - } - break; - } - case QAccessible::TextSelectionChanged: { - if (sendObject || sendObject_text_selection_changed) { - QAccessibleInterface * iface = event->accessibleInterface(); - QString path = pathForInterface(iface); - QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(QString())))); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("TextSelectionChanged"), args); - } - break; - } - case QAccessible::ValueChanged: { - if (sendObject || sendObject_value_changed || sendObject_property_change_accessible_value) { - QAccessibleInterface * iface = event->accessibleInterface(); - if (!iface) { - qCWarning(lcAccessibilityAtspi) << "ValueChanged event from invalid accessible."; - return; - } - if (iface->valueInterface()) { - QString path = pathForInterface(iface); - QVariantList args = packDBusSignalArguments(QLatin1String("accessible-value"), 0, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("PropertyChange"), args); - } else if (iface->role() == QAccessible::ComboBox) { - // Combo Box with AT-SPI likes to be special - // It requires a name-change to update caches and then selection-changed - QString path = pathForInterface(iface); - QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("PropertyChange"), args1); - QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0)))); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("SelectionChanged"), args2); - } else { - qCWarning(lcAccessibilityAtspi) << "ValueChanged event and no ValueInterface or ComboBox: " << iface; - } - } - break; - } - case QAccessible::SelectionAdd: - case QAccessible::SelectionRemove: - case QAccessible::Selection: { - QAccessibleInterface * iface = event->accessibleInterface(); - if (!iface) { - qCWarning(lcAccessibilityAtspi) << "Selection event from invalid accessible."; - return; - } - QString path = pathForInterface(iface); - int selected = iface->state().selected ? 1 : 0; - QVariantList stateArgs = packDBusSignalArguments(QLatin1String("selected"), selected, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("StateChanged"), stateArgs); - break; - } - - case QAccessible::StateChanged: { - if (sendObject || sendObject_state_changed || sendWindow || sendWindow_activate) { - QAccessible::State stateChange = static_cast<QAccessibleStateChangeEvent*>(event)->changedStates(); - if (stateChange.checked) { - QAccessibleInterface * iface = event->accessibleInterface(); - if (!iface) { - qCWarning(lcAccessibilityAtspi) << "StateChanged event from invalid accessible."; - return; - } - int checked = iface->state().checked; - notifyStateChange(iface, QLatin1String("checked"), checked); - } else if (stateChange.active) { - QAccessibleInterface * iface = event->accessibleInterface(); - if (!iface || !(iface->role() == QAccessible::Window && (sendWindow || sendWindow_activate))) - return; - int isActive = iface->state().active; - QString windowTitle = iface->text(QAccessible::Name); - QDBusVariant data; - data.setVariant(windowTitle); - QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(data)); - QString status = isActive ? QLatin1String("Activate") : QLatin1String("Deactivate"); - QString path = pathForInterface(iface); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_WINDOW), status, args); - notifyStateChange(iface, QLatin1String("active"), isActive); - } else if (stateChange.disabled) { - QAccessibleInterface *iface = event->accessibleInterface(); - QAccessible::State state = iface->state(); - bool enabled = !state.disabled; - - notifyStateChange(iface, QLatin1String("enabled"), enabled); - notifyStateChange(iface, QLatin1String("sensitive"), enabled); - } - } - break; - } - // For now we ignore these events - case QAccessible::TableModelChanged: - // For tables, setting manages_descendants should - // indicate to the client that it cannot cache these - // interfaces. - case QAccessible::ParentChanged: - case QAccessible::DialogStart: - case QAccessible::DialogEnd: - case QAccessible::PopupMenuStart: - case QAccessible::PopupMenuEnd: - case QAccessible::SoundPlayed: - case QAccessible::Alert: - case QAccessible::ForegroundChanged: - case QAccessible::MenuStart: - case QAccessible::MenuEnd: - case QAccessible::ContextHelpStart: - case QAccessible::ContextHelpEnd: - case QAccessible::DragDropStart: - case QAccessible::DragDropEnd: - case QAccessible::ScrollingStart: - case QAccessible::ScrollingEnd: - case QAccessible::MenuCommand: - case QAccessible::ActionChanged: - case QAccessible::ActiveDescendantChanged: - case QAccessible::AttributeChanged: - case QAccessible::DocumentContentChanged: - case QAccessible::DocumentLoadComplete: - case QAccessible::DocumentLoadStopped: - case QAccessible::DocumentReload: - case QAccessible::HyperlinkEndIndexChanged: - case QAccessible::HyperlinkNumberOfAnchorsChanged: - case QAccessible::HyperlinkSelectedLinkChanged: - case QAccessible::HypertextLinkActivated: - case QAccessible::HypertextLinkSelected: - case QAccessible::HyperlinkStartIndexChanged: - case QAccessible::HypertextChanged: - case QAccessible::HypertextNLinksChanged: - case QAccessible::ObjectAttributeChanged: - case QAccessible::PageChanged: - case QAccessible::SectionChanged: - case QAccessible::TableCaptionChanged: - case QAccessible::TableColumnDescriptionChanged: - case QAccessible::TableColumnHeaderChanged: - case QAccessible::TableRowDescriptionChanged: - case QAccessible::TableRowHeaderChanged: - case QAccessible::TableSummaryChanged: - case QAccessible::TextAttributeChanged: - case QAccessible::TextColumnChanged: - case QAccessible::VisibleDataChanged: - case QAccessible::SelectionWithin: - case QAccessible::LocationChanged: - case QAccessible::HelpChanged: - case QAccessible::DefaultActionChanged: - case QAccessible::AcceleratorChanged: - case QAccessible::InvalidEvent: - break; - } -} - -void AtSpiAdaptor::sendFocusChanged(QAccessibleInterface *interface) const -{ - static QString lastFocusPath; - // "remove" old focus - if (!lastFocusPath.isEmpty()) { - QVariantList stateArgs = packDBusSignalArguments(QLatin1String("focused"), 0, 0, variantForPath(lastFocusPath)); - sendDBusSignal(lastFocusPath, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("StateChanged"), stateArgs); - } - // send new focus - { - QString path = pathForInterface(interface); - - QVariantList stateArgs = packDBusSignalArguments(QLatin1String("focused"), 1, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), - QLatin1String("StateChanged"), stateArgs); - - QVariantList focusArgs = packDBusSignalArguments(QString(), 0, 0, variantForPath(path)); - sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_FOCUS), - QLatin1String("Focus"), focusArgs); - lastFocusPath = path; - } -} - -void AtSpiAdaptor::childrenChanged(QAccessibleInterface *interface) const -{ - QString parentPath = pathForInterface(interface); - int childCount = interface->childCount(); - for (int i = 0; i < interface->childCount(); ++i) { - QString childPath = pathForInterface(interface->child(i)); - QVariantList args = packDBusSignalArguments(QLatin1String("add"), childCount, 0, childPath); - sendDBusSignal(parentPath, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), QLatin1String("ChildrenChanged"), args); - } -} - -void AtSpiAdaptor::notifyAboutCreation(QAccessibleInterface *interface) const -{ -// // say hello to d-bus -// cache->emitAddAccessible(accessible->getCacheItem()); - - // notify about the new child of our parent - QAccessibleInterface * parent = interface->parent(); - if (!parent) { - qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::notifyAboutCreation: Could not find parent for " << interface->object(); - return; - } - QString path = pathForInterface(interface); - int childCount = parent->childCount(); - QString parentPath = pathForInterface(parent); - QVariantList args = packDBusSignalArguments(QLatin1String("add"), childCount, 0, variantForPath(path)); - sendDBusSignal(parentPath, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), QLatin1String("ChildrenChanged"), args); -} - -void AtSpiAdaptor::notifyAboutDestruction(QAccessibleInterface *interface) const -{ - if (!interface || !interface->isValid()) - return; - - QAccessibleInterface * parent = interface->parent(); - if (!parent) { - qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::notifyAboutDestruction: Could not find parent for " << interface->object(); - return; - } - QString path = pathForInterface(interface); - - // this is in the destructor. we have no clue which child we used to be. - // FIXME - int childIndex = -1; - // if (child) { - // childIndex = child; - // } else { - // childIndex = parent->indexOfChild(interface); - // } - - QString parentPath = pathForInterface(parent); - QVariantList args = packDBusSignalArguments(QLatin1String("remove"), childIndex, 0, variantForPath(path)); - sendDBusSignal(parentPath, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), QLatin1String("ChildrenChanged"), args); -} - -/*! - Handle incoming DBus message. - This function dispatches the dbus message to the right interface handler. - */ -bool AtSpiAdaptor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection) -{ - // get accessible interface - QAccessibleInterface * accessible = interfaceFromPath(message.path()); - if (!accessible) { - qCDebug(lcAccessibilityAtspi) << "WARNING Qt AtSpiAdaptor: Could not find accessible on path: " << message.path(); - return false; - } - if (!accessible->isValid()) { - qCWarning(lcAccessibilityAtspi) << "WARNING Qt AtSpiAdaptor: Accessible invalid: " << accessible << message.path(); - return false; - } - - QString interface = message.interface(); - QString function = message.member(); - - // qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::handleMessage: " << interface << function; - - if (function == QLatin1String("Introspect")) { - //introspect(message.path()); - return false; - } - - // handle properties like regular functions - if (interface == QLatin1String("org.freedesktop.DBus.Properties")) { - interface = message.arguments().at(0).toString(); - // Get/Set + Name - function = message.member() + message.arguments().at(1).toString(); - } - - // switch interface to call - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_ACCESSIBLE)) - return accessibleInterface(accessible, function, message, connection); - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_APPLICATION)) - return applicationInterface(accessible, function, message, connection); - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_COMPONENT)) - return componentInterface(accessible, function, message, connection); - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_ACTION)) - return actionInterface(accessible, function, message, connection); - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_TEXT)) - return textInterface(accessible, function, message, connection); - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_EDITABLE_TEXT)) - return editableTextInterface(accessible, function, message, connection); - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_VALUE)) - return valueInterface(accessible, function, message, connection); - if (interface == QLatin1String(ATSPI_DBUS_INTERFACE_TABLE)) - return tableInterface(accessible, function, message, connection); - - qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::handleMessage with unknown interface: " << message.path() << interface << function; - return false; -} - -// Application -bool AtSpiAdaptor::applicationInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - if (message.path() != QLatin1String(ATSPI_DBUS_PATH_ROOT)) { - qCDebug(lcAccessibilityAtspi) << "WARNING Qt AtSpiAdaptor: Could not find application interface for: " << message.path() << interface; - return false; - } - - if (function == QLatin1String("SetId")) { - Q_ASSERT(message.signature() == QLatin1String("ssv")); - QVariant value = qvariant_cast<QDBusVariant>(message.arguments().at(2)).variant(); - - m_applicationId = value.toInt(); - return true; - } - if (function == QLatin1String("GetId")) { - Q_ASSERT(message.signature() == QLatin1String("ss")); - QDBusMessage reply = message.createReply(QVariant::fromValue(QDBusVariant(m_applicationId))); - return connection.send(reply); - } - if (function == QLatin1String("GetToolkitName")) { - Q_ASSERT(message.signature() == QLatin1String("ss")); - QDBusMessage reply = message.createReply(QVariant::fromValue(QDBusVariant(QLatin1String("Qt")))); - return connection.send(reply); - } - if (function == QLatin1String("GetVersion")) { - Q_ASSERT(message.signature() == QLatin1String("ss")); - QDBusMessage reply = message.createReply(QVariant::fromValue(QDBusVariant(QLatin1String(qVersion())))); - return connection.send(reply); - } - if (function == QLatin1String("GetLocale")) { - Q_ASSERT(message.signature() == QLatin1String("u")); - QDBusMessage reply = message.createReply(QVariant::fromValue(QLocale().name())); - return connection.send(reply); - } - qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::applicationInterface " << message.path() << interface << function; - return false; -} - -/*! - Register this application as accessible on the accessibility DBus. - */ -void AtSpiAdaptor::registerApplication() -{ - OrgA11yAtspiSocketInterface *registry; - registry = new OrgA11yAtspiSocketInterface(QLatin1String(QSPI_REGISTRY_NAME), - QLatin1String(QSPI_OBJECT_PATH_ROOT), m_dbus->connection()); - - QDBusPendingReply<QSpiObjectReference> reply; - QSpiObjectReference ref = QSpiObjectReference(m_dbus->connection(), QDBusObjectPath(QSPI_OBJECT_PATH_ROOT)); - reply = registry->Embed(ref); - reply.waitForFinished(); // TODO: make this async - if (reply.isValid ()) { - const QSpiObjectReference &socket = reply.value(); - accessibilityRegistry = QSpiObjectReference(socket); - } else { - qCDebug(lcAccessibilityAtspi) << "Error in contacting registry: " - << reply.error().name() - << reply.error().message(); - } - delete registry; -} - -// Accessible -bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - if (function == QLatin1String("GetRole")) { - sendReply(connection, message, (uint) getRole(interface)); - } else if (function == QLatin1String("GetName")) { - sendReply(connection, message, QVariant::fromValue(QDBusVariant(interface->text(QAccessible::Name)))); - } else if (function == QLatin1String("GetRoleName")) { - sendReply(connection, message, qSpiRoleMapping[interface->role()].name()); - } else if (function == QLatin1String("GetLocalizedRoleName")) { - sendReply(connection, message, QVariant::fromValue(qSpiRoleMapping[interface->role()].localizedName())); - } else if (function == QLatin1String("GetChildCount")) { - sendReply(connection, message, QVariant::fromValue(QDBusVariant(interface->childCount()))); - } else if (function == QLatin1String("GetIndexInParent")) { - int childIndex = -1; - QAccessibleInterface * parent = interface->parent(); - if (parent) { - childIndex = parent->indexOfChild(interface); - if (childIndex < 0) { - qCDebug(lcAccessibilityAtspi) << "GetIndexInParent get invalid index: " << childIndex << interface; - } - } - sendReply(connection, message, childIndex); - } else if (function == QLatin1String("GetParent")) { - QString path; - QAccessibleInterface * parent = interface->parent(); - if (!parent) { - path = QLatin1String(ATSPI_DBUS_PATH_NULL); - } else if (parent->role() == QAccessible::Application) { - path = QLatin1String(ATSPI_DBUS_PATH_ROOT); - } else { - path = pathForInterface(parent); - } - // Parent is a property, so it needs to be wrapped inside an extra variant. - sendReply(connection, message, QVariant::fromValue( - QDBusVariant(QVariant::fromValue(QSpiObjectReference(connection, QDBusObjectPath(path)))))); - } else if (function == QLatin1String("GetChildAtIndex")) { - const int index = message.arguments().at(0).toInt(); - if (index < 0) { - sendReply(connection, message, QVariant::fromValue( - QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL)))); - } else { - QAccessibleInterface * childInterface = interface->child(index); - sendReply(connection, message, QVariant::fromValue( - QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(childInterface))))); - } - } else if (function == QLatin1String("GetInterfaces")) { - sendReply(connection, message, accessibleInterfaces(interface)); - } else if (function == QLatin1String("GetDescription")) { - sendReply(connection, message, QVariant::fromValue(QDBusVariant(interface->text(QAccessible::Description)))); - } else if (function == QLatin1String("GetState")) { - quint64 spiState = spiStatesFromQState(interface->state()); - if (interface->tableInterface()) { - setSpiStateBit(&spiState, ATSPI_STATE_MANAGES_DESCENDANTS); - } - QAccessible::Role role = interface->role(); - if (role == QAccessible::TreeItem || - role == QAccessible::ListItem) { - /* Transient means libatspi2 will not cache items. - This is important because when adding/removing an item - the cache becomes outdated and we don't change the paths of - items in lists/trees/tables. */ - setSpiStateBit(&spiState, ATSPI_STATE_TRANSIENT); - } - sendReply(connection, message, - QVariant::fromValue(spiStateSetFromSpiStates(spiState))); - } else if (function == QLatin1String("GetAttributes")) { - sendReply(connection, message, QVariant::fromValue(QSpiAttributeSet())); - } else if (function == QLatin1String("GetRelationSet")) { - sendReply(connection, message, QVariant::fromValue(relationSet(interface, connection))); - } else if (function == QLatin1String("GetApplication")) { - sendReply(connection, message, QVariant::fromValue( - QSpiObjectReference(connection, QDBusObjectPath(QSPI_OBJECT_PATH_ROOT)))); - } else if (function == QLatin1String("GetChildren")) { - QSpiObjectReferenceArray children; - const int numChildren = interface->childCount(); - children.reserve(numChildren); - for (int i = 0; i < numChildren; ++i) { - QString childPath = pathForInterface(interface->child(i)); - QSpiObjectReference ref(connection, QDBusObjectPath(childPath)); - children << ref; - } - connection.send(message.createReply(QVariant::fromValue(children))); - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path(); - return false; - } - return true; -} - -AtspiRole AtSpiAdaptor::getRole(QAccessibleInterface *interface) const -{ - if ((interface->role() == QAccessible::EditableText) && interface->state().passwordEdit) - return ATSPI_ROLE_PASSWORD_TEXT; - return qSpiRoleMapping[interface->role()].spiRole(); -} - -QStringList AtSpiAdaptor::accessibleInterfaces(QAccessibleInterface *interface) const -{ - QStringList ifaces; - qCDebug(lcAccessibilityAtspiCreation) << "AtSpiAdaptor::accessibleInterfaces create: " << interface->object(); - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_ACCESSIBLE); - - if ( (!interface->rect().isEmpty()) || - (interface->object() && interface->object()->isWidgetType()) || - (interface->role() == QAccessible::ListItem) || - (interface->role() == QAccessible::Cell) || - (interface->role() == QAccessible::TreeItem) || - (interface->role() == QAccessible::Row) || - (interface->object() && interface->object()->inherits("QSGItem")) - ) { - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_COMPONENT); - } else { - qCDebug(lcAccessibilityAtspiCreation) << " IS NOT a component"; - } - if (interface->role() == QAccessible::Application) - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_APPLICATION); - - if (interface->actionInterface() || interface->valueInterface()) - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_ACTION); - - if (interface->textInterface()) - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_TEXT); - - if (interface->editableTextInterface()) - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_EDITABLE_TEXT); - - if (interface->valueInterface()) - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_VALUE); - - if (interface->tableInterface()) - ifaces << QLatin1String(ATSPI_DBUS_INTERFACE_TABLE); - - return ifaces; -} - -QSpiRelationArray AtSpiAdaptor::relationSet(QAccessibleInterface *interface, const QDBusConnection &connection) const -{ - typedef QPair<QAccessibleInterface*, QAccessible::Relation> RelationPair; - const QVector<RelationPair> relationInterfaces = interface->relations(); - - QSpiRelationArray relations; - for (const RelationPair &pair : relationInterfaces) { -// FIXME: this loop seems a bit strange... "related" always have one item when we check. -//And why is it a list, when it always have one item? And it seems to assume that the QAccessible::Relation enum maps directly to AtSpi - QSpiObjectReferenceArray related; - - QDBusObjectPath path = QDBusObjectPath(pathForInterface(pair.first)); - related.append(QSpiObjectReference(connection, path)); - - if (!related.isEmpty()) - relations.append(QSpiRelationArrayEntry(qAccessibleRelationToAtSpiRelation(pair.second), related)); - } - return relations; -} - -void AtSpiAdaptor::sendReply(const QDBusConnection &connection, const QDBusMessage &message, const QVariant &argument) const -{ - QDBusMessage reply = message.createReply(argument); - connection.send(reply); -} - - -QString AtSpiAdaptor::pathForObject(QObject *object) const -{ - Q_ASSERT(object); - - if (inheritsQAction(object)) { - qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::pathForObject: warning: creating path with QAction as object."; - } - - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(object); - return pathForInterface(iface); -} - -QString AtSpiAdaptor::pathForInterface(QAccessibleInterface *interface) const -{ - if (!interface || !interface->isValid()) - return QLatin1String(ATSPI_DBUS_PATH_NULL); - if (interface->role() == QAccessible::Application) - return QLatin1String(QSPI_OBJECT_PATH_ROOT); - - QAccessible::Id id = QAccessible::uniqueId(interface); - Q_ASSERT((int)id < 0); - return QLatin1String(QSPI_OBJECT_PATH_PREFIX) + QString::number(id); -} - -bool AtSpiAdaptor::inheritsQAction(QObject *object) -{ - const QMetaObject *mo = object->metaObject(); - while (mo) { - const QLatin1String cn(mo->className()); - if (cn == QLatin1String("QAction")) - return true; - mo = mo->superClass(); - } - return false; -} - -// Component -static QAccessibleInterface * getWindow(QAccessibleInterface * interface) -{ - if (interface->role() == QAccessible::Window) - return interface; - - QAccessibleInterface * parent = interface->parent(); - while (parent && parent->role() != QAccessible::Window) - parent = parent->parent(); - - return parent; -} - -static QRect getRelativeRect(QAccessibleInterface *interface) -{ - QAccessibleInterface * window; - QRect wr, cr; - - cr = interface->rect(); - - window = getWindow(interface); - if (window) { - wr = window->rect(); - - cr.setX(cr.x() - wr.x()); - cr.setY(cr.x() - wr.y()); - } - return cr; -} - -bool AtSpiAdaptor::componentInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - if (function == QLatin1String("Contains")) { - bool ret = false; - int x = message.arguments().at(0).toInt(); - int y = message.arguments().at(1).toInt(); - uint coordType = message.arguments().at(2).toUInt(); - if (coordType == ATSPI_COORD_TYPE_SCREEN) - ret = interface->rect().contains(x, y); - else - ret = getRelativeRect(interface).contains(x, y); - sendReply(connection, message, ret); - } else if (function == QLatin1String("GetAccessibleAtPoint")) { - int x = message.arguments().at(0).toInt(); - int y = message.arguments().at(1).toInt(); - uint coordType = message.arguments().at(2).toUInt(); - if (coordType == ATSPI_COORD_TYPE_WINDOW) { - QWindow * window = interface->window(); - if (window) { - x += window->position().x(); - y += window->position().y(); - } - } - - QAccessibleInterface * childInterface(interface->childAt(x, y)); - QAccessibleInterface * iface = 0; - while (childInterface) { - iface = childInterface; - childInterface = iface->childAt(x, y); - } - if (iface) { - QString path = pathForInterface(iface); - sendReply(connection, message, QVariant::fromValue( - QSpiObjectReference(connection, QDBusObjectPath(path)))); - } else { - sendReply(connection, message, QVariant::fromValue( - QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL)))); - } - } else if (function == QLatin1String("GetAlpha")) { - sendReply(connection, message, (double) 1.0); - } else if (function == QLatin1String("GetExtents")) { - uint coordType = message.arguments().at(0).toUInt(); - sendReply(connection, message, QVariant::fromValue(getExtents(interface, coordType))); - } else if (function == QLatin1String("GetLayer")) { - sendReply(connection, message, QVariant::fromValue((uint)1)); - } else if (function == QLatin1String("GetMDIZOrder")) { - sendReply(connection, message, QVariant::fromValue((short)0)); - } else if (function == QLatin1String("GetPosition")) { - uint coordType = message.arguments().at(0).toUInt(); - QRect rect; - if (coordType == ATSPI_COORD_TYPE_SCREEN) - rect = interface->rect(); - else - rect = getRelativeRect(interface); - QVariantList pos; - pos << rect.x() << rect.y(); - connection.send(message.createReply(pos)); - } else if (function == QLatin1String("GetSize")) { - QRect rect = interface->rect(); - QVariantList size; - size << rect.width() << rect.height(); - connection.send(message.createReply(size)); - } else if (function == QLatin1String("GrabFocus")) { - QAccessibleActionInterface *actionIface = interface->actionInterface(); - if (actionIface && actionIface->actionNames().contains(QAccessibleActionInterface::setFocusAction())) { - actionIface->doAction(QAccessibleActionInterface::setFocusAction()); - sendReply(connection, message, true); - } else { - sendReply(connection, message, false); - } - } else if (function == QLatin1String("SetExtents")) { -// int x = message.arguments().at(0).toInt(); -// int y = message.arguments().at(1).toInt(); -// int width = message.arguments().at(2).toInt(); -// int height = message.arguments().at(3).toInt(); -// uint coordinateType = message.arguments().at(4).toUInt(); - qCDebug(lcAccessibilityAtspi) << "SetExtents is not implemented."; - sendReply(connection, message, false); - } else if (function == QLatin1String("SetPosition")) { -// int x = message.arguments().at(0).toInt(); -// int y = message.arguments().at(1).toInt(); -// uint coordinateType = message.arguments().at(2).toUInt(); - qCDebug(lcAccessibilityAtspi) << "SetPosition is not implemented."; - sendReply(connection, message, false); - } else if (function == QLatin1String("SetSize")) { -// int width = message.arguments().at(0).toInt(); -// int height = message.arguments().at(1).toInt(); - qCDebug(lcAccessibilityAtspi) << "SetSize is not implemented."; - sendReply(connection, message, false); - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::componentInterface does not implement " << function << message.path(); - return false; - } - return true; -} - -QRect AtSpiAdaptor::getExtents(QAccessibleInterface *interface, uint coordType) -{ - return (coordType == ATSPI_COORD_TYPE_SCREEN) ? interface->rect() : getRelativeRect(interface); -} - -// Action interface -bool AtSpiAdaptor::actionInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - if (function == QLatin1String("GetNActions")) { - int count = QAccessibleBridgeUtils::effectiveActionNames(interface).count(); - sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(count)))); - } else if (function == QLatin1String("DoAction")) { - int index = message.arguments().at(0).toInt(); - const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) - return false; - const QString actionName = actionNames.at(index); - bool success = QAccessibleBridgeUtils::performEffectiveAction(interface, actionName); - sendReply(connection, message, success); - } else if (function == QLatin1String("GetActions")) { - sendReply(connection, message, QVariant::fromValue(getActions(interface))); - } else if (function == QLatin1String("GetName")) { - int index = message.arguments().at(0).toInt(); - const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) - return false; - sendReply(connection, message, actionNames.at(index)); - } else if (function == QLatin1String("GetDescription")) { - int index = message.arguments().at(0).toInt(); - const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) - return false; - QString description; - if (QAccessibleActionInterface *actionIface = interface->actionInterface()) - description = actionIface->localizedActionDescription(actionNames.at(index)); - else - description = qAccessibleLocalizedActionDescription(actionNames.at(index)); - sendReply(connection, message, description); - } else if (function == QLatin1String("GetKeyBinding")) { - int index = message.arguments().at(0).toInt(); - const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - if (index < 0 || index >= actionNames.count()) - return false; - QStringList keyBindings; - if (QAccessibleActionInterface *actionIface = interface->actionInterface()) - keyBindings = actionIface->keyBindingsForAction(actionNames.at(index)); - if (keyBindings.isEmpty()) { - QString acc = interface->text(QAccessible::Accelerator); - if (!acc.isEmpty()) - keyBindings.append(acc); - } - if (keyBindings.length() > 0) - sendReply(connection, message, keyBindings.join(QLatin1Char(';'))); - else - sendReply(connection, message, QString()); - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::actionInterface does not implement " << function << message.path(); - return false; - } - return true; -} - -QSpiActionArray AtSpiAdaptor::getActions(QAccessibleInterface *interface) const -{ - QAccessibleActionInterface *actionInterface = interface->actionInterface(); - QSpiActionArray actions; - const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface); - actions.reserve(actionNames.size()); - for (const QString &actionName : actionNames) { - QSpiAction action; - - action.name = actionName; - if (actionInterface) { - action.description = actionInterface->localizedActionDescription(actionName); - const QStringList keyBindings = actionInterface->keyBindingsForAction(actionName); - if (!keyBindings.isEmpty()) - action.keyBinding = keyBindings.front(); - } else { - action.description = qAccessibleLocalizedActionDescription(actionName); - } - - actions.append(std::move(action)); - } - return actions; -} - -// Text interface -bool AtSpiAdaptor::textInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - if (!interface->textInterface()) - return false; - - // properties - if (function == QLatin1String("GetCaretOffset")) { - sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(interface->textInterface()->cursorPosition())))); - } else if (function == QLatin1String("GetCharacterCount")) { - sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(interface->textInterface()->characterCount())))); - - // functions - } else if (function == QLatin1String("AddSelection")) { - int startOffset = message.arguments().at(0).toInt(); - int endOffset = message.arguments().at(1).toInt(); - int lastSelection = interface->textInterface()->selectionCount(); - interface->textInterface()->setSelection(lastSelection, startOffset, endOffset); - sendReply(connection, message, (interface->textInterface()->selectionCount() > lastSelection)); - } else if (function == QLatin1String("GetAttributeRun")) { - int offset = message.arguments().at(0).toInt(); - bool includeDefaults = message.arguments().at(1).toBool(); - Q_UNUSED(includeDefaults) - connection.send(message.createReply(getAttributes(interface, offset, includeDefaults))); - } else if (function == QLatin1String("GetAttributeValue")) { - int offset = message.arguments().at(0).toInt(); - QString attributeName = message.arguments().at(1).toString(); - connection.send(message.createReply(getAttributeValue(interface, offset, attributeName))); - } else if (function == QLatin1String("GetAttributes")) { - int offset = message.arguments().at(0).toInt(); - connection.send(message.createReply(getAttributes(interface, offset, true))); - } else if (function == QLatin1String("GetBoundedRanges")) { - int x = message.arguments().at(0).toInt(); - int y = message.arguments().at(1).toInt(); - int width = message.arguments().at(2).toInt(); - int height = message.arguments().at(3).toInt(); - uint coordType = message.arguments().at(4).toUInt(); - uint xClipType = message.arguments().at(5).toUInt(); - uint yClipType = message.arguments().at(6).toUInt(); - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(width); - Q_UNUSED(height); - Q_UNUSED(coordType); - Q_UNUSED(xClipType); - Q_UNUSED(yClipType); - qCDebug(lcAccessibilityAtspi) << "Not implemented: QSpiAdaptor::GetBoundedRanges"; - sendReply(connection, message, QVariant::fromValue(QSpiTextRangeList())); - } else if (function == QLatin1String("GetCharacterAtOffset")) { - int offset = message.arguments().at(0).toInt(); - int start; - int end; - QString result = interface->textInterface()->textAtOffset(offset, QAccessible::CharBoundary, &start, &end); - sendReply(connection, message, (int) *(qPrintable (result))); - } else if (function == QLatin1String("GetCharacterExtents")) { - int offset = message.arguments().at(0).toInt(); - int coordType = message.arguments().at(1).toUInt(); - connection.send(message.createReply(getCharacterExtents(interface, offset, coordType))); - } else if (function == QLatin1String("GetDefaultAttributeSet") || function == QLatin1String("GetDefaultAttributes")) { - // GetDefaultAttributes is deprecated in favour of GetDefaultAttributeSet. - // Empty set seems reasonable. There is no default attribute set. - sendReply(connection, message, QVariant::fromValue(QSpiAttributeSet())); - } else if (function == QLatin1String("GetNSelections")) { - sendReply(connection, message, interface->textInterface()->selectionCount()); - } else if (function == QLatin1String("GetOffsetAtPoint")) { - qCDebug(lcAccessibilityAtspi) << message.signature(); - Q_ASSERT(!message.signature().isEmpty()); - QPoint point(message.arguments().at(0).toInt(), message.arguments().at(1).toInt()); - uint coordType = message.arguments().at(2).toUInt(); - if (coordType == ATSPI_COORD_TYPE_WINDOW) { - QWindow *win = interface->window(); - point -= QPoint(win->x(), win->y()); - } - int offset = interface->textInterface()->offsetAtPoint(point); - sendReply(connection, message, offset); - } else if (function == QLatin1String("GetRangeExtents")) { - int startOffset = message.arguments().at(0).toInt(); - int endOffset = message.arguments().at(1).toInt(); - uint coordType = message.arguments().at(2).toUInt(); - connection.send(message.createReply(getRangeExtents(interface, startOffset, endOffset, coordType))); - } else if (function == QLatin1String("GetSelection")) { - int selectionNum = message.arguments().at(0).toInt(); - int start, end; - interface->textInterface()->selection(selectionNum, &start, &end); - if (start < 0) - start = end = interface->textInterface()->cursorPosition(); - QVariantList sel; - sel << start << end; - connection.send(message.createReply(sel)); - } else if (function == QLatin1String("GetText")) { - int startOffset = message.arguments().at(0).toInt(); - int endOffset = message.arguments().at(1).toInt(); - if (endOffset == -1) // AT-SPI uses -1 to signal all characters - endOffset = interface->textInterface()->characterCount(); - sendReply(connection, message, interface->textInterface()->text(startOffset, endOffset)); - } else if (function == QLatin1String("GetTextAfterOffset")) { - int offset = message.arguments().at(0).toInt(); - int type = message.arguments().at(1).toUInt(); - int startOffset, endOffset; - QString text = interface->textInterface()->textAfterOffset(offset, qAccessibleBoundaryType(type), &startOffset, &endOffset); - QVariantList ret; - ret << text << startOffset << endOffset; - connection.send(message.createReply(ret)); - } else if (function == QLatin1String("GetTextAtOffset")) { - int offset = message.arguments().at(0).toInt(); - int type = message.arguments().at(1).toUInt(); - int startOffset, endOffset; - QString text = interface->textInterface()->textAtOffset(offset, qAccessibleBoundaryType(type), &startOffset, &endOffset); - QVariantList ret; - ret << text << startOffset << endOffset; - connection.send(message.createReply(ret)); - } else if (function == QLatin1String("GetTextBeforeOffset")) { - int offset = message.arguments().at(0).toInt(); - int type = message.arguments().at(1).toUInt(); - int startOffset, endOffset; - QString text = interface->textInterface()->textBeforeOffset(offset, qAccessibleBoundaryType(type), &startOffset, &endOffset); - QVariantList ret; - ret << text << startOffset << endOffset; - connection.send(message.createReply(ret)); - } else if (function == QLatin1String("RemoveSelection")) { - int selectionNum = message.arguments().at(0).toInt(); - interface->textInterface()->removeSelection(selectionNum); - sendReply(connection, message, true); - } else if (function == QLatin1String("SetCaretOffset")) { - int offset = message.arguments().at(0).toInt(); - interface->textInterface()->setCursorPosition(offset); - sendReply(connection, message, true); - } else if (function == QLatin1String("SetSelection")) { - int selectionNum = message.arguments().at(0).toInt(); - int startOffset = message.arguments().at(1).toInt(); - int endOffset = message.arguments().at(2).toInt(); - interface->textInterface()->setSelection(selectionNum, startOffset, endOffset); - sendReply(connection, message, true); - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::textInterface does not implement " << function << message.path(); - return false; - } - return true; -} - -QAccessible::TextBoundaryType AtSpiAdaptor::qAccessibleBoundaryType(int atspiTextBoundaryType) const -{ - switch (atspiTextBoundaryType) { - case ATSPI_TEXT_BOUNDARY_CHAR: - return QAccessible::CharBoundary; - case ATSPI_TEXT_BOUNDARY_WORD_START: - case ATSPI_TEXT_BOUNDARY_WORD_END: - return QAccessible::WordBoundary; - case ATSPI_TEXT_BOUNDARY_SENTENCE_START: - case ATSPI_TEXT_BOUNDARY_SENTENCE_END: - return QAccessible::SentenceBoundary; - case ATSPI_TEXT_BOUNDARY_LINE_START: - case ATSPI_TEXT_BOUNDARY_LINE_END: - return QAccessible::LineBoundary; - } - Q_ASSERT_X(0, "", "Requested invalid boundary type."); - return QAccessible::CharBoundary; -} - -namespace -{ - struct AtSpiAttribute { - QString name; - QString value; - AtSpiAttribute(const QString &aName, const QString &aValue) : name(aName), value(aValue) {} - bool isNull() const { return name.isNull() || value.isNull(); } - }; - - QString atspiColor(const QString &ia2Color) - { - // "rgb(%u,%u,%u)" -> "%u,%u,%u" - return ia2Color.mid(4, ia2Color.length() - (4+1)); - } - - QString atspiSize(const QString &ia2Size) - { - // "%fpt" -> "%f" - return ia2Size.left(ia2Size.length() - 2); - } - - AtSpiAttribute atspiTextAttribute(const QString &ia2Name, const QString &ia2Value) - { - QString name = ia2Name; - QString value = ia2Value; - - // IAccessible2: http://www.linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2/textattributes - // ATK attribute names: https://git.gnome.org/browse/orca/tree/src/orca/text_attribute_names.py - // ATK attribute values: https://developer.gnome.org/atk/unstable/AtkText.html#AtkTextAttribute - - // https://bugzilla.gnome.org/show_bug.cgi?id=744553 "ATK docs provide no guidance for allowed values of some text attributes" - // specifically for "weight", "invalid", "language" and value range for colors - - if (ia2Name == QLatin1String("background-color")) { - name = QStringLiteral("bg-color"); - value = atspiColor(value); - } else if (ia2Name == QLatin1String("font-family")) { - name = QStringLiteral("family-name"); - } else if (ia2Name == QLatin1String("color")) { - name = QStringLiteral("fg-color"); - value = atspiColor(value); - } else if (ia2Name == QLatin1String("text-align")) { - name = QStringLiteral("justification"); - if (value == QLatin1String("justify")) { - value = QStringLiteral("fill"); - } else { - if (value != QLatin1String("left") && - value != QLatin1String("right") && - value != QLatin1String("center") - ) { - value = QString(); - qCDebug(lcAccessibilityAtspi) << "Unknown text-align attribute value \"" << value << "\" cannot be translated to AT-SPI."; - } - } - } else if (ia2Name == QLatin1String("font-size")) { - name = QStringLiteral("size"); - value = atspiSize(value); - } else if (ia2Name == QLatin1String("font-style")) { - name = QStringLiteral("style"); - if (value != QLatin1String("normal") && - value != QLatin1String("italic") && - value != QLatin1String("oblique") - ) { - value = QString(); - qCDebug(lcAccessibilityAtspi) << "Unknown font-style attribute value \"" << value << "\" cannot be translated to AT-SPI."; - } - } else if (ia2Name == QLatin1String("text-underline-type")) { - name = QStringLiteral("underline"); - if (value != QLatin1String("none") && - value != QLatin1String("single") && - value != QLatin1String("double") - ) { - value = QString(); - qCDebug(lcAccessibilityAtspi) << "Unknown text-underline-type attribute value \"" << value << "\" cannot be translated to AT-SPI."; - } - } else if (ia2Name == QLatin1String("font-weight")) { - name = QStringLiteral("weight"); - if (value == QLatin1String("normal")) - // Orca seems to accept all IAccessible2 values except for "normal" - // (on which it produces traceback and fails to read any following text attributes), - // but that is the default value, so omit it anyway - value = QString(); - } else if (ia2Name == QLatin1String("text-position")) { - name = QStringLiteral("vertical-align"); - if (value != QLatin1String("baseline") && - value != QLatin1String("super") && - value != QLatin1String("sub") - ) { - value = QString(); - qCDebug(lcAccessibilityAtspi) << "Unknown text-position attribute value \"" << value << "\" cannot be translated to AT-SPI."; - } - } else if (ia2Name == QLatin1String("writing-mode")) { - name = QStringLiteral("direction"); - if (value == QLatin1String("lr")) - value = QStringLiteral("ltr"); - else if (value == QLatin1String("rl")) - value = QStringLiteral("rtl"); - else if (value == QLatin1String("tb")) { - // IAccessible2 docs refer to XSL, which specifies "tb" is shorthand for "tb-rl"; so at least give a hint about the horizontal direction (ATK does not support vertical direction in this attribute (yet)) - value = QStringLiteral("rtl"); - qCDebug(lcAccessibilityAtspi) << "writing-mode attribute value \"tb\" translated only w.r.t. horizontal direction; vertical direction ignored"; - } else { - value = QString(); - qCDebug(lcAccessibilityAtspi) << "Unknown writing-mode attribute value \"" << value << "\" cannot be translated to AT-SPI."; - } - } else if (ia2Name == QLatin1String("language")) { - // OK - ATK has no docs on the format of the value, IAccessible2 has reasonable format - leave it at that now - } else if (ia2Name == QLatin1String("invalid")) { - // OK - ATK docs are vague but suggest they support the same range of values as IAccessible2 - } else { - // attribute we know nothing about - name = QString(); - value = QString(); - } - return AtSpiAttribute(name, value); - } -} - -// FIXME all attribute methods below should share code -QVariantList AtSpiAdaptor::getAttributes(QAccessibleInterface *interface, int offset, bool includeDefaults) const -{ - Q_UNUSED(includeDefaults); - - QSpiAttributeSet set; - int startOffset; - int endOffset; - - QString joined = interface->textInterface()->attributes(offset, &startOffset, &endOffset); - const QStringList attributes = joined.split (QLatin1Char(';'), Qt::SkipEmptyParts, Qt::CaseSensitive); - for (const QString &attr : attributes) { - QStringList items; - items = attr.split(QLatin1Char(':'), Qt::SkipEmptyParts, Qt::CaseSensitive); - AtSpiAttribute attribute = atspiTextAttribute(items[0], items[1]); - if (!attribute.isNull()) - set[attribute.name] = attribute.value; - } - - QVariantList list; - list << QVariant::fromValue(set) << startOffset << endOffset; - - return list; -} - -QVariantList AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, int offset, const QString &attributeName) const -{ - QString mapped; - QString joined; - QSpiAttributeSet map; - int startOffset; - int endOffset; - - joined = interface->textInterface()->attributes(offset, &startOffset, &endOffset); - const QStringList attributes = joined.split (QLatin1Char(';'), Qt::SkipEmptyParts, Qt::CaseSensitive); - for (const QString& attr : attributes) { - QStringList items; - items = attr.split(QLatin1Char(':'), Qt::SkipEmptyParts, Qt::CaseSensitive); - AtSpiAttribute attribute = atspiTextAttribute(items[0], items[1]); - if (!attribute.isNull()) - map[attribute.name] = attribute.value; - } - mapped = map[attributeName]; - const bool defined = !mapped.isEmpty(); - QVariantList list; - list << mapped << startOffset << endOffset << defined; - return list; -} - -QList<QVariant> AtSpiAdaptor::getCharacterExtents(QAccessibleInterface *interface, int offset, uint coordType) const -{ - QRect rect = interface->textInterface()->characterRect(offset); - - if (coordType == ATSPI_COORD_TYPE_WINDOW) - rect = translateRectToWindowCoordinates(interface, rect); - - return QList<QVariant>() << rect.x() << rect.y() << rect.width() << rect.height(); -} - -QList<QVariant> AtSpiAdaptor::getRangeExtents(QAccessibleInterface *interface, - int startOffset, int endOffset, uint coordType) const -{ - if (endOffset == -1) - endOffset = interface->textInterface()->characterCount(); - - QAccessibleTextInterface *textInterface = interface->textInterface(); - if (endOffset <= startOffset || !textInterface) - return QList<QVariant>() << -1 << -1 << 0 << 0; - - QRect rect = textInterface->characterRect(startOffset); - for (int i=startOffset + 1; i <= endOffset; i++) - rect = rect | textInterface->characterRect(i); - - // relative to window - if (coordType == ATSPI_COORD_TYPE_WINDOW) - rect = translateRectToWindowCoordinates(interface, rect); - - return QList<QVariant>() << rect.x() << rect.y() << rect.width() << rect.height(); -} - -QRect AtSpiAdaptor::translateRectToWindowCoordinates(QAccessibleInterface *interface, const QRect &rect) -{ - QAccessibleInterface * window = getWindow(interface); - if (window) - return rect.translated(-window->rect().x(), -window->rect().y()); - - return rect; -} - - -// Editable Text interface -static QString textForRange(QAccessibleInterface *accessible, int startOffset, int endOffset) -{ - if (QAccessibleTextInterface *textIface = accessible->textInterface()) { - if (endOffset == -1) - endOffset = textIface->characterCount(); - return textIface->text(startOffset, endOffset); - } - QString txt = accessible->text(QAccessible::Value); - if (endOffset == -1) - endOffset = txt.length(); - return txt.mid(startOffset, endOffset - startOffset); -} - -static void replaceTextFallback(QAccessibleInterface *accessible, long startOffset, long endOffset, const QString &txt) -{ - QString t = textForRange(accessible, 0, -1); - if (endOffset == -1) - endOffset = t.length(); - if (endOffset - startOffset == 0) - t.insert(startOffset, txt); - else - t.replace(startOffset, endOffset - startOffset, txt); - accessible->setText(QAccessible::Value, t); -} - -bool AtSpiAdaptor::editableTextInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - if (function == QLatin1String("CopyText")) { -#ifndef QT_NO_CLIPBOARD - int startOffset = message.arguments().at(0).toInt(); - int endOffset = message.arguments().at(1).toInt(); - const QString t = textForRange(interface, startOffset, endOffset); - QGuiApplication::clipboard()->setText(t); -#endif - connection.send(message.createReply(true)); - } else if (function == QLatin1String("CutText")) { -#ifndef QT_NO_CLIPBOARD - int startOffset = message.arguments().at(0).toInt(); - int endOffset = message.arguments().at(1).toInt(); - const QString t = textForRange(interface, startOffset, endOffset); - if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface()) - editableTextIface->deleteText(startOffset, endOffset); - else - replaceTextFallback(interface, startOffset, endOffset, QString()); - QGuiApplication::clipboard()->setText(t); -#endif - connection.send(message.createReply(true)); - } else if (function == QLatin1String("DeleteText")) { - int startOffset = message.arguments().at(0).toInt(); - int endOffset = message.arguments().at(1).toInt(); - if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface()) - editableTextIface->deleteText(startOffset, endOffset); - else - replaceTextFallback(interface, startOffset, endOffset, QString()); - connection.send(message.createReply(true)); - } else if (function == QLatin1String("InsertText")) { - int position = message.arguments().at(0).toInt(); - QString text = message.arguments().at(1).toString(); - int length = message.arguments().at(2).toInt(); - text.resize(length); - if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface()) - editableTextIface->insertText(position, text); - else - replaceTextFallback(interface, position, position, text); - connection.send(message.createReply(true)); - } else if (function == QLatin1String("PasteText")) { -#ifndef QT_NO_CLIPBOARD - int position = message.arguments().at(0).toInt(); - const QString txt = QGuiApplication::clipboard()->text(); - if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface()) - editableTextIface->insertText(position, txt); - else - replaceTextFallback(interface, position, position, txt); -#endif - connection.send(message.createReply(true)); - } else if (function == QLatin1String("SetTextContents")) { - QString newContents = message.arguments().at(0).toString(); - if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface()) - editableTextIface->replaceText(0, interface->textInterface()->characterCount(), newContents); - else - replaceTextFallback(interface, 0, -1, newContents); - connection.send(message.createReply(true)); - } else if (function == QLatin1String("")) { - connection.send(message.createReply()); - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::editableTextInterface does not implement " << function << message.path(); - return false; - } - return true; -} - -// Value interface -bool AtSpiAdaptor::valueInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - QAccessibleValueInterface *valueIface = interface->valueInterface(); - if (!valueIface) - return false; - - if (function == QLatin1String("SetCurrentValue")) { - QDBusVariant v = qvariant_cast<QDBusVariant>(message.arguments().at(2)); - double value = v.variant().toDouble(); - //Temporary fix - //See https://bugzilla.gnome.org/show_bug.cgi?id=652596 - valueIface->setCurrentValue(value); - connection.send(message.createReply()); // FIXME is the reply needed? - } else { - QVariant value; - if (function == QLatin1String("GetCurrentValue")) - value = valueIface->currentValue(); - else if (function == QLatin1String("GetMaximumValue")) - value = valueIface->maximumValue(); - else if (function == QLatin1String("GetMinimumIncrement")) - value = valueIface->minimumStepSize(); - else if (function == QLatin1String("GetMinimumValue")) - value = valueIface->minimumValue(); - else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::valueInterface does not implement " << function << message.path(); - return false; - } - if (!value.canConvert(QMetaType::Double)) { - qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::valueInterface: Could not convert to double: " << function; - } - - // explicitly convert to dbus-variant containing one double since atspi expects that - // everything else might fail to convert back on the other end - connection.send(message.createReply( - QVariant::fromValue(QDBusVariant(QVariant::fromValue(value.toDouble()))))); - } - return true; -} - -// Table interface -bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection) -{ - if (!(interface->tableInterface() || interface->tableCellInterface())) { - qCDebug(lcAccessibilityAtspi) << "WARNING Qt AtSpiAdaptor: Could not find table interface for: " << message.path() << interface; - return false; - } - - if (0) { - // properties - } else if (function == QLatin1String("GetCaption")) { - QAccessibleInterface * captionInterface= interface->tableInterface()->caption(); - if (captionInterface) { - QSpiObjectReference ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(captionInterface))); - sendReply(connection, message, QVariant::fromValue(ref)); - } else { - sendReply(connection, message, QVariant::fromValue( - QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL)))); - } - } else if (function == QLatin1String("GetNColumns")) { - connection.send(message.createReply(QVariant::fromValue(QDBusVariant( - QVariant::fromValue(interface->tableInterface()->columnCount()))))); - } else if (function == QLatin1String("GetNRows")) { - connection.send(message.createReply(QVariant::fromValue(QDBusVariant( - QVariant::fromValue(interface->tableInterface()->rowCount()))))); - } else if (function == QLatin1String("GetNSelectedColumns")) { - connection.send(message.createReply(QVariant::fromValue(QDBusVariant( - QVariant::fromValue(interface->tableInterface()->selectedColumnCount()))))); - } else if (function == QLatin1String("GetNSelectedRows")) { - connection.send(message.createReply(QVariant::fromValue(QDBusVariant( - QVariant::fromValue(interface->tableInterface()->selectedRowCount()))))); - } else if (function == QLatin1String("GetSummary")) { - QAccessibleInterface * summary = interface->tableInterface() ? interface->tableInterface()->summary() : 0; - QSpiObjectReference ref(connection, QDBusObjectPath(pathForInterface(summary))); - connection.send(message.createReply(QVariant::fromValue(QDBusVariant(QVariant::fromValue(ref))))); - } else if (function == QLatin1String("GetAccessibleAt")) { - int row = message.arguments().at(0).toInt(); - int column = message.arguments().at(1).toInt(); - if ((row < 0) || - (column < 0) || - (row >= interface->tableInterface()->rowCount()) || - (column >= interface->tableInterface()->columnCount())) { - qCDebug(lcAccessibilityAtspi) << "WARNING: invalid index for tableInterface GetAccessibleAt (" << row << ", " << column << ')'; - return false; - } - - QSpiObjectReference ref; - QAccessibleInterface * cell(interface->tableInterface()->cellAt(row, column)); - if (cell) { - ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(cell))); - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: no cell interface returned for " << interface->object() << row << column; - ref = QSpiObjectReference(); - } - connection.send(message.createReply(QVariant::fromValue(ref))); - - } else if (function == QLatin1String("GetIndexAt")) { - int row = message.arguments().at(0).toInt(); - int column = message.arguments().at(1).toInt(); - QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, column); - if (!cell) { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::GetIndexAt(" << row << ',' << column << ") did not find a cell. " << interface; - return false; - } - int index = interface->indexOfChild(cell); - qCDebug(lcAccessibilityAtspi) << "QSpiAdaptor::GetIndexAt row:" << row << " col:" << column << " logical index:" << index; - Q_ASSERT(index > 0); - connection.send(message.createReply(index)); - } else if ((function == QLatin1String("GetColumnAtIndex")) || (function == QLatin1String("GetRowAtIndex"))) { - int index = message.arguments().at(0).toInt(); - int ret = -1; - if (index >= 0) { - QAccessibleInterface * cell = interface->child(index); - if (cell) { - if (function == QLatin1String("GetColumnAtIndex")) { - if (cell->role() == QAccessible::ColumnHeader) { - ret = index; - } else if (cell->role() == QAccessible::RowHeader) { - ret = -1; - } else { - if (!cell->tableCellInterface()) { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::" << function << " No table cell interface: " << cell; - return false; - } - ret = cell->tableCellInterface()->columnIndex(); - } - } else { - if (cell->role() == QAccessible::ColumnHeader) { - ret = -1; - } else if (cell->role() == QAccessible::RowHeader) { - ret = index % interface->tableInterface()->columnCount(); - } else { - if (!cell->tableCellInterface()) { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::" << function << " No table cell interface: " << cell; - return false; - } - ret = cell->tableCellInterface()->rowIndex(); - } - } - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::" << function << " No cell at index: " << index << interface; - return false; - } - } - connection.send(message.createReply(ret)); - - } else if (function == QLatin1String("GetColumnDescription")) { - int column = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->columnDescription(column))); - } else if (function == QLatin1String("GetRowDescription")) { - int row = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->rowDescription(row))); - - - - } else if (function == QLatin1String("GetRowColumnExtentsAtIndex")) { - int index = message.arguments().at(0).toInt(); - bool success = false; - - int row = -1; - int col = -1; - int rowExtents = -1; - int colExtents = -1; - bool isSelected = false; - - int cols = interface->tableInterface()->columnCount(); - if (cols > 0) { - row = index / cols; - col = index % cols; - QAccessibleTableCellInterface *cell = interface->tableInterface()->cellAt(row, col)->tableCellInterface(); - if (cell) { - row = cell->rowIndex(); - col = cell->columnIndex(); - rowExtents = cell->rowExtent(); - colExtents = cell->columnExtent(); - isSelected = cell->isSelected(); - success = true; - } - } - QVariantList list; - list << success << row << col << rowExtents << colExtents << isSelected; - connection.send(message.createReply(list)); - - } else if (function == QLatin1String("GetColumnExtentAt")) { - int row = message.arguments().at(0).toInt(); - int column = message.arguments().at(1).toInt(); - connection.send(message.createReply(interface->tableInterface()->cellAt(row, column)->tableCellInterface()->columnExtent())); - - } else if (function == QLatin1String("GetRowExtentAt")) { - int row = message.arguments().at(0).toInt(); - int column = message.arguments().at(1).toInt(); - connection.send(message.createReply(interface->tableInterface()->cellAt(row, column)->tableCellInterface()->rowExtent())); - - } else if (function == QLatin1String("GetColumnHeader")) { - int column = message.arguments().at(0).toInt(); - QSpiObjectReference ref; - - QAccessibleInterface * cell(interface->tableInterface()->cellAt(0, column)); - if (cell && cell->tableCellInterface()) { - QList<QAccessibleInterface*> header = cell->tableCellInterface()->columnHeaderCells(); - if (header.size() > 0) { - ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(header.takeAt(0)))); - } - } - connection.send(message.createReply(QVariant::fromValue(ref))); - - } else if (function == QLatin1String("GetRowHeader")) { - int row = message.arguments().at(0).toInt(); - QSpiObjectReference ref; - QAccessibleTableCellInterface *cell = interface->tableInterface()->cellAt(row, 0)->tableCellInterface(); - if (cell) { - QList<QAccessibleInterface*> header = cell->rowHeaderCells(); - if (header.size() > 0) { - ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(header.takeAt(0)))); - } - } - connection.send(message.createReply(QVariant::fromValue(ref))); - - } else if (function == QLatin1String("GetSelectedColumns")) { - connection.send(message.createReply(QVariant::fromValue(interface->tableInterface()->selectedColumns()))); - } else if (function == QLatin1String("GetSelectedRows")) { - connection.send(message.createReply(QVariant::fromValue(interface->tableInterface()->selectedRows()))); - } else if (function == QLatin1String("IsColumnSelected")) { - int column = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->isColumnSelected(column))); - } else if (function == QLatin1String("IsRowSelected")) { - int row = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->isRowSelected(row))); - } else if (function == QLatin1String("IsSelected")) { - int row = message.arguments().at(0).toInt(); - int column = message.arguments().at(1).toInt(); - QAccessibleTableCellInterface* cell = interface->tableInterface()->cellAt(row, column)->tableCellInterface(); - connection.send(message.createReply(cell->isSelected())); - } else if (function == QLatin1String("AddColumnSelection")) { - int column = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->selectColumn(column))); - } else if (function == QLatin1String("AddRowSelection")) { - int row = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->selectRow(row))); - } else if (function == QLatin1String("RemoveColumnSelection")) { - int column = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->unselectColumn(column))); - } else if (function == QLatin1String("RemoveRowSelection")) { - int row = message.arguments().at(0).toInt(); - connection.send(message.createReply(interface->tableInterface()->unselectRow(row))); - } else { - qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::tableInterface does not implement " << function << message.path(); - return false; - } - return true; -} - -QT_END_NAMESPACE -#endif //QT_NO_ACCESSIBILITY diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h deleted file mode 100644 index 97d302a779..0000000000 --- a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 ATSPIADAPTOR_H -#define ATSPIADAPTOR_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 <atspi/atspi-constants.h> - -#include <QtGui/private/qtguiglobal_p.h> -#include <QtCore/qsharedpointer.h> -#include <QtDBus/qdbusvirtualobject.h> -#include <QtGui/qaccessible.h> - -#include "dbusconnection_p.h" -#include "struct_marshallers_p.h" - -QT_REQUIRE_CONFIG(accessibility); - -QT_BEGIN_NAMESPACE - -class QAccessibleInterface; -class QSpiAccessibleInterface; -class QSpiApplicationAdaptor; - - -class AtSpiAdaptor :public QDBusVirtualObject -{ - Q_OBJECT - -public: - explicit AtSpiAdaptor(DBusConnection *connection, QObject *parent = nullptr); - ~AtSpiAdaptor(); - - void registerApplication(); - QString introspect(const QString &path) const override; - bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) override; - void notify(QAccessibleEvent *event); - - void init(); - void checkInitializedAndEnabled(); -public Q_SLOTS: - void eventListenerRegistered(const QString &bus, const QString &path); - void eventListenerDeregistered(const QString &bus, const QString &path); - void windowActivated(QObject* window, bool active); - -private: - void updateEventListeners(); - void setBitFlag(const QString &flag); - - // sending messages - QVariantList packDBusSignalArguments(const QString &type, int data1, int data2, const QVariant &variantData) const; - bool sendDBusSignal(const QString &path, const QString &interface, const QString &name, const QVariantList &arguments) const; - QVariant variantForPath(const QString &path) const; - - void sendFocusChanged(QAccessibleInterface *interface) const; - void notifyAboutCreation(QAccessibleInterface *interface) const; - void notifyAboutDestruction(QAccessibleInterface *interface) const; - void childrenChanged(QAccessibleInterface *interface) const; - - // handlers for the different accessible interfaces - bool applicationInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - bool accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - bool componentInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - bool actionInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - bool textInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - bool editableTextInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - bool valueInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - bool tableInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection); - - void sendReply(const QDBusConnection &connection, const QDBusMessage &message, const QVariant &argument) const; - - QAccessibleInterface *interfaceFromPath(const QString& dbusPath) const; - QString pathForInterface(QAccessibleInterface *interface) const; - QString pathForObject(QObject *object) const; - - void notifyStateChange(QAccessibleInterface *interface, const QString& state, int value); - - // accessible helper functions - AtspiRole getRole(QAccessibleInterface *interface) const; - QSpiRelationArray relationSet(QAccessibleInterface *interface, const QDBusConnection &connection) const; - QStringList accessibleInterfaces(QAccessibleInterface *interface) const; - - // component helper functions - static QRect getExtents(QAccessibleInterface *interface, uint coordType); - static QRect translateRectToWindowCoordinates(QAccessibleInterface *interface, const QRect &rect); - - // action helper functions - QSpiActionArray getActions(QAccessibleInterface *interface) const; - - // text helper functions - QVariantList getAttributes(QAccessibleInterface *, int offset, bool includeDefaults) const; - QVariantList getAttributeValue(QAccessibleInterface *, int offset, const QString &attributeName) const; - QList<QVariant> getCharacterExtents(QAccessibleInterface *, int offset, uint coordType) const; - QList<QVariant> getRangeExtents(QAccessibleInterface *, int startOffset, int endOffset, uint coordType) const; - QAccessible::TextBoundaryType qAccessibleBoundaryType(int atspiTextBoundaryType) const; - static bool inheritsQAction(QObject *object); - - // private vars - QSpiObjectReference accessibilityRegistry; - DBusConnection *m_dbus; - QSpiApplicationAdaptor *m_applicationAdaptor; - - /// Assigned from the accessibility registry. - int m_applicationId; - - // Bit fields - which updates to send - - // AT-SPI has some events that we do not care about: - // document - // document-load-complete - // document-load-stopped - // document-reload - uint sendFocus : 1; - // mouse abs/rel/button - - // all of object - uint sendObject : 1; - uint sendObject_active_descendant_changed : 1; - uint sendObject_attributes_changed : 1; - uint sendObject_bounds_changed : 1; - uint sendObject_children_changed : 1; -// uint sendObject_children_changed_add : 1; -// uint sendObject_children_changed_remove : 1; - uint sendObject_column_deleted : 1; - uint sendObject_column_inserted : 1; - uint sendObject_column_reordered : 1; - uint sendObject_link_selected : 1; - uint sendObject_model_changed : 1; - uint sendObject_property_change : 1; - uint sendObject_property_change_accessible_description : 1; - uint sendObject_property_change_accessible_name : 1; - uint sendObject_property_change_accessible_parent : 1; - uint sendObject_property_change_accessible_role : 1; - uint sendObject_property_change_accessible_table_caption : 1; - uint sendObject_property_change_accessible_table_column_description : 1; - uint sendObject_property_change_accessible_table_column_header : 1; - uint sendObject_property_change_accessible_table_row_description : 1; - uint sendObject_property_change_accessible_table_row_header : 1; - uint sendObject_property_change_accessible_table_summary : 1; - uint sendObject_property_change_accessible_value : 1; - uint sendObject_row_deleted : 1; - uint sendObject_row_inserted : 1; - uint sendObject_row_reordered : 1; - uint sendObject_selection_changed : 1; - uint sendObject_state_changed : 1; - uint sendObject_text_attributes_changed : 1; - uint sendObject_text_bounds_changed : 1; - uint sendObject_text_caret_moved : 1; - uint sendObject_text_changed : 1; -// uint sendObject_text_changed_delete : 1; -// uint sendObject_text_changed_insert : 1; - uint sendObject_text_selection_changed : 1; - uint sendObject_value_changed : 1; - uint sendObject_visible_data_changed : 1; - - // we don't implement terminal - // terminal-application_changed/charwidth_changed/columncount_changed/line_changed/linecount_changed - uint sendWindow : 1; - uint sendWindow_activate : 1; - uint sendWindow_close: 1; - uint sendWindow_create : 1; - uint sendWindow_deactivate : 1; -// uint sendWindow_desktop_create : 1; -// uint sendWindow_desktop_destroy : 1; - uint sendWindow_lower : 1; - uint sendWindow_maximize : 1; - uint sendWindow_minimize : 1; - uint sendWindow_move : 1; - uint sendWindow_raise : 1; - uint sendWindow_reparent : 1; - uint sendWindow_resize : 1; - uint sendWindow_restore : 1; - uint sendWindow_restyle : 1; - uint sendWindow_shade : 1; - uint sendWindow_unshade : 1; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/platformsupport/linuxaccessibility/bridge.cpp b/src/platformsupport/linuxaccessibility/bridge.cpp deleted file mode 100644 index fdc8cd3198..0000000000 --- a/src/platformsupport/linuxaccessibility/bridge.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "bridge_p.h" - -#include <atspi/atspi-constants.h> -#include <qstring.h> - -#include "atspiadaptor_p.h" - -#include "cache_p.h" -#include "constant_mappings_p.h" -#include "dbusconnection_p.h" -#include "struct_marshallers_p.h" - -#ifndef QT_NO_ACCESSIBILITY -#include "deviceeventcontroller_adaptor.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QSpiAccessibleBridge - \internal -*/ - -QSpiAccessibleBridge::QSpiAccessibleBridge() - : cache(0), dec(0), dbusAdaptor(0) -{ - dbusConnection = new DBusConnection(); - connect(dbusConnection, SIGNAL(enabledChanged(bool)), this, SLOT(enabledChanged(bool))); -} - -void QSpiAccessibleBridge::enabledChanged(bool enabled) -{ - setActive(enabled); - updateStatus(); -} - -QSpiAccessibleBridge::~QSpiAccessibleBridge() -{ - delete dbusConnection; -} // Qt currently doesn't delete plugins. - -QDBusConnection QSpiAccessibleBridge::dBusConnection() const -{ - return dbusConnection->connection(); -} - -void QSpiAccessibleBridge::updateStatus() -{ - // create the adaptor to handle everything if we are in enabled state - if (!dbusAdaptor && isActive()) { - qSpiInitializeStructTypes(); - initializeConstantMappings(); - - cache = new QSpiDBusCache(dbusConnection->connection(), this); - dec = new DeviceEventControllerAdaptor(this); - - dbusConnection->connection().registerObject(QLatin1String(ATSPI_DBUS_PATH_DEC), this, QDBusConnection::ExportAdaptors); - - dbusAdaptor = new AtSpiAdaptor(dbusConnection, this); - dbusConnection->connection().registerVirtualObject(QLatin1String(QSPI_OBJECT_PATH_ACCESSIBLE), dbusAdaptor, QDBusConnection::SubPath); - dbusAdaptor->registerApplication(); - } -} - -void QSpiAccessibleBridge::notifyAccessibilityUpdate(QAccessibleEvent *event) -{ - if (!dbusAdaptor) - return; - if (isActive() && event->accessibleInterface()) - dbusAdaptor->notify(event); -} - -struct RoleMapping { - QAccessible::Role role; - AtspiRole spiRole; - const char *name; -}; - -static RoleMapping map[] = { - //: Role of an accessible object - the object is in an invalid state or could not be constructed - { QAccessible::NoRole, ATSPI_ROLE_INVALID, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "invalid role") }, - //: Role of an accessible object - { QAccessible::TitleBar, ATSPI_ROLE_TEXT, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "title bar") }, - //: Role of an accessible object - { QAccessible::MenuBar, ATSPI_ROLE_MENU_BAR, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "menu bar") }, - //: Role of an accessible object - { QAccessible::ScrollBar, ATSPI_ROLE_SCROLL_BAR, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "scroll bar") }, - //: Role of an accessible object - the grip is usually used for resizing another object - { QAccessible::Grip, ATSPI_ROLE_UNKNOWN, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "grip") }, - //: Role of an accessible object - { QAccessible::Sound, ATSPI_ROLE_UNKNOWN, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "sound") }, - //: Role of an accessible object - { QAccessible::Cursor, ATSPI_ROLE_UNKNOWN, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "cursor") }, - //: Role of an accessible object - { QAccessible::Caret, ATSPI_ROLE_UNKNOWN, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "text caret") }, - //: Role of an accessible object - { QAccessible::AlertMessage, ATSPI_ROLE_ALERT, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "alert message") }, - //: Role of an accessible object: a window with frame and title - { QAccessible::Window, ATSPI_ROLE_FRAME, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "frame") }, - //: Role of an accessible object - { QAccessible::Client, ATSPI_ROLE_FILLER, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "filler") }, - //: Role of an accessible object - { QAccessible::PopupMenu, ATSPI_ROLE_POPUP_MENU, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "popup menu") }, - //: Role of an accessible object - { QAccessible::MenuItem, ATSPI_ROLE_MENU_ITEM, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "menu item") }, - //: Role of an accessible object - { QAccessible::ToolTip, ATSPI_ROLE_TOOL_TIP, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "tool tip") }, - //: Role of an accessible object - { QAccessible::Application, ATSPI_ROLE_APPLICATION, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "application") }, - //: Role of an accessible object - { QAccessible::Document, ATSPI_ROLE_DOCUMENT_FRAME, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "document") }, - //: Role of an accessible object - { QAccessible::Pane, ATSPI_ROLE_PANEL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "panel") }, - //: Role of an accessible object - { QAccessible::Chart, ATSPI_ROLE_CHART, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "chart") }, - //: Role of an accessible object - { QAccessible::Dialog, ATSPI_ROLE_DIALOG, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "dialog") }, - //: Role of an accessible object - { QAccessible::Border, ATSPI_ROLE_FRAME, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "frame") }, - //: Role of an accessible object - { QAccessible::Grouping, ATSPI_ROLE_PANEL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "panel") }, - //: Role of an accessible object - { QAccessible::Separator, ATSPI_ROLE_SEPARATOR, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "separator") }, - //: Role of an accessible object - { QAccessible::ToolBar, ATSPI_ROLE_TOOL_BAR, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "tool bar") }, - //: Role of an accessible object - { QAccessible::StatusBar, ATSPI_ROLE_STATUS_BAR, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "status bar") }, - //: Role of an accessible object - { QAccessible::Table, ATSPI_ROLE_TABLE, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "table") }, - //: Role of an accessible object - part of a table - { QAccessible::ColumnHeader, ATSPI_ROLE_TABLE_COLUMN_HEADER, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "column header") }, - //: Role of an accessible object - part of a table - { QAccessible::RowHeader, ATSPI_ROLE_TABLE_ROW_HEADER, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "row header") }, - //: Role of an accessible object - part of a table - { QAccessible::Column, ATSPI_ROLE_TABLE_CELL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "column") }, - //: Role of an accessible object - part of a table - { QAccessible::Row, ATSPI_ROLE_TABLE_ROW, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "row") }, - //: Role of an accessible object - part of a table - { QAccessible::Cell, ATSPI_ROLE_TABLE_CELL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "cell") }, - //: Role of an accessible object - { QAccessible::Link, ATSPI_ROLE_LINK, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "link") }, - //: Role of an accessible object - { QAccessible::HelpBalloon, ATSPI_ROLE_DIALOG, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "help balloon") }, - //: Role of an accessible object - a helper dialog - { QAccessible::Assistant, ATSPI_ROLE_DIALOG, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "assistant") }, - //: Role of an accessible object - { QAccessible::List, ATSPI_ROLE_LIST, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "list") }, - //: Role of an accessible object - { QAccessible::ListItem, ATSPI_ROLE_LIST_ITEM, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "list item") }, - //: Role of an accessible object - { QAccessible::Tree, ATSPI_ROLE_TREE, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "tree") }, - //: Role of an accessible object - { QAccessible::TreeItem, ATSPI_ROLE_TABLE_CELL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "tree item") }, - //: Role of an accessible object - { QAccessible::PageTab, ATSPI_ROLE_PAGE_TAB, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "page tab") }, - //: Role of an accessible object - { QAccessible::PropertyPage, ATSPI_ROLE_PAGE_TAB, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "property page") }, - //: Role of an accessible object - { QAccessible::Indicator, ATSPI_ROLE_UNKNOWN, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "indicator") }, - //: Role of an accessible object - { QAccessible::Graphic, ATSPI_ROLE_IMAGE, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "graphic") }, - //: Role of an accessible object - { QAccessible::StaticText, ATSPI_ROLE_LABEL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "label") }, - //: Role of an accessible object - { QAccessible::EditableText, ATSPI_ROLE_TEXT, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "text") }, - //: Role of an accessible object - { QAccessible::PushButton, ATSPI_ROLE_PUSH_BUTTON, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "push button") }, - //: Role of an accessible object - { QAccessible::CheckBox, ATSPI_ROLE_CHECK_BOX, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "check box") }, - //: Role of an accessible object - { QAccessible::RadioButton, ATSPI_ROLE_RADIO_BUTTON, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "radio button") }, - //: Role of an accessible object - { QAccessible::ComboBox, ATSPI_ROLE_COMBO_BOX, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "combo box") }, - //: Role of an accessible object - { QAccessible::ProgressBar, ATSPI_ROLE_PROGRESS_BAR, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "progress bar") }, - //: Role of an accessible object - { QAccessible::Dial, ATSPI_ROLE_DIAL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "dial") }, - //: Role of an accessible object - { QAccessible::HotkeyField, ATSPI_ROLE_TEXT, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "hotkey field") }, - //: Role of an accessible object - { QAccessible::Slider, ATSPI_ROLE_SLIDER, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "slider") }, - //: Role of an accessible object - { QAccessible::SpinBox, ATSPI_ROLE_SPIN_BUTTON, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "spin box") }, - //: Role of an accessible object - { QAccessible::Canvas, ATSPI_ROLE_CANVAS, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "canvas") }, - //: Role of an accessible object - { QAccessible::Animation, ATSPI_ROLE_ANIMATION, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "animation") }, - //: Role of an accessible object - { QAccessible::Equation, ATSPI_ROLE_TEXT, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "equation") }, - //: Role of an accessible object - { QAccessible::ButtonDropDown, ATSPI_ROLE_PUSH_BUTTON, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "button with drop down") }, - //: Role of an accessible object - { QAccessible::ButtonMenu, ATSPI_ROLE_PUSH_BUTTON, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "button menu") }, - //: Role of an accessible object - a button that expands a grid. - { QAccessible::ButtonDropGrid, ATSPI_ROLE_PUSH_BUTTON, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "button with drop down grid") }, - //: Role of an accessible object - blank space between other objects. - { QAccessible::Whitespace, ATSPI_ROLE_FILLER, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "space") }, - //: Role of an accessible object - { QAccessible::PageTabList, ATSPI_ROLE_PAGE_TAB_LIST, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "page tab list") }, - //: Role of an accessible object - { QAccessible::Clock, ATSPI_ROLE_UNKNOWN, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "clock") }, - //: Role of an accessible object - { QAccessible::Splitter, ATSPI_ROLE_SPLIT_PANE, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "splitter") }, - //: Role of an accessible object - { QAccessible::LayeredPane, ATSPI_ROLE_LAYERED_PANE, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "layered pane") }, - //: Role of an accessible object - { QAccessible::WebDocument, ATSPI_ROLE_DOCUMENT_WEB, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "web document") }, - //: Role of an accessible object - { QAccessible::Paragraph, ATSPI_ROLE_PARAGRAPH, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "paragraph") }, - //: Role of an accessible object - { QAccessible::Section, ATSPI_ROLE_SECTION, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "section") }, - //: Role of an accessible object - { QAccessible::ColorChooser, ATSPI_ROLE_COLOR_CHOOSER, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "color chooser") }, - //: Role of an accessible object - { QAccessible::Footer, ATSPI_ROLE_FOOTER, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "footer") }, - //: Role of an accessible object - { QAccessible::Form, ATSPI_ROLE_FORM, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "form") }, - //: Role of an accessible object - { QAccessible::Heading, ATSPI_ROLE_HEADING, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "heading") }, - //: Role of an accessible object - { QAccessible::Note, ATSPI_ROLE_COMMENT, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "note") }, - //: Role of an accessible object - { QAccessible::ComplementaryContent, ATSPI_ROLE_SECTION, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "complementary content") }, - //: Role of an accessible object - { QAccessible::Terminal, ATSPI_ROLE_TERMINAL, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "terminal") }, - //: Role of an accessible object - { QAccessible::Desktop, ATSPI_ROLE_DESKTOP_FRAME, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "desktop") }, - //: Role of an accessible object - { QAccessible::Notification, ATSPI_ROLE_NOTIFICATION, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "notification") }, - //: Role of an accessible object - { QAccessible::UserRole, ATSPI_ROLE_UNKNOWN, QT_TRANSLATE_NOOP("QSpiAccessibleBridge", "unknown") } -}; - -void QSpiAccessibleBridge::initializeConstantMappings() -{ - for (uint i = 0; i < sizeof(map) / sizeof(RoleMapping); ++i) - qSpiRoleMapping.insert(map[i].role, RoleNames(map[i].spiRole, QLatin1String(map[i].name), tr(map[i].name))); - - // -1 because we have button duplicated, as PushButton and Button. - Q_ASSERT_X(qSpiRoleMapping.size() == - QAccessible::staticMetaObject.enumerator( - QAccessible::staticMetaObject.indexOfEnumerator("Role")).keyCount() - 1, - "", "Handle all QAccessible::Role members in qSpiRoleMapping"); -} - -QT_END_NAMESPACE -#endif //QT_NO_ACCESSIBILITY diff --git a/src/platformsupport/linuxaccessibility/bridge_p.h b/src/platformsupport/linuxaccessibility/bridge_p.h deleted file mode 100644 index c48bbd3710..0000000000 --- a/src/platformsupport/linuxaccessibility/bridge_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 QSPIACCESSIBLEBRIDGE_H -#define QSPIACCESSIBLEBRIDGE_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 <QtGui/private/qtguiglobal_p.h> -#include <QtDBus/qdbusconnection.h> -#include <qpa/qplatformaccessibility.h> - -class DeviceEventControllerAdaptor; - -QT_REQUIRE_CONFIG(accessibility); - -QT_BEGIN_NAMESPACE - -class DBusConnection; -class QSpiDBusCache; -class AtSpiAdaptor; - -class QSpiAccessibleBridge: public QObject, public QPlatformAccessibility -{ - Q_OBJECT -public: - QSpiAccessibleBridge(); - - virtual ~QSpiAccessibleBridge(); - - void notifyAccessibilityUpdate(QAccessibleEvent *event) override; - QDBusConnection dBusConnection() const; - -public Q_SLOTS: - void enabledChanged(bool enabled); - -private: - void initializeConstantMappings(); - void updateStatus(); - - QSpiDBusCache *cache; - DeviceEventControllerAdaptor *dec; - AtSpiAdaptor *dbusAdaptor; - DBusConnection* dbusConnection; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/platformsupport/linuxaccessibility/cache.cpp b/src/platformsupport/linuxaccessibility/cache.cpp deleted file mode 100644 index fe4d1e26f9..0000000000 --- a/src/platformsupport/linuxaccessibility/cache.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "cache_p.h" -#include "bridge_p.h" - -#ifndef QT_NO_ACCESSIBILITY -#include "cache_adaptor.h" - -#define QSPI_OBJECT_PATH_CACHE "/org/a11y/atspi/cache" - -QT_BEGIN_NAMESPACE - -/*! - \class QSpiDBusCache - \internal - \brief This class is responsible for the AT-SPI cache interface. - - The idea behind the cache is that starting an application would - result in many dbus calls. The way GTK/Gail/ATK work is that - they create accessibles for all objects on startup. - In order to avoid querying all the objects individually via DBus - they get sent by using the GetItems call of the cache. - - Additionally the AddAccessible and RemoveAccessible signals - are responsible for adding/removing objects from the cache. - - Currently the Qt bridge chooses to ignore these. -*/ - -QSpiDBusCache::QSpiDBusCache(QDBusConnection c, QObject* parent) - : QObject(parent) -{ - new CacheAdaptor(this); - c.registerObject(QLatin1String(QSPI_OBJECT_PATH_CACHE), this, QDBusConnection::ExportAdaptors); -} - -void QSpiDBusCache::emitAddAccessible(const QSpiAccessibleCacheItem& item) -{ - emit AddAccessible(item); -} - -void QSpiDBusCache::emitRemoveAccessible(const QSpiObjectReference& item) -{ - emit RemoveAccessible(item); -} - -QSpiAccessibleCacheArray QSpiDBusCache::GetItems() -{ - return QSpiAccessibleCacheArray(); -} - -QT_END_NAMESPACE -#endif //QT_NO_ACCESSIBILITY diff --git a/src/platformsupport/linuxaccessibility/cache_p.h b/src/platformsupport/linuxaccessibility/cache_p.h deleted file mode 100644 index cc55acc6f8..0000000000 --- a/src/platformsupport/linuxaccessibility/cache_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 Q_SPI_CACHE_H -#define Q_SPI_CACHE_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 <QtGui/private/qtguiglobal_p.h> -#include <QtCore/QObject> -#include "struct_marshallers_p.h" - -QT_REQUIRE_CONFIG(accessibility); - -QT_BEGIN_NAMESPACE - -class QSpiDBusCache : public QObject -{ - Q_OBJECT - -public: - explicit QSpiDBusCache(QDBusConnection c, QObject* parent = nullptr); - void emitAddAccessible(const QSpiAccessibleCacheItem& item); - void emitRemoveAccessible(const QSpiObjectReference& item); - -Q_SIGNALS: - void AddAccessible(const QSpiAccessibleCacheItem &nodeAdded); - void RemoveAccessible(const QSpiObjectReference &nodeRemoved); - -public Q_SLOTS: - QSpiAccessibleCacheArray GetItems(); -}; - -QT_END_NAMESPACE - -#endif /* Q_SPI_CACHE_H */ diff --git a/src/platformsupport/linuxaccessibility/constant_mappings.cpp b/src/platformsupport/linuxaccessibility/constant_mappings.cpp deleted file mode 100644 index fce2919e73..0000000000 --- a/src/platformsupport/linuxaccessibility/constant_mappings.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "constant_mappings_p.h" - -#include <qobject.h> -#include <qdebug.h> - -// FIXME the assignment of roles is quite arbitrary, at some point go through this list and sort and check that it makes sense -// "calendar" "check menu item" "color chooser" "column header" "dateeditor" "desktop icon" "desktop frame" -// "directory pane" "drawing area" "file chooser" "fontchooser" "frame" "glass pane" "html container" "icon" -// "internal frame" "option pane" "password text" "radio menu item" "root pane" "row header" "scroll pane" -// "tear off menu item" "terminal" "toggle button" "tree table" "unknown" "viewport" "header" "footer" "paragraph" -// "ruler" "autocomplete" "edit bar" "embedded component" "entry" "caption" -// "heading" "page" "section" "redundant object" "form" "input method window" "menu" - -#ifndef QT_NO_ACCESSIBILITY -QT_BEGIN_NAMESPACE - -QHash <QAccessible::Role, RoleNames> qSpiRoleMapping; - -quint64 spiStatesFromQState(QAccessible::State state) -{ - quint64 spiState = 0; - - if (state.active) - setSpiStateBit(&spiState, ATSPI_STATE_ACTIVE); - if (state.editable) - setSpiStateBit(&spiState, ATSPI_STATE_EDITABLE); - if (!state.disabled) { - setSpiStateBit(&spiState, ATSPI_STATE_ENABLED); - setSpiStateBit(&spiState, ATSPI_STATE_SENSITIVE); - } - if (state.selected) - setSpiStateBit(&spiState, ATSPI_STATE_SELECTED); - if (state.focused) - setSpiStateBit(&spiState, ATSPI_STATE_FOCUSED); - if (state.pressed) - setSpiStateBit(&spiState, ATSPI_STATE_PRESSED); - if (state.checked) - setSpiStateBit(&spiState, ATSPI_STATE_CHECKED); - if (state.checkStateMixed) - setSpiStateBit(&spiState, ATSPI_STATE_INDETERMINATE); - if (state.readOnly) - setSpiStateBit(&spiState, ATSPI_STATE_READ_ONLY); - // if (state.HotTracked) - if (state.defaultButton) - setSpiStateBit(&spiState, ATSPI_STATE_IS_DEFAULT); - if (state.expandable) - setSpiStateBit(&spiState, ATSPI_STATE_EXPANDABLE); - if (state.expanded) - setSpiStateBit(&spiState, ATSPI_STATE_EXPANDED); - if (state.collapsed) - setSpiStateBit(&spiState, ATSPI_STATE_COLLAPSED); - if (state.busy) - setSpiStateBit(&spiState, ATSPI_STATE_BUSY); - if (state.marqueed || state.animated) - setSpiStateBit(&spiState, ATSPI_STATE_ANIMATED); - if (!state.invisible && !state.offscreen) { - setSpiStateBit(&spiState, ATSPI_STATE_SHOWING); - setSpiStateBit(&spiState, ATSPI_STATE_VISIBLE); - } - if (state.sizeable) - setSpiStateBit(&spiState, ATSPI_STATE_RESIZABLE); - // if (state.Movable) - // if (state.SelfVoicing) - if (state.focusable) - setSpiStateBit(&spiState, ATSPI_STATE_FOCUSABLE); - if (state.selectable) - setSpiStateBit(&spiState, ATSPI_STATE_SELECTABLE); - // if (state.Linked) - if (state.traversed) - setSpiStateBit(&spiState, ATSPI_STATE_VISITED); - if (state.multiSelectable) - setSpiStateBit(&spiState, ATSPI_STATE_MULTISELECTABLE); - if (state.extSelectable) - setSpiStateBit(&spiState, ATSPI_STATE_SELECTABLE); - // if (state.Protected) - // if (state.HasPopup) - if (state.modal) - setSpiStateBit(&spiState, ATSPI_STATE_MODAL); - if (state.multiLine) - setSpiStateBit(&spiState, ATSPI_STATE_MULTI_LINE); - - return spiState; -} - -QSpiUIntList spiStateSetFromSpiStates(quint64 states) -{ - uint low = states & 0xFFFFFFFF; - uint high = (states >> 32) & 0xFFFFFFFF; - - QSpiUIntList stateList; - stateList.append(low); - stateList.append(high); - return stateList; -} - -AtspiRelationType qAccessibleRelationToAtSpiRelation(QAccessible::Relation relation) -{ - switch (relation) { - case QAccessible::Label: - return ATSPI_RELATION_LABELLED_BY; - case QAccessible::Labelled: - return ATSPI_RELATION_LABEL_FOR; - case QAccessible::Controller: - return ATSPI_RELATION_CONTROLLED_BY; - case QAccessible::Controlled: - return ATSPI_RELATION_CONTROLLER_FOR; - default: - qWarning() << "Cannot return AT-SPI relation for:" << relation; - } - return ATSPI_RELATION_NULL; -} - -QT_END_NAMESPACE -#endif //QT_NO_ACCESSIBILITY diff --git a/src/platformsupport/linuxaccessibility/constant_mappings_p.h b/src/platformsupport/linuxaccessibility/constant_mappings_p.h deleted file mode 100644 index 1d4dd833e1..0000000000 --- a/src/platformsupport/linuxaccessibility/constant_mappings_p.h +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ - -// -// 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. -// - -/* - * This file contains AT-SPI constants and mappings between QAccessible - * and AT-SPI constants such as 'role' and 'state' enumerations. - */ - -#ifndef Q_SPI_CONSTANT_MAPPINGS_H -#define Q_SPI_CONSTANT_MAPPINGS_H - -#include "struct_marshallers_p.h" - -#include <QtGui/private/qtguiglobal_p.h> -#include <QtGui/QAccessible> -#include <atspi/atspi-constants.h> - -QT_REQUIRE_CONFIG(accessibility); - -// interface names from at-spi2-core/atspi/atspi-misc-private.h -#define ATSPI_DBUS_NAME_REGISTRY "org.a11y.atspi.Registry" -#define ATSPI_DBUS_PATH_REGISTRY "/org/a11y/atspi/registry" -#define ATSPI_DBUS_INTERFACE_REGISTRY "org.a11y.atspi.Registry" - -#define ATSPI_DBUS_PATH_ROOT "/org/a11y/atspi/accessible/root" - -#define ATSPI_DBUS_PATH_DEC "/org/a11y/atspi/registry/deviceeventcontroller" -#define ATSPI_DBUS_INTERFACE_DEC "org.a11y.atspi.DeviceEventController" -#define ATSPI_DBUS_INTERFACE_DEVICE_EVENT_LISTENER "org.a11y.atspi.DeviceEventListener" - -#define ATSPI_DBUS_INTERFACE_CACHE "org.a11y.atspi.Cache" -#define ATSPI_DBUS_INTERFACE_ACCESSIBLE "org.a11y.atspi.Accessible" -#define ATSPI_DBUS_INTERFACE_ACTION "org.a11y.atspi.Action" -#define ATSPI_DBUS_INTERFACE_APPLICATION "org.a11y.atspi.Application" -#define ATSPI_DBUS_INTERFACE_COLLECTION "org.a11y.atspi.Collection" -#define ATSPI_DBUS_INTERFACE_COMPONENT "org.a11y.atspi.Component" -#define ATSPI_DBUS_INTERFACE_DOCUMENT "org.a11y.atspi.Document" -#define ATSPI_DBUS_INTERFACE_EDITABLE_TEXT "org.a11y.atspi.EditableText" -#define ATSPI_DBUS_INTERFACE_EVENT_KEYBOARD "org.a11y.atspi.Event.Keyboard" -#define ATSPI_DBUS_INTERFACE_EVENT_MOUSE "org.a11y.atspi.Event.Mouse" -#define ATSPI_DBUS_INTERFACE_EVENT_OBJECT "org.a11y.atspi.Event.Object" -#define ATSPI_DBUS_INTERFACE_HYPERLINK "org.a11y.atspi.Hyperlink" -#define ATSPI_DBUS_INTERFACE_HYPERTEXT "org.a11y.atspi.Hypertext" -#define ATSPI_DBUS_INTERFACE_IMAGE "org.a11y.atspi.Image" -#define ATSPI_DBUS_INTERFACE_SELECTION "org.a11y.atspi.Selection" -#define ATSPI_DBUS_INTERFACE_TABLE "org.a11y.atspi.Table" -#define ATSPI_DBUS_INTERFACE_TEXT "org.a11y.atspi.Text" -#define ATSPI_DBUS_INTERFACE_VALUE "org.a11y.atspi.Value" -#define ATSPI_DBUS_INTERFACE_SOCKET "org.a11y.atspi.Socket" - -// missing from at-spi2-core: -#define ATSPI_DBUS_INTERFACE_EVENT_WINDOW "org.a11y.atspi.Event.Window" -#define ATSPI_DBUS_INTERFACE_EVENT_FOCUS "org.a11y.atspi.Event.Focus" - -#define QSPI_OBJECT_PATH_ACCESSIBLE "/org/a11y/atspi/accessible" -#define QSPI_OBJECT_PATH_PREFIX "/org/a11y/atspi/accessible/" -#define QSPI_OBJECT_PATH_ROOT QSPI_OBJECT_PATH_PREFIX "root" - -#define QSPI_REGISTRY_NAME "org.a11y.atspi.Registry" - -QT_BEGIN_NAMESPACE - -struct RoleNames { - RoleNames() {} - RoleNames(AtspiRole r, const QString& n, const QString& ln) - :m_spiRole(r), m_name(n), m_localizedName(ln) - {} - - AtspiRole spiRole() const {return m_spiRole;} - QString name() const {return m_name;} - QString localizedName() const {return m_localizedName;} - -private: - AtspiRole m_spiRole = ATSPI_ROLE_INVALID; - QString m_name; - QString m_localizedName; -}; - -extern QHash <QAccessible::Role, RoleNames> qSpiRoleMapping; -extern QHash <int, AtspiStateType> qSpiStateMapping; - -inline void setSpiStateBit(quint64* state, AtspiStateType spiState) -{ - *state |= quint64(1) << spiState; -} - -inline void unsetSpiStateBit(quint64* state, AtspiStateType spiState) -{ - *state &= ~(quint64(1) << spiState); -} - -quint64 spiStatesFromQState(QAccessible::State state); -QSpiUIntList spiStateSetFromSpiStates(quint64 states); - -AtspiRelationType qAccessibleRelationToAtSpiRelation(QAccessible::Relation relation); - -QT_END_NAMESPACE - -#endif /* Q_SPI_CONSTANT_MAPPINGS_H */ diff --git a/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/src/platformsupport/linuxaccessibility/dbusconnection.cpp deleted file mode 100644 index 45ddc8e496..0000000000 --- a/src/platformsupport/linuxaccessibility/dbusconnection.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "dbusconnection_p.h" - -#include <QtDBus/QDBusMessage> -#include <QtDBus/QDBusServiceWatcher> -#include <qdebug.h> - -#include <QDBusConnectionInterface> -#include "bus_interface.h" - -#include <QtGui/qguiapplication.h> -#include <qpa/qplatformnativeinterface.h> - -QT_BEGIN_NAMESPACE - -/* note: do not change these to QStringLiteral; - we are unloaded before QtDBus is done using the strings. - */ -#define A11Y_SERVICE QLatin1String("org.a11y.Bus") -#define A11Y_PATH QLatin1String("/org/a11y/bus") - -/*! - \class DBusConnection - \internal - \brief Connects to the accessibility dbus. - - This is usually a different bus from the session bus. -*/ -DBusConnection::DBusConnection(QObject *parent) - : QObject(parent), m_a11yConnection(QString()), m_enabled(false) -{ - // Start monitoring if "org.a11y.Bus" is registered as DBus service. - QDBusConnection c = QDBusConnection::sessionBus(); - if (!c.isConnected()) { - return; - } - - dbusWatcher = new QDBusServiceWatcher(A11Y_SERVICE, c, QDBusServiceWatcher::WatchForRegistration, this); - connect(dbusWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(serviceRegistered())); - - // If it is registered already, setup a11y right away - if (c.interface()->isServiceRegistered(A11Y_SERVICE)) - serviceRegistered(); - - // In addition try if there is an xatom exposing the bus address, this allows applications run as root to work - QString address = getAddressFromXCB(); - if (!address.isEmpty()) { - m_enabled = true; - connectA11yBus(address); - } -} - -QString DBusConnection::getAddressFromXCB() -{ - QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance()); - if (!app) - return QString(); - QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface(); - QByteArray *addressByteArray = reinterpret_cast<QByteArray*>( - platformNativeInterface->nativeResourceForIntegration(QByteArrayLiteral("AtspiBus"))); - if (addressByteArray) { - QString address = QString::fromLatin1(*addressByteArray); - delete addressByteArray; - return address; - } - return QString(); -} - -// We have the a11y registry on the session bus. -// Subscribe to updates about a11y enabled state. -// Find out the bus address -void DBusConnection::serviceRegistered() -{ - // listen to enabled changes - QDBusConnection c = QDBusConnection::sessionBus(); - OrgA11yStatusInterface *a11yStatus = new OrgA11yStatusInterface(A11Y_SERVICE, A11Y_PATH, c, this); - - //The variable was introduced because on some embedded platforms there are custom accessibility - //clients which don't set Status.ScreenReaderEnabled to true. The variable is also useful for - //debugging. - static const bool a11yAlwaysOn = qEnvironmentVariableIsSet("QT_LINUX_ACCESSIBILITY_ALWAYS_ON"); - - bool enabled = a11yAlwaysOn || a11yStatus->screenReaderEnabled() || a11yStatus->isEnabled(); - - if (enabled != m_enabled) { - m_enabled = enabled; - if (m_a11yConnection.isConnected()) { - emit enabledChanged(m_enabled); - } else { - QDBusConnection c = QDBusConnection::sessionBus(); - QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String("org.a11y.Bus"), - QLatin1String("/org/a11y/bus"), - QLatin1String("org.a11y.Bus"), QLatin1String("GetAddress")); - c.callWithCallback(m, this, SLOT(connectA11yBus(QString)), SLOT(dbusError(QDBusError))); - } - } - - // connect(a11yStatus, ); QtDbus doesn't support notifications for property changes yet -} - -void DBusConnection::serviceUnregistered() -{ - emit enabledChanged(false); -} - -void DBusConnection::connectA11yBus(const QString &address) -{ - if (address.isEmpty()) { - qWarning("Could not find Accessibility DBus address."); - return; - } - m_a11yConnection = QDBusConnection(QDBusConnection::connectToBus(address, QLatin1String("a11y"))); - - if (m_enabled) - emit enabledChanged(true); -} - -void DBusConnection::dbusError(const QDBusError &error) -{ - qWarning() << "Accessibility encountered a DBus error:" << error; -} - -/*! - Returns the DBus connection that got established. - Or an invalid connection if not yet connected. -*/ -QDBusConnection DBusConnection::connection() const -{ - return m_a11yConnection; -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/linuxaccessibility/dbusconnection_p.h b/src/platformsupport/linuxaccessibility/dbusconnection_p.h deleted file mode 100644 index dde3bbb98f..0000000000 --- a/src/platformsupport/linuxaccessibility/dbusconnection_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 DBUSCONNECTION_H -#define DBUSCONNECTION_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 <QtCore/QString> -#include <QtDBus/QDBusConnection> -#include <QtDBus/QDBusVariant> -Q_MOC_INCLUDE(<QtDBus/QDBusError>) - -QT_BEGIN_NAMESPACE - -class QDBusServiceWatcher; - -class DBusConnection : public QObject -{ - Q_OBJECT - -public: - DBusConnection(QObject *parent = nullptr); - QDBusConnection connection() const; - bool isEnabled() const { return m_enabled; } - -Q_SIGNALS: - // Emitted when the global accessibility status changes to enabled - void enabledChanged(bool enabled); - -private Q_SLOTS: - QString getAddressFromXCB(); - void serviceRegistered(); - void serviceUnregistered(); - void connectA11yBus(const QString &address); - - void dbusError(const QDBusError &error); - -private: - QString getAccessibilityBusAddress() const; - - QDBusServiceWatcher *dbusWatcher; - QDBusConnection m_a11yConnection; - bool m_enabled; -}; - -QT_END_NAMESPACE - -#endif // DBUSCONNECTION_H diff --git a/src/platformsupport/linuxaccessibility/dbusxml/Bus.xml b/src/platformsupport/linuxaccessibility/dbusxml/Bus.xml deleted file mode 100644 index 5a33e335a1..0000000000 --- a/src/platformsupport/linuxaccessibility/dbusxml/Bus.xml +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node> - <interface name="org.a11y.Status"> - <property type="b" name="IsEnabled" access="readwrite"> - </property> - <property type="b" name="ScreenReaderEnabled" access="readwrite"> - </property> - </interface> - <interface name="org.a11y.Bus"> - <method name="GetAddress"> - <arg type="s" name="address" direction="out"> - </arg> - </method> - </interface> -</node> - diff --git a/src/platformsupport/linuxaccessibility/dbusxml/Cache.xml b/src/platformsupport/linuxaccessibility/dbusxml/Cache.xml deleted file mode 100644 index 01c52810ac..0000000000 --- a/src/platformsupport/linuxaccessibility/dbusxml/Cache.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<node name="/node"> -<interface name="org.a11y.atspi.Cache"> - - <method name="GetItems"> - <arg name="nodes" type="a((so)(so)a(so)assusau)" direction="out"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QSpiAccessibleCacheArray"/> - </method> - - <signal name="AddAccessible"> - <arg name="nodeAdded" type="((so)(so)a(so)assusau)"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QSpiAccessibleCacheItem"/> - </signal> - - <signal name="RemoveAccessible"> - <arg name="nodeRemoved" type="(so)"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QSpiObjectReference"/> - </signal> - -</interface> -</node> diff --git a/src/platformsupport/linuxaccessibility/dbusxml/DeviceEventController.xml b/src/platformsupport/linuxaccessibility/dbusxml/DeviceEventController.xml deleted file mode 100644 index d4c26ef7e7..0000000000 --- a/src/platformsupport/linuxaccessibility/dbusxml/DeviceEventController.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<node name="/node"> -<interface name="org.a11y.atspi.DeviceEventController"> - -<!-- - <method name="RegisterKeystrokeListener"> - <arg direction="in" name="listener" type="o"/> - <arg direction="in" name="keys" type="a(iisi)"> - <annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="QSpiKeyTypeArray"/> - </arg> - <arg direction="in" name="mask" type="u"/> - <arg direction="in" name="type" type="au"> - <annotation name="com.trolltech.QtDBus.QtTypeName.In3" value="QSpiEventTypeArray"/> - </arg> - <arg direction="in" name="mode" type="(bbb)"> - <annotation name="com.trolltech.QtDBus.QtTypeName.In4" value="QSpiEventMode"/> - </arg> - <arg direction="out" type="b"/> - </method> - - <method name="DeregisterKeystrokeListener"> - <arg direction="in" name="listener" type="o"/> - <arg direction="in" name="keys" type="a(iisi)"> - <annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="QSpiKeyTypeArray"/> - </arg> - <arg direction="in" name="mask" type="u"/> - <arg direction="in" name="type" type="u"/> - </method> - - <method name="RegisterDeviceEventListener"> - <arg direction="in" name="listener" type="o"/> - <arg direction="in" name="types" type="u"/> - <arg direction="out" type="b"/> - </method> - - <method name="DeregisterDeviceEventListener"> - <arg direction="in" name="listener" type="o"/> - <arg direction="in" name="types" type="u"/> - </method> - - <method name="GenerateKeyboardEvent"> - <arg direction="in" name="keycode" type="i"/> - <arg direction="in" name="keystring" type="s"/> - <arg direction="in" name="type" type="u"/> - </method> - - <method name="GenerateMouseEvent"> - <arg direction="in" name="x" type="i"/> - <arg direction="in" name="y" type="i"/> - <arg direction="in" name="eventName" type="s"/> - </method> ---> - - <method name="NotifyListenersSync"> - <arg direction="in" name="event" type="(uinnisb)"/> - <arg direction="out" type="b"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiDeviceEvent"/> - </method> - - <method name="NotifyListenersAsync"> - <arg direction="in" name="event" type="(uinnisb)"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiDeviceEvent"/> - </method> - -</interface> -</node> diff --git a/src/platformsupport/linuxaccessibility/dbusxml/Socket.xml b/src/platformsupport/linuxaccessibility/dbusxml/Socket.xml deleted file mode 100644 index 75ec99f994..0000000000 --- a/src/platformsupport/linuxaccessibility/dbusxml/Socket.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<node name="/node"> -<interface name="org.a11y.atspi.Socket"> - - <method name="Embed"> - <arg direction="in" name="plug" type="(so)"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/> - <arg direction="out" name="socket" type="(so)"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QSpiObjectReference"/> - </method> - - <method name="Unembed"> - <arg direction="in" name="plug" type="(so)"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/> - </method> - - <signal name="Available"> - <arg direction="in" name="socket" type="(so)"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiObjectReference"/> - </method> - -</interface> -</node> diff --git a/src/platformsupport/linuxaccessibility/linuxaccessibility.pro b/src/platformsupport/linuxaccessibility/linuxaccessibility.pro deleted file mode 100644 index 9ccb4893d2..0000000000 --- a/src/platformsupport/linuxaccessibility/linuxaccessibility.pro +++ /dev/null @@ -1,36 +0,0 @@ -TARGET = QtLinuxAccessibilitySupport -MODULE = linuxaccessibility_support - -QT = core-private dbus gui-private -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h - -DBUS_ADAPTORS = $$PWD/dbusxml/Cache.xml $$PWD/dbusxml/DeviceEventController.xml -QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS = -i struct_marshallers_p.h - -DBUS_INTERFACES = $$PWD/dbusxml/Socket.xml $$PWD/dbusxml/Bus.xml -QDBUSXML2CPP_INTERFACE_HEADER_FLAGS = -i struct_marshallers_p.h - -QMAKE_USE += atspi/nolink - -HEADERS += \ - application_p.h \ - bridge_p.h \ - cache_p.h \ - struct_marshallers_p.h \ - constant_mappings_p.h \ - dbusconnection_p.h \ - atspiadaptor_p.h - -SOURCES += \ - application.cpp \ - bridge.cpp \ - cache.cpp \ - struct_marshallers.cpp \ - constant_mappings.cpp \ - dbusconnection.cpp \ - atspiadaptor.cpp - -load(qt_module) diff --git a/src/platformsupport/linuxaccessibility/struct_marshallers.cpp b/src/platformsupport/linuxaccessibility/struct_marshallers.cpp deleted file mode 100644 index 9bbaf23332..0000000000 --- a/src/platformsupport/linuxaccessibility/struct_marshallers.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 "struct_marshallers_p.h" - -#include <atspi/atspi-constants.h> -#include <QtCore/qdebug.h> -#include <QtDBus/qdbusmetatype.h> - -#include "bridge_p.h" - -#ifndef QT_NO_ACCESSIBILITY -QT_BEGIN_NAMESPACE - -QSpiObjectReference::QSpiObjectReference() - : path(QDBusObjectPath(ATSPI_DBUS_PATH_NULL)) -{} - -/* QSpiAccessibleCacheArray */ -/*---------------------------------------------------------------------------*/ - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAccessibleCacheItem &item) -{ - argument.beginStructure(); - argument << item.path; - argument << item.application; - argument << item.parent; - argument << item.children; - argument << item.supportedInterfaces; - argument << item.name; - argument << item.role; - argument << item.description; - argument << item.state; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAccessibleCacheItem &item) -{ - argument.beginStructure(); - argument >> item.path; - argument >> item.application; - argument >> item.parent; - argument >> item.children; - argument >> item.supportedInterfaces; - argument >> item.name; - argument >> item.role; - argument >> item.description; - argument >> item.state; - argument.endStructure(); - return argument; -} - -/* QSpiObjectReference */ -/*---------------------------------------------------------------------------*/ - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiObjectReference &address) -{ - argument.beginStructure(); - argument << address.service; - argument << address.path; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiObjectReference &address) -{ - argument.beginStructure(); - argument >> address.service; - argument >> address.path; - argument.endStructure(); - return argument; -} - -/* QSpiAction */ -/*---------------------------------------------------------------------------*/ - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAction &action) -{ - argument.beginStructure(); - argument << action.name; - argument << action.description; - argument << action.keyBinding; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAction &action) -{ - argument.beginStructure(); - argument >> action.name; - argument >> action.description; - argument >> action.keyBinding; - argument.endStructure(); - return argument; -} - - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiEventListener &ev) -{ - argument.beginStructure(); - argument << ev.listenerAddress; - argument << ev.eventName; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiEventListener &ev) -{ - argument.beginStructure(); - argument >> ev.listenerAddress; - argument >> ev.eventName; - argument.endStructure(); - return argument; -} - -/* QSpiAppUpdate */ -/*---------------------------------------------------------------------------*/ - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAppUpdate &update) { - argument.beginStructure(); - argument << update.type << update.address; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update) { - argument.beginStructure(); - argument >> update.type >> update.address; - argument.endStructure(); - return argument; -} - -/* QSpiRelationArrayEntry */ -/*---------------------------------------------------------------------------*/ - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiRelationArrayEntry &entry) { - argument.beginStructure(); - argument << entry.first << entry.second; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiRelationArrayEntry &entry) { - argument.beginStructure(); - argument >> entry.first >> entry.second; - argument.endStructure(); - return argument; -} - -/* QSpiDeviceEvent */ -/*---------------------------------------------------------------------------*/ - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiDeviceEvent &event) { - argument.beginStructure(); - argument << event.type - << event.id - << event.hardwareCode - << event.modifiers - << event.timestamp - << event.text - << event.isText; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiDeviceEvent &event) { - argument.beginStructure(); - argument >> event.type - >> event.id - >> event.hardwareCode - >> event.modifiers - >> event.timestamp - >> event.text - >> event.isText; - argument.endStructure(); - return argument; -} - -void qSpiInitializeStructTypes() -{ - qDBusRegisterMetaType<QSpiIntList>(); - qDBusRegisterMetaType<QSpiUIntList>(); - qDBusRegisterMetaType<QSpiAccessibleCacheItem>(); - qDBusRegisterMetaType<QSpiAccessibleCacheArray>(); - qDBusRegisterMetaType<QSpiObjectReference>(); - qDBusRegisterMetaType<QSpiObjectReferenceArray>(); - qDBusRegisterMetaType<QSpiAttributeSet>(); - qDBusRegisterMetaType<QSpiAction>(); - qDBusRegisterMetaType<QSpiActionArray>(); - qDBusRegisterMetaType<QSpiEventListener>(); - qDBusRegisterMetaType<QSpiEventListenerArray>(); - qDBusRegisterMetaType<QSpiDeviceEvent>(); - qDBusRegisterMetaType<QSpiAppUpdate>(); - qDBusRegisterMetaType<QSpiRelationArrayEntry>(); - qDBusRegisterMetaType<QSpiRelationArray>(); -} - -QT_END_NAMESPACE -#endif //QT_NO_ACCESSIBILITY diff --git a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h b/src/platformsupport/linuxaccessibility/struct_marshallers_p.h deleted file mode 100644 index c8cc05ab5b..0000000000 --- a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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 Q_SPI_STRUCT_MARSHALLERS_H -#define Q_SPI_STRUCT_MARSHALLERS_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 <QtGui/private/qtguiglobal_p.h> -#include <QtCore/qvector.h> -#include <QtCore/qpair.h> -#include <QtDBus/QDBusArgument> -#include <QtDBus/QDBusConnection> -#include <QtDBus/QDBusObjectPath> - -QT_REQUIRE_CONFIG(accessibility); - -QT_BEGIN_NAMESPACE - -typedef QVector<int> QSpiIntList; -typedef QVector<uint> QSpiUIntList; - -// FIXME: make this copy on write -struct QSpiObjectReference -{ - QString service; - QDBusObjectPath path; - - QSpiObjectReference(); - QSpiObjectReference(const QDBusConnection& connection, const QDBusObjectPath& path) - : service(connection.baseService()), path(path) {} -}; -Q_DECLARE_TYPEINFO(QSpiObjectReference, Q_MOVABLE_TYPE); // QDBusObjectPath is movable, even though it - // cannot be marked that way until Qt 6 - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiObjectReference &address); -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiObjectReference &address); - -typedef QVector<QSpiObjectReference> QSpiObjectReferenceArray; - -struct QSpiAccessibleCacheItem -{ - QSpiObjectReference path; - QSpiObjectReference application; - QSpiObjectReference parent; - QSpiObjectReferenceArray children; - QStringList supportedInterfaces; - QString name; - uint role; - QString description; - QSpiUIntList state; -}; -Q_DECLARE_TYPEINFO(QSpiAccessibleCacheItem, Q_MOVABLE_TYPE); - -typedef QVector<QSpiAccessibleCacheItem> QSpiAccessibleCacheArray; - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAccessibleCacheItem &item); -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAccessibleCacheItem &item); - -struct QSpiAction -{ - QString name; - QString description; - QString keyBinding; -}; -Q_DECLARE_TYPEINFO(QSpiAction, Q_MOVABLE_TYPE); - -typedef QVector<QSpiAction> QSpiActionArray; - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAction &action); -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAction &action); - -struct QSpiEventListener -{ - QString listenerAddress; - QString eventName; -}; -Q_DECLARE_TYPEINFO(QSpiEventListener, Q_MOVABLE_TYPE); - -typedef QVector<QSpiEventListener> QSpiEventListenerArray; - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiEventListener &action); -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiEventListener &action); - -typedef QPair<unsigned int, QSpiObjectReferenceArray> QSpiRelationArrayEntry; -typedef QVector<QSpiRelationArrayEntry> QSpiRelationArray; - -//a(iisv) -struct QSpiTextRange { - int startOffset; - int endOffset; - QString contents; - QVariant v; -}; -Q_DECLARE_TYPEINFO(QSpiTextRange, Q_MOVABLE_TYPE); - -typedef QVector<QSpiTextRange> QSpiTextRangeList; -typedef QMap <QString, QString> QSpiAttributeSet; - -enum QSpiAppUpdateType { - QSPI_APP_UPDATE_ADDED = 0, - QSPI_APP_UPDATE_REMOVED = 1 -}; -Q_DECLARE_TYPEINFO(QSpiAppUpdateType, Q_PRIMITIVE_TYPE); - -struct QSpiAppUpdate { - int type; /* Is an application added or removed */ - QString address; /* D-Bus address of application added or removed */ -}; -Q_DECLARE_TYPEINFO(QSpiAppUpdate, Q_MOVABLE_TYPE); - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAppUpdate &update); -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update); - -struct QSpiDeviceEvent { - unsigned int type; - int id; - int hardwareCode; - int modifiers; - int timestamp; - QString text; - bool isText; -}; -Q_DECLARE_TYPEINFO(QSpiDeviceEvent, Q_MOVABLE_TYPE); - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiDeviceEvent &event); -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiDeviceEvent &event); - -void qSpiInitializeStructTypes(); - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QSpiIntList) -Q_DECLARE_METATYPE(QSpiUIntList) -Q_DECLARE_METATYPE(QSpiObjectReference) -Q_DECLARE_METATYPE(QSpiObjectReferenceArray) -Q_DECLARE_METATYPE(QSpiAccessibleCacheItem) -Q_DECLARE_METATYPE(QSpiAccessibleCacheArray) -Q_DECLARE_METATYPE(QSpiAction) -Q_DECLARE_METATYPE(QSpiActionArray) -Q_DECLARE_METATYPE(QSpiEventListener) -Q_DECLARE_METATYPE(QSpiEventListenerArray) -Q_DECLARE_METATYPE(QSpiRelationArrayEntry) -Q_DECLARE_METATYPE(QSpiRelationArray) -Q_DECLARE_METATYPE(QSpiTextRange) -Q_DECLARE_METATYPE(QSpiTextRangeList) -Q_DECLARE_METATYPE(QSpiAttributeSet) -Q_DECLARE_METATYPE(QSpiAppUpdate) -Q_DECLARE_METATYPE(QSpiDeviceEvent) - -#endif /* Q_SPI_STRUCT_MARSHALLERS_H */ diff --git a/src/platformsupport/linuxofono/CMakeLists.txt b/src/platformsupport/linuxofono/CMakeLists.txt deleted file mode 100644 index 8eadff551d..0000000000 --- a/src/platformsupport/linuxofono/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Generated from linuxofono.pro. - -##################################################################### -## LinuxOfonoSupport Module: -##################################################################### - -qt_add_module(LinuxOfonoSupport - STATIC - INTERNAL_MODULE - SOURCES - qofonoservice_linux.cpp qofonoservice_linux_p.h - DEFINES - QT_NO_CAST_FROM_ASCII - PUBLIC_LIBRARIES - Qt::Core - Qt::DBus -) - -#### Keys ignored in scope 1:.:.:linuxofono.pro:<TRUE>: -# MODULE = "linuxofono_support" diff --git a/src/platformsupport/linuxofono/linuxofono.pro b/src/platformsupport/linuxofono/linuxofono.pro deleted file mode 100644 index 1bc5b10225..0000000000 --- a/src/platformsupport/linuxofono/linuxofono.pro +++ /dev/null @@ -1,15 +0,0 @@ -TARGET = QtLinuxOfonoSupport -MODULE = linuxofono_support - -QT = core dbus -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII - -HEADERS += \ - qofonoservice_linux_p.h - -SOURCES += \ - qofonoservice_linux.cpp - -load(qt_module) diff --git a/src/platformsupport/linuxofono/qofonoservice_linux.cpp b/src/platformsupport/linuxofono/qofonoservice_linux.cpp deleted file mode 100644 index 792c703966..0000000000 --- a/src/platformsupport/linuxofono/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(), - QLatin1String(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/platformsupport/linuxofono/qofonoservice_linux_p.h b/src/platformsupport/linuxofono/qofonoservice_linux_p.h deleted file mode 100644 index 62df5d4fa7..0000000000 --- a/src/platformsupport/linuxofono/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/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro deleted file mode 100644 index 76ed9da61a..0000000000 --- a/src/platformsupport/platformsupport.pro +++ /dev/null @@ -1,28 +0,0 @@ -TEMPLATE = subdirs -QT_FOR_CONFIG += gui-private - -SUBDIRS = \ - devicediscovery \ - fbconvenience - -qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput)|qtConfig(integrityhid)|qtConfig(xkbcommon) { - SUBDIRS += input - input.depends += devicediscovery -} - -qtConfig(egl): \ - SUBDIRS += eglconvenience -qtConfig(xlib):qtConfig(opengl):!qtConfig(opengles2): \ - SUBDIRS += glxconvenience -qtConfig(kms): \ - SUBDIRS += kmsconvenience - -qtConfig(accessibility) { - qtConfig(accessibility-atspi-bridge) { - SUBDIRS += linuxaccessibility - } -} - -!android:linux*:qtHaveModule(dbus) \ - SUBDIRS += linuxofono - |