summaryrefslogtreecommitdiffstats
path: root/native/src/mouse
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-01-31 17:01:19 +0700
committerLibravatar GitHub <noreply@github.com>2022-01-31 17:01:19 +0700
commite4ef29ef20724c3d1a4beff39ddfdaf6d45f9683 (patch)
tree6e0c9c38366c9d70204c80fc66bd8e8a7652cf52 /native/src/mouse
parentc75ed37148b019358b0297171cf31b2577eeb9ae (diff)
parent6f604ab3995cb345aacf183a569589988aa3ad1f (diff)
downloadiced-e4ef29ef20724c3d1a4beff39ddfdaf6d45f9683.tar.gz
iced-e4ef29ef20724c3d1a4beff39ddfdaf6d45f9683.tar.bz2
iced-e4ef29ef20724c3d1a4beff39ddfdaf6d45f9683.zip
Merge pull request #1096 from pacmancoder/feat/wgpu-webgl
Experimental WebGL wgpu backend support
Diffstat (limited to 'native/src/mouse')
-rw-r--r--native/src/mouse/click.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/native/src/mouse/click.rs b/native/src/mouse/click.rs
index 6c8b61a5..4a7d796c 100644
--- a/native/src/mouse/click.rs
+++ b/native/src/mouse/click.rs
@@ -1,6 +1,6 @@
//! Track mouse clicks.
+use crate::time::Instant;
use crate::Point;
-use std::time::Instant;
/// A mouse click.
#[derive(Debug, Clone, Copy)]
@@ -62,9 +62,14 @@ impl Click {
}
fn is_consecutive(&self, new_position: Point, time: Instant) -> bool {
+ let duration = if time > self.time {
+ Some(time - self.time)
+ } else {
+ None
+ };
+
self.position == new_position
- && time
- .checked_duration_since(self.time)
+ && duration
.map(|duration| duration.as_millis() <= 300)
.unwrap_or(false)
}