| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2009 Michael Leupold <lemma@confuego.org> |
| 3 | SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #ifndef KMODIFIERKEYINFOPROVIDERXCB_H |
| 9 | #define KMODIFIERKEYINFOPROVIDERXCB_H |
| 10 | |
| 11 | #include "kmodifierkeyinfoprovider_p.h" |
| 12 | #include <QAbstractNativeEventFilter> |
| 13 | |
| 14 | class KModifierKeyInfoProviderXcb : public KModifierKeyInfoProvider, public QAbstractNativeEventFilter |
| 15 | { |
| 16 | Q_OBJECT |
| 17 | public: |
| 18 | KModifierKeyInfoProviderXcb(); |
| 19 | ~KModifierKeyInfoProviderXcb() override; |
| 20 | |
| 21 | bool setKeyLatched(Qt::Key key, bool latched) override; |
| 22 | bool setKeyLocked(Qt::Key key, bool locked) override; |
| 23 | |
| 24 | bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override; |
| 25 | |
| 26 | void xkbUpdateModifierMapping(); |
| 27 | void xkbModifierStateChanged(unsigned char mods, unsigned char latched_mods, unsigned char locked_mods); |
| 28 | void xkbButtonStateChanged(unsigned short ptr_buttons); |
| 29 | |
| 30 | private: |
| 31 | int m_xkbEv; |
| 32 | bool m_xkbAvailable; |
| 33 | |
| 34 | // maps a Qt::Key to a modifier mask |
| 35 | QHash<Qt::Key, unsigned int> m_xkbModifiers; |
| 36 | // maps a Qt::MouseButton to a button mask |
| 37 | QHash<Qt::MouseButton, unsigned short> m_xkbButtons; |
| 38 | }; |
| 39 | |
| 40 | #endif |
| 41 | |