mirror of
				https://github.com/slint-ui/slint.git
				synced 2025-10-31 03:54:25 +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,11 +411,15 @@ impl EventLoopState { | |||
|                 runtime_window.process_mouse_input(ev); | ||||
|             } | ||||
|             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 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, | ||||
|  | @ -423,6 +428,7 @@ impl EventLoopState { | |||
|                         } | ||||
|                         winit::event::TouchPhase::Ended | winit::event::TouchPhase::Cancelled => { | ||||
|                             self.pressed = false; | ||||
|                             self.current_touch_id = None; | ||||
|                             MouseEvent::Released { | ||||
|                                 position, | ||||
|                                 button: PointerEventButton::Left, | ||||
|  | @ -433,6 +439,7 @@ impl EventLoopState { | |||
|                     }; | ||||
|                     runtime_window.process_mouse_input(ev); | ||||
|                 } | ||||
|             } | ||||
|             WindowEvent::ScaleFactorChanged { scale_factor, inner_size_writer: _ } => { | ||||
|                 if std::env::var("SLINT_SCALE_FACTOR").is_err() { | ||||
|                     window.window().dispatch_event( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Wannes Van Leemput
						Wannes Van Leemput