Also prevent an intermediate selection entry for triple click

If a release event is the result of a double click, don't copy immediately
to X11 selection. Instead, start a timer, and copy only if no third click
happens during the interval.
This commit is contained in:
Matan Ziv-Av
2022-12-10 01:44:21 +02:00
committed by Kurt Hindenburg
parent f68f7f7cff
commit 0752cf3d62
2 changed files with 12 additions and 1 deletions

View File

@@ -1118,6 +1118,7 @@ void TerminalDisplay::mousePressEvent(QMouseEvent *ev)
}
if (_possibleTripleClick && (ev->button() == Qt::LeftButton)) {
_needCopyToX11Selection = false;
mouseTripleClickEvent(ev);
return;
}
@@ -1476,7 +1477,16 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent *ev)
_screenWindow->clearSelection();
} else {
if (_actSel > 1) {
copyToX11Selection();
if (_possibleTripleClick) {
_needCopyToX11Selection = true;
QTimer::singleShot(QApplication::doubleClickInterval(), this, [this]() {
if (_needCopyToX11Selection) {
copyToX11Selection();
}
});
} else {
copyToX11Selection();
}
}
_actSel = 0;

View File

@@ -730,6 +730,7 @@ private:
Enum::TripleClickModeEnum _tripleClickMode = Enum::SelectWholeLine;
bool _possibleTripleClick = false; // is set in mouseDoubleClickEvent and deleted
// after QApplication::doubleClickInterval() delay
bool _needCopyToX11Selection = false; // set in mouseReleaseEvent after mouseDoubleClickEvent
QLabel *_resizeWidget = nullptr;
QTimer *_resizeTimer = nullptr;