mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-28 18:52:16 +00:00
Allow one winit touch id at the time
This commit is contained in:
parent
62e0fdd5bd
commit
9f3eef8960
1 changed files with 27 additions and 20 deletions
|
|
@ -247,6 +247,7 @@ pub struct EventLoopState {
|
|||
// last seen cursor position
|
||||
cursor_pos: LogicalPoint,
|
||||
pressed: bool,
|
||||
current_touch_id: Option<u64>,
|
||||
|
||||
loop_error: Option<PlatformError>,
|
||||
current_resize_direction: Option<ResizeDirection>,
|
||||
|
|
@ -410,28 +411,34 @@ impl EventLoopState {
|
|||
runtime_window.process_mouse_input(ev);
|
||||
}
|
||||
WindowEvent::Touch(touch) => {
|
||||
let location = touch.location.to_logical(runtime_window.scale_factor() as f64);
|
||||
let position = euclid::point2(location.x, location.y);
|
||||
let ev = match touch.phase {
|
||||
winit::event::TouchPhase::Started => {
|
||||
self.pressed = true;
|
||||
MouseEvent::Pressed {
|
||||
position,
|
||||
button: PointerEventButton::Left,
|
||||
click_count: 0,
|
||||
if Some(touch.id) == self.current_touch_id || self.current_touch_id.is_none() {
|
||||
let location = touch.location.to_logical(runtime_window.scale_factor() as f64);
|
||||
let position = euclid::point2(location.x, location.y);
|
||||
let ev = match touch.phase {
|
||||
winit::event::TouchPhase::Started => {
|
||||
self.pressed = true;
|
||||
if self.current_touch_id.is_none() {
|
||||
self.current_touch_id = Some(touch.id);
|
||||
}
|
||||
MouseEvent::Pressed {
|
||||
position,
|
||||
button: PointerEventButton::Left,
|
||||
click_count: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
winit::event::TouchPhase::Ended | winit::event::TouchPhase::Cancelled => {
|
||||
self.pressed = false;
|
||||
MouseEvent::Released {
|
||||
position,
|
||||
button: PointerEventButton::Left,
|
||||
click_count: 0,
|
||||
winit::event::TouchPhase::Ended | winit::event::TouchPhase::Cancelled => {
|
||||
self.pressed = false;
|
||||
self.current_touch_id = None;
|
||||
MouseEvent::Released {
|
||||
position,
|
||||
button: PointerEventButton::Left,
|
||||
click_count: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
winit::event::TouchPhase::Moved => MouseEvent::Moved { position },
|
||||
};
|
||||
runtime_window.process_mouse_input(ev);
|
||||
winit::event::TouchPhase::Moved => MouseEvent::Moved { position },
|
||||
};
|
||||
runtime_window.process_mouse_input(ev);
|
||||
}
|
||||
}
|
||||
WindowEvent::ScaleFactorChanged { scale_factor, inner_size_writer: _ } => {
|
||||
if std::env::var("SLINT_SCALE_FACTOR").is_err() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue