Warning, /graphics/krita/3rdparty/ext_qt/0001-Fix-unbalanced-KeyPress-Release-on-non-latin-keyboar.patch is written in an unsupported language. File is not indexed.

0001 From 9e4969677dcdc80b19090faa71c722d9c3a43cf9 Mon Sep 17 00:00:00 2001
0002 From: Dmitry Kazakov <dimula73@gmail.com>
0003 Date: Thu, 26 May 2022 11:46:19 +0300
0004 Subject: [PATCH] Fix unbalanced KeyPress/Release on non-latin keyboard on
0005  Linux
0006 
0007 Key release should come for exactly the same qt-key that was pressed
0008 before to keep them balanced. Even when the modifiers state changes
0009 in the meantime.
0010 
0011 https://bugs.kde.org/show_bug.cgi?id=454256
0012 ---
0013  src/plugins/platforms/xcb/qxcbkeyboard.cpp | 49 +++++++++++++++++-----
0014  src/plugins/platforms/xcb/qxcbkeyboard.h   |  6 +++
0015  2 files changed, 44 insertions(+), 11 deletions(-)
0016 
0017 diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
0018 index c5dc7b21..a02f76da 100644
0019 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
0020 +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
0021 @@ -1577,17 +1577,44 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type,
0022              m_isAutoRepeat = false;
0023      } else {
0024          m_isAutoRepeat = false;
0025 -        // Look at the next event in the queue to see if we are auto-repeating.
0026 -        connection()->eventQueue()->peek(QXcbEventQueue::PeekRetainMatch,
0027 -                                         [this, time, code](xcb_generic_event_t *event, int type) {
0028 -            if (type == XCB_KEY_PRESS) {
0029 -                auto keyPress = reinterpret_cast<xcb_key_press_event_t *>(event);
0030 -                m_isAutoRepeat = keyPress->time == time && keyPress->detail == code;
0031 -                if (m_isAutoRepeat)
0032 -                    m_autoRepeatCode = code;
0033 -            }
0034 -            return true;
0035 -        });
0036 +
0037 +        if (m_keyPressRegister.contains(code) && m_keyPressRegister[code].qtCode == qtcode) {
0038 +          // Look at the next event in the queue to see if we are auto-repeating.
0039 +          connection()->eventQueue()->peek(QXcbEventQueue::PeekRetainMatch,
0040 +                                           [this, time, code](xcb_generic_event_t *event, int type) {
0041 +              if (type == XCB_KEY_PRESS) {
0042 +                  auto keyPress = reinterpret_cast<xcb_key_press_event_t *>(event);
0043 +                  m_isAutoRepeat = keyPress->time == time && keyPress->detail == code;
0044 +                  if (m_isAutoRepeat)
0045 +                      m_autoRepeatCode = code;
0046 +              }
0047 +              return true;
0048 +          });
0049 +        }
0050 +    }
0051 +
0052 +    if (type == QEvent::KeyPress) {
0053 +        if (m_keyPressRegister.contains(code)) {
0054 +             qCWarning(lcQpaKeyboard) << "QXcbKeyboard::handleKeyEvent: key pressed, but it is already present in the registry"
0055 +                                      << "code" << code
0056 +                                      << "qtcode" << qtcode
0057 +                                      << "registered qtcode" << m_keyPressRegister[code].qtCode;
0058 +        }
0059 +        m_keyPressRegister[code] = {qtcode, text};
0060 +
0061 +    } else {
0062 +          if (m_keyPressRegister.contains(code)) {
0063 +             if (m_keyPressRegister[code].qtCode != qtcode) {
0064 +                  qCDebug(lcQpaKeyboard) << "QXcbKeyboard::handleKeyEvent: replacing qtcode on release" << qtcode << " -> " << m_keyPressRegister[code].qtCode;
0065 +                  qtcode = m_keyPressRegister[code].qtCode;
0066 +                  text = m_keyPressRegister[code].text;
0067 +             }
0068 +             m_keyPressRegister.remove(code);
0069 +          } else {
0070 +              qCWarning(lcQpaKeyboard) << "QXcbKeyboard::handleKeyEvent: key released, but it has no record in the registry"
0071 +                                       << "code" << code
0072 +                                       << "qtcode" << qtcode;
0073 +          }
0074      }
0075  
0076      bool filtered = false;
0077 diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
0078 index f8490592..3a0de5b7 100644
0079 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h
0080 +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
0081 @@ -119,6 +119,12 @@ private:
0082      bool m_isAutoRepeat = false;
0083      xcb_keycode_t m_autoRepeatCode = 0;
0084  
0085 +    struct KeyPressRecord {
0086 +        int qtCode;
0087 +        QString text;
0088 +    };
0089 +    QHash<xcb_keycode_t, KeyPressRecord> m_keyPressRegister;
0090 +
0091      struct _mod_masks {
0092          uint alt;
0093          uint altgr;
0094 -- 
0095 2.17.1
0096