diff --git a/src/Session.h b/src/Session.h --- a/src/Session.h +++ b/src/Session.h @@ -377,6 +377,10 @@ bool isReadOnly() const; void setReadOnly(bool readOnly); + // Returns true if the current screen is the secondary/alternate one + // or false if it's the primary/normal buffer + bool isPrimaryScreen(); + public Q_SLOTS: /** @@ -728,7 +732,7 @@ void updateFlowControlState(bool suspended); void updateWindowSize(int lines, int columns); - // signal relayer + // Relays the signal from Emulation and sets _isPrimaryScreen void onPrimaryScreenInUse(bool use); void sessionAttributeRequest(int id); @@ -813,6 +817,8 @@ bool _readOnly; static int lastSessionId; + + bool _isPrimaryScreen; }; /** diff --git a/src/Session.cpp b/src/Session.cpp --- a/src/Session.cpp +++ b/src/Session.cpp @@ -104,6 +104,7 @@ , _hasDarkBackground(false) , _preferredSize(QSize()) , _readOnly(false) + , _isPrimaryScreen(true) { _uniqueIdentifier = QUuid::createUuid(); @@ -662,8 +663,14 @@ void Session::onPrimaryScreenInUse(bool use) { + + _isPrimaryScreen = use; emit primaryScreenInUse(use); } +bool Session::isPrimaryScreen() +{ + return _isPrimaryScreen; +} void Session::sessionAttributeRequest(int id) { diff --git a/src/SessionController.cpp b/src/SessionController.cpp --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -215,8 +215,6 @@ 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 @@ -653,15 +653,6 @@ */ void setAlternateScrolling(bool enable); - /** - * 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); /** @@ -958,7 +949,6 @@ bool _bidiEnabled; bool _usesMouseTracking; bool _alternateScrolling; - bool _isPrimaryScreen; bool _bracketedPasteMode; QPoint _iPntSel; // initial selection point @@ -1047,6 +1037,11 @@ SessionController *_sessionController; + // Returns true if the screen buffer used in the current session is + // the primary/normal buffer or false if it's the alternate/secondary + // one + bool sessionIsPrimaryScreen(); + bool _trimLeadingSpaces; // trim leading spaces in selected text bool _trimTrailingSpaces; // trim trailing spaces in selected text bool _mouseWheelZoom; // enable mouse wheel zooming or not diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -383,7 +383,6 @@ , _bidiEnabled(false) , _usesMouseTracking(false) , _alternateScrolling(true) - , _isPrimaryScreen(true) , _bracketedPasteMode(false) , _iPntSel(QPoint()) , _pntSel(QPoint()) @@ -2836,7 +2835,7 @@ } else if (!_readOnly) { _scrollWheelState.addWheelEvent(ev); - if(!_usesMouseTracking && !_isPrimaryScreen && _alternateScrolling) { + if(!_usesMouseTracking && !sessionIsPrimaryScreen() && _alternateScrolling) { // Send simulated up / down key presses to the terminal program // for the benefit of programs such as 'less' (which use the alternate screen) @@ -3209,11 +3208,6 @@ return _alternateScrolling; } -void TerminalDisplay::usingPrimaryScreen(bool use) -{ - _isPrimaryScreen = use; -} - void TerminalDisplay::setBracketedPasteMode(bool on) { _bracketedPasteMode = on; @@ -3872,6 +3866,16 @@ return _sessionController; } +bool TerminalDisplay::sessionIsPrimaryScreen() +{ + Session *currentSession = _sessionController->session(); + if (currentSession !=nullptr) { + return currentSession->isPrimaryScreen(); + } + + return true; +} + AutoScrollHandler::AutoScrollHandler(QWidget* parent) : QObject(parent) , _timerId(0)