From 04cb8d1d3bbb2da17705862218b01d8aa0c85587 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 10 Dec 2021 10:33:00 -0700 Subject: [PATCH] gui: skip mouse event handling if window is not focused The intent is to workaround what appears to be an i3 bug. Not totally sure this is a good change, but let's try it! Might also help with an issue on macos. refs: #1140 refs: #1310 --- wezterm-gui/src/termwindow/mouseevent.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs index c56908769..8fda53ed2 100644 --- a/wezterm-gui/src/termwindow/mouseevent.rs +++ b/wezterm-gui/src/termwindow/mouseevent.rs @@ -424,6 +424,14 @@ impl super::TermWindow { event: MouseEvent, context: &dyn WindowOps, ) { + if self.focused.is_none() { + // Ignore the mouse event if the window doesn't have focus. + // Some Window managers can send events in a strange order + // + // and that can confuse neovim for example. + return; + } + let mut is_click_to_focus = false; for pos in self.get_panes_to_render() {