Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions internal/backends/winit/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl winit::application::ApplicationHandler<SlintEvent> for EventLoopState {
}
}

#[allow(clippy::collapsible_match)]
fn window_event(
&mut self,
event_loop: &ActiveEventLoop,
Expand Down Expand Up @@ -380,12 +381,13 @@ impl winit::application::ApplicationHandler<SlintEvent> for EventLoopState {
// arrives.
self.pending_mouse_move = Some((window_id, self.cursor_pos));
}
// On the html canvas, we don't get the mouse move or release event when outside the canvas. So we have no choice but canceling the event
WindowEvent::CursorLeft { .. } if cfg!(target_arch = "wasm32") || !self.pressed => {
self.pressed = false;
runtime_window.process_mouse_input(MouseEvent::Exit);
WindowEvent::CursorLeft { .. } => {
// On the html canvas, we don't get the mouse move or release event when outside the canvas. So we have no choice but canceling the event
if cfg!(target_arch = "wasm32") || !self.pressed {
self.pressed = false;
runtime_window.process_mouse_input(MouseEvent::Exit);
}
}
WindowEvent::CursorLeft { .. } => {}
WindowEvent::MouseWheel { delta, phase, .. } => {
let (delta_x, delta_y) = match delta {
winit::event::MouseScrollDelta::LineDelta(lx, ly) => (lx * 60., ly * 60.),
Expand Down Expand Up @@ -457,19 +459,18 @@ impl winit::application::ApplicationHandler<SlintEvent> for EventLoopState {
winit_touch_phase(touch.phase),
);
}
WindowEvent::ScaleFactorChanged { scale_factor, inner_size_writer: _ }
if std::env::var("SLINT_SCALE_FACTOR").is_err() =>
{
self.loop_error = window
.window()
.try_dispatch_event(corelib::platform::WindowEvent::ScaleFactorChanged {
scale_factor: scale_factor as f32,
})
.err();
// TODO: send a resize event or try to keep the logical size the same.
//window.resize_event(inner_size_writer.???)?;
WindowEvent::ScaleFactorChanged { scale_factor, inner_size_writer: _ } => {
if std::env::var("SLINT_SCALE_FACTOR").is_err() {
self.loop_error = window
.window()
.try_dispatch_event(corelib::platform::WindowEvent::ScaleFactorChanged {
scale_factor: scale_factor as f32,
})
.err();
// TODO: send a resize event or try to keep the logical size the same.
//window.resize_event(inner_size_writer.???)?;
}
}
WindowEvent::ScaleFactorChanged { .. } => {}
WindowEvent::ThemeChanged(theme) => {
window.set_color_scheme(match theme {
winit::window::Theme::Dark => ColorScheme::Dark,
Expand Down
30 changes: 17 additions & 13 deletions internal/core/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,7 @@ impl TouchState {
// 3+ fingers: tracked in active_touches but ignored for gesture.
}

#[allow(clippy::collapsible_match)]
fn process_moved(&mut self, id: u64, position: LogicalPoint, events: &mut TouchEventBuffer) {
if let Some(tp) = self.active_touches.get_mut(id) {
tp.position = position;
Expand All @@ -1704,10 +1705,11 @@ impl TouchState {
let is_gesture_finger = self.is_gesture_finger(id);

match self.gesture_state {
GestureRecognitionState::Idle if self.primary_touch_id == Some(id) => {
events.push(MouseEvent::Moved { position, is_touch: true });
GestureRecognitionState::Idle => {
if self.primary_touch_id == Some(id) {
events.push(MouseEvent::Moved { position, is_touch: true });
}
}
GestureRecognitionState::Idle => {}
GestureRecognitionState::TwoFingersDown {
finger_ids,
initial_distance,
Expand Down Expand Up @@ -1784,6 +1786,7 @@ impl TouchState {
}
}

#[allow(clippy::collapsible_match)]
fn process_ended(
&mut self,
id: u64,
Expand All @@ -1797,17 +1800,18 @@ impl TouchState {
self.active_touches.remove(id);

match self.gesture_state {
GestureRecognitionState::Idle if self.primary_touch_id == Some(id) => {
self.primary_touch_id = None;
events.push(MouseEvent::Released {
position,
button: PointerEventButton::Left,
click_count: 0,
is_touch: true,
});
events.push(MouseEvent::Exit);
GestureRecognitionState::Idle => {
if self.primary_touch_id == Some(id) {
self.primary_touch_id = None;
events.push(MouseEvent::Released {
position,
button: PointerEventButton::Left,
click_count: 0,
is_touch: true,
});
events.push(MouseEvent::Exit);
}
}
GestureRecognitionState::Idle => {}
GestureRecognitionState::TwoFingersDown { .. } if is_gesture_finger => {
self.gesture_state = GestureRecognitionState::Idle;
if !is_cancelled {
Expand Down
8 changes: 5 additions & 3 deletions tools/updater/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ struct State {
lookup_change: LookupChangeState,
}

#[allow(clippy::collapsible_match)]
fn visit_node(
node: SyntaxNode,
file: &mut impl Write,
Expand Down Expand Up @@ -212,10 +213,11 @@ fn visit_node(
}
}
}
SyntaxKind::RepeatedElement | SyntaxKind::ConditionalElement if args.move_declarations => {
experiments::lookup_changes::collect_movable_properties(&mut state);
SyntaxKind::RepeatedElement | SyntaxKind::ConditionalElement => {
if args.move_declarations {
experiments::lookup_changes::collect_movable_properties(&mut state);
}
}
SyntaxKind::RepeatedElement | SyntaxKind::ConditionalElement => {}
SyntaxKind::Element => {
if let Some(parent_el) = state.current_elem.take() {
state.current_elem = parent_el
Expand Down
Loading