Commit 6aa40563 authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Tomaz Canabrava
Browse files

Only generate autoscroll events while selecting

As gumix explains in the bug below, "Konsole keeps sending mouse-drag
reports in ESC[?1003h mode after releasing button outside window [...]
The only way to stop it is to get mouse back over Konsole window."

These mouse-drag reports are actually generated by AutoScrollHandler, to
support the use case of extending the selection by dragging the mouse
outside the display area.

So, only generate those reports while selecting.

Can be tested by playing around in vttest:

 - 11. Test non-VT100 (e.g., VT220, XTERM) terminals
 - 8. Test XTERM special features
 - 5. Mouse features
 - 7. Mouse Button-Event Tracking (XFree86 xterm)

BUG: 391975
parent c9f77e52
......@@ -2886,3 +2886,8 @@ Character TerminalDisplay::getCursorCharacter(int column, int line)
{
return _image[loc(column, line)];
}
int TerminalDisplay::selectionState() const
{
return _actSel;
}
......@@ -338,6 +338,9 @@ public:
// returns the position of the cursor in columns and lines
QPoint cursorPosition() const;
// returns 0 - not selecting, 1 - pending selection (button pressed but no movement yet), 2 - selecting
int selectionState() const;
public Q_SLOTS:
/**
* Scrolls current ScreenWindow
......
......@@ -6,6 +6,7 @@
*/
#include "AutoScrollHandler.h"
#include "../TerminalDisplay.h"
#include <QApplication>
#include <QAccessible>
......@@ -42,6 +43,7 @@ bool AutoScrollHandler::eventFilter(QObject* watched, QEvent* event)
case QEvent::MouseMove: {
auto* mouseEvent = static_cast<QMouseEvent*>(event);
bool mouseInWidget = widget()->rect().contains(mouseEvent->pos());
auto* terminalDisplay = static_cast<TerminalDisplay*>(parent());
if (mouseInWidget) {
if (_timerId != 0) {
killTimer(_timerId);
......@@ -49,7 +51,7 @@ bool AutoScrollHandler::eventFilter(QObject* watched, QEvent* event)
_timerId = 0;
} else {
if ((_timerId == 0) && ((mouseEvent->buttons() & Qt::LeftButton) != 0U)) {
if ((_timerId == 0) && terminalDisplay->selectionState() != 0 && ((mouseEvent->buttons() & Qt::LeftButton) != 0U)) {
_timerId = startTimer(100);
}
}
......
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