Warning, /graphics/krita/3rdparty/ext_qt/0114-Fix-shortcuts-with-special-keys-on-non-US-layouts-on.patch is written in an unsupported language. File is not indexed.

0001 From 04dc4790ab91d904dcafb767762592a4c8de6f86 Mon Sep 17 00:00:00 2001
0002 From: Dmitry Kazakov <dimula73@gmail.com>
0003 Date: Tue, 16 Feb 2021 09:03:52 +0300
0004 Subject: [PATCH] Fix shortcuts with special keys on non-US layouts on Linux
0005 
0006 ---
0007  src/plugins/platforms/xcb/qxcbkeyboard.cpp | 34 +++++++++++++++++++++++++++---
0008  1 file changed, 31 insertions(+), 3 deletions(-)
0009 
0010 diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
0011 index c5dc7b2..48d1793 100644
0012 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
0013 +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
0014 @@ -83,6 +83,22 @@ struct Xkb2Qt
0015  
0016  static constexpr const auto KeyTbl = qMakeArray(
0017      QSortedData<
0018 +
0019 +        // isUSKeyboardShortcut()-positive data
0020 +
0021 +        Xkb2Qt<'.',                  Qt::Key_Period>,
0022 +        Xkb2Qt<',',                  Qt::Key_Comma>,
0023 +        Xkb2Qt<';',                  Qt::Key_Semicolon>,
0024 +        Xkb2Qt<'|',                  Qt::Key_Bar>,
0025 +        Xkb2Qt<'/',                  Qt::Key_Slash>,
0026 +        Xkb2Qt<'\\',                 Qt::Key_Backslash>,
0027 +        Xkb2Qt<'-',                  Qt::Key_Minus>,
0028 +        Xkb2Qt<'=',                  Qt::Key_Equal>,
0029 +        Xkb2Qt<'`',                  Qt::Key_QuoteLeft>,
0030 +        Xkb2Qt<'\'',                 Qt::Key_Apostrophe>,
0031 +        Xkb2Qt<'[',                  Qt::Key_BracketLeft>,
0032 +        Xkb2Qt<']',                  Qt::Key_BracketRight>,
0033 +
0034          // misc keys
0035  
0036          Xkb2Qt<XKB_KEY_Escape,                  Qt::Key_Escape>,
0037 @@ -923,6 +939,16 @@ static bool isLatin(xkb_keysym_t sym)
0038      return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
0039  }
0040  
0041 +static bool isUSKeyboardShortcut(xkb_keysym_t sym)
0042 +{
0043 +    return sym == '.' || sym == ',' ||
0044 +           sym == ';' || sym == '|' ||
0045 +           sym == '/' || sym == '\\' ||
0046 +           sym == '-' || sym == '=' ||
0047 +           sym == '`' || sym == '\'' ||
0048 +           sym == '[' || sym == ']';
0049 +}
0050 +
0051  void QXcbKeyboard::checkForLatinLayout() const
0052  {
0053      const xkb_layout_index_t layoutCount = xkb_keymap_num_layouts(m_xkbKeymap.get());
0054 @@ -966,7 +992,7 @@ xkb_keysym_t QXcbKeyboard::lookupLatinKeysym(xkb_keycode_t keycode) const
0055          xkb_level_index_t level = xkb_state_key_get_level(m_xkbState.get(), keycode, layout);
0056          if (xkb_keymap_key_get_syms_by_level(m_xkbKeymap.get(), keycode, layout, level, &syms) != 1)
0057              continue;
0058 -        if (isLatin(syms[0])) {
0059 +        if (isLatin(syms[0]) || isUSKeyboardShortcut(syms[0])) {
0060              sym = syms[0];
0061              break;
0062          }
0063 @@ -1067,8 +1093,9 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
0064          Qt::KeyboardModifiers neededMods = ModsTbl[i];
0065          if ((modifiers & neededMods) == neededMods) {
0066              if (i == 8) {
0067 -                if (isLatin(baseQtKey))
0068 +                if (isLatin(baseQtKey) || isUSKeyboardShortcut(baseQtKey))
0069                      continue;
0070 +
0071                  // add a latin key as a fall back key
0072                  sym = lookupLatinKeysym(keycode);
0073              } else {
0074 @@ -1127,6 +1154,7 @@ int QXcbKeyboard::keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers modif
0075          qtKey = xkbcommon_xkb_keysym_to_upper(keysym);
0076      } else {
0077          // check if we have a direct mapping
0078 +        // isUSKeyboardShortcut(keysym) is handled by the map
0079          xkb2qt_t searchKey{keysym, 0};
0080          auto it = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey);
0081          if (it != KeyTbl.end() && !(searchKey < *it))
0082 @@ -1564,7 +1592,7 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type,
0083      if (modifiers & Qt::ControlModifier) {
0084          // With standard shortcuts we should prefer a latin character, this is
0085          // in checks like "event == QKeySequence::Copy".
0086 -        if (!isLatin(sym))
0087 +        if (!isLatin(sym) && !isUSKeyboardShortcut(sym))
0088              latinKeysym = lookupLatinKeysym(code);
0089      }
0090  
0091 -- 
0092 2.7.4
0093