| 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) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 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 http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | #include "application_p.h" | - | ||||||||||||
| 36 | - | |||||||||||||
| 37 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||
| 38 | #include <QtDBus/qdbuspendingreply.h> | - | ||||||||||||
| 39 | #include <qdebug.h> | - | ||||||||||||
| 40 | - | |||||||||||||
| 41 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 42 | #include "deviceeventcontroller_adaptor.h" | - | ||||||||||||
| 43 | #include "atspi/atspi-constants.h" | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | //#define KEYBOARD_DEBUG | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | /*! | - | ||||||||||||
| 50 | \class QSpiApplicationAdaptor | - | ||||||||||||
| 51 | \internal | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | \brief QSpiApplicationAdaptor | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | QSpiApplicationAdaptor | - | ||||||||||||
| 56 | */ | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | QSpiApplicationAdaptor::QSpiApplicationAdaptor(const QDBusConnection &connection, QObject *parent) | - | ||||||||||||
| 59 | : QObject(parent), dbusConnection(connection), inCapsLock(false) | - | ||||||||||||
| 60 | { | - | ||||||||||||
| 61 | } never executed: end of block | 0 | ||||||||||||
| 62 | - | |||||||||||||
| 63 | enum QSpiKeyEventType { | - | ||||||||||||
| 64 | QSPI_KEY_EVENT_PRESS, | - | ||||||||||||
| 65 | QSPI_KEY_EVENT_RELEASE, | - | ||||||||||||
| 66 | QSPI_KEY_EVENT_LAST_DEFINED | - | ||||||||||||
| 67 | }; | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | void QSpiApplicationAdaptor::sendEvents(bool active) | - | ||||||||||||
| 70 | { | - | ||||||||||||
| 71 | if (active) {
| 0 | ||||||||||||
| 72 | qApp->installEventFilter(this); | - | ||||||||||||
| 73 | } else { never executed: end of block | 0 | ||||||||||||
| 74 | qApp->removeEventFilter(this); | - | ||||||||||||
| 75 | } never executed: end of block | 0 | ||||||||||||
| 76 | } | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | - | |||||||||||||
| 79 | bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | if (!event->spontaneous())
| 0 | ||||||||||||
| 82 | return false; never executed: return false; | 0 | ||||||||||||
| 83 | - | |||||||||||||
| 84 | switch (event->type()) { | - | ||||||||||||
| 85 | case QEvent::WindowActivate: never executed: case QEvent::WindowActivate: | 0 | ||||||||||||
| 86 | emit windowActivated(target, true); | - | ||||||||||||
| 87 | break; never executed: break; | 0 | ||||||||||||
| 88 | case QEvent::WindowDeactivate: never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||
| 89 | emit windowActivated(target, false); | - | ||||||||||||
| 90 | break; never executed: break; | 0 | ||||||||||||
| 91 | case QEvent::KeyPress: never executed: case QEvent::KeyPress: | 0 | ||||||||||||
| 92 | case QEvent::KeyRelease: { never executed: case QEvent::KeyRelease: | 0 | ||||||||||||
| 93 | QKeyEvent *keyEvent = static_cast <QKeyEvent *>(event); | - | ||||||||||||
| 94 | QSpiDeviceEvent de; | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | if (event->type() == QEvent::KeyPress)
| 0 | ||||||||||||
| 97 | de.type = QSPI_KEY_EVENT_PRESS; never executed: de.type = QSPI_KEY_EVENT_PRESS; | 0 | ||||||||||||
| 98 | else | - | ||||||||||||
| 99 | de.type = QSPI_KEY_EVENT_RELEASE; never executed: de.type = QSPI_KEY_EVENT_RELEASE; | 0 | ||||||||||||
| 100 | - | |||||||||||||
| 101 | de.id = keyEvent->nativeVirtualKey(); | - | ||||||||||||
| 102 | de.hardwareCode = keyEvent->nativeScanCode(); | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | de.timestamp = QDateTime::currentMSecsSinceEpoch(); | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | if (keyEvent->key() == Qt::Key_Tab)
| 0 | ||||||||||||
| 107 | 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 | ||||||||||||
| 108 | else if (keyEvent->key() == Qt::Key_Backtab)
| 0 | ||||||||||||
| 109 | 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 | ||||||||||||
| 110 | else if (keyEvent->key() == Qt::Key_Control)
| 0 | ||||||||||||
| 111 | 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 | ||||||||||||
| 112 | else if (keyEvent->key() == Qt::Key_Left)
| 0 | ||||||||||||
| 113 | 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 | ||||||||||||
| 114 | else if (keyEvent->key() == Qt::Key_Right)
| 0 | ||||||||||||
| 115 | 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 | ||||||||||||
| 116 | else if (keyEvent->key() == Qt::Key_Up)
| 0 | ||||||||||||
| 117 | 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 | ||||||||||||
| 118 | else if (keyEvent->key() == Qt::Key_Down)
| 0 | ||||||||||||
| 119 | 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 | ||||||||||||
| 120 | else if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)
| 0 | ||||||||||||
| 121 | 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 | ||||||||||||
| 122 | else if (keyEvent->key() == Qt::Key_Backspace)
| 0 | ||||||||||||
| 123 | 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 | ||||||||||||
| 124 | else if (keyEvent->key() == Qt::Key_Delete)
| 0 | ||||||||||||
| 125 | 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 | ||||||||||||
| 126 | else if (keyEvent->key() == Qt::Key_PageUp)
| 0 | ||||||||||||
| 127 | 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 | ||||||||||||
| 128 | else if (keyEvent->key() == Qt::Key_PageDown)
| 0 | ||||||||||||
| 129 | 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 | ||||||||||||
| 130 | else if (keyEvent->key() == Qt::Key_Home)
| 0 | ||||||||||||
| 131 | 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 | ||||||||||||
| 132 | else if (keyEvent->key() == Qt::Key_End)
| 0 | ||||||||||||
| 133 | 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 | ||||||||||||
| 134 | else if (keyEvent->key() == Qt::Key_Clear && (keyEvent->modifiers() & Qt::KeypadModifier))
| 0 | ||||||||||||
| 135 | 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 | ||||||||||||
| 136 | else if (keyEvent->key() == Qt::Key_Escape)
| 0 | ||||||||||||
| 137 | 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 | ||||||||||||
| 138 | else if (keyEvent->key() == Qt::Key_Space)
| 0 | ||||||||||||
| 139 | 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 | ||||||||||||
| 140 | else if (keyEvent->key() == Qt::Key_CapsLock) {
| 0 | ||||||||||||
| 141 | de.text = QStringLiteral("Caps_Lock"); never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 142 | if (event->type() == QEvent::KeyPress)
| 0 | ||||||||||||
| 143 | inCapsLock = true; never executed: inCapsLock = true; | 0 | ||||||||||||
| 144 | else | - | ||||||||||||
| 145 | inCapsLock = false; never executed: inCapsLock = false; | 0 | ||||||||||||
| 146 | } else if (keyEvent->key() == Qt::Key_NumLock)
| 0 | ||||||||||||
| 147 | 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 | ||||||||||||
| 148 | else if (keyEvent->key() == Qt::Key_Insert)
| 0 | ||||||||||||
| 149 | 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 | ||||||||||||
| 150 | else | - | ||||||||||||
| 151 | de.text = keyEvent->text(); never executed: de.text = keyEvent->text(); | 0 | ||||||||||||
| 152 | - | |||||||||||||
| 153 | // This is a bit dubious, Gnome uses some gtk function here. | - | ||||||||||||
| 154 | // Long term the spec will hopefully change to just use keycodes. | - | ||||||||||||
| 155 | de.isText = !de.text.isEmpty(); | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | de.modifiers = 0; | - | ||||||||||||
| 158 | if (!inCapsLock && keyEvent->modifiers() & Qt::ShiftModifier)
| 0 | ||||||||||||
| 159 | de.modifiers |= 1 << ATSPI_MODIFIER_SHIFT; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_SHIFT; | 0 | ||||||||||||
| 160 | if (inCapsLock && (keyEvent->key() != Qt::Key_CapsLock))
| 0 | ||||||||||||
| 161 | de.modifiers |= 1 << ATSPI_MODIFIER_SHIFTLOCK; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_SHIFTLOCK; | 0 | ||||||||||||
| 162 | if ((keyEvent->modifiers() & Qt::ControlModifier) && (keyEvent->key() != Qt::Key_Control))
| 0 | ||||||||||||
| 163 | de.modifiers |= 1 << ATSPI_MODIFIER_CONTROL; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_CONTROL; | 0 | ||||||||||||
| 164 | if ((keyEvent->modifiers() & Qt::AltModifier) && (keyEvent->key() != Qt::Key_Alt))
| 0 | ||||||||||||
| 165 | de.modifiers |= 1 << ATSPI_MODIFIER_ALT; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_ALT; | 0 | ||||||||||||
| 166 | if ((keyEvent->modifiers() & Qt::MetaModifier) && (keyEvent->key() != Qt::Key_Meta))
| 0 | ||||||||||||
| 167 | de.modifiers |= 1 << ATSPI_MODIFIER_META; never executed: de.modifiers |= 1 << ATSPI_MODIFIER_META; | 0 | ||||||||||||
| 168 | - | |||||||||||||
| 169 | #ifdef KEYBOARD_DEBUG | - | ||||||||||||
| 170 | qDebug() << "Key event text:" << event->type() << de.text | - | ||||||||||||
| 171 | << "native virtual key:" << de.id | - | ||||||||||||
| 172 | << "hardware code/scancode:" << de.hardwareCode | - | ||||||||||||
| 173 | << "modifiers:" << de.modifiers | - | ||||||||||||
| 174 | << "text:" << de.text; | - | ||||||||||||
| 175 | #endif | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | QDBusMessage m = QDBusMessage::createMethodCall(QStringLiteral("org.a11y.atspi.Registry"), never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 178 | QStringLiteral("/org/a11y/atspi/registry/deviceeventcontroller"), never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 179 | QStringLiteral("org.a11y.atspi.DeviceEventController"), QStringLiteral("NotifyListenersSync")); never executed: return qstring_literal_temp;never executed: return qstring_literal_temp; | 0 | ||||||||||||
| 180 | m.setArguments(QVariantList() << QVariant::fromValue(de)); | - | ||||||||||||
| 181 | - | |||||||||||||
| 182 | // FIXME: this is critical, the timeout should probably be pretty low to allow normal processing | - | ||||||||||||
| 183 | int timeout = 100; | - | ||||||||||||
| 184 | bool sent = dbusConnection.callWithCallback(m, this, SLOT(notifyKeyboardListenerCallback(QDBusMessage)), | - | ||||||||||||
| 185 | SLOT(notifyKeyboardListenerError(QDBusError,QDBusMessage)), timeout); | - | ||||||||||||
| 186 | if (sent) {
| 0 | ||||||||||||
| 187 | //queue the event and send it after callback | - | ||||||||||||
| 188 | keyEvents.enqueue(QPair<QPointer<QObject>, QKeyEvent*> (QPointer<QObject>(target), copyKeyEvent(keyEvent))); | - | ||||||||||||
| 189 | return true; never executed: return true; | 0 | ||||||||||||
| 190 | } | - | ||||||||||||
| 191 | } | - | ||||||||||||
| 192 | default: code before this statement never executed: default:never executed: default: | 0 | ||||||||||||
| 193 | break; never executed: break; | 0 | ||||||||||||
| 194 | } | - | ||||||||||||
| 195 | return false; never executed: return false; | 0 | ||||||||||||
| 196 | } | - | ||||||||||||
| 197 | - | |||||||||||||
| 198 | QKeyEvent* QSpiApplicationAdaptor::copyKeyEvent(QKeyEvent* old) | - | ||||||||||||
| 199 | { | - | ||||||||||||
| 200 | 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 | ||||||||||||
| 201 | 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 | ||||||||||||
| 202 | 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 | ||||||||||||
| 203 | } | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage& message) | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | if (!keyEvents.length()) {
| 0 | ||||||||||||
| 208 | qWarning("QSpiApplication::notifyKeyboardListenerCallback with no queued key called"); | - | ||||||||||||
| 209 | return; never executed: return; | 0 | ||||||||||||
| 210 | } | - | ||||||||||||
| 211 | Q_ASSERT(message.arguments().length() == 1); | - | ||||||||||||
| 212 | if (message.arguments().at(0).toBool() == true) {
| 0 | ||||||||||||
| 213 | QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); | - | ||||||||||||
| 214 | delete event.second; | - | ||||||||||||
| 215 | } else { never executed: end of block | 0 | ||||||||||||
| 216 | QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); | - | ||||||||||||
| 217 | if (event.first)
| 0 | ||||||||||||
| 218 | QCoreApplication::postEvent(event.first.data(), event.second); never executed: QCoreApplication::postEvent(event.first.data(), event.second); | 0 | ||||||||||||
| 219 | } never executed: end of block | 0 | ||||||||||||
| 220 | } | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error, const QDBusMessage& /*message*/) | - | ||||||||||||
| 223 | { | - | ||||||||||||
| 224 | qWarning() << "QSpiApplication::keyEventError " << error.name() << error.message(); | - | ||||||||||||
| 225 | while (!keyEvents.isEmpty()) {
| 0 | ||||||||||||
| 226 | QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue(); | - | ||||||||||||
| 227 | if (event.first)
| 0 | ||||||||||||
| 228 | QCoreApplication::postEvent(event.first.data(), event.second); never executed: QCoreApplication::postEvent(event.first.data(), event.second); | 0 | ||||||||||||
| 229 | } never executed: end of block | 0 | ||||||||||||
| 230 | } never executed: end of block | 0 | ||||||||||||
| 231 | - | |||||||||||||
| 232 | QT_END_NAMESPACE | - | ||||||||||||
| 233 | - | |||||||||||||
| 234 | #endif //QT_NO_ACCESSIBILITY | - | ||||||||||||
| Source code | Switch to Preprocessed file |