diff options
Diffstat (limited to 'src/platformsupport/linuxaccessibility/application.cpp')
-rw-r--r-- | src/platformsupport/linuxaccessibility/application.cpp | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/src/platformsupport/linuxaccessibility/application.cpp b/src/platformsupport/linuxaccessibility/application.cpp index ae52ab3b57..7d5d189379 100644 --- a/src/platformsupport/linuxaccessibility/application.cpp +++ b/src/platformsupport/linuxaccessibility/application.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -47,6 +39,7 @@ #include <qdebug.h> #include "deviceeventcontroller_adaptor.h" +#include "atspi/atspi-constants.h" //#define KEYBOARD_DEBUG @@ -62,7 +55,7 @@ QT_BEGIN_NAMESPACE */ QSpiApplicationAdaptor::QSpiApplicationAdaptor(const QDBusConnection &connection, QObject *parent) - : QObject(parent), dbusConnection(connection) + : QObject(parent), dbusConnection(connection), inCapsLock(false) { } @@ -107,13 +100,14 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) de.id = keyEvent->nativeVirtualKey(); de.hardwareCode = keyEvent->nativeScanCode(); - de.modifiers = keyEvent->nativeModifiers(); 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) @@ -142,9 +136,13 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) de.text = QStringLiteral("Escape"); else if (keyEvent->key() == Qt::Key_Space) de.text = QStringLiteral("space"); - else if (keyEvent->key() == Qt::Key_CapsLock) + else if (keyEvent->key() == Qt::Key_CapsLock) { de.text = QStringLiteral("Caps_Lock"); - else if (keyEvent->key() == Qt::Key_NumLock) + 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"); @@ -155,18 +153,30 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) // 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() << QStringLiteral("Key event text: ") << event->type() << de.isText << QStringLiteral(" ") << de.text - << QStringLiteral(" hardware code: ") << de.hardwareCode - << QStringLiteral(" native sc: ") << keyEvent->nativeScanCode() - << QStringLiteral(" native mod: ") << keyEvent->nativeModifiers() - << QStringLiteral("native virt: ") << keyEvent->nativeVirtualKey(); + qDebug() << QStringLiteral("Key event text:") << event->type() << de.text + << QStringLiteral("native virtual key:") << de.id + << QStringLiteral("hardware code/scancode:") << de.hardwareCode + << QStringLiteral("modifiers:") << de.modifiers + << QStringLiteral("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)); + m.setArguments(QVariantList() << QVariant::fromValue(de)); // FIXME: this is critical, the timeout should probably be pretty low to allow normal processing int timeout = 100; @@ -175,9 +185,6 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event) if (sent) { //queue the event and send it after callback keyEvents.enqueue(QPair<QPointer<QObject>, QKeyEvent*> (QPointer<QObject>(target), copyKeyEvent(keyEvent))); -#ifdef KEYBOARD_DEBUG - qDebug() << QStringLiteral("Sent key: ") << de.text; -#endif return true; } } |