plugins/stickykeys: Ring system bell when modifiers are used

BUG: 464456
This commit is contained in:
Nicolas Fella 2024-07-30 15:11:08 +02:00
parent 80b5910594
commit b1ac04179d
2 changed files with 9 additions and 0 deletions

View file

@ -5,6 +5,7 @@
*/
#include "stickykeys.h"
#include "effect/effecthandler.h"
#include "keyboard_input.h"
#include "xkb.h"
@ -67,6 +68,7 @@ void StickyKeysFilter::loadConfig(const KConfigGroup &group)
m_lockKeys = group.readEntry<bool>("StickyKeysLatch", true);
m_showNotificationForLockedKeys = group.readEntry<bool>("kNotifyModifiers", false);
m_disableOnTwoKeys = group.readEntry<bool>("StickyKeysAutoOff", false);
m_ringBell = group.readEntry<bool>("StickyKeysBeep", false);
if (!m_lockKeys) {
// locking keys is deactivated, unlock all locked keys
@ -105,6 +107,12 @@ bool StickyKeysFilter::keyEvent(KWin::KeyEvent *event)
auto keyState = m_keyStates.find(event->key());
if (m_ringBell && event->type() == QEvent::KeyRelease) {
if (auto effect = KWin::effects->provides(KWin::Effect::SystemBell)) {
effect->perform(KWin::Effect::SystemBell, {});
}
}
if (keyState != m_keyStates.end()) {
if (event->type() == QKeyEvent::KeyPress) {
// An unlatched modifier was pressed, latch it

View file

@ -36,4 +36,5 @@ private:
bool m_showNotificationForLockedKeys = false;
bool m_disableOnTwoKeys = false;
QSet<int> m_pressedModifiers;
bool m_ringBell = false;
};