File indexing completed on 2024-12-08 03:39:28

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     bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override;
0024 
0025     void xkbUpdateModifierMapping();
0026     void xkbModifierStateChanged(unsigned char mods, unsigned char latched_mods, unsigned char locked_mods);
0027     void xkbButtonStateChanged(unsigned short ptr_buttons);
0028 
0029 private:
0030     int m_xkbEv;
0031     bool m_xkbAvailable;
0032 
0033     // maps a Qt::Key to a modifier mask
0034     QHash<Qt::Key, unsigned int> m_xkbModifiers;
0035     // maps a Qt::MouseButton to a button mask
0036     QHash<Qt::MouseButton, unsigned short> m_xkbButtons;
0037 };
0038 
0039 #endif