fn handle_event(
		&mut self,
		event: winit::event::Event<ContextFunction>,
		event_loop: &EventLoopWindowTarget,
		control_flow: &mut winit::event_loop::ControlFlow,
	) {
		*control_flow = winit::event_loop::ControlFlow::Wait;

		// Split between Event<ContextFunction> and ContextFunction commands.
		let event = match super::event::map_nonuser_event(event) {
			Ok(event) => event,
			Err(function) => {
				(function)(&mut ContextHandle::new(self, event_loop));
				return;
			},
		};

		self.mouse_cache.handle_event(&event);

		// Convert to own event type.
		let mut event = match super::event::convert_winit_event(event, &self.mouse_cache) {
			Some(x) => x,
			None => return,
		};

		// If we have nothing more to do, clean the background tasks.
		if let Event::MainEventsCleared = &event {
			self.clean_background_tasks();
		}

		// Run window event handlers.
		let run_context_handlers = match &mut event {
			Event::WindowEvent(event) => self.run_window_event_handlers(event, event_loop),
			_ => true,
		};

		// Run context event handlers.
		if run_context_handlers {
			self.run_event_handlers(&mut event, event_loop);
		}

		// Perform default actions for events.
		match event {
			#[cfg(feature = "save")]
			#[allow(deprecated)]
			Event::WindowEvent(WindowEvent::KeyboardInput(event)) => {
				if event.input.state.is_pressed() && event.input.key_code == Some(event::VirtualKeyCode::S) {
					let overlays = event.input.modifiers.alt();
					let modifiers = event.input.modifiers & !event::ModifiersState::ALT;
					if modifiers == event::ModifiersState::CTRL {
						self.save_image_prompt(event.window_id, overlays);
					} else if modifiers == event::ModifiersState::CTRL | event::ModifiersState::SHIFT {
						self.save_image(event.window_id, overlays);
					}
				}
			},
			Event::WindowEvent(WindowEvent::Resized(event)) => {
				if event.size.width > 0 && event.size.height > 0 {
					let _ = self.resize_window(event.window_id, event.size);
				}
			},
			Event::WindowEvent(WindowEvent::MouseWheel(event)) => {
				let delta = match event.delta {
					winit::event::MouseScrollDelta::LineDelta(_, y) => y,
					_ => 0.0
				};
				let current_position = self.mouse_cache.get_position(event.window_id, event.device_id).unwrap_or_else(|| [0.0, 0.0].into());
				let _ = self.zoom_window(event.window_id, delta, current_position.x as f32, current_position.y as f32);
			},
			Event::WindowEvent(WindowEvent::MouseMove(event)) => {
				if event.buttons.is_pressed(event::MouseButton::Left) {
					let current_position = self.mouse_cache.get_position(event.window_id, event.device_id).unwrap_or_else(|| [0.0, 0.0].into());
					let prev_position = self.mouse_cache.get_previous_position(event.window_id, event.device_id).unwrap_or_else(|| [0.0, 0.0].into());

					let _ = self.pan_window(
						event.window_id,
						(current_position.x - prev_position.x) as f32,
						(current_position.y - prev_position.y) as f32,
					);
				}
			},
			Event::WindowEvent(WindowEvent::RedrawRequested(event)) => {
				let _ = self.render_window(event.window_id);
			},
			Event::WindowEvent(WindowEvent::CloseRequested(event)) => {
				let _ = self.destroy_window(event.window_id);
			},
			_ => {},
		}
	}
/// Handle an event from the event loop.
Handle an event from the event loop.
Handle an event from the event loop .
fn handle_event(
		&mut self,
		event: winit::event::Event<ContextFunction>,
		event_loop: &EventLoopWindowTarget,
		control_flow: &mut winit::event_loop::ControlFlow,
	) {
		*control_flow = winit::event_loop::ControlFlow::Wait;
		// Split between Event<ContextFunction> and ContextFunction commands.
		let event = match super::event::map_nonuser_event(event) {
			Ok(event) => event,
			Err(function) => {
				(function)(&mut ContextHandle::new(self, event_loop));
				return;
			},
		};
		self.mouse_cache.handle_event(&event);
		// Convert to own event type.
		let mut event = match super::event::convert_winit_event(event, &self.mouse_cache) {
			Some(x) => x,
			None => return,
		};
		// If we have nothing more to do, clean the background tasks.
		if let Event::MainEventsCleared = &event {
			self.clean_background_tasks();
		}
		// Run window event handlers.
		let run_context_handlers = match &mut event {
			Event::WindowEvent(event) => self.run_window_event_handlers(event, event_loop),
			_ => true,
		};
		// Run context event handlers.
		if run_context_handlers {
			self.run_event_handlers(&mut event, event_loop);
		}
		// Perform default actions for events.
		match event {
			#[cfg(feature = "save")]
			#[allow(deprecated)]
			Event::WindowEvent(WindowEvent::KeyboardInput(event)) => {
				if event.input.state.is_pressed() && event.input.key_code == Some(event::VirtualKeyCode::S) {
					let overlays = event.input.modifiers.alt();
					let modifiers = event.input.modifiers & !event::ModifiersState::ALT;
					if modifiers == event::ModifiersState::CTRL {
						self.save_image_prompt(event.window_id, overlays);
					} else if modifiers == event::ModifiersState::CTRL | event::ModifiersState::SHIFT {
						self.save_image(event.window_id, overlays);
					}
				}
			},
			Event::WindowEvent(WindowEvent::Resized(event)) => {
				if event.size.width > 0 && event.size.height > 0 {
					let _ = self.resize_window(event.window_id, event.size);
				}
			},
			Event::WindowEvent(WindowEvent::MouseWheel(event)) => {
				let delta = match event.delta {
					winit::event::MouseScrollDelta::LineDelta(_, y) => y,
					_ => 0.0
				};
				let current_position = self.mouse_cache.get_position(event.window_id, event.device_id).unwrap_or_else(|| [0.0, 0.0].into());
				let _ = self.zoom_window(event.window_id, delta, current_position.x as f32, current_position.y as f32);
			},
			Event::WindowEvent(WindowEvent::MouseMove(event)) => {
				if event.buttons.is_pressed(event::MouseButton::Left) {
					let current_position = self.mouse_cache.get_position(event.window_id, event.device_id).unwrap_or_else(|| [0.0, 0.0].into());
					let prev_position = self.mouse_cache.get_previous_position(event.window_id, event.device_id).unwrap_or_else(|| [0.0, 0.0].into());
					let _ = self.pan_window(
						event.window_id,
						(current_position.x - prev_position.x) as f32,
						(current_position.y - prev_position.y) as f32,
					);
				}
			},
			Event::WindowEvent(WindowEvent::RedrawRequested(event)) => {
				let _ = self.render_window(event.window_id);
			},
			Event::WindowEvent(WindowEvent::CloseRequested(event)) => {
				let _ = self.destroy_window(event.window_id);
			},
			_ => {},
		}
	}
fn handle_event ( & mut self , event : winit :: event :: Event < ContextFunction > , event_loop : & EventLoopWindowTarget , control_flow : & mut winit :: event_loop :: ControlFlow , ) { * control_flow = winit :: event_loop :: ControlFlow :: Wait ; // Split between Event<ContextFunction> and ContextFunction commands. let event = match super :: event :: map_nonuser_event ( event ) { Ok ( event ) => event , Err ( function ) => { ( function ) ( & mut ContextHandle :: new ( self , event_loop ) ) ; return ; } , } ; self . mouse_cache . handle_event ( & event ) ; // Convert to own event type. let mut event = match super :: event :: convert_winit_event ( event , & self . mouse_cache ) { Some ( x ) => x , None => return , } ; // If we have nothing more to do, clean the background tasks. if let Event :: MainEventsCleared = & event { self . clean_background_tasks ( ) ; } // Run window event handlers. let run_context_handlers = match & mut event { Event :: WindowEvent ( event ) => self . run_window_event_handlers ( event , event_loop ) , _ => true , } ; // Run context event handlers. if run_context_handlers { self . run_event_handlers ( & mut event , event_loop ) ; } // Perform default actions for events. match event { # [ cfg ( feature " " ) ] # [ allow ( deprecated ) ] Event :: WindowEvent ( WindowEvent :: KeyboardInput ( event ) ) => { if event . input . state . is_pressed ( ) && event . input . key_code == Some ( event :: VirtualKeyCode :: S ) { let overlays = event . input . modifiers . alt ( ) ; let modifiers = event . input . modifiers & ! event :: ModifiersState :: ALT ; if modifiers == event :: ModifiersState :: CTRL { self . save_image_prompt ( event . window_id , overlays ) ; } else if modifiers == event :: ModifiersState :: CTRL | event :: ModifiersState :: SHIFT { self . save_image ( event . window_id , overlays ) ; } } } , Event :: WindowEvent ( WindowEvent :: Resized ( event ) ) => { if event . size . width > 0 && event . size . height > 0 { let _ = self . resize_window ( event . window_id , event . size ) ; } } , Event :: WindowEvent ( WindowEvent :: MouseWheel ( event ) ) => { let delta = match event . delta { winit :: event :: MouseScrollDelta :: LineDelta ( _ , y ) => y , _ => 0.0 } ; let current_position = self . mouse_cache . get_position ( event . window_id , event . device_id ) . unwrap_or_else ( | | [ 0.0 , 0.0 ] . into ( ) ) ; let _ = self . zoom_window ( event . window_id , delta , current_position . x as f32 , current_position . y as f32 ) ; } , Event :: WindowEvent ( WindowEvent :: MouseMove ( event ) ) => { if event . buttons . is_pressed ( event :: MouseButton :: Left ) { let current_position = self . mouse_cache . get_position ( event . window_id , event . device_id ) . unwrap_or_else ( | | [ 0.0 , 0.0 ] . into ( ) ) ; let prev_position = self . mouse_cache . get_previous_position ( event . window_id , event . device_id ) . unwrap_or_else ( | | [ 0.0 , 0.0 ] . into ( ) ) ; let _ = self . pan_window ( event . window_id , ( current_position . x - prev_position . x ) as f32 , ( current_position . y - prev_position . y ) as f32 , ) ; } } , Event :: WindowEvent ( WindowEvent :: RedrawRequested ( event ) ) => { let _ = self . render_window ( event . window_id ) ; } , Event :: WindowEvent ( WindowEvent :: CloseRequested ( event ) ) => { let _ = self . destroy_window ( event . window_id ) ; } , _ => { } , } }
Handle an event from the event loop.
Handle an event from the event loop .
&mut self
event
winit::event::Event<ContextFunction>
event_loop
&EventLoopWindowTarget
control_flow
&mut winit::event_loop::ControlFlow