mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-30 19:47:03 +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
|
// last seen cursor position
|
||||||
cursor_pos: LogicalPoint,
|
cursor_pos: LogicalPoint,
|
||||||
pressed: bool,
|
pressed: bool,
|
||||||
|
current_touch_id: Option<u64>,
|
||||||
|
|
||||||
loop_error: Option<PlatformError>,
|
loop_error: Option<PlatformError>,
|
||||||
current_resize_direction: Option<ResizeDirection>,
|
current_resize_direction: Option<ResizeDirection>,
|
||||||
|
|
@ -410,11 +411,15 @@ impl EventLoopState {
|
||||||
runtime_window.process_mouse_input(ev);
|
runtime_window.process_mouse_input(ev);
|
||||||
}
|
}
|
||||||
WindowEvent::Touch(touch) => {
|
WindowEvent::Touch(touch) => {
|
||||||
|
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 location = touch.location.to_logical(runtime_window.scale_factor() as f64);
|
||||||
let position = euclid::point2(location.x, location.y);
|
let position = euclid::point2(location.x, location.y);
|
||||||
let ev = match touch.phase {
|
let ev = match touch.phase {
|
||||||
winit::event::TouchPhase::Started => {
|
winit::event::TouchPhase::Started => {
|
||||||
self.pressed = true;
|
self.pressed = true;
|
||||||
|
if self.current_touch_id.is_none() {
|
||||||
|
self.current_touch_id = Some(touch.id);
|
||||||
|
}
|
||||||
MouseEvent::Pressed {
|
MouseEvent::Pressed {
|
||||||
position,
|
position,
|
||||||
button: PointerEventButton::Left,
|
button: PointerEventButton::Left,
|
||||||
|
|
@ -423,6 +428,7 @@ impl EventLoopState {
|
||||||
}
|
}
|
||||||
winit::event::TouchPhase::Ended | winit::event::TouchPhase::Cancelled => {
|
winit::event::TouchPhase::Ended | winit::event::TouchPhase::Cancelled => {
|
||||||
self.pressed = false;
|
self.pressed = false;
|
||||||
|
self.current_touch_id = None;
|
||||||
MouseEvent::Released {
|
MouseEvent::Released {
|
||||||
position,
|
position,
|
||||||
button: PointerEventButton::Left,
|
button: PointerEventButton::Left,
|
||||||
|
|
@ -433,6 +439,7 @@ impl EventLoopState {
|
||||||
};
|
};
|
||||||
runtime_window.process_mouse_input(ev);
|
runtime_window.process_mouse_input(ev);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
WindowEvent::ScaleFactorChanged { scale_factor, inner_size_writer: _ } => {
|
WindowEvent::ScaleFactorChanged { scale_factor, inner_size_writer: _ } => {
|
||||||
if std::env::var("SLINT_SCALE_FACTOR").is_err() {
|
if std::env::var("SLINT_SCALE_FACTOR").is_err() {
|
||||||
window.window().dispatch_event(
|
window.window().dispatch_event(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue