File indexing completed on 2024-12-08 12:18:39
0001 /* 0002 SPDX-FileCopyrightText: 2009 Michael Leupold <lemma@confuego.org> 0003 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef KMODIFIERKEYINFOPROVIDERXCB_H 0009 #define KMODIFIERKEYINFOPROVIDERXCB_H 0010 0011 #include "kmodifierkeyinfoprovider_p.h" 0012 #include <QAbstractNativeEventFilter> 0013 class KModifierKeyInfoProviderXcb : public KModifierKeyInfoProvider, public QAbstractNativeEventFilter 0014 { 0015 Q_OBJECT 0016 public: 0017 KModifierKeyInfoProviderXcb(); 0018 ~KModifierKeyInfoProviderXcb() override; 0019 0020 bool setKeyLatched(Qt::Key key, bool latched) override; 0021 bool setKeyLocked(Qt::Key key, bool locked) override; 0022 0023 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 0024 bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override; 0025 #else 0026 bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override; 0027 #endif 0028 0029 void xkbUpdateModifierMapping(); 0030 void xkbModifierStateChanged(unsigned char mods, unsigned char latched_mods, unsigned char locked_mods); 0031 void xkbButtonStateChanged(unsigned short ptr_buttons); 0032 0033 private: 0034 int m_xkbEv; 0035 bool m_xkbAvailable; 0036 0037 // maps a Qt::Key to a modifier mask 0038 QHash<Qt::Key, unsigned int> m_xkbModifiers; 0039 // maps a Qt::MouseButton to a button mask 0040 QHash<Qt::MouseButton, unsigned short> m_xkbButtons; 0041 }; 0042 0043 #endif