From 15b2bffeb4bb4d1a4722d1faf863280786054ba4 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Wed, 18 May 2022 15:48:21 +0100 Subject: [PATCH] use mouse event count for double click --- lapce-ui/src/title.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lapce-ui/src/title.rs b/lapce-ui/src/title.rs index adc3d33e..09268304 100644 --- a/lapce-ui/src/title.rs +++ b/lapce-ui/src/title.rs @@ -23,7 +23,6 @@ pub struct Title { mouse_pos: Point, commands: Vec<(Rect, Command)>, - last_mouse_up: Instant, } impl Title { @@ -31,7 +30,6 @@ pub fn new() -> Self { Self { mouse_pos: Point::ZERO, commands: Vec::new(), - last_mouse_up: Instant::now(), } } @@ -81,9 +79,9 @@ fn event( Event::MouseDown(mouse_event) => { self.mouse_down(ctx, mouse_event); } - Event::MouseUp(_) => { - #[cfg(target_os = "macos")] - if self.last_mouse_up.elapsed().as_millis() < 500 { + #[cfg(target_os = "macos")] + Event::MouseUp(mouse_event) => { + if mouse_event.count >= 2 { let state = match ctx.window().get_window_state() { WindowState::Maximized => WindowState::Restored, WindowState::Restored => WindowState::Maximized, @@ -95,7 +93,6 @@ fn event( .to(Target::Window(data.window_id)), ) } - self.last_mouse_up = Instant::now(); } _ => {} }