diff --git a/src/SessionController.cpp b/src/SessionController.cpp --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -206,6 +206,8 @@ connect(_session.data(), &Konsole::Session::getBackgroundColor, this, &Konsole::SessionController::sendBackgroundColor); + connect(_session, &Konsole::Session::primaryScreenInUse, view, &Konsole::TerminalDisplay::usingPrimaryScreen); + _allControllers.insert(this); // A list of programs that accept Ctrl+C to clear command line used diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -625,6 +625,15 @@ */ void setUsesMouse(bool on); + /** + * Sets _isPrimaryScreen depending on which screen is currently in + * use, primary or alternate + * + * @param use Set to @c true if the primary screen is in use or to + * @c false otherwise (i.e. the alternate screen is in use) + */ + void usingPrimaryScreen(bool use); + void setBracketedPasteMode(bool on); /** @@ -917,6 +926,7 @@ bool _showTerminalSizeHint; bool _bidiEnabled; bool _mouseMarks; + bool _isPrimaryScreen; bool _bracketedPasteMode; QPoint _iPntSel; // initial selection point diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -2745,17 +2745,17 @@ return; } - // if the terminal program is not interested with mouse events: - // * send the event to the scrollbar if the slider has room to move - // * otherwise, send simulated up / down key presses to the terminal program - // for the benefit of programs such as 'less' + // If the program running in the terminal is not interested in mouse events: + // - Send the event to the scrollbar if the slider has room to move + // - Otherwise, send simulated up / down key presses to the terminal program + // for the benefit of programs such as 'less' (which use the alternate screen) if (_mouseMarks) { const bool canScroll = _scrollBar->maximum() > 0; if (canScroll) { _scrollBar->event(ev); _sessionController->setSearchStartToWindowCurrentLine(); _scrollWheelState.clearAll(); - } else { + } else if (!_isPrimaryScreen) { // assume that each Up / Down key event will cause the terminal application // to scroll by one line. // @@ -3107,6 +3107,12 @@ return _mouseMarks; } + +void TerminalDisplay::usingPrimaryScreen(bool use) +{ + _isPrimaryScreen = use; +} + void TerminalDisplay::setBracketedPasteMode(bool on) { _bracketedPasteMode = on;