From 1d09cdb3826c40185f52e3124f182d4ca07b4361 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 2 Oct 2024 17:05:03 -0700 Subject: [PATCH] Mouse movement events are sent with shift until a button is pressed Ghostty was previously treating shift as a way to always stop mouse reporting. That's true for mouse button events, but not for mouse movement events. For mouse movement events, shift should be treated as a modifier until a button (any mouse button) is pressed. Once it is pressed, we pause mouse reporting until all buttons are released. Found by @ldemailly. This matches the behavior of Kitty, Alacritty, WezTerm, and xterm. --- src/Surface.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 7c994ef0f..3af7b8e9d 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3040,8 +3040,13 @@ pub fn cursorPosCallback( // Do a mouse report if (self.io.terminal.flags.mouse_event != .none) report: { // Shift overrides mouse "grabbing" in the window, taken from Kitty. - if (self.mouse.mods.shift and - !self.mouseShiftCapture(false)) break :report; + // This only applies if there is a mouse button pressed so that + // movement reports are not affected. + if (self.mouse.mods.shift and !self.mouseShiftCapture(false)) { + for (self.mouse.click_state) |state| { + if (state != .release) break :report; + } + } // We use the first mouse button we find pressed in order to report // since the spec (afaict) does not say...