File indexing completed on 2024-11-10 04:57:11
0001 /* 0002 SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "plugin.h" 0010 0011 #include "input.h" 0012 #include "input_event.h" 0013 0014 class StickyKeysFilter : public KWin::Plugin, public KWin::InputEventFilter 0015 { 0016 Q_OBJECT 0017 public: 0018 explicit StickyKeysFilter(); 0019 0020 bool keyEvent(KWin::KeyEvent *event) override; 0021 0022 enum KeyState { 0023 None, 0024 Latched, 0025 Locked, 0026 }; 0027 0028 private: 0029 void loadConfig(const KConfigGroup &group); 0030 0031 KConfigWatcher::Ptr m_configWatcher; 0032 QMap<int, KeyState> m_keyStates; 0033 QList<int> m_modifiers = {Qt::Key_Shift, Qt::Key_Control, Qt::Key_Alt, Qt::Key_AltGr, Qt::Key_Meta}; 0034 bool m_lockKeys = false; 0035 };