[plugins/stickykeys] Unlatch keys when deactivating sticky keys
Otherwise when deactivating sticky keys while a modifier is latched it will stay latched forever with no way to unlatch
This commit is contained in:
parent
1187f3c624
commit
dd604c8e42
1 changed files with 18 additions and 10 deletions
|
@ -24,15 +24,6 @@ StickyKeysFilter::StickyKeysFilter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickyKeysFilter::loadConfig(const KConfigGroup &group)
|
|
||||||
{
|
|
||||||
KWin::input()->uninstallInputEventFilter(this);
|
|
||||||
|
|
||||||
if (group.readEntry<bool>("StickyKeys", false)) {
|
|
||||||
KWin::input()->prependInputEventFilter(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::KeyboardModifier keyToModifier(Qt::Key key)
|
Qt::KeyboardModifier keyToModifier(Qt::Key key)
|
||||||
{
|
{
|
||||||
if (key == Qt::Key_Shift) {
|
if (key == Qt::Key_Shift) {
|
||||||
|
@ -50,6 +41,23 @@ Qt::KeyboardModifier keyToModifier(Qt::Key key)
|
||||||
return Qt::NoModifier;
|
return Qt::NoModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StickyKeysFilter::loadConfig(const KConfigGroup &group)
|
||||||
|
{
|
||||||
|
KWin::input()->uninstallInputEventFilter(this);
|
||||||
|
|
||||||
|
if (group.readEntry<bool>("StickyKeys", false)) {
|
||||||
|
KWin::input()->prependInputEventFilter(this);
|
||||||
|
} else {
|
||||||
|
// sticky keys are deactivated, unlatch all latched keys
|
||||||
|
for (auto it = m_keyStates.keyValueBegin(); it != m_keyStates.keyValueEnd(); ++it) {
|
||||||
|
if (it->second != KeyState::None) {
|
||||||
|
it->second = KeyState::None;
|
||||||
|
KWin::input()->keyboard()->xkb()->setModifierLatched(keyToModifier((Qt::Key)it->first), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool StickyKeysFilter::keyEvent(KWin::KeyEvent *event)
|
bool StickyKeysFilter::keyEvent(KWin::KeyEvent *event)
|
||||||
{
|
{
|
||||||
if (m_modifiers.contains(event->key())) {
|
if (m_modifiers.contains(event->key())) {
|
||||||
|
@ -65,7 +73,7 @@ bool StickyKeysFilter::keyEvent(KWin::KeyEvent *event)
|
||||||
for (auto it = m_keyStates.keyValueBegin(); it != m_keyStates.keyValueEnd(); ++it) {
|
for (auto it = m_keyStates.keyValueBegin(); it != m_keyStates.keyValueEnd(); ++it) {
|
||||||
it->second = KeyState::None;
|
it->second = KeyState::None;
|
||||||
|
|
||||||
KWin::input()->keyboard()->xkb()->setModifierLatched(keyToModifier((Qt::Key)it->first), false);
|
KWin::input()->keyboard()->xkb()->setModifierLatched(keyToModifier(static_cast<Qt::Key>(it->first)), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue