Changeset View
Changeset View
Standalone View
Standalone View
keyboard_input.cpp
Show First 20 Lines • Show All 397 Lines • ▼ Show 20 Line(s) | 397 | if (xkb_state_mod_index_is_active(m_state, m_altModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | |||
---|---|---|---|---|---|
398 | mods |= Qt::AltModifier; | 398 | mods |= Qt::AltModifier; | ||
399 | } | 399 | } | ||
400 | if (xkb_state_mod_index_is_active(m_state, m_controlModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | 400 | if (xkb_state_mod_index_is_active(m_state, m_controlModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | ||
401 | mods |= Qt::ControlModifier; | 401 | mods |= Qt::ControlModifier; | ||
402 | } | 402 | } | ||
403 | if (xkb_state_mod_index_is_active(m_state, m_metaModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | 403 | if (xkb_state_mod_index_is_active(m_state, m_metaModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | ||
404 | mods |= Qt::MetaModifier; | 404 | mods |= Qt::MetaModifier; | ||
405 | } | 405 | } | ||
406 | | ||||
407 | // workaround xkbcommon limitation concerning consumed modifiers | ||||
408 | // if a key could be turned into a keysym with a modifier xkbcommon | ||||
409 | // considers the modifier as consumed even if not pressed | ||||
410 | // e.g. alt+F3 considers alt as consumed as there is a keysym generated | ||||
411 | // with ctrl+alt+F3 (vt switching) | ||||
412 | // For more information see: | ||||
413 | // https://bugs.freedesktop.org/show_bug.cgi?id=92818 | ||||
414 | // https://github.com/xkbcommon/libxkbcommon/issues/17 | ||||
415 | | ||||
416 | // the workaround is to not consider the modifiers as consumed | ||||
417 | // if they are not a currently | ||||
418 | // this might have other side effects, though. The only proper way to | ||||
419 | // handle this is through new API in xkbcommon which doesn't exist yet | ||||
420 | if (m_consumedModifiers & ~m_modifiers) { | ||||
luebking: Possible pitfalls:
What if eg. Ctrl+Alt+Foo creates a keysym, but Ctrl+Alt+Shift+Foo does not? | |||||
Equality doesn't work: Alt+F3 consumes ctrl+Alt, but only alt is pressed. graesslin: Equality doesn't work: Alt+F3 consumes ctrl+Alt, but only alt is pressed. | |||||
421 | return mods; | ||||
422 | } | ||||
423 | | ||||
406 | return mods & ~m_consumedModifiers; | 424 | return mods & ~m_consumedModifiers; | ||
407 | } | 425 | } | ||
408 | 426 | | |||
409 | xkb_keysym_t Xkb::toKeysym(uint32_t key) | 427 | xkb_keysym_t Xkb::toKeysym(uint32_t key) | ||
410 | { | 428 | { | ||
411 | if (!m_state) { | 429 | if (!m_state) { | ||
412 | return XKB_KEY_NoSymbol; | 430 | return XKB_KEY_NoSymbol; | ||
413 | } | 431 | } | ||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |
Possible pitfalls:
What if eg. Ctrl+Alt+Foo creates a keysym, but Ctrl+Alt+Shift+Foo does not?
If however Ctrl+Alt+Foo and Ctrl+Alt+Shift+Foo create keysyms, Ctrl+Alt+Shift would be consumed but Ctrl+Alt should be considered consumed as well (so this test fails), right?
-> should one test for equality to rule out at least case one?