Skip to content

Commit

Permalink
Reworks initiating mouse selection in alt-screen mode.
Browse files Browse the repository at this point in the history
Fixes mouse selection to only be initiated if actually meant to, i.e. in alt screen mode only if bypass-modifier was pressed (#1017).

Signed-off-by: Christian Parpart <christian@parpart.family>
  • Loading branch information
christianparpart committed Feb 14, 2023
1 parent 9b856e1 commit 4db6ff1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<li>Fixes use of config `bypass_mouse_protocol_modifier` that was ignored.</li>
<li>Fixes abnormal termination on incomplete foreground/background color-pair specification.</li>
<li>Fixes `SendChars` input acion to actually send the chars as-is to the standard input of the connected application.</li>
<li>Fixes mouse selection to only be initiated if actually meant to, i.e. in alt screen mode only if bypass-modifier was pressed (#1017).</li>
<li>Adds normal mode motion `[[`, `]]`, `[]`, `][` mimmicking exactly what vim does.</li>
<li>Adds normal mode motion `[m` and `]m` to jump line marks up/down.</li>
<li>Adds normal mode motion `mm` to toggle the line mark at the current active cursor position.</li>
Expand Down
18 changes: 8 additions & 10 deletions src/vtbackend/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,18 +648,17 @@ bool Terminal::sendMousePressEvent(Modifier modifier,
bool uiHandledHint)
{
if (button == MouseButton::Left)
uiHandledHint = handleMouseSelection(modifier) || uiHandledHint;

if (!allowPassMouseEventToApp(modifier))
return false;
{
_leftMouseButtonPressed = true;
if (!allowPassMouseEventToApp(modifier))
uiHandledHint = handleMouseSelection(modifier) || uiHandledHint;
}

verifyState();

auto const eventSent = _state.inputGenerator.generateMousePress(
modifier, button, _currentMousePosition, pixelPosition, uiHandledHint);

if (!eventSent)
return false;
if (allowPassMouseEventToApp(modifier))
_state.inputGenerator.generateMousePress(
modifier, button, _currentMousePosition, pixelPosition, uiHandledHint);

// TODO: Ctrl+(Left)Click's should still be catched by the terminal iff there's a hyperlink
// under the current position
Expand All @@ -674,7 +673,6 @@ bool Terminal::handleMouseSelection(Modifier modifier)
double const diff_ms = chrono::duration<double, milli>(_currentTime - _lastClick).count();
_lastClick = _currentTime;
_speedClicks = (diff_ms >= 0.0 && diff_ms <= 750.0 ? _speedClicks : 0) % 3 + 1;
_leftMouseButtonPressed = true;

auto const startPos = CellLocation {
_currentMousePosition.line - boxed_cast<LineOffset>(_viewport.scrollOffset()),
Expand Down
3 changes: 2 additions & 1 deletion src/vtbackend/Terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ class Terminal

bool allowPassMouseEventToApp(Modifier currentlyPressedModifier) const noexcept
{
return allowInput() && !allowBypassAppMouseGrabViaModifier(currentlyPressedModifier);
return _state.inputGenerator.mouseProtocol().has_value() && allowInput()
&& !allowBypassAppMouseGrabViaModifier(currentlyPressedModifier);
}

template <typename BlinkerState>
Expand Down

0 comments on commit 4db6ff1

Please sign in to comment.