From 5ba0c70cdb7ae4bb7ac398982f4f3ec6cb1b7bff Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 2 Jan 2020 20:02:59 -0800 Subject: [PATCH] add Tab::is_mouse_grabbed concept refs: https://github.com/wez/wezterm/issues/106 --- src/localtab.rs | 4 ++++ src/mux/tab.rs | 6 ++++++ src/server/tab.rs | 5 +++++ src/termwiztermtab.rs | 4 ++++ term/src/terminalstate.rs | 4 ++++ 5 files changed, 23 insertions(+) diff --git a/src/localtab.rs b/src/localtab.rs index 5f70eb73e..05ad7cefd 100644 --- a/src/localtab.rs +++ b/src/localtab.rs @@ -103,6 +103,10 @@ impl Tab for LocalTab { let terminal = self.terminal.borrow(); Some(terminal.get_selection_text()) } + + fn is_mouse_grabbed(&self) -> bool { + self.terminal.borrow().is_mouse_grabbed() + } } impl LocalTab { diff --git a/src/mux/tab.rs b/src/mux/tab.rs index 997d5b33d..02cf05f7c 100644 --- a/src/mux/tab.rs +++ b/src/mux/tab.rs @@ -62,6 +62,12 @@ pub trait Tab: Downcast { fn palette(&self) -> ColorPalette; fn domain_id(&self) -> DomainId; + /// Returns true if the terminal has grabbed the mouse and wants to + /// give the embedded application a chance to process events. + /// In practice this controls whether the gui will perform local + /// handling of clicks. + fn is_mouse_grabbed(&self) -> bool; + fn set_clipboard(&self, _clipboard: &Arc) {} /// Returns the selection range adjusted to the viewport diff --git a/src/server/tab.rs b/src/server/tab.rs index 1d4ed0185..52a7ec08f 100644 --- a/src/server/tab.rs +++ b/src/server/tab.rs @@ -332,6 +332,11 @@ impl Tab for ClientTab { // FIXME: get selection from peer or the surface None } + + fn is_mouse_grabbed(&self) -> bool { + // FIXME: get the real state from the remote + true + } } struct RenderableInner { diff --git a/src/termwiztermtab.rs b/src/termwiztermtab.rs index 70cce9d42..9ae7c3f23 100644 --- a/src/termwiztermtab.rs +++ b/src/termwiztermtab.rs @@ -331,6 +331,10 @@ impl Tab for TermWizTerminalTab { // FIXME: grab it from the surface None } + + fn is_mouse_grabbed(&self) -> bool { + true + } } pub struct TermWizTerminal { diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index 97f8c26ee..8df5fed88 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -876,6 +876,10 @@ impl TerminalState { } } + pub fn is_mouse_grabbed(&self) -> bool { + self.sgr_mouse + } + pub fn bracketed_paste_enabled(&self) -> bool { self.bracketed_paste }