Skip to content

Commit 7ca11ae

Browse files
committed
chore: fmt
Signed-off-by: Sam Gammon <[email protected]>
1 parent f167515 commit 7ca11ae

File tree

6 files changed

+64
-75
lines changed

6 files changed

+64
-75
lines changed

src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
use std::path::PathBuf;
4141
use std::time::Instant;
4242

43+
use crate::push::PushToken;
4344
use crate::{
4445
dpi::{PhysicalPosition, PhysicalSize},
4546
keyboard::{self, ModifiersState},
4647
platform_impl,
4748
window::{Theme, WindowId},
4849
};
49-
use crate::push::PushToken;
5050

5151
/// Describes a generic event.
5252
///

src/event_loop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
//! [create_proxy]: crate::event_loop::EventLoop::create_proxy
1414
//! [event_loop_proxy]: crate::event_loop::EventLoopProxy
1515
//! [send_event]: crate::event_loop::EventLoopProxy::send_event
16-
use std::time::Instant;
17-
use std::{error, fmt, marker::PhantomData, ops::Deref};
18-
use windows::Networking::PushNotifications::PushNotificationChannel;
1916
use crate::{
2017
dpi::PhysicalPosition,
2118
error::ExternalError,
@@ -24,6 +21,9 @@ use crate::{
2421
platform_impl,
2522
window::{ProgressBarState, Theme},
2623
};
24+
use std::time::Instant;
25+
use std::{error, fmt, marker::PhantomData, ops::Deref};
26+
use windows::Networking::PushNotifications::PushNotificationChannel;
2727

2828
/// Provides a way to retrieve events from the system and from the windows that were registered to
2929
/// the events loop.

src/platform/windows.rs

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@ use windows::Win32::UI::Input::KeyboardAndMouse::*;
1919

2020
#[cfg(feature = "push-notifications")]
2121
use windows::Networking::PushNotifications::{
22-
PushNotificationChannel,
23-
PushNotificationChannelManager,
22+
PushNotificationChannel, PushNotificationChannelManager,
2423
};
2524

2625
#[cfg(feature = "push-notifications")]
27-
use {
28-
windows::Foundation::AsyncStatus,
29-
windows::Foundation::IAsyncOperation,
30-
};
26+
use {windows::Foundation::AsyncStatus, windows::Foundation::IAsyncOperation};
3127

3228
pub type HWND = isize;
3329
pub type HMENU = isize;
@@ -471,20 +467,18 @@ pub trait PushNotificationsExtWindows {
471467
return Err(1);
472468
}
473469
};
474-
let push_channel_op = match
475-
mgr.CreatePushNotificationChannelForApplicationAsync() {
470+
let push_channel_op = match mgr.CreatePushNotificationChannelForApplicationAsync() {
476471
Ok(channel) => channel,
477472
Err(_) => {
478473
return Err(2);
479474
}
480475
};
481476
// Attach callback
482-
attach_callback(push_channel_op, |result| {
483-
match result {
484-
Ok(value) => register_push_channel(value),
485-
Err(e) => println!("Operation failed with error: {:?}", e),
486-
}
487-
}).expect("failed to attach callback for windows push notification token");
477+
attach_callback(push_channel_op, |result| match result {
478+
Ok(value) => register_push_channel(value),
479+
Err(e) => println!("Operation failed with error: {:?}", e),
480+
})
481+
.expect("failed to attach callback for windows push notification token");
488482

489483
Ok(())
490484
}
@@ -498,30 +492,28 @@ fn register_push_channel(_channel: PushNotificationChannel) {
498492
#[cfg(feature = "push-notifications")]
499493
fn attach_callback<T, F>(operation: IAsyncOperation<T>, callback: F) -> windows::core::Result<()>
500494
where
501-
T: windows::core::RuntimeType + 'static,
502-
F: FnOnce(windows::core::Result<T>) + Send + Clone + Copy + 'static,
495+
T: windows::core::RuntimeType + 'static,
496+
F: FnOnce(windows::core::Result<T>) + Send + Clone + Copy + 'static,
503497
{
504498
unsafe {
505-
operation.SetCompleted(
506-
&windows::Foundation::AsyncOperationCompletedHandler::new(
507-
move |op, _| {
508-
let result = match op.unwrap().Status()? {
509-
AsyncStatus::Completed => Ok(op.unwrap().GetResults()),
510-
AsyncStatus::Canceled => Err(windows::core::Error:: new::<String>(
511-
windows::core::HRESULT(0x800704C7u32 as i32), // Operation canceled
512-
"Operation was canceled".into(),
513-
)),
514-
AsyncStatus::Error => Err(windows::core::Error::new::<String>(
515-
op.unwrap().ErrorCode().unwrap(), // Operation failed
516-
"Operation failed".into(),
517-
)),
518-
AsyncStatus::Started => unreachable!(),
519-
_ => unreachable!(),
520-
};
521-
callback(result.expect("empty waiter"));
522-
Ok(())
523-
},
524-
),
525-
)
499+
operation.SetCompleted(&windows::Foundation::AsyncOperationCompletedHandler::new(
500+
move |op, _| {
501+
let result = match op.unwrap().Status()? {
502+
AsyncStatus::Completed => Ok(op.unwrap().GetResults()),
503+
AsyncStatus::Canceled => Err(windows::core::Error::new::<String>(
504+
windows::core::HRESULT(0x800704C7u32 as i32), // Operation canceled
505+
"Operation was canceled".into(),
506+
)),
507+
AsyncStatus::Error => Err(windows::core::Error::new::<String>(
508+
op.unwrap().ErrorCode().unwrap(), // Operation failed
509+
"Operation failed".into(),
510+
)),
511+
AsyncStatus::Started => unreachable!(),
512+
_ => unreachable!(),
513+
};
514+
callback(result.expect("empty waiter"));
515+
Ok(())
516+
},
517+
))
526518
}
527519
}

src/platform_impl/macos/app_delegate.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ use cocoa::{
99
foundation::NSString,
1010
};
1111
use objc::{
12-
msg_send,
13-
sel,
14-
sel_impl,
1512
class,
1613
declare::ClassDecl,
14+
msg_send,
1715
runtime::{Class, Object, Sel, BOOL},
16+
sel, sel_impl,
1817
};
1918
use std::{
2019
cell::{RefCell, RefMut},
@@ -211,14 +210,14 @@ extern "C" fn did_fail_to_register_for_apns(_: &Object, _: Sel, _: id, err: *mut
211210
let is_error: bool = msg_send![err, isKindOfClass:class!(NSError)];
212211
if !is_error {
213212
trace!("Invalid error object type for push registration failure");
214-
return
213+
return;
215214
}
216215

217216
// Get the localizedDescription
218217
let description: *mut Object = msg_send![err, localizedDescription];
219218
if description.is_null() {
220219
trace!("Error had no description");
221-
return
220+
return;
222221
}
223222

224223
// Convert NSString to str
@@ -234,7 +233,5 @@ extern "C" fn did_fail_to_register_for_apns(_: &Object, _: Sel, _: id, err: *mut
234233
}
235234

236235
fn get_shared_application() -> *mut Object {
237-
unsafe {
238-
msg_send![class!(NSApplication), sharedApplication]
239-
}
236+
unsafe { msg_send![class!(NSApplication), sharedApplication] }
240237
}

src/platform_impl/macos/app_state.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,9 @@ impl AppState {
418418
}
419419

420420
pub fn did_register_push_token(token_data: Vec<u8>) {
421-
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::PushRegistration(token_data)));
421+
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::PushRegistration(
422+
token_data,
423+
)));
422424
}
423425

424426
pub fn did_fail_to_register_push_token(err: String) {

src/platform_impl/windows/event_loop.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,30 @@
66

77
mod runner;
88

9+
use crate::{
10+
dpi::{PhysicalPosition, PhysicalSize, PixelUnit},
11+
error::ExternalError,
12+
event::{DeviceEvent, Event, Force, RawKeyEvent, Touch, TouchPhase, WindowEvent},
13+
event_loop::{ControlFlow, DeviceEventFilter, EventLoopClosed, EventLoopWindowTarget as RootELW},
14+
keyboard::{KeyCode, ModifiersState},
15+
monitor::MonitorHandle as RootMonitorHandle,
16+
platform_impl::platform::{
17+
dark_mode::try_window_theme,
18+
dpi::{become_dpi_aware, dpi_to_scale_factor, enable_non_client_dpi_scaling},
19+
keyboard::is_msg_keyboard_related,
20+
keyboard_layout::LAYOUT_CACHE,
21+
minimal_ime::is_msg_ime_related,
22+
monitor::{self, MonitorHandle},
23+
raw_input, util,
24+
window::set_skip_taskbar,
25+
window_state::{CursorFlags, WindowFlags, WindowState},
26+
wrap_device_id, WindowId, DEVICE_ID,
27+
},
28+
window::{Fullscreen, Theme, WindowId as RootWindowId},
29+
};
930
use crossbeam_channel::{self as channel, Receiver, Sender};
1031
use parking_lot::Mutex;
32+
use runner::{EventLoopRunner, EventLoopRunnerShared};
1133
use std::{
1234
cell::Cell,
1335
collections::VecDeque,
@@ -42,33 +64,9 @@ use windows::{
4264
},
4365
},
4466
};
45-
use crate::{
46-
dpi::{PhysicalPosition, PhysicalSize, PixelUnit},
47-
error::ExternalError,
48-
event::{DeviceEvent, Event, Force, RawKeyEvent, Touch, TouchPhase, WindowEvent},
49-
event_loop::{ControlFlow, DeviceEventFilter, EventLoopClosed, EventLoopWindowTarget as RootELW},
50-
keyboard::{KeyCode, ModifiersState},
51-
monitor::MonitorHandle as RootMonitorHandle,
52-
platform_impl::platform::{
53-
dark_mode::try_window_theme,
54-
dpi::{become_dpi_aware, dpi_to_scale_factor, enable_non_client_dpi_scaling},
55-
keyboard::is_msg_keyboard_related,
56-
keyboard_layout::LAYOUT_CACHE,
57-
minimal_ime::is_msg_ime_related,
58-
monitor::{self, MonitorHandle},
59-
raw_input, util,
60-
window::set_skip_taskbar,
61-
window_state::{CursorFlags, WindowFlags, WindowState},
62-
wrap_device_id, WindowId, DEVICE_ID,
63-
},
64-
window::{Fullscreen, Theme, WindowId as RootWindowId},
65-
};
66-
use runner::{EventLoopRunner, EventLoopRunnerShared};
6767

6868
#[cfg(feature = "push-notifications")]
69-
use {
70-
windows::Networking::PushNotifications::PushNotificationChannel,
71-
};
69+
use windows::Networking::PushNotifications::PushNotificationChannel;
7270

7371
type GetPointerFrameInfoHistory = unsafe extern "system" fn(
7472
pointerId: u32,

0 commit comments

Comments
 (0)