Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 17c77a87 authored by Ahmad Samir's avatar Ahmad Samir Committed by Kurt Hindenburg

Only emulate up/down key presses for mouse scrolls on alternate screen

Summary:
Konsole sends up/down key press events for mouse scrolls for apps that
aren't interested in mouse events, such as less. Only do this when the
terminal is using the alternate screen.

Now scrolling up/down will be translated to up/down key presses only
when the terminal is using the alternate screen but scrolling in a terminal
using the primary screen will only scroll using the scrollbar, now it does
not cycle through the shell history.
Now the behavior matches xterm and and gnome-terminal.

BUG: 355106
FIXED-IN: 18.04

Reviewers: hindenburg

Reviewed By: hindenburg

Subscribers: rkflx, ngraham, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11146
parent 2a71f063
......@@ -206,6 +206,8 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
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
......
......@@ -2745,17 +2745,17 @@ void TerminalDisplay::wheelEvent(QWheelEvent* ev)
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 @@ bool TerminalDisplay::usesMouse() const
return _mouseMarks;
}
void TerminalDisplay::usingPrimaryScreen(bool use)
{
_isPrimaryScreen = use;
}
void TerminalDisplay::setBracketedPasteMode(bool on)
{
_bracketedPasteMode = on;
......
......@@ -625,6 +625,15 @@ public Q_SLOTS:
*/
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 @@ private:
bool _showTerminalSizeHint;
bool _bidiEnabled;
bool _mouseMarks;
bool _isPrimaryScreen;
bool _bracketedPasteMode;
QPoint _iPntSel; // initial selection point
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment