diff --git a/tabby-terminal/src/api/baseTerminalTab.component.ts b/tabby-terminal/src/api/baseTerminalTab.component.ts index 87d445bec..beb903211 100644 --- a/tabby-terminal/src/api/baseTerminalTab.component.ts +++ b/tabby-terminal/src/api/baseTerminalTab.component.ts @@ -665,6 +665,7 @@ export class BaseTerminalTabComponent
extends Bas
}
private rightMouseDownTime = 0
+ private rightClickLeftToApp = false
protected async handleRightMouseDown (event: MouseEvent): Promise extends Bas
this.termContainerSubscriptions.subscribe(this.focused$, () => this.frontend && (this.frontend.enableResizing = true))
this.termContainerSubscriptions.subscribe(this.blurred$, () => this.frontend && (this.frontend.enableResizing = false))
- this.termContainerSubscriptions.subscribe(this.frontend.mouseEvent$, event => {
+ const frontend = this.frontend
+ this.termContainerSubscriptions.subscribe(frontend.mouseEvent$, event => {
if (event.type === 'mousedown') {
if (event.which === 1) {
this.multifocus.cancel()
@@ -743,13 +745,21 @@ export class BaseTerminalTabComponent extends Bas
return
}
if (event.which === 3 || event.which === 1 && event.ctrlKey) {
- this.handleRightMouseDown(event)
+ // Right-click is off and the app tracks the mouse: xterm has reported
+ // the press and listens for the release on `document`, so leave both
+ // events alone. Decided on the press, as the app may change modes in response.
+ this.rightClickLeftToApp = this.config.store.terminal.rightClick === 'off' && frontend.isMouseTrackingActive()
+ if (!this.rightClickLeftToApp) {
+ this.handleRightMouseDown(event)
+ }
return
}
}
if (event.type === 'mouseup') {
if (event.which === 3 || event.which === 1 && event.ctrlKey) {
- this.handleRightMouseUp(event)
+ if (!this.rightClickLeftToApp) {
+ this.handleRightMouseUp(event)
+ }
return
}
}
diff --git a/tabby-terminal/src/frontends/frontend.ts b/tabby-terminal/src/frontends/frontend.ts
index b4d0d7332..3105ef778 100644
--- a/tabby-terminal/src/frontends/frontend.ts
+++ b/tabby-terminal/src/frontends/frontend.ts
@@ -94,6 +94,11 @@ export abstract class Frontend {
abstract supportsBracketedPaste (): boolean
abstract isAlternateScreenActive (): boolean
+ /** Whether the running application has asked for mouse events */
+ isMouseTrackingActive (): boolean {
+ return false
+ }
+
/**
* Reset terminal modes (mouse tracking, bracketed paste, cursor visibility, etc.)
* Called on session reconnection to prevent stale modes from leaking
diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts
index 6ecfdda26..e58286fc5 100644
--- a/tabby-terminal/src/frontends/xtermFrontend.ts
+++ b/tabby-terminal/src/frontends/xtermFrontend.ts
@@ -497,12 +497,16 @@ export class XTermFrontend extends Frontend {
mousedown: event => this.mouseEvent.next(event as MouseEvent),
mouseup: event => this.mouseEvent.next(event as MouseEvent),
rightButtonCapture: event => {
- // Tabby always handles right-click itself (menu/paste/copy).
- // Don't let xterm also report it to apps with mouse tracking
- // enabled - some of them paste on right-click, doubling the paste
- if ((event as MouseEvent).button === 2 && this.xterm.modes.mouseTrackingMode !== 'none') {
- event.stopPropagation()
- this.mouseEvent.next(event as MouseEvent)
+ // Tabby handles right-click itself (menu/paste/copy), so don't let
+ // xterm also report it to apps with mouse tracking enabled - some of
+ // them paste on right-click, doubling the paste.
+ // With right-click turned off, the click is the app's instead.
+ const e = event as MouseEvent
+ const rightClick = e.button === 2 || e.button === 0 && e.ctrlKey
+ if (rightClick && this.isMouseTrackingActive() && this.configService.store.terminal.rightClick !== 'off') {
+ // "immediate" also skips our own bubble listener when the host itself is the target
+ event.stopImmediatePropagation()
+ this.mouseEvent.next(e)
}
},
mousewheel: event => this.mouseEvent.next(event as MouseEvent),
@@ -834,6 +838,10 @@ export class XTermFrontend extends Frontend {
return this.xterm.modes.bracketedPasteMode
}
+ isMouseTrackingActive (): boolean {
+ return this.xterm.modes.mouseTrackingMode !== 'none'
+ }
+
isAlternateScreenActive (): boolean {
return this.xterm.buffer.active.type === 'alternate'
}