From 03fdb38a96ac04cb8cc93c6dfa4f3da0211cb840 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 22 Nov 2022 20:59:15 -0800 Subject: [PATCH] moving the mouse too far between clicks will reset the click count --- src/Window.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Window.zig b/src/Window.zig index 70527741f..b24af8c73 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -1527,6 +1527,18 @@ fn mouseButtonCallback( return; }); + // If we move our cursor too much between clicks then we reset + // the multi-click state. + if (win.mouse.left_click_count > 0) { + const max_distance = win.cell_size.width; + const distance = @sqrt( + std.math.pow(f64, pos.xpos - win.mouse.left_click_xpos, 2) + + std.math.pow(f64, pos.ypos - win.mouse.left_click_ypos, 2), + ); + + if (distance > max_distance) win.mouse.left_click_count = 0; + } + // Store it const point = win.posToViewport(pos.xpos, pos.ypos); win.mouse.left_click_point = point.toScreen(&win.io.terminal.screen);