diff --git a/src/Screen.cpp b/src/Screen.cpp index 98913f59..389af4d2 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -1113,6 +1113,11 @@ void Screen::clearSelection() _selBegin = -1; } +bool Screen::hasSelection() const +{ + return _selBegin != -1; +} + void Screen::getSelectionStart(int& column , int& line) const { if (_selTopLeft != -1) { diff --git a/src/Screen.h b/src/Screen.h index 01c263e5..97f25ac8 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -454,6 +454,9 @@ public: /** Clears the current selection */ void clearSelection(); + /** Return the selection state */ + bool hasSelection() const; + /** * Returns true if the character at (@p x, @p y) is part of the * current selection. diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 895440f8..6fcee232 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -2231,15 +2231,6 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev) } else if (_usesMouseTracking && !_readOnly) { emit mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 0); } - - if ((_openLinksByDirectClick || ((ev->modifiers() & Qt::ControlModifier) != 0u))) { - auto spot = _filterChain->hotSpotAt(charLine, charColumn); - if ((spot != nullptr) && spot->type() == Filter::HotSpot::Link) { - QObject action; - action.setObjectName(QStringLiteral("open-action")); - spot->activate(&action); - } - } } } else if (ev->button() == Qt::MidButton) { processMidButtonClick(ev); @@ -2598,6 +2589,13 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent* ev) charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 2); } + + if (!_screenWindow->screen()->hasSelection() && (_openLinksByDirectClick || ((ev->modifiers() & Qt::ControlModifier) != 0u))) { + auto spot = _filterChain->hotSpotAt(charLine, charColumn); + if ((spot != nullptr) && spot->type() == Filter::HotSpot::Link) { + spot->activate(); + } + } } void TerminalDisplay::getCharacterPosition(const QPoint& widgetPoint, int& line, int& column, bool edge) const