Skip to content

Commit ddde870

Browse files
committed
cargo +nightly fmt
1 parent a88dac3 commit ddde870

File tree

9 files changed

+81
-115
lines changed

9 files changed

+81
-115
lines changed

src/application.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
33
use crate::event::{DeviceEvent, DeviceId, StartCause, SurfaceEvent};
44
use crate::event_loop::ActiveEventLoop;
5-
use crate::window::SurfaceId;
6-
75
#[cfg(any(docsrs, macos_platform))]
86
use crate::platform::macos::ApplicationHandlerExtMacOS;
7+
use crate::window::SurfaceId;
98

109
/// The handler of the application events.
1110
pub trait ApplicationHandler {

src/platform_impl/apple/appkit/app.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,28 @@ fn maybe_dispatch_device_event(app_state: &Rc<AppState>, event: &NSEvent) {
6060

6161
if delta_x != 0.0 || delta_y != 0.0 {
6262
app_state.maybe_queue_with_handler(move |app, event_loop| {
63-
app.device_event(
64-
event_loop,
65-
None,
66-
DeviceEvent::PointerMotion { delta: (delta_x, delta_y) },
67-
);
63+
app.device_event(event_loop, None, DeviceEvent::PointerMotion {
64+
delta: (delta_x, delta_y),
65+
});
6866
});
6967
}
7068
},
7169
NSEventType::LeftMouseDown | NSEventType::RightMouseDown | NSEventType::OtherMouseDown => {
7270
let button = unsafe { event.buttonNumber() } as u32;
7371
app_state.maybe_queue_with_handler(move |app, event_loop| {
74-
app.device_event(
75-
event_loop,
76-
None,
77-
DeviceEvent::Button { button, state: ElementState::Pressed },
78-
);
72+
app.device_event(event_loop, None, DeviceEvent::Button {
73+
button,
74+
state: ElementState::Pressed,
75+
});
7976
});
8077
},
8178
NSEventType::LeftMouseUp | NSEventType::RightMouseUp | NSEventType::OtherMouseUp => {
8279
let button = unsafe { event.buttonNumber() } as u32;
8380
app_state.maybe_queue_with_handler(move |app, event_loop| {
84-
app.device_event(
85-
event_loop,
86-
None,
87-
DeviceEvent::Button { button, state: ElementState::Released },
88-
);
81+
app.device_event(event_loop, None, DeviceEvent::Button {
82+
button,
83+
state: ElementState::Released,
84+
});
8985
});
9086
},
9187
_ => (),

src/platform_impl/linux/x11/dnd.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ impl Dnd {
7373
DndState::Rejected => (0, atoms[DndNone]),
7474
};
7575
self.xconn
76-
.send_client_msg(
77-
target_window,
78-
target_window,
79-
atoms[XdndStatus] as _,
80-
None,
81-
[this_window, accepted, 0, 0, action as _],
82-
)?
76+
.send_client_msg(target_window, target_window, atoms[XdndStatus] as _, None, [
77+
this_window,
78+
accepted,
79+
0,
80+
0,
81+
action as _,
82+
])?
8383
.ignore_error();
8484

8585
Ok(())
@@ -97,13 +97,13 @@ impl Dnd {
9797
DndState::Rejected => (0, atoms[DndNone]),
9898
};
9999
self.xconn
100-
.send_client_msg(
101-
target_window,
102-
target_window,
103-
atoms[XdndFinished] as _,
104-
None,
105-
[this_window, accepted, action as _, 0, 0],
106-
)?
100+
.send_client_msg(target_window, target_window, atoms[XdndFinished] as _, None, [
101+
this_window,
102+
accepted,
103+
action as _,
104+
0,
105+
0,
106+
])?
107107
.ignore_error();
108108

109109
Ok(())

src/platform_impl/linux/x11/event_processor.rs

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,10 @@ impl EventProcessor {
658658
drop(shared_state_lock);
659659

660660
if moved {
661-
callback(
662-
&self.target,
663-
Event::SurfaceEvent { window_id, event: SurfaceEvent::Moved(outer.into()) },
664-
);
661+
callback(&self.target, Event::SurfaceEvent {
662+
window_id,
663+
event: SurfaceEvent::Moved(outer.into()),
664+
});
665665
}
666666
outer
667667
};
@@ -707,18 +707,13 @@ impl EventProcessor {
707707
drop(shared_state_lock);
708708

709709
let surface_size = Arc::new(Mutex::new(new_surface_size));
710-
callback(
711-
&self.target,
712-
Event::SurfaceEvent {
713-
window_id,
714-
event: SurfaceEvent::ScaleFactorChanged {
715-
scale_factor: new_scale_factor,
716-
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(
717-
&surface_size,
718-
)),
719-
},
710+
callback(&self.target, Event::SurfaceEvent {
711+
window_id,
712+
event: SurfaceEvent::ScaleFactorChanged {
713+
scale_factor: new_scale_factor,
714+
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&surface_size)),
720715
},
721-
);
716+
});
722717

723718
let new_surface_size = *surface_size.lock().unwrap();
724719
drop(surface_size);
@@ -768,13 +763,10 @@ impl EventProcessor {
768763
}
769764

770765
if resized {
771-
callback(
772-
&self.target,
773-
Event::SurfaceEvent {
774-
window_id,
775-
event: SurfaceEvent::SurfaceResized(new_surface_size.into()),
776-
},
777-
);
766+
callback(&self.target, Event::SurfaceEvent {
767+
window_id,
768+
event: SurfaceEvent::SurfaceResized(new_surface_size.into()),
769+
});
778770
}
779771
}
780772

@@ -1527,13 +1519,10 @@ impl EventProcessor {
15271519
}
15281520
let physical_key = xkb::raw_keycode_to_physicalkey(keycode);
15291521

1530-
callback(
1531-
&self.target,
1532-
Event::DeviceEvent {
1533-
device_id,
1534-
event: DeviceEvent::Key(RawKeyEvent { physical_key, state }),
1535-
},
1536-
);
1522+
callback(&self.target, Event::DeviceEvent {
1523+
device_id,
1524+
event: DeviceEvent::Key(RawKeyEvent { physical_key, state }),
1525+
});
15371526
}
15381527

15391528
fn xinput2_hierarchy_changed(&mut self, xev: &XIHierarchyEvent) {

src/platform_impl/linux/x11/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,18 +1032,15 @@ impl Device {
10321032
let ty = unsafe { (*class_ptr)._type };
10331033
if ty == ffi::XIScrollClass {
10341034
let info = unsafe { &*(class_ptr as *const ffi::XIScrollClassInfo) };
1035-
scroll_axes.push((
1036-
info.number,
1037-
ScrollAxis {
1038-
increment: info.increment,
1039-
orientation: match info.scroll_type {
1040-
ffi::XIScrollTypeHorizontal => ScrollOrientation::Horizontal,
1041-
ffi::XIScrollTypeVertical => ScrollOrientation::Vertical,
1042-
_ => unreachable!(),
1043-
},
1044-
position: 0.0,
1035+
scroll_axes.push((info.number, ScrollAxis {
1036+
increment: info.increment,
1037+
orientation: match info.scroll_type {
1038+
ffi::XIScrollTypeHorizontal => ScrollOrientation::Horizontal,
1039+
ffi::XIScrollTypeVertical => ScrollOrientation::Vertical,
1040+
_ => unreachable!(),
10451041
},
1046-
));
1042+
position: 0.0,
1043+
}));
10471044
}
10481045
}
10491046
}

src/platform_impl/linux/x11/util/input.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ impl XConnection {
2020
mask: xinput::XIEventMask,
2121
) -> Result<VoidCookie<'_>, X11Error> {
2222
self.xcb_connection()
23-
.xinput_xi_select_events(
24-
window,
25-
&[xinput::EventMask { deviceid: device_id, mask: vec![mask] }],
26-
)
23+
.xinput_xi_select_events(window, &[xinput::EventMask {
24+
deviceid: device_id,
25+
mask: vec![mask],
26+
}])
2727
.map_err(Into::into)
2828
}
2929

src/platform_impl/orbital/event_loop.rs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -402,22 +402,16 @@ impl EventLoop {
402402
);
403403
},
404404
EventOption::Mouse(MouseEvent { x, y }) => {
405-
app.window_event(
406-
window_target,
407-
window_id,
408-
event::SurfaceEvent::PointerMoved {
409-
device_id: None,
410-
position: (x, y).into(),
411-
source: event::PointerSource::Mouse,
412-
},
413-
);
405+
app.window_event(window_target, window_id, event::SurfaceEvent::PointerMoved {
406+
device_id: None,
407+
position: (x, y).into(),
408+
source: event::PointerSource::Mouse,
409+
});
414410
},
415411
EventOption::MouseRelative(MouseRelativeEvent { dx, dy }) => {
416-
app.device_event(
417-
window_target,
418-
None,
419-
event::DeviceEvent::PointerMotion { delta: (dx as f64, dy as f64) },
420-
);
412+
app.device_event(window_target, None, event::DeviceEvent::PointerMotion {
413+
delta: (dx as f64, dy as f64),
414+
});
421415
},
422416
EventOption::Button(ButtonEvent { left, middle, right }) => {
423417
while let Some((button, state)) = event_state.mouse(left, middle, right) {
@@ -434,15 +428,11 @@ impl EventLoop {
434428
}
435429
},
436430
EventOption::Scroll(ScrollEvent { x, y }) => {
437-
app.window_event(
438-
window_target,
439-
window_id,
440-
event::SurfaceEvent::MouseWheel {
441-
device_id: None,
442-
delta: event::MouseScrollDelta::LineDelta(x as f32, y as f32),
443-
phase: event::TouchPhase::Moved,
444-
},
445-
);
431+
app.window_event(window_target, window_id, event::SurfaceEvent::MouseWheel {
432+
device_id: None,
433+
delta: event::MouseScrollDelta::LineDelta(x as f32, y as f32),
434+
phase: event::TouchPhase::Moved,
435+
});
446436
},
447437
EventOption::Quit(QuitEvent {}) => {
448438
app.window_event(window_target, window_id, event::SurfaceEvent::CloseRequested);

src/platform_impl/windows/window_state.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -362,26 +362,20 @@ impl WindowFlags {
362362

363363
if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
364364
unsafe {
365-
ShowWindow(
366-
window,
367-
match new.contains(WindowFlags::MAXIMIZED) {
368-
true => SW_MAXIMIZE,
369-
false => SW_RESTORE,
370-
},
371-
);
365+
ShowWindow(window, match new.contains(WindowFlags::MAXIMIZED) {
366+
true => SW_MAXIMIZE,
367+
false => SW_RESTORE,
368+
});
372369
}
373370
}
374371

375372
// Minimize operations should execute after maximize for proper window animations
376373
if diff.contains(WindowFlags::MINIMIZED) {
377374
unsafe {
378-
ShowWindow(
379-
window,
380-
match new.contains(WindowFlags::MINIMIZED) {
381-
true => SW_MINIMIZE,
382-
false => SW_RESTORE,
383-
},
384-
);
375+
ShowWindow(window, match new.contains(WindowFlags::MINIMIZED) {
376+
true => SW_MINIMIZE,
377+
false => SW_RESTORE,
378+
});
385379
}
386380

387381
diff.remove(WindowFlags::MINIMIZED);

src/window.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ pub trait Surface: AsAny + Send + Sync {
505505
/// [`contentScaleFactor`]: https://developer.apple.com/documentation/uikit/uiview/1622657-contentscalefactor?language=objc
506506
fn scale_factor(&self) -> f64;
507507

508-
/// Queues a [`SurfaceEvent::RedrawRequested`] event to be emitted that aligns with the windowing
509-
/// system drawing loop.
508+
/// Queues a [`SurfaceEvent::RedrawRequested`] event to be emitted that aligns with the
509+
/// windowing system drawing loop.
510510
///
511511
/// This is the **strongly encouraged** method of redrawing windows, as it can integrate with
512512
/// OS-requested redraws (e.g. when a window gets resized). To improve the event delivery
@@ -758,7 +758,8 @@ pub trait Surface: AsAny + Send + Sync {
758758
#[cfg(feature = "rwh_06")]
759759
fn rwh_06_window_handle(&self) -> &dyn rwh_06::HasWindowHandle;
760760

761-
/// Tries to downcast this surface to a [`Window`]. Returns `None` if the surface is not a window.
761+
/// Tries to downcast this surface to a [`Window`]. Returns `None` if the surface is not a
762+
/// window.
762763
fn as_window(&self) -> Option<&dyn Window> {
763764
None
764765
}

0 commit comments

Comments
 (0)