Changeset View
Changeset View
Standalone View
Standalone View
keyboard_input.cpp
Show First 20 Lines • Show All 395 Lines • ▼ Show 20 Line(s) | 394 | waylandServer()->seat()->updateKeyboardModifiers(xkb_state_serialize_mods(m_state, xkb_state_component(XKB_STATE_MODS_DEPRESSED)), | |||
---|---|---|---|---|---|
396 | xkb_state_serialize_mods(m_state, xkb_state_component(XKB_STATE_MODS_LOCKED)), | 396 | xkb_state_serialize_mods(m_state, xkb_state_component(XKB_STATE_MODS_LOCKED)), | ||
397 | layout); | 397 | layout); | ||
398 | } | 398 | } | ||
399 | } | 399 | } | ||
400 | 400 | | |||
401 | void Xkb::updateConsumedModifiers(uint32_t key) | 401 | void Xkb::updateConsumedModifiers(uint32_t key) | ||
402 | { | 402 | { | ||
403 | Qt::KeyboardModifiers mods = Qt::NoModifier; | 403 | Qt::KeyboardModifiers mods = Qt::NoModifier; | ||
404 | if (xkb_state_mod_index_is_consumed(m_state, key + 8, m_shiftModifier) == 1) { | 404 | if (xkb_state_mod_index_is_consumed2(m_state, key + 8, m_shiftModifier, XKB_CONSUMED_MODE_GTK) == 1) { | ||
405 | mods |= Qt::ShiftModifier; | 405 | mods |= Qt::ShiftModifier; | ||
406 | } | 406 | } | ||
407 | if (xkb_state_mod_index_is_consumed(m_state, key + 8, m_altModifier) == 1) { | 407 | if (xkb_state_mod_index_is_consumed2(m_state, key + 8, m_altModifier, XKB_CONSUMED_MODE_GTK) == 1) { | ||
408 | mods |= Qt::AltModifier; | 408 | mods |= Qt::AltModifier; | ||
409 | } | 409 | } | ||
410 | if (xkb_state_mod_index_is_consumed(m_state, key + 8, m_controlModifier) == 1) { | 410 | if (xkb_state_mod_index_is_consumed2(m_state, key + 8, m_controlModifier, XKB_CONSUMED_MODE_GTK) == 1) { | ||
411 | mods |= Qt::ControlModifier; | 411 | mods |= Qt::ControlModifier; | ||
412 | } | 412 | } | ||
413 | if (xkb_state_mod_index_is_consumed(m_state, key + 8, m_metaModifier) == 1) { | 413 | if (xkb_state_mod_index_is_consumed2(m_state, key + 8, m_metaModifier, XKB_CONSUMED_MODE_GTK) == 1) { | ||
414 | mods |= Qt::MetaModifier; | 414 | mods |= Qt::MetaModifier; | ||
415 | } | 415 | } | ||
416 | m_consumedModifiers = mods; | 416 | m_consumedModifiers = mods; | ||
417 | } | 417 | } | ||
418 | 418 | | |||
419 | Qt::KeyboardModifiers Xkb::modifiersRelevantForGlobalShortcuts() const | 419 | Qt::KeyboardModifiers Xkb::modifiersRelevantForGlobalShortcuts() const | ||
420 | { | 420 | { | ||
421 | Qt::KeyboardModifiers mods = Qt::NoModifier; | 421 | Qt::KeyboardModifiers mods = Qt::NoModifier; | ||
422 | if (xkb_state_mod_index_is_active(m_state, m_shiftModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | 422 | if (xkb_state_mod_index_is_active(m_state, m_shiftModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | ||
423 | mods |= Qt::ShiftModifier; | 423 | mods |= Qt::ShiftModifier; | ||
424 | } | 424 | } | ||
425 | if (xkb_state_mod_index_is_active(m_state, m_altModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | 425 | if (xkb_state_mod_index_is_active(m_state, m_altModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | ||
426 | mods |= Qt::AltModifier; | 426 | mods |= Qt::AltModifier; | ||
427 | } | 427 | } | ||
428 | if (xkb_state_mod_index_is_active(m_state, m_controlModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | 428 | if (xkb_state_mod_index_is_active(m_state, m_controlModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | ||
429 | mods |= Qt::ControlModifier; | 429 | mods |= Qt::ControlModifier; | ||
430 | } | 430 | } | ||
431 | if (xkb_state_mod_index_is_active(m_state, m_metaModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | 431 | if (xkb_state_mod_index_is_active(m_state, m_metaModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { | ||
432 | mods |= Qt::MetaModifier; | 432 | mods |= Qt::MetaModifier; | ||
433 | } | 433 | } | ||
434 | 434 | | |||
435 | // workaround xkbcommon limitation concerning consumed modifiers | | |||
436 | // if a key could be turned into a keysym with a modifier xkbcommon | | |||
437 | // considers the modifier as consumed even if not pressed | | |||
438 | // e.g. alt+F3 considers alt as consumed as there is a keysym generated | | |||
439 | // with ctrl+alt+F3 (vt switching) | | |||
440 | // For more information see: | | |||
441 | // https://bugs.freedesktop.org/show_bug.cgi?id=92818 | | |||
442 | // https://github.com/xkbcommon/libxkbcommon/issues/17 | | |||
443 | | ||||
444 | // the workaround is to not consider the modifiers as consumed | | |||
445 | // if they are not a currently | | |||
446 | // this might have other side effects, though. The only proper way to | | |||
447 | // handle this is through new API in xkbcommon which doesn't exist yet | | |||
448 | if (m_consumedModifiers & ~m_modifiers) { | | |||
449 | return mods; | | |||
450 | } | | |||
451 | | ||||
452 | Qt::KeyboardModifiers consumedMods = m_consumedModifiers; | 435 | Qt::KeyboardModifiers consumedMods = m_consumedModifiers; | ||
453 | if ((mods & Qt::ShiftModifier) && (consumedMods == Qt::ShiftModifier)) { | 436 | if ((mods & Qt::ShiftModifier) && (consumedMods == Qt::ShiftModifier)) { | ||
454 | // test whether current keysym is a letter | 437 | // test whether current keysym is a letter | ||
455 | // in that case the shift should be removed from the consumed modifiers again | 438 | // in that case the shift should be removed from the consumed modifiers again | ||
456 | // otherwise it would not be possible to trigger e.g. Shift+W as a shortcut | 439 | // otherwise it would not be possible to trigger e.g. Shift+W as a shortcut | ||
457 | // see BUG: 370341 | 440 | // see BUG: 370341 | ||
458 | if (QChar(toQtKey(m_keysym)).isLetter()) { | 441 | if (QChar(toQtKey(m_keysym)).isLetter()) { | ||
459 | consumedMods = Qt::KeyboardModifiers(); | 442 | consumedMods = Qt::KeyboardModifiers(); | ||
▲ Show 20 Lines • Show All 260 Lines • Show Last 20 Lines |