From 657ed92d823ba04c20bf658fc4e3df2787fe006d Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 23 Apr 2021 21:45:47 -0700 Subject: [PATCH] add swallow_mouse_click_on_pane_focus option refs: https://github.com/wez/wezterm/issues/724 --- config/src/lib.rs | 3 +++ docs/changelog.md | 1 + .../lua/config/swallow_mouse_click_on_pane_focus.md | 10 ++++++++++ wezterm-gui/src/termwindow/mouseevent.rs | 6 +++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 docs/config/lua/config/swallow_mouse_click_on_pane_focus.md diff --git a/config/src/lib.rs b/config/src/lib.rs index 639e99fa6..aa3833d27 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1064,6 +1064,9 @@ pub struct Config { #[serde(default)] pub sort_fallback_fonts_by_coverage: bool, + + #[serde(default)] + pub swallow_mouse_click_on_pane_focus: bool, } impl_lua_conversion!(Config); diff --git a/docs/changelog.md b/docs/changelog.md index 081463d2a..16ad03594 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -33,6 +33,7 @@ As features stabilize some brief notes about them will accumulate here. * Fixed: key and mouse assignments set via [window:set_config_overrides](config/lua/window/set_config_overrides.md) were not respected. [#656](https://github.com/wez/wezterm/issues/656) * Fixed: potential panic when word selecting off top of viewport [#713](https://github.com/wez/wezterm/issues/713) * Fixed: really long busy wait when displaying single logical json line of 1.5MB in length [#714](https://github.com/wez/wezterm/issues/714) +* New: [swallow_mouse_click_on_pane_focus](config/lua/config/swallow_mouse_click_on_pane_focus.md) option [#724](https://github.com/wez/wezterm/issues/724) ### 20210405-110924-a5bb5be8 diff --git a/docs/config/lua/config/swallow_mouse_click_on_pane_focus.md b/docs/config/lua/config/swallow_mouse_click_on_pane_focus.md new file mode 100644 index 000000000..f32bb2891 --- /dev/null +++ b/docs/config/lua/config/swallow_mouse_click_on_pane_focus.md @@ -0,0 +1,10 @@ +# `swallow_mouse_click_on_pane_focus = false` + +*Since: nightly builds only* + +When set to `true`, clicking on a pane will focus it. + +When set to `false` (the default), clicking on a pane will focus it and then +pass the click through to the application in the terminal. + + diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs index 6a2d89538..e456c9b54 100644 --- a/wezterm-gui/src/termwindow/mouseevent.rs +++ b/wezterm-gui/src/termwindow/mouseevent.rs @@ -287,6 +287,7 @@ impl super::TermWindow { context: &dyn WindowOps, ) { let mut on_split = None; + let mut is_click_to_focus = false; if y >= 0 { let y = y as usize; @@ -337,6 +338,7 @@ impl super::TermWindow { .map(|tab| tab.set_active_idx(pos.index)); pane = Rc::clone(&pos.pane); + is_click_to_focus = true; } WMEK::Move => {} WMEK::Release(_) => {} @@ -503,7 +505,9 @@ impl super::TermWindow { modifiers: window_mods_to_termwiz_mods(event.modifiers), }; - pane.mouse_event(mouse_event).ok(); + if !(self.config.swallow_mouse_click_on_pane_focus && is_click_to_focus) { + pane.mouse_event(mouse_event).ok(); + } match event.kind { WMEK::Move => {}