| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/linuxaccessibility/application.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | - | |||||||||||||
| 41 | #include "application_p.h" | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||
| 44 | #include <QtDBus/qdbuspendingreply.h> | - | ||||||||||||
| 45 | #include <qdebug.h> | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 48 | #include "deviceeventcontroller_adaptor.h" | - | ||||||||||||
| 49 | #include "atspi/atspi-constants.h" | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | //#define KEYBOARD_DEBUG | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | /*! | - | ||||||||||||
| 56 | \class QSpiApplicationAdaptor | - | ||||||||||||
| 57 | \internal | - | ||||||||||||
| 58 | - | |||||||||||||
| 59 | \brief QSpiApplicationAdaptor | - | ||||||||||||
| 60 | - | |||||||||||||
| 61 | QSpiApplicationAdaptor | - | ||||||||||||
| 62 | */ | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | QSpiApplicationAdaptor::QSpiApplicationAdaptor(const QDBusConnection &connection, QObject *parent) | - | ||||||||||||
| 65 | : QObject(parent), dbusConnection(connection), inCapsLock(false) | - | ||||||||||||
| 66 | { | - | ||||||||||||
| 67 | } never executed: end of block | 0 | ||||||||||||
| 68 | - | |||||||||||||
| 69 | enum QSpiKeyEventType { | - | ||||||||||||
| 70 | QSPI_KEY_EVENT_PRESS, | - | ||||||||||||
| 71 | QSPI_KEY_EVENT_RELEASE, | - | ||||||||||||
| 72 | QSPI_KEY_EVENT_LAST_DEFINED | - | ||||||||||||
| 73 | }; | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | void QSpiApplicationAdaptor::sendEvents(bool active) | - | ||||||||||||
| 76 | { | - | ||||||||||||
| 77 | if (active) {
| 0 | ||||||||||||
| 78 | qApp->installEventFilter(this); | - | ||||||||||||
| 79 | } else { never executed: end of block | 0 | ||||||||||||
| 80 | qApp->removeEventFilter(this); | - | ||||||||||||
| 81 | } never executed: end of block | 0 | ||||||||||||
| 82 | } | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | - | |||||||||||||
| 85 | bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 | if (!event->spontaneous())
| 0 | ||||||||||||
| 88 | return false; never executed: return false; | 0 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | switch (event->type()) { | - | ||||||||||||
| 91 | case QEvent::WindowActivate: never executed: case QEvent::WindowActivate: | 0 | ||||||||||||
| 92 | emit windowActivated(target, true); | - | ||||||||||||
| 93 | break; never executed: break; | 0 | ||||||||||||
| 94 | case QEvent::WindowDeactivate: never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||
| 95 | emit windowActivated(target, false); | - | ||||||||||||
| 96 | break; never executed: break; | 0 | ||||||||||||
| 97 | case QEvent::KeyPress: never executed: case QEvent::KeyPress: | 0 | ||||||||||||
| 98 | case QEvent::KeyRelease: { never executed: case QEvent::KeyRelease: | 0 | ||||||||||||
| 99 | QKeyEvent *keyEvent = static_cast <QKeyEvent *>(event); | - | ||||||||||||
| 100 | QSpiDeviceEvent de; | - | ||||||||||||
| 101 | - | |||||||||||||
| 102 | if (event->type() == QEvent::KeyPress)
| 0 | ||||||||||||
| 103 | de.type = QSPI_KEY_EVENT_PRESS; never executed: de.type = QSPI_KEY_EVENT_PRESS; | 0 | ||||||||||||
| 104 | else | - | ||||||||||||
| 105 | de.type = QSPI_KEY_EVENT_RELEASE; never executed: de.type = QSPI_KEY_EVENT_RELEASE; | 0 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | de.id = keyEvent->nativeVirtualKey(); | - | ||||||||||||
| 108 | de.hardwareCode = keyEvent->nativeScanCode(); | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | de.timestamp = QDateTime::currentMSecsSinceEpoch(); | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | if (keyEvent->key() == Qt::Key_Tab)
| 0 | ||||||||||||
| 113 | de.text = QStringLiteral("Tab"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Tab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Tab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 114 | else if (keyEvent->key() == Qt::Key_Backtab)
| 0 | ||||||||||||
| 115 | de.text = QStringLiteral("Backtab"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Backtab")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Backtab" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 116 | else if (keyEvent->key() == Qt::Key_Control)
| 0 | ||||||||||||
| 117 | de.text = QStringLiteral("Control_L"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Control_L")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Control_L" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 118 | else if (keyEvent->key() == Qt::Key_Left)
| 0 | ||||||||||||
| 119 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Left") : QStringLiteral("Left"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_Left")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Left" }; QStringData... static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Left" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 120 | else if (keyEvent->key() == Qt::Key_Right)
| 0 | ||||||||||||
| 121 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Right") : QStringLiteral("Right"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_Right")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Right" }; QStringDa...static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Right" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 122 | else if (keyEvent->key() == Qt::Key_Up)
| 0 | ||||||||||||
| 123 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Up") : QStringLiteral("Up"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_Up")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Up" }; QStringDataPtr ...}; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Up" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 124 | else if (keyEvent->key() == Qt::Key_Down)
| 0 | ||||||||||||
| 125 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Down") : QStringLiteral("Down"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_Down")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Down" }; QStringData... static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Down" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 126 | else if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)
| 0 | ||||||||||||
| 127 | de.text = QStringLiteral("Return"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Return")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Return" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 128 | else if (keyEvent->key() == Qt::Key_Backspace)
| 0 | ||||||||||||
| 129 | de.text = QStringLiteral("BackSpace"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "BackSpace")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "BackSpace" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 130 | else if (keyEvent->key() == Qt::Key_Delete)
| 0 | ||||||||||||
| 131 | de.text = QStringLiteral("Delete"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Delete")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Delete" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 132 | else if (keyEvent->key() == Qt::Key_PageUp)
| 0 | ||||||||||||
| 133 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Page_Up") : QStringLiteral("Page_Up"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_Page_Up")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Page_Up" }; QStri...atic const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Page_Up" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 134 | else if (keyEvent->key() == Qt::Key_PageDown)
| 0 | ||||||||||||
| 135 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Page_Up") : QStringLiteral("Page_Down"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_Page_Up")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Page_Up" }; QStri...ic const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Page_Down" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 136 | else if (keyEvent->key() == Qt::Key_Home)
| 0 | ||||||||||||
| 137 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_Home") : QStringLiteral("Home"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_Home")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Home" }; QStringData... static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Home" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 138 | else if (keyEvent->key() == Qt::Key_End)
| 0 | ||||||||||||
| 139 | de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? QStringLiteral("KP_End") : QStringLiteral("End"); never executed: de.text = (keyEvent->modifiers() & Qt::KeypadModifier) ? ([]() -> QString { enum { Size = sizeof(u"" "KP_End")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_End" }; QStringDataPt...; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "End" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp;never executed: return qstring_literal_temp;
| 0 | ||||||||||||
| 140 | else if (keyEvent->key() == Qt::Key_Clear && (keyEvent->modifiers() & Qt::KeypadModifier))
| 0 | ||||||||||||
| 141 | de.text = QStringLiteral("KP_Begin"); // Key pad 5 never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "KP_Begin")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "KP_Begin" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 142 | else if (keyEvent->key() == Qt::Key_Escape)
| 0 | ||||||||||||
| 143 | de.text = QStringLiteral("Escape"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Escape")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Escape" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 144 | else if (keyEvent->key() == Qt::Key_Space)
| 0 | ||||||||||||
| 145 | de.text = QStringLiteral("space"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "space")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "space" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 146 | else if (keyEvent->key() == Qt::Key_CapsLock) {
| 0 | ||||||||||||
| 147 | de.text = QStringLiteral("Caps_Lock"); never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 148 | if (event->type() == QEvent::KeyPress)
| 0 | ||||||||||||
| 149 | inCapsLock = true; never executed: inCapsLock = true; | 0 | ||||||||||||
| 150 | else | - | ||||||||||||
| 151 | inCapsLock = false; never executed: inCapsLock = false; | 0 | ||||||||||||
| 152 | } else if (keyEvent->key() == Qt::Key_NumLock)
| 0 | ||||||||||||
| 153 | de.text = QStringLiteral("Num_Lock"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Num_Lock")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Num_Lock" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 154 | else if (keyEvent->key() == Qt::Key_Insert)
| 0 | ||||||||||||
| 155 | de.text = QStringLiteral("Insert"); never executed: de.text = ([]() -> QString { enum { Size = sizeof(u"" "Insert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Insert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 156 | else | - | ||||||||||||
| 157 | de.text = keyEvent->text(); never executed: de.text = keyEvent->text(); | 0 | ||||||||||||
| 158 | - | |||||||||||||
| 159 | // This is a bit dubious, Gnome uses some gtk function here. | - | ||||||||||||
| 160 | // Long term the spec will hopefully change to just use keycodes. | - | ||||||||||||
| 161 | de.isText = !de.text.isEmpty(); | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | de.modifiers = 0; | - | ||||||||||||
| 164 | if (!inCapsLock && keyEvent->modifiers() & Qt::ShiftModifier)
| 0 | ||||||||||||
| 165 | de.modifiers |= 1 << ATSPI_MODIFIER_SHIFT; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_SHIFT; | 0 | ||||||||||||
| 166 | if (inCapsLock && (keyEvent->key() != Qt::Key_CapsLock))
| 0 | ||||||||||||
| 167 | de.modifiers |= 1 << ATSPI_MODIFIER_SHIFTLOCK; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_SHIFTLOCK; | 0 | ||||||||||||
| 168 | if ((keyEvent->modifiers() & Qt::ControlModifier) && (keyEvent->key() != Qt::Key_Control))
| 0 | ||||||||||||
| 169 | de.modifiers |= 1 << ATSPI_MODIFIER_CONTROL; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_CONTROL; | 0 | ||||||||||||
| 170 | if ((keyEvent->modifiers() & Qt::AltModifier) && (keyEvent->key() != Qt::Key_Alt))
| 0 | ||||||||||||
| 171 | de.modifiers |= 1 << ATSPI_MODIFIER_ALT; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_ALT; | 0 | ||||||||||||
| 172 | if ((keyEvent->modifiers() & Qt::MetaModifier) && (keyEvent->key() != Qt::Key_Meta))
| 0 | ||||||||||||
| 173 | de.modifiers |= 1 << ATSPI_MODIFIER_META; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_META; | 0 | ||||||||||||
| 174 | - | |||||||||||||
| 175 | #ifdef KEYBOARD_DEBUG | - | ||||||||||||
| 176 | qDebug() << "Key event text:" << event->type() << de.text | - | ||||||||||||
| 177 | << "native virtual key:" << de.id | - | ||||||||||||
| 178 | << "hardware code/scancode:" << de.hardwareCode | - | ||||||||||||
| 179 | << "modifiers:" << de.modifiers | - | ||||||||||||
| 180 | << "text:" << de.text; | - | ||||||||||||
| 181 | #endif | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.a11y.atspi.Registry"), never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 184 | QStringLiteral("/org/a11y/atspi/registry/deviceeventcontroller"), never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 185 | QStringLiteral("org.a11y.atspi.DeviceEventController"), QStringLiteral("NotifyListenersSync")); never executed: return qstring_literal_temp;never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 186 | m.setArguments(QVariantList() << QVariant::fromValue(de)); | - | ||||||||||||
| 187 | - | |||||||||||||
| 188 | // FIXME: this is critical, the timeout should probably be pretty low to allow normal processing | - | ||||||||||||
| 189 | int timeout = 100; | - | ||||||||||||
| 190 | bool sent = dbusConnection.callWithCallback(m, this, SLOT(notifyKeyboardListenerCallback(QDBusMessage)), | - | ||||||||||||
| 191 | SLOT(notifyKeyboardListenerError(QDBusError,QDBusMessage)), timeout); | - | ||||||||||||
| 192 | if (sent) {
| 0 | ||||||||||||
| 193 | //queue the event and send it after callback | - | ||||||||||||
| 194 | keyEvents.enqueue(QPair<QPointer<QObject>, QKeyEvent*> (QPointer<QObject>(target), copyKeyEvent(keyEvent))); | - | ||||||||||||
| 195 | return true; never executed: return true; | 0 | ||||||||||||
| 196 | } | - | ||||||||||||
| 197 | } | - | ||||||||||||
| 198 | default: code before this statement never executed: default:never executed: default: | 0 | ||||||||||||
| 199 | break; never executed: break; | 0 | ||||||||||||
| 200 | } | - | ||||||||||||
| 201 | return false; never executed: return false; | 0 | ||||||||||||
| 202 | } | - | ||||||||||||
| 203 | - | |||||||||||||
| 204 | QKeyEvent* QSpiApplicationAdaptor::copyKeyEvent(QKeyEvent* old) | - | ||||||||||||
| 205 | { | - | ||||||||||||
| 206 | return new QKeyEvent(old->type(), old->key(), old->modifiers(), never executed: return new QKeyEvent(old->type(), old->key(), old->modifiers(), old->nativeScanCode(), old->nativeVirtualKey(), old->nativeModifiers(), old->text(), old->isAutoRepeat(), old->count()); | 0 | ||||||||||||
| 207 | old->nativeScanCode(), old->nativeVirtualKey(), old->nativeModifiers(), never executed: return new QKeyEvent(old->type(), old->key(), old->modifiers(), old->nativeScanCode(), old->nativeVirtualKey(), old->nativeModifiers(), old->text(), old->isAutoRepeat(), old->count()); | 0 | ||||||||||||
| 208 | old->text(), old->isAutoRepeat(), old->count()); never executed: return new QKeyEvent(old->type(), old->key(), old->modifiers(), old->nativeScanCode(), old->nativeVirtualKey(), old->nativeModifiers(), old->text(), old->isAutoRepeat(), old->count()); | 0 | ||||||||||||
| 209 | } | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage& message) | - | ||||||||||||
| 212 | { | - | ||||||||||||
| 213 | if (!keyEvents.length()) {
| 0 | ||||||||||||
| 214 | qWarning("QSpiApplication::notifyKeyboardListenerCallback with no queued key called"); | - | ||||||||||||
| 215 | return; never executed: return; | 0 | ||||||||||||
| 216 | } | - | ||||||||||||
| 217 | Q_ASSERT(message.arguments().length() == 1); | - | ||||||||||||
| 218 | if (message.arguments().at(0).toBool() == true) {
| 0 | ||||||||||||
| 219 | QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); | - | ||||||||||||
| 220 | delete event.second; | - | ||||||||||||
| 221 | } else { never executed: end of block | 0 | ||||||||||||
| 222 | QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); | - | ||||||||||||
| 223 | if (event.first)
| 0 | ||||||||||||
| 224 | QCoreApplication::postEvent(event.first.data(), event.second); never executed: QCoreApplication::postEvent(event.first.data(), event.second); | 0 | ||||||||||||
| 225 | } never executed: end of block | 0 | ||||||||||||
| 226 | } | - | ||||||||||||
| 227 | - | |||||||||||||
| 228 | void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& /*message*/) | - | ||||||||||||
| 229 | { | - | ||||||||||||
| 230 | qWarning() << "QSpiApplication::keyEventError " << error.name() << error.message(); | - | ||||||||||||
| 231 | while (!keyEvents.isEmpty()) {
| 0 | ||||||||||||
| 232 | QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); | - | ||||||||||||
| 233 | if (event.first)
| 0 | ||||||||||||
| 234 | QCoreApplication::postEvent(event.first.data(), event.second); never executed: QCoreApplication::postEvent(event.first.data(), event.second); | 0 | ||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||
| 236 | } never executed: end of block | 0 | ||||||||||||
| 237 | - | |||||||||||||
| 238 | QT_END_NAMESPACE | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | #endif //QT_NO_ACCESSIBILITY | - | ||||||||||||
| Source code | Switch to Preprocessed file |