https://bugs.kde.org/show_bug.cgi?id=524571

--- Comment #1 from Johannes Altmanninger <[email protected]> ---
a fix might look something like this:

```diff
diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp
index 9d36205f2b..549733864c 100644
--- a/src/Vt102Emulation.cpp
+++ b/src/Vt102Emulation.cpp
@@ -3207,16 +3207,9 @@
     }
 #endif

-    // Kitty keyboard protocol — must be checked before the KeyPress-only gate
-    // because flag 2 (report event types) needs release/repeat events too.
-    if (_kittyKeyboardEnabled && currentKittyKeyboardFlags() != 0 &&
!isReadOnly) {
-        if (handleKittyKeyEvent(event)) {
-            return;
-        }
-    }
-
-    if (event->type() != QEvent::KeyPress) return;
-
+    const bool kitty = _kittyKeyboardEnabled && currentKittyKeyboardFlags() !=
0;
+
+    if (event->type() == QEvent::KeyPress) {
         const Qt::KeyboardModifiers modifiers = event->modifiers();
         KeyboardTranslator::States states = KeyboardTranslator::NoState;

@@ -3243,7 +3236,7 @@
                 switch (event->key()) {
                 case Qt::Key_S:
                     Q_EMIT flowControlKeyPressed(true);
-                break;
+                    return;
                 case Qt::Key_C:
                     if (m_SixelStarted) {
                         SixelModeAbort();
@@ -3252,10 +3245,10 @@
                     // Allow the user to take back control
                     resetTokenizer();
                     Q_EMIT flowControlKeyPressed(false);
-                break;
+                    return;
                 case Qt::Key_Q: // cancel flow control
                     Q_EMIT flowControlKeyPressed(false);
-                break;
+                    return;
                 }
             }
         }
@@ -3268,7 +3261,7 @@
             int cuX = _currentScreen->getCursorX();
             int cuY = _currentScreen->getCursorY();
             bool up = event->key() == Qt::Key_Up;
-        if (((up || event->key() == Qt::Key_Down) &&
_currentScreen->replMode() == REPL_INPUT &&
_currentScreen->currentTerminalDisplay()->semanticUpDown())
+            if (!kitty && ((up || event->key() == Qt::Key_Down) &&
_currentScreen->replMode() == REPL_INPUT &&
_currentScreen->currentTerminalDisplay()->semanticUpDown())
                 && ((up && _currentScreen->replModeStart() <=
std::make_pair(cuY - 1, cuX))
                     || (!up && std::make_pair(cuY + 1, cuX) <=
_currentScreen->replModeEnd()))) {
                 entry = _keyTranslator->findEntry(up ? Qt::Key_Left :
Qt::Key_Right, Qt::NoModifier, states);
@@ -3287,18 +3280,19 @@
                 const bool wantsMetaModifier = ((entry.modifiers() &
entry.modifierMask() & Qt::MetaModifier) != 0U);
                 const bool wantsAnyModifier = ((entry.state() &
entry.stateMask() & KeyboardTranslator::AnyModifierState) != 0);

-            if (((modifiers & Qt::AltModifier) != 0U) && !(wantsAltModifier ||
wantsAnyModifier) && !event->text().isEmpty()) {
+                if (!kitty && ((modifiers & Qt::AltModifier) != 0U) &&
!(wantsAltModifier || wantsAnyModifier) && !event->text().isEmpty()) {
                     textToSend.prepend("\033");
                 }
-            if (((modifiers & Qt::MetaModifier) != 0U) && !(wantsMetaModifier
|| wantsAnyModifier) && !event->text().isEmpty()) {
+                if (!kitty && ((modifiers & Qt::MetaModifier) != 0U) &&
!(wantsMetaModifier || wantsAnyModifier) && !event->text().isEmpty()) {
                     textToSend.prepend("\030@s");
                 }

                 if (entry.command() != KeyboardTranslator::NoCommand) {
-                if ((entry.command() & KeyboardTranslator::EraseCommand) != 0)
{
+                    if (!kitty && (entry.command() &
KeyboardTranslator::EraseCommand) != 0) {
                         textToSend += eraseChar();
                     }
                     if (currentView != nullptr) {
+                        bool handled = true;
                         if ((entry.command() &
KeyboardTranslator::ScrollPageUpCommand) != 0) {
                            
currentView->scrollScreenWindow(ScreenWindow::ScrollPages, -1);
                         } else if ((entry.command() &
KeyboardTranslator::ScrollPageDownCommand) != 0) {
@@ -3315,17 +3309,21 @@
                            
currentView->scrollScreenWindow(ScreenWindow::ScrollPrompts, -1);
                         } else if ((entry.command() &
KeyboardTranslator::ScrollPromptDownCommand) != 0) {
                            
currentView->scrollScreenWindow(ScreenWindow::ScrollPrompts, 1);
+                        } else {
+                            handled = false;
                         }
+                        if (handled)
+                            return;
                     }
-            } else if (!entry.text().isEmpty()) {
+                } else if (!kitty && !entry.text().isEmpty()) {
                     textToSend += entry.text(true, modifiers);
-            } else {
+                } else if (!kitty) {
                     Q_ASSERT(_encoder.isValid());
                     textToSend += _encoder.encode(event->text());
                 }
             }

-        if (!isReadOnly) {
+            if (!kitty && !isReadOnly) {
                 Q_EMIT sendData(textToSend);
             }
         } else {
@@ -3341,6 +3339,14 @@
                 receiveData(translatorError.toLatin1().constData(),
translatorError.length());
             }
         }
+    }
+
+    // Kitty keyboard protocol.
+    if (kitty && !isReadOnly) {
+        if (handleKittyKeyEvent(event)) {
+            return;
+        }
+    }
 }

 /* -------------------------------------------------------------------------
*/
```

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to