Changeset View
Changeset View
Standalone View
Standalone View
keyboard_input.cpp
Show First 20 Lines • Show All 443 Lines • ▼ Show 20 Line(s) | 420 | { | |||
---|---|---|---|---|---|
444 | // the workaround is to not consider the modifiers as consumed | 444 | // the workaround is to not consider the modifiers as consumed | ||
445 | // if they are not a currently | 445 | // if they are not a currently | ||
446 | // this might have other side effects, though. The only proper way to | 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 | 447 | // handle this is through new API in xkbcommon which doesn't exist yet | ||
448 | if (m_consumedModifiers & ~m_modifiers) { | 448 | if (m_consumedModifiers & ~m_modifiers) { | ||
449 | return mods; | 449 | return mods; | ||
450 | } | 450 | } | ||
451 | 451 | | |||
452 | return mods & ~m_consumedModifiers; | 452 | Qt::KeyboardModifiers consumedMods = m_consumedModifiers; | ||
453 | if ((mods & Qt::ShiftModifier) && (consumedMods == Qt::ShiftModifier)) { | ||||
454 | // test whether current keysym is a letter | ||||
455 | // 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 | ||||
457 | // see BUG: 370341 | ||||
458 | if (QChar(toQtKey(m_keysym)).isLetter()) { | ||||
459 | consumedMods = Qt::KeyboardModifiers(); | ||||
460 | } | ||||
461 | } | ||||
462 | | ||||
463 | return mods & ~consumedMods; | ||||
453 | } | 464 | } | ||
454 | 465 | | |||
455 | xkb_keysym_t Xkb::toKeysym(uint32_t key) | 466 | xkb_keysym_t Xkb::toKeysym(uint32_t key) | ||
456 | { | 467 | { | ||
457 | if (!m_state) { | 468 | if (!m_state) { | ||
458 | return XKB_KEY_NoSymbol; | 469 | return XKB_KEY_NoSymbol; | ||
459 | } | 470 | } | ||
460 | return xkb_state_key_get_one_sym(m_state, key + 8); | 471 | return xkb_state_key_get_one_sym(m_state, key + 8); | ||
461 | } | 472 | } | ||
462 | 473 | | |||
463 | QString Xkb::toString(xkb_keysym_t keysym) | 474 | QString Xkb::toString(xkb_keysym_t keysym) | ||
464 | { | 475 | { | ||
465 | if (!m_state || keysym == XKB_KEY_NoSymbol) { | 476 | if (!m_state || keysym == XKB_KEY_NoSymbol) { | ||
466 | return QString(); | 477 | return QString(); | ||
467 | } | 478 | } | ||
468 | QByteArray byteArray(7, 0); | 479 | QByteArray byteArray(7, 0); | ||
469 | int ok = xkb_keysym_to_utf8(keysym, byteArray.data(), byteArray.size()); | 480 | int ok = xkb_keysym_to_utf8(keysym, byteArray.data(), byteArray.size()); | ||
470 | if (ok == -1 || ok == 0) { | 481 | if (ok == -1 || ok == 0) { | ||
471 | return QString(); | 482 | return QString(); | ||
472 | } | 483 | } | ||
473 | return QString::fromUtf8(byteArray.constData()); | 484 | return QString::fromUtf8(byteArray.constData()); | ||
474 | } | 485 | } | ||
475 | 486 | | |||
476 | Qt::Key Xkb::toQtKey(xkb_keysym_t keysym) | 487 | Qt::Key Xkb::toQtKey(xkb_keysym_t keysym) const | ||
477 | { | 488 | { | ||
478 | int key = Qt::Key_unknown; | 489 | int key = Qt::Key_unknown; | ||
479 | KKeyServer::symXToKeyQt(keysym, &key); | 490 | KKeyServer::symXToKeyQt(keysym, &key); | ||
480 | return static_cast<Qt::Key>(key); | 491 | return static_cast<Qt::Key>(key); | ||
481 | } | 492 | } | ||
482 | 493 | | |||
483 | bool Xkb::shouldKeyRepeat(quint32 key) const | 494 | bool Xkb::shouldKeyRepeat(quint32 key) const | ||
484 | { | 495 | { | ||
▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines |