From b0463effd817aa327107eb62fe868a2aeb084da1 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Fri, 5 Jul 2019 18:32:13 +0200 Subject: [PATCH] Fix display sometimes randomly scrolling down Something in Qt has changed, so e. g. Super_L isn't passed as a modifier anymore, so there's a regression from what eea5ecfc5ed93515afaae5b9b938154eeaaf0ba8 fixed. This is especially annoying e. g. for people using i3, where just switching focus away with the keyboard will lead to Konsole scrolling back to the bottom. --- src/SessionController.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/SessionController.cpp b/src/SessionController.cpp index dc2c5da6..fc9d2d11 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -240,9 +240,27 @@ void SessionController::trackOutput(QKeyEvent* event) { Q_ASSERT(_view->screenWindow()); + // Qt has broken something, so we can't rely on just checking if certain + // keys are passed as modifiers anymore. + const int key = event->key(); + const bool shouldNotTriggerScroll = + key == Qt::Key_Super_L || + key == Qt::Key_Super_R || + key == Qt::Key_Hyper_L || + key == Qt::Key_Hyper_R || + key == Qt::Key_Shift || + key == Qt::Key_Control || + key == Qt::Key_Meta || + key == Qt::Key_Alt || + key == Qt::Key_AltGr || + key == Qt::Key_CapsLock || + key == Qt::Key_NumLock || + key == Qt::Key_ScrollLock; + + // Only jump to the bottom if the user actually typed something in, // not if the user e. g. just pressed a modifier. - if (event->text().isEmpty() && (event->modifiers() != 0u)) { + if (event->text().isEmpty() && (event->modifiers() || shouldNotTriggerScroll)) { return; }