diff --git a/.travis.yml b/.travis.yml index 3a0a3390..7e6bc833 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,11 +45,10 @@ matrix: install: - rustup self update - rustup target add $TARGET; true - - rustup install nightly - - rustup component add rustfmt --toolchain nightly + - rustup component add rustfmt script: - - cargo +nightly fmt --all -- --check + - cargo fmt --all -- --check - cargo build --target $TARGET --verbose - cargo build --target $TARGET --features serde --verbose # Running iOS apps on OSX requires the simulator so we skip that for now diff --git a/examples/cursor.rs b/examples/cursor.rs index 118a190d..d5bd34a9 100644 --- a/examples/cursor.rs +++ b/examples/cursor.rs @@ -12,37 +12,35 @@ fn main() { let mut cursor_idx = 0; - event_loop.run(move |event, _, control_flow| { - match event { - Event::WindowEvent { - event: - WindowEvent::KeyboardInput { - input: - KeyboardInput { - state: ElementState::Pressed, - .. - }, - .. - }, - .. - } => { - println!("Setting cursor to \"{:?}\"", CURSORS[cursor_idx]); - window.set_cursor_icon(CURSORS[cursor_idx]); - if cursor_idx < CURSORS.len() - 1 { - cursor_idx += 1; - } else { - cursor_idx = 0; - } - }, - Event::WindowEvent { - event: WindowEvent::CloseRequested, - .. - } => { - *control_flow = ControlFlow::Exit; - return; - }, - _ => (), + event_loop.run(move |event, _, control_flow| match event { + Event::WindowEvent { + event: + WindowEvent::KeyboardInput { + input: + KeyboardInput { + state: ElementState::Pressed, + .. + }, + .. + }, + .. + } => { + println!("Setting cursor to \"{:?}\"", CURSORS[cursor_idx]); + window.set_cursor_icon(CURSORS[cursor_idx]); + if cursor_idx < CURSORS.len() - 1 { + cursor_idx += 1; + } else { + cursor_idx = 0; + } } + Event::WindowEvent { + event: WindowEvent::CloseRequested, + .. + } => { + *control_flow = ControlFlow::Exit; + return; + } + _ => (), }); } diff --git a/examples/cursor_grab.rs b/examples/cursor_grab.rs index 028a7634..40613d70 100644 --- a/examples/cursor_grab.rs +++ b/examples/cursor_grab.rs @@ -34,7 +34,7 @@ fn main() { H => window.set_cursor_visible(modifiers.shift), _ => (), } - }, + } _ => (), } } diff --git a/examples/fullscreen.rs b/examples/fullscreen.rs index 8d521d43..27df2276 100644 --- a/examples/fullscreen.rs +++ b/examples/fullscreen.rs @@ -24,7 +24,7 @@ fn main() { let num = num.trim().parse().ok().expect("Please enter a number"); match num { 2 => macos_use_simple_fullscreen = true, - _ => {}, + _ => {} } // Prompt for monitor when using native fullscreen @@ -54,69 +54,62 @@ fn main() { *control_flow = ControlFlow::Wait; match event { - Event::WindowEvent { event, .. } => { - match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, - WindowEvent::KeyboardInput { - input: - KeyboardInput { - virtual_keycode: Some(virtual_code), - state, - .. - }, - .. - } => { - match (virtual_code, state) { - (VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit, - (VirtualKeyCode::F, ElementState::Pressed) => { - #[cfg(target_os = "macos")] - { - if macos_use_simple_fullscreen { - use winit::platform::macos::WindowExtMacOS; - if WindowExtMacOS::set_simple_fullscreen( - &window, - !is_fullscreen, - ) { - is_fullscreen = !is_fullscreen; - } - return; - } + Event::WindowEvent { event, .. } => match event { + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::KeyboardInput { + input: + KeyboardInput { + virtual_keycode: Some(virtual_code), + state, + .. + }, + .. + } => match (virtual_code, state) { + (VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit, + (VirtualKeyCode::F, ElementState::Pressed) => { + #[cfg(target_os = "macos")] + { + if macos_use_simple_fullscreen { + use winit::platform::macos::WindowExtMacOS; + if WindowExtMacOS::set_simple_fullscreen(&window, !is_fullscreen) { + is_fullscreen = !is_fullscreen; } - - is_fullscreen = !is_fullscreen; - if !is_fullscreen { - window.set_fullscreen(None); - } else { - window.set_fullscreen(Some(window.current_monitor())); - } - }, - (VirtualKeyCode::S, ElementState::Pressed) => { - println!("window.fullscreen {:?}", window.fullscreen()); - - #[cfg(target_os = "macos")] - { - use winit::platform::macos::WindowExtMacOS; - println!( - "window.simple_fullscreen {:?}", - WindowExtMacOS::simple_fullscreen(&window) - ); - } - }, - (VirtualKeyCode::M, ElementState::Pressed) => { - is_maximized = !is_maximized; - window.set_maximized(is_maximized); - }, - (VirtualKeyCode::D, ElementState::Pressed) => { - decorations = !decorations; - window.set_decorations(decorations); - }, - _ => (), + return; + } } - }, + + is_fullscreen = !is_fullscreen; + if !is_fullscreen { + window.set_fullscreen(None); + } else { + window.set_fullscreen(Some(window.current_monitor())); + } + } + (VirtualKeyCode::S, ElementState::Pressed) => { + println!("window.fullscreen {:?}", window.fullscreen()); + + #[cfg(target_os = "macos")] + { + use winit::platform::macos::WindowExtMacOS; + println!( + "window.simple_fullscreen {:?}", + WindowExtMacOS::simple_fullscreen(&window) + ); + } + } + (VirtualKeyCode::M, ElementState::Pressed) => { + is_maximized = !is_maximized; + window.set_maximized(is_maximized); + } + (VirtualKeyCode::D, ElementState::Pressed) => { + decorations = !decorations; + window.set_decorations(decorations); + } _ => (), - } + }, + _ => (), }, - _ => {}, + _ => {} } }); } diff --git a/examples/handling_close.rs b/examples/handling_close.rs index 0df014f4..d67c0046 100644 --- a/examples/handling_close.rs +++ b/examples/handling_close.rs @@ -40,7 +40,7 @@ fn main() { // action from the user, this is generally where you'd handle cleanup before // closing the window. How to close the window is detailed in the handler for // the Y key. - }, + } WindowEvent::KeyboardInput { input: KeyboardInput { @@ -63,19 +63,19 @@ fn main() { // sent. *control_flow = ControlFlow::Exit; } - }, + } N => { if close_requested { println!("Your window will continue to stay by your side."); close_requested = false; } - }, + } _ => (), } - }, + } _ => (), } - }, + } _ => (), } }); diff --git a/examples/multithreaded.rs b/examples/multithreaded.rs index 59cac69b..39f7af3d 100644 --- a/examples/multithreaded.rs +++ b/examples/multithreaded.rs @@ -39,19 +39,15 @@ fn main() { use self::VirtualKeyCode::*; match key { A => window.set_always_on_top(state), - C => { - window.set_cursor_icon(match state { - true => CursorIcon::Progress, - false => CursorIcon::Default, - }) - }, + C => window.set_cursor_icon(match state { + true => CursorIcon::Progress, + false => CursorIcon::Default, + }), D => window.set_decorations(!state), - F => { - window.set_fullscreen(match state { - true => Some(window.current_monitor()), - false => None, - }) - }, + F => window.set_fullscreen(match state { + true => Some(window.current_monitor()), + false => None, + }), G => window.set_cursor_grab(state).unwrap(), H => window.set_cursor_visible(!state), I => { @@ -60,49 +56,41 @@ fn main() { println!("-> inner_position : {:?}", window.inner_position()); println!("-> outer_size : {:?}", window.outer_size()); println!("-> inner_size : {:?}", window.inner_size()); - }, - L => { - window.set_min_inner_size(match state { - true => Some(WINDOW_SIZE.into()), - false => None, - }) - }, + } + L => window.set_min_inner_size(match state { + true => Some(WINDOW_SIZE.into()), + false => None, + }), M => window.set_maximized(state), - P => { - window.set_outer_position({ - let mut position = window.outer_position().unwrap(); - let sign = if state { 1.0 } else { -1.0 }; - position.x += 10.0 * sign; - position.y += 10.0 * sign; - position - }) - }, + P => window.set_outer_position({ + let mut position = window.outer_position().unwrap(); + let sign = if state { 1.0 } else { -1.0 }; + position.x += 10.0 * sign; + position.y += 10.0 * sign; + position + }), Q => window.request_redraw(), R => window.set_resizable(state), - S => { - window.set_inner_size( - match state { - true => (WINDOW_SIZE.0 + 100, WINDOW_SIZE.1 + 100), - false => WINDOW_SIZE, - } - .into(), + S => window.set_inner_size( + match state { + true => (WINDOW_SIZE.0 + 100, WINDOW_SIZE.1 + 100), + false => WINDOW_SIZE, + } + .into(), + ), + W => window + .set_cursor_position( + (WINDOW_SIZE.0 as i32 / 2, WINDOW_SIZE.1 as i32 / 2).into(), ) - }, - W => { - window - .set_cursor_position( - (WINDOW_SIZE.0 as i32 / 2, WINDOW_SIZE.1 as i32 / 2).into(), - ) - .unwrap() - }, + .unwrap(), Z => { window.set_visible(false); thread::sleep(Duration::from_secs(1)); window.set_visible(true); - }, + } _ => (), } - }, + } _ => (), } } @@ -114,25 +102,23 @@ fn main() { false => ControlFlow::Exit, }; match event { - Event::WindowEvent { event, window_id } => { - match event { - WindowEvent::CloseRequested - | WindowEvent::Destroyed - | WindowEvent::KeyboardInput { - input: - KeyboardInput { - virtual_keycode: Some(VirtualKeyCode::Escape), - .. - }, - .. - } => { - window_senders.remove(&window_id); - }, - _ => { - if let Some(tx) = window_senders.get(&window_id) { - tx.send(event).unwrap(); - } - }, + Event::WindowEvent { event, window_id } => match event { + WindowEvent::CloseRequested + | WindowEvent::Destroyed + | WindowEvent::KeyboardInput { + input: + KeyboardInput { + virtual_keycode: Some(VirtualKeyCode::Escape), + .. + }, + .. + } => { + window_senders.remove(&window_id); + } + _ => { + if let Some(tx) = window_senders.get(&window_id) { + tx.send(event).unwrap(); + } } }, _ => (), diff --git a/examples/multiwindow.rs b/examples/multiwindow.rs index 43a48797..61dc1fd7 100644 --- a/examples/multiwindow.rs +++ b/examples/multiwindow.rs @@ -28,7 +28,7 @@ fn main() { if windows.is_empty() { *control_flow = ControlFlow::Exit; } - }, + } WindowEvent::KeyboardInput { input: KeyboardInput { @@ -39,10 +39,10 @@ fn main() { } => { let window = Window::new(&event_loop).unwrap(); windows.insert(window.id(), window); - }, + } _ => (), } - }, + } _ => (), } }) diff --git a/examples/request_redraw.rs b/examples/request_redraw.rs index 8b4d1d56..35ef4a12 100644 --- a/examples/request_redraw.rs +++ b/examples/request_redraw.rs @@ -25,7 +25,7 @@ fn main() { Event::EventsCleared => { window.request_redraw(); *control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0)) - }, + } _ => (), } }); diff --git a/examples/resizable.rs b/examples/resizable.rs index ae30585f..8aa6f706 100644 --- a/examples/resizable.rs +++ b/examples/resizable.rs @@ -19,24 +19,22 @@ fn main() { event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Wait; match event { - Event::WindowEvent { event, .. } => { - match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, - WindowEvent::KeyboardInput { - input: - KeyboardInput { - virtual_keycode: Some(VirtualKeyCode::Space), - state: ElementState::Released, - .. - }, - .. - } => { - resizable = !resizable; - println!("Resizable: {}", resizable); - window.set_resizable(resizable); - }, - _ => (), + Event::WindowEvent { event, .. } => match event { + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::KeyboardInput { + input: + KeyboardInput { + virtual_keycode: Some(VirtualKeyCode::Space), + state: ElementState::Released, + .. + }, + .. + } => { + resizable = !resizable; + println!("Resizable: {}", resizable); + window.set_resizable(resizable); } + _ => (), }, _ => (), }; diff --git a/examples/timer.rs b/examples/timer.rs index 03e0e0ae..8d3b9bde 100644 --- a/examples/timer.rs +++ b/examples/timer.rs @@ -21,11 +21,11 @@ fn main() { match event { Event::NewEvents(StartCause::Init) => { *control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length) - }, + } Event::NewEvents(StartCause::ResumeTimeReached { .. }) => { *control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length); println!("\nTimer\n"); - }, + } Event::WindowEvent { event: WindowEvent::CloseRequested, .. diff --git a/examples/window_icon.rs b/examples/window_icon.rs index 5f47f123..4a8ad31f 100644 --- a/examples/window_icon.rs +++ b/examples/window_icon.rs @@ -43,7 +43,7 @@ fn main() { CloseRequested => *control_flow = ControlFlow::Exit, DroppedFile(path) => { window.set_window_icon(Some(load_icon(&path))); - }, + } _ => (), } } diff --git a/examples/window_run_return.rs b/examples/window_run_return.rs index 34b07d93..d2516c7a 100644 --- a/examples/window_run_return.rs +++ b/examples/window_run_return.rs @@ -14,14 +14,12 @@ fn main() { .unwrap(); println!("Close the window to continue."); - event_loop.run_return(|event, _, control_flow| { - match event { - Event::WindowEvent { - event: WindowEvent::CloseRequested, - .. - } => *control_flow = ControlFlow::Exit, - _ => *control_flow = ControlFlow::Wait, - } + event_loop.run_return(|event, _, control_flow| match event { + Event::WindowEvent { + event: WindowEvent::CloseRequested, + .. + } => *control_flow = ControlFlow::Exit, + _ => *control_flow = ControlFlow::Wait, }); drop(window); @@ -31,14 +29,12 @@ fn main() { .unwrap(); println!("Wa ha ha! You thought that closing the window would finish this?!"); - event_loop.run_return(|event, _, control_flow| { - match event { - Event::WindowEvent { - event: WindowEvent::CloseRequested, - .. - } => *control_flow = ControlFlow::Exit, - _ => *control_flow = ControlFlow::Wait, - } + event_loop.run_return(|event, _, control_flow| match event { + Event::WindowEvent { + event: WindowEvent::CloseRequested, + .. + } => *control_flow = ControlFlow::Exit, + _ => *control_flow = ControlFlow::Wait, }); println!("Okay we're done now for real."); diff --git a/rustfmt.toml b/rustfmt.toml index 285acaed..a069b434 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,7 +1,3 @@ -merge_imports=true -match_block_trailing_comma=true force_explicit_abi=true -format_macro_matchers=true use_field_init_shorthand=true -format_code_in_doc_comments=true -force_multiline_blocks=true +# merge_imports=true diff --git a/src/platform/unix.rs b/src/platform/unix.rs index 420e062c..494ed398 100644 --- a/src/platform/unix.rs +++ b/src/platform/unix.rs @@ -122,11 +122,9 @@ pub trait EventLoopExtUnix { impl EventLoopExtUnix for EventLoop { #[inline] fn new_x11() -> Result { - LinuxEventLoop::new_x11().map(|ev| { - EventLoop { - event_loop: ev, - _marker: ::std::marker::PhantomData, - } + LinuxEventLoop::new_x11().map(|ev| EventLoop { + event_loop: ev, + _marker: ::std::marker::PhantomData, }) } @@ -294,7 +292,7 @@ impl WindowExtUnix for Window { fn set_wayland_theme(&self, theme: WaylandTheme) { match self.window { LinuxWindow::Wayland(ref w) => w.set_theme(WaylandThemeObject(theme)), - _ => {}, + _ => {} } } diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index c286dfd8..42430d01 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -79,21 +79,21 @@ impl EventLoop { device_id: DEVICE_ID, }), }) - }, + } android_glue::Event::InitWindow => { // The activity went to foreground. if let Some(cb) = self.suspend_callback.borrow().as_ref() { (*cb)(false); } Some(Event::Resumed) - }, + } android_glue::Event::TermWindow => { // The activity went to background. if let Some(cb) = self.suspend_callback.borrow().as_ref() { (*cb)(true); } Some(Event::Suspended) - }, + } android_glue::Event::WindowResized | android_glue::Event::ConfigChanged => { // Activity Orientation changed or resized. let native_window = unsafe { android_glue::native_window() }; @@ -108,14 +108,14 @@ impl EventLoop { event: WindowEvent::Resized(size), }) } - }, + } android_glue::Event::WindowRedrawNeeded => { // The activity needs to be redrawn. Some(Event::WindowEvent { window_id: RootWindowId(WindowId), event: WindowEvent::Redraw, }) - }, + } android_glue::Event::Wake => Some(Event::Awakened), _ => None, }; diff --git a/src/platform_impl/emscripten/mod.rs b/src/platform_impl/emscripten/mod.rs index 4af96f97..9148dab0 100644 --- a/src/platform_impl/emscripten/mod.rs +++ b/src/platform_impl/emscripten/mod.rs @@ -251,7 +251,7 @@ extern "C" fn mouse_callback( delta: ((*event).movementX as f64, (*event).movementY as f64), }, }); - }, + } mouse_input @ ffi::EMSCRIPTEN_EVENT_MOUSEDOWN | mouse_input @ ffi::EMSCRIPTEN_EVENT_MOUSEUP => { let button = match (*event).button { @@ -274,8 +274,8 @@ extern "C" fn mouse_callback( modifiers, }, }) - }, - _ => {}, + } + _ => {} } } ffi::EM_FALSE @@ -310,7 +310,7 @@ extern "C" fn keyboard_callback( }, }, }); - }, + } ffi::EMSCRIPTEN_EVENT_KEYUP => { queue.lock().unwrap().push_back(::Event::WindowEvent { window_id: ::WindowId(WindowId(0)), @@ -324,8 +324,8 @@ extern "C" fn keyboard_callback( }, }, }); - }, - _ => {}, + } + _ => {} } } ffi::EM_FALSE @@ -757,7 +757,7 @@ fn error_to_str(code: ffi::EMSCRIPTEN_RESULT) -> &'static str { match code { ffi::EMSCRIPTEN_RESULT_SUCCESS | ffi::EMSCRIPTEN_RESULT_DEFERRED => { "Internal error in the library (success detected as failure)" - }, + } ffi::EMSCRIPTEN_RESULT_NOT_SUPPORTED => "Not supported", ffi::EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED => "Failed not deferred", @@ -778,7 +778,7 @@ fn key_translate(input: [ffi::EM_UTF8; ffi::EM_HTML5_SHORT_STRING_LEN_BYTES]) -> Ok(key) => key, Err(_) => { return 0; - }, + } }; if key.chars().count() == 1 { key.as_bytes()[0] @@ -797,25 +797,21 @@ fn key_translate_virt( Ok(key) => key, Err(_) => { return None; - }, + } }; use VirtualKeyCode::*; match key { - "Alt" => { - match location { - ffi::DOM_KEY_LOCATION_LEFT => Some(LAlt), - ffi::DOM_KEY_LOCATION_RIGHT => Some(RAlt), - _ => None, - } + "Alt" => match location { + ffi::DOM_KEY_LOCATION_LEFT => Some(LAlt), + ffi::DOM_KEY_LOCATION_RIGHT => Some(RAlt), + _ => None, }, "AltGraph" => None, "CapsLock" => None, - "Control" => { - match location { - ffi::DOM_KEY_LOCATION_LEFT => Some(LControl), - ffi::DOM_KEY_LOCATION_RIGHT => Some(RControl), - _ => None, - } + "Control" => match location { + ffi::DOM_KEY_LOCATION_LEFT => Some(LControl), + ffi::DOM_KEY_LOCATION_RIGHT => Some(RControl), + _ => None, }, "Fn" => None, "FnLock" => None, @@ -823,22 +819,18 @@ fn key_translate_virt( "Meta" => None, "NumLock" => Some(Numlock), "ScrollLock" => Some(Scroll), - "Shift" => { - match location { - ffi::DOM_KEY_LOCATION_LEFT => Some(LShift), - ffi::DOM_KEY_LOCATION_RIGHT => Some(RShift), - _ => None, - } + "Shift" => match location { + ffi::DOM_KEY_LOCATION_LEFT => Some(LShift), + ffi::DOM_KEY_LOCATION_RIGHT => Some(RShift), + _ => None, }, "Super" => None, "Symbol" => None, "SymbolLock" => None, - "Enter" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadEnter), - _ => Some(Return), - } + "Enter" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadEnter), + _ => Some(Return), }, "Tab" => Some(Tab), " " => Some(Space), @@ -1163,65 +1155,45 @@ fn key_translate_virt( "Divide" => Some(Divide), "Subtract" | "-" => Some(Subtract), "Separator" => None, - "0" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad0), - _ => Some(Key0), - } + "0" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad0), + _ => Some(Key0), }, - "1" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad1), - _ => Some(Key1), - } + "1" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad1), + _ => Some(Key1), }, - "2" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad2), - _ => Some(Key2), - } + "2" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad2), + _ => Some(Key2), }, - "3" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad3), - _ => Some(Key3), - } + "3" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad3), + _ => Some(Key3), }, - "4" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad4), - _ => Some(Key4), - } + "4" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad4), + _ => Some(Key4), }, - "5" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad5), - _ => Some(Key5), - } + "5" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad5), + _ => Some(Key5), }, - "6" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad6), - _ => Some(Key6), - } + "6" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad6), + _ => Some(Key6), }, - "7" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad7), - _ => Some(Key7), - } + "7" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad7), + _ => Some(Key7), }, - "8" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad8), - _ => Some(Key8), - } + "8" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad8), + _ => Some(Key8), }, - "9" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad9), - _ => Some(Key9), - } + "9" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(Numpad9), + _ => Some(Key9), }, "A" | "a" => Some(A), @@ -1254,17 +1226,13 @@ fn key_translate_virt( "'" => Some(Apostrophe), "\\" => Some(Backslash), ":" => Some(Colon), - "," => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadComma), - _ => Some(Comma), - } + "," => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadComma), + _ => Some(Comma), }, - "=" => { - match location { - ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadEquals), - _ => Some(Equals), - } + "=" => match location { + ffi::DOM_KEY_LOCATION_NUMPAD => Some(NumpadEquals), + _ => Some(Equals), }, "{" => Some(LBracket), "." => Some(Period), diff --git a/src/platform_impl/ios/app_state.rs b/src/platform_impl/ios/app_state.rs index f070f641..5b982b14 100644 --- a/src/platform_impl/ios/app_state.rs +++ b/src/platform_impl/ios/app_state.rs @@ -71,7 +71,7 @@ impl Drop for AppStateImpl { let () = msg_send![window, release]; } }, - _ => {}, + _ => {} } } } @@ -128,15 +128,13 @@ impl AppState { queued_windows.push(window); msg_send![window, retain]; return; - }, - &mut AppStateImpl::ProcessingEvents { .. } => {}, - &mut AppStateImpl::InUserCallback { .. } => {}, - &mut AppStateImpl::Terminated => { - panic!( - "Attempt to create a `Window` \ - after the app has terminated" - ) - }, + } + &mut AppStateImpl::ProcessingEvents { .. } => {} + &mut AppStateImpl::InUserCallback { .. } => {} + &mut AppStateImpl::Terminated => panic!( + "Attempt to create a `Window` \ + after the app has terminated" + ), app_state => unreachable!("unexpected state: {:#?}", app_state), /* all other cases should be impossible */ } drop(this); @@ -154,13 +152,11 @@ impl AppState { let windows = ptr::read(queued_windows); let events = ptr::read(queued_events); (windows, events) - }, - _ => { - panic!( - "winit iOS expected the app to be in a `NotLaunched` \ - state, but was not - please file an issue" - ) - }, + } + _ => panic!( + "winit iOS expected the app to be in a `NotLaunched` \ + state, but was not - please file an issue" + ), }; ptr::write( &mut this.app_state, @@ -180,12 +176,10 @@ impl AppState { ref mut queued_windows, .. } => mem::replace(queued_windows, Vec::new()), - _ => { - panic!( - "winit iOS expected the app to be in a `Launching` \ - state, but was not - please file an issue" - ) - }, + _ => panic!( + "winit iOS expected the app to be in a `Launching` \ + state, but was not - please file an issue" + ), }; // have to drop RefMut because the window setup code below can trigger new events drop(this); @@ -228,13 +222,11 @@ impl AppState { let events = ptr::read(queued_events); let event_handler = ptr::read(queued_event_handler); (windows, events, event_handler) - }, - _ => { - panic!( - "winit iOS expected the app to be in a `Launching` \ - state, but was not - please file an issue" - ) - }, + } + _ => panic!( + "winit iOS expected the app to be in a `Launching` \ + state, but was not - please file an issue" + ), }; ptr::write( &mut this.app_state, @@ -283,7 +275,7 @@ impl AppState { }, ); Event::NewEvents(StartCause::Poll) - }, + } ControlFlow::Wait => { let (event_handler, start) = match &mut this.app_state { &mut AppStateImpl::NotLaunched { .. } @@ -305,7 +297,7 @@ impl AppState { start, requested_resume: None, }) - }, + } ControlFlow::WaitUntil(requested_resume) => { let (event_handler, start) = match &mut this.app_state { &mut AppStateImpl::NotLaunched { .. } @@ -334,7 +326,7 @@ impl AppState { requested_resume: Some(requested_resume), }) } - }, + } ControlFlow::Exit => bug!("unexpected controlflow `Exit`"), }; drop(this); @@ -365,7 +357,7 @@ impl AppState { } => { queued_events.extend(events); return; - }, + } &mut AppStateImpl::ProcessingEvents { ref mut event_handler, ref mut active_control_flow, @@ -461,7 +453,7 @@ impl AppState { let mut this = AppState::get_mut(); match &mut this.app_state { &mut AppStateImpl::NotLaunched { .. } | &mut AppStateImpl::Launching { .. } => return, - &mut AppStateImpl::ProcessingEvents { .. } => {}, + &mut AppStateImpl::ProcessingEvents { .. } => {} _ => unreachable!(), }; drop(this); @@ -474,25 +466,21 @@ impl AppState { &mut AppStateImpl::ProcessingEvents { ref mut event_handler, ref mut active_control_flow, - } => { - ( - ManuallyDrop::new(ptr::read(event_handler)), - *active_control_flow, - ) - }, + } => ( + ManuallyDrop::new(ptr::read(event_handler)), + *active_control_flow, + ), _ => unreachable!(), }; let new = this.control_flow; match (old, new) { - (ControlFlow::Poll, ControlFlow::Poll) => { - ptr::write( - &mut this.app_state, - AppStateImpl::PollFinished { - waiting_event_handler: ManuallyDrop::into_inner(event_handler), - }, - ) - }, + (ControlFlow::Poll, ControlFlow::Poll) => ptr::write( + &mut this.app_state, + AppStateImpl::PollFinished { + waiting_event_handler: ManuallyDrop::into_inner(event_handler), + }, + ), (ControlFlow::Wait, ControlFlow::Wait) => { let start = Instant::now(); ptr::write( @@ -502,7 +490,7 @@ impl AppState { start, }, ) - }, + } (ControlFlow::WaitUntil(old_instant), ControlFlow::WaitUntil(new_instant)) if old_instant == new_instant => { @@ -525,7 +513,7 @@ impl AppState { }, ); this.waker.stop() - }, + } (_, ControlFlow::WaitUntil(new_instant)) => { let start = Instant::now(); ptr::write( @@ -536,7 +524,7 @@ impl AppState { }, ); this.waker.start_at(new_instant) - }, + } (_, ControlFlow::Poll) => { ptr::write( &mut this.app_state, @@ -545,13 +533,13 @@ impl AppState { }, ); this.waker.start() - }, + } (_, ControlFlow::Exit) => { // https://developer.apple.com/library/archive/qa/qa1561/_index.html // it is not possible to quit an iOS app gracefully and programatically warn!("`ControlFlow::Exit` ignored on iOS"); this.control_flow = old - }, + } } } diff --git a/src/platform_impl/ios/ffi.rs b/src/platform_impl/ios/ffi.rs index 132230d3..9b0c26be 100644 --- a/src/platform_impl/ios/ffi.rs +++ b/src/platform_impl/ios/ffi.rs @@ -161,14 +161,14 @@ impl UIInterfaceOrientationMask { match (valid_orientations, idiom) { (ValidOrientations::LandscapeAndPortrait, Idiom::Phone) => { UIInterfaceOrientationMask::AllButUpsideDown - }, + } (ValidOrientations::LandscapeAndPortrait, _) => UIInterfaceOrientationMask::All, (ValidOrientations::Landscape, _) => UIInterfaceOrientationMask::Landscape, (ValidOrientations::Portrait, Idiom::Phone) => UIInterfaceOrientationMask::Portrait, (ValidOrientations::Portrait, _) => { UIInterfaceOrientationMask::Portrait | UIInterfaceOrientationMask::PortraitUpsideDown - }, + } } } } diff --git a/src/platform_impl/ios/window.rs b/src/platform_impl/ios/window.rs index 890ef748..ea4f022f 100644 --- a/src/platform_impl/ios/window.rs +++ b/src/platform_impl/ios/window.rs @@ -170,7 +170,7 @@ impl Inner { let () = msg_send![self.window, setScreen: uiscreen]; } let () = msg_send![self.window, setFrame: bounds]; - }, + } None => warn!("`Window::set_fullscreen(None)` ignored on iOS"), } } @@ -301,14 +301,12 @@ impl Window { let screen_bounds: CGRect = msg_send![screen, bounds]; let frame = match window_attributes.inner_size { - Some(dim) => { - CGRect { - origin: screen_bounds.origin, - size: CGSize { - width: dim.width, - height: dim.height, - }, - } + Some(dim) => CGRect { + origin: screen_bounds.origin, + size: CGSize { + width: dim.width, + height: dim.height, + }, }, None => screen_bounds, }; diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index 4258d936..62366a13 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -158,10 +158,10 @@ impl Window { match *window_target { EventLoopWindowTarget::Wayland(ref window_target) => { wayland::Window::new(window_target, attribs, pl_attribs).map(Window::Wayland) - }, + } EventLoopWindowTarget::X(ref window_target) => { x11::Window::new(window_target, attribs, pl_attribs).map(Window::X) - }, + } } } @@ -313,13 +313,9 @@ impl Window { pub fn fullscreen(&self) -> Option { match self { &Window::X(ref w) => w.fullscreen(), - &Window::Wayland(ref w) => { - w.fullscreen().map(|monitor_id| { - RootMonitorHandle { - inner: MonitorHandle::Wayland(monitor_id), - } - }) - }, + &Window::Wayland(ref w) => w.fullscreen().map(|monitor_id| RootMonitorHandle { + inner: MonitorHandle::Wayland(monitor_id), + }), } } @@ -374,15 +370,11 @@ impl Window { #[inline] pub fn current_monitor(&self) -> RootMonitorHandle { match self { - &Window::X(ref window) => { - RootMonitorHandle { - inner: MonitorHandle::X(window.current_monitor()), - } + &Window::X(ref window) => RootMonitorHandle { + inner: MonitorHandle::X(window.current_monitor()), }, - &Window::Wayland(ref window) => { - RootMonitorHandle { - inner: MonitorHandle::Wayland(window.current_monitor()), - } + &Window::Wayland(ref window) => RootMonitorHandle { + inner: MonitorHandle::Wayland(window.current_monitor()), }, } } @@ -390,20 +382,16 @@ impl Window { #[inline] pub fn available_monitors(&self) -> VecDeque { match self { - &Window::X(ref window) => { - window - .available_monitors() - .into_iter() - .map(MonitorHandle::X) - .collect() - }, - &Window::Wayland(ref window) => { - window - .available_monitors() - .into_iter() - .map(MonitorHandle::Wayland) - .collect() - }, + &Window::X(ref window) => window + .available_monitors() + .into_iter() + .map(MonitorHandle::X) + .collect(), + &Window::Wayland(ref window) => window + .available_monitors() + .into_iter() + .map(MonitorHandle::Wayland) + .collect(), } } @@ -464,16 +452,14 @@ impl EventLoop { "x11" => { // TODO: propagate return EventLoop::new_x11().expect("Failed to initialize X11 backend"); - }, + } "wayland" => { return EventLoop::new_wayland().expect("Failed to initialize Wayland backend"); - }, - _ => { - panic!( - "Unknown environment variable value for {}, try one of `x11`,`wayland`", - BACKEND_PREFERENCE_ENV_VAR, - ) - }, + } + _ => panic!( + "Unknown environment variable value for {}, try one of `x11`,`wayland`", + BACKEND_PREFERENCE_ENV_VAR, + ), } } @@ -511,19 +497,17 @@ impl EventLoop { #[inline] pub fn available_monitors(&self) -> VecDeque { match *self { - EventLoop::Wayland(ref evlp) => { - evlp.available_monitors() - .into_iter() - .map(MonitorHandle::Wayland) - .collect() - }, - EventLoop::X(ref evlp) => { - evlp.x_connection() - .available_monitors() - .into_iter() - .map(MonitorHandle::X) - .collect() - }, + EventLoop::Wayland(ref evlp) => evlp + .available_monitors() + .into_iter() + .map(MonitorHandle::Wayland) + .collect(), + EventLoop::X(ref evlp) => evlp + .x_connection() + .available_monitors() + .into_iter() + .map(MonitorHandle::X) + .collect(), } } diff --git a/src/platform_impl/linux/wayland/event_loop.rs b/src/platform_impl/linux/wayland/event_loop.rs index 09b851a7..8fa7c994 100644 --- a/src/platform_impl/linux/wayland/event_loop.rs +++ b/src/platform_impl/linux/wayland/event_loop.rs @@ -137,22 +137,20 @@ impl EventLoop { let env = Environment::from_display_with_cb( &display, &mut event_queue, - move |event, registry| { - match event { - GlobalEvent::New { - id, - ref interface, - version, - } => { - if interface == "wl_seat" { - seat_manager.add_seat(id, version, registry) - } - }, - GlobalEvent::Removed { id, ref interface } => { - if interface == "wl_seat" { - seat_manager.remove_seat(id) - } - }, + move |event, registry| match event { + GlobalEvent::New { + id, + ref interface, + version, + } => { + if interface == "wl_seat" { + seat_manager.add_seat(id, version, registry) + } + } + GlobalEvent::Removed { id, ref interface } => { + if interface == "wl_seat" { + seat_manager.remove_seat(id) + } } }, ) @@ -299,7 +297,7 @@ impl EventLoop { &self.window_target, &mut control_flow, ); - }, + } ControlFlow::Wait => { self.inner_loop.dispatch(None, &mut ()).unwrap(); callback( @@ -310,7 +308,7 @@ impl EventLoop { &self.window_target, &mut control_flow, ); - }, + } ControlFlow::WaitUntil(deadline) => { let start = Instant::now(); // compute the blocking duration @@ -344,7 +342,7 @@ impl EventLoop { &mut control_flow, ); } - }, + } } } @@ -536,7 +534,7 @@ impl SeatData { } } } - }, + } _ => unreachable!(), } } @@ -648,12 +646,10 @@ impl MonitorHandle { .with_info(&self.proxy, |_, info| info.modes.clone()) .unwrap_or(vec![]) .into_iter() - .map(|x| { - VideoMode { - size: (x.dimensions.0 as u32, x.dimensions.1 as u32), - refresh_rate: (x.refresh_rate as f32 / 1000.0).round() as u16, - bit_depth: 32, - } + .map(|x| VideoMode { + size: (x.dimensions.0 as u32, x.dimensions.1 as u32), + refresh_rate: (x.refresh_rate as f32 / 1000.0).round() as u16, + bit_depth: 32, }) } } @@ -674,11 +670,9 @@ pub fn primary_monitor(outputs: &OutputMgr) -> MonitorHandle { pub fn available_monitors(outputs: &OutputMgr) -> VecDeque { outputs.with_all(|list| { list.iter() - .map(|&(_, ref proxy, _)| { - MonitorHandle { - proxy: proxy.clone(), - mgr: outputs.clone(), - } + .map(|&(_, ref proxy, _)| MonitorHandle { + proxy: proxy.clone(), + mgr: outputs.clone(), }) .collect() }) diff --git a/src/platform_impl/linux/wayland/keyboard.rs b/src/platform_impl/linux/wayland/keyboard.rs index 42809482..4002603d 100644 --- a/src/platform_impl/linux/wayland/keyboard.rs +++ b/src/platform_impl/linux/wayland/keyboard.rs @@ -31,12 +31,12 @@ pub fn init_keyboard( let wid = make_wid(&surface); my_sink.send((WindowEvent::Focused(true), wid)).unwrap(); *target.lock().unwrap() = Some(wid); - }, + } KbEvent::Leave { surface, .. } => { let wid = make_wid(&surface); my_sink.send((WindowEvent::Focused(false), wid)).unwrap(); *target.lock().unwrap() = None; - }, + } KbEvent::Key { rawkey, keysym, @@ -79,8 +79,8 @@ pub fn init_keyboard( } } } - }, - KbEvent::RepeatInfo { .. } => { /* Handled by smithay client toolkit */ }, + } + KbEvent::RepeatInfo { .. } => { /* Handled by smithay client toolkit */ } KbEvent::Modifiers { modifiers: event_modifiers, } => *modifiers_tracker.lock().unwrap() = event_modifiers.into(), @@ -133,53 +133,49 @@ pub fn init_keyboard( // } seat.get_keyboard(|keyboard| { keyboard.implement_closure( - move |evt, _| { - match evt { - wl_keyboard::Event::Enter { surface, .. } => { - let wid = make_wid(&surface); - my_sink.send((WindowEvent::Focused(true), wid)).unwrap(); - target = Some(wid); - }, - wl_keyboard::Event::Leave { surface, .. } => { - let wid = make_wid(&surface); - my_sink.send((WindowEvent::Focused(false), wid)).unwrap(); - target = None; - }, - wl_keyboard::Event::Key { key, state, .. } => { - if let Some(wid) = target { - let state = match state { - wl_keyboard::KeyState::Pressed => ElementState::Pressed, - wl_keyboard::KeyState::Released => ElementState::Released, - _ => unreachable!(), - }; - my_sink - .send(( - WindowEvent::KeyboardInput { - device_id: crate::event::DeviceId( - crate::platform_impl::DeviceId::Wayland( - DeviceId, - ), - ), - input: KeyboardInput { - state, - scancode: key, - virtual_keycode: None, - modifiers: ModifiersState::default(), - }, - }, - wid, - )) - .unwrap(); - } - }, - _ => (), + move |evt, _| match evt { + wl_keyboard::Event::Enter { surface, .. } => { + let wid = make_wid(&surface); + my_sink.send((WindowEvent::Focused(true), wid)).unwrap(); + target = Some(wid); } + wl_keyboard::Event::Leave { surface, .. } => { + let wid = make_wid(&surface); + my_sink.send((WindowEvent::Focused(false), wid)).unwrap(); + target = None; + } + wl_keyboard::Event::Key { key, state, .. } => { + if let Some(wid) = target { + let state = match state { + wl_keyboard::KeyState::Pressed => ElementState::Pressed, + wl_keyboard::KeyState::Released => ElementState::Released, + _ => unreachable!(), + }; + my_sink + .send(( + WindowEvent::KeyboardInput { + device_id: crate::event::DeviceId( + crate::platform_impl::DeviceId::Wayland(DeviceId), + ), + input: KeyboardInput { + state, + scancode: key, + virtual_keycode: None, + modifiers: ModifiersState::default(), + }, + }, + wid, + )) + .unwrap(); + } + } + _ => (), }, (), ) }) .unwrap() - }, + } } } diff --git a/src/platform_impl/linux/wayland/pointer.rs b/src/platform_impl/linux/wayland/pointer.rs index 425bfb1b..b2f00d89 100644 --- a/src/platform_impl/linux/wayland/pointer.rs +++ b/src/platform_impl/linux/wayland/pointer.rs @@ -56,7 +56,7 @@ pub fn implement_pointer( wid, ); } - }, + } PtrEvent::Leave { surface, .. } => { mouse_focus = None; let wid = store.find_wid(&surface); @@ -70,7 +70,7 @@ pub fn implement_pointer( wid, ); } - }, + } PtrEvent::Motion { surface_x, surface_y, @@ -88,7 +88,7 @@ pub fn implement_pointer( wid, ); } - }, + } PtrEvent::Button { button, state, .. } => { if let Some(wid) = mouse_focus { let state = match state { @@ -115,7 +115,7 @@ pub fn implement_pointer( wid, ); } - }, + } PtrEvent::Axis { axis, value, .. } => { if let Some(wid) = mouse_focus { if pointer.as_ref().version() < 5 { @@ -155,7 +155,7 @@ pub fn implement_pointer( } } } - }, + } PtrEvent::Frame => { let axis_buffer = axis_buffer.take(); let axis_discrete_buffer = axis_discrete_buffer.take(); @@ -188,11 +188,11 @@ pub fn implement_pointer( ); } } - }, + } PtrEvent::AxisSource { .. } => (), PtrEvent::AxisStop { .. } => { axis_state = TouchPhase::Ended; - }, + } PtrEvent::AxisDiscrete { axis, discrete } => { let (mut x, mut y) = axis_discrete_buffer.unwrap_or((0, 0)); match axis { @@ -206,7 +206,7 @@ pub fn implement_pointer( TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved, _ => TouchPhase::Started, } - }, + } _ => unreachable!(), } }, diff --git a/src/platform_impl/linux/wayland/touch.rs b/src/platform_impl/linux/wayland/touch.rs index 2a7858c7..916c4536 100644 --- a/src/platform_impl/linux/wayland/touch.rs +++ b/src/platform_impl/linux/wayland/touch.rs @@ -49,7 +49,7 @@ pub(crate) fn implement_touch( id, }); } - }, + } TouchEvent::Up { id, .. } => { let idx = pending_ids.iter().position(|p| p.id == id); if let Some(idx) = idx { @@ -66,7 +66,7 @@ pub(crate) fn implement_touch( pt.wid, ); } - }, + } TouchEvent::Motion { id, x, y, .. } => { let pt = pending_ids.iter_mut().find(|p| p.id == id); if let Some(pt) = pt { @@ -83,7 +83,7 @@ pub(crate) fn implement_touch( pt.wid, ); } - }, + } TouchEvent::Frame => (), TouchEvent::Cancel => { for pt in pending_ids.drain(..) { @@ -99,7 +99,7 @@ pub(crate) fn implement_touch( pt.wid, ); } - }, + } _ => unreachable!(), } }, diff --git a/src/platform_impl/linux/wayland/window.rs b/src/platform_impl/linux/wayland/window.rs index 2f692050..bad69b4d 100644 --- a/src/platform_impl/linux/wayland/window.rs +++ b/src/platform_impl/linux/wayland/window.rs @@ -107,7 +107,7 @@ impl Window { return; } } - }, + } WEvent::Refresh => { let store = window_store.lock().unwrap(); for window in &store.windows { @@ -116,7 +116,7 @@ impl Window { return; } } - }, + } WEvent::Close => { let mut store = window_store.lock().unwrap(); for window in &mut store.windows { @@ -125,7 +125,7 @@ impl Window { return; } } - }, + } } }, ) diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index 153fdcd6..edabc02a 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -118,7 +118,7 @@ impl EventProcessor { wt.xconn .check_errors() .expect("Failed to call XRefreshKeyboardMapping"); - }, + } ffi::ClientMessage => { let client_msg: &ffi::XClientMessageEvent = xev.as_ref(); @@ -236,7 +236,7 @@ impl EventProcessor { event: WindowEvent::HoveredFileCancelled, }); } - }, + } ffi::SelectionNotify => { let xsel: &ffi::XSelectionEvent = xev.as_ref(); @@ -263,7 +263,7 @@ impl EventProcessor { self.dnd.result = result; } - }, + } ffi::ConfigureNotify => { #[derive(Debug, Default)] @@ -429,7 +429,7 @@ impl EventProcessor { callback(Event::WindowEvent { window_id, event }); } } - }, + } ffi::ReparentNotify => { let xev: &ffi::XReparentEvent = xev.as_ref(); @@ -444,7 +444,7 @@ impl EventProcessor { self.with_window(xev.window, |window| { window.invalidate_cached_frame_extents(); }); - }, + } ffi::DestroyNotify => { let xev: &ffi::XDestroyWindowEvent = xev.as_ref(); @@ -467,7 +467,7 @@ impl EventProcessor { window_id, event: WindowEvent::Destroyed, }); - }, + } ffi::Expose => { let xev: &ffi::XExposeEvent = xev.as_ref(); @@ -479,7 +479,7 @@ impl EventProcessor { window_id, event: WindowEvent::RedrawRequested, }); - }, + } ffi::KeyPress | ffi::KeyRelease => { use crate::event::ElementState::{Pressed, Released}; @@ -554,7 +554,7 @@ impl EventProcessor { callback(event); } } - }, + } ffi::GenericEvent => { let guard = if let Some(e) = GenericEventCookie::from_event(&wt.xconn, *xev) { @@ -596,39 +596,33 @@ impl EventProcessor { Released }; match xev.detail as u32 { - ffi::Button1 => { - callback(Event::WindowEvent { - window_id, - event: MouseInput { - device_id, - state, - button: Left, - modifiers, - }, - }) - }, - ffi::Button2 => { - callback(Event::WindowEvent { - window_id, - event: MouseInput { - device_id, - state, - button: Middle, - modifiers, - }, - }) - }, - ffi::Button3 => { - callback(Event::WindowEvent { - window_id, - event: MouseInput { - device_id, - state, - button: Right, - modifiers, - }, - }) - }, + ffi::Button1 => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Left, + modifiers, + }, + }), + ffi::Button2 => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Middle, + modifiers, + }, + }), + ffi::Button3 => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Right, + modifiers, + }, + }), // Suppress emulated scroll wheel clicks, since we handle the real motion events for those. // In practice, even clicky scroll wheels appear to be reported by evdev (and XInput2 in @@ -651,21 +645,19 @@ impl EventProcessor { }, }); } - }, + } - x => { - callback(Event::WindowEvent { - window_id, - event: MouseInput { - device_id, - state, - button: Other(x as u8), - modifiers, - }, - }) - }, + x => callback(Event::WindowEvent { + window_id, + event: MouseInput { + device_id, + state, + button: Other(x as u8), + modifiers, + }, + }), } - }, + } ffi::XI_Motion => { let xev: &ffi::XIDeviceEvent = unsafe { &*(xev.data as *const _) }; let device_id = mkdid(xev.deviceid); @@ -734,11 +726,11 @@ impl EventProcessor { delta: match info.orientation { ScrollOrientation::Horizontal => { LineDelta(delta as f32, 0.0) - }, + } // X11 vertical scroll coordinates are opposite to winit's ScrollOrientation::Vertical => { LineDelta(0.0, -delta as f32) - }, + } }, phase: TouchPhase::Moved, modifiers, @@ -761,7 +753,7 @@ impl EventProcessor { for event in events { callback(event); } - }, + } ffi::XI_Enter => { let xev: &ffi::XIEnterEvent = unsafe { &*(xev.data as *const _) }; @@ -821,7 +813,7 @@ impl EventProcessor { }, }); } - }, + } ffi::XI_Leave => { let xev: &ffi::XILeaveEvent = unsafe { &*(xev.data as *const _) }; @@ -836,7 +828,7 @@ impl EventProcessor { }, }); } - }, + } ffi::XI_FocusIn => { let xev: &ffi::XIFocusInEvent = unsafe { &*(xev.data as *const _) }; @@ -878,7 +870,7 @@ impl EventProcessor { modifiers: ModifiersState::from(xev.mods), }, }); - }, + } ffi::XI_FocusOut => { let xev: &ffi::XIFocusOutEvent = unsafe { &*(xev.data as *const _) }; if !self.window_exists(xev.event) { @@ -892,7 +884,7 @@ impl EventProcessor { window_id: mkwid(xev.event), event: Focused(false), }) - }, + } ffi::XI_TouchBegin | ffi::XI_TouchUpdate | ffi::XI_TouchEnd => { let xev: &ffi::XIDeviceEvent = unsafe { &*(xev.data as *const _) }; @@ -920,7 +912,7 @@ impl EventProcessor { }), }) } - }, + } ffi::XI_RawButtonPress | ffi::XI_RawButtonRelease => { let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) }; @@ -937,7 +929,7 @@ impl EventProcessor { }, }); } - }, + } ffi::XI_RawMotion => { let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) }; @@ -962,7 +954,7 @@ impl EventProcessor { 1 => mouse_delta.1 = x, 2 => scroll_delta.0 = x as f32, 3 => scroll_delta.1 = x as f32, - _ => {}, + _ => {} } callback(Event::DeviceEvent { device_id: did, @@ -988,7 +980,7 @@ impl EventProcessor { }, }); } - }, + } ffi::XI_RawKeyPress | ffi::XI_RawKeyRelease => { let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) }; @@ -1033,7 +1025,7 @@ impl EventProcessor { modifiers: ModifiersState::default(), }), }); - }, + } ffi::XI_HierarchyChanged => { let xev: &ffi::XIHierarchyEvent = unsafe { &*(xev.data as *const _) }; @@ -1056,11 +1048,11 @@ impl EventProcessor { devices.remove(&DeviceId(info.deviceid)); } } - }, + } - _ => {}, + _ => {} } - }, + } _ => { if event_type == self.randr_event_offset { // In the future, it would be quite easy to emit monitor hotplug events. @@ -1101,13 +1093,13 @@ impl EventProcessor { } } } - }, + } } match self.ime_receiver.try_recv() { Ok((window_id, x, y)) => { wt.ime.borrow_mut().send_xim_spot(window_id, x, y); - }, + } Err(_) => (), } } diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 1ad75c29..0f8b9b1a 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -308,7 +308,7 @@ impl EventLoop { &self.target, &mut control_flow, ); - }, + } ControlFlow::Wait => { self.inner_loop.dispatch(None, &mut ()).unwrap(); callback( @@ -319,7 +319,7 @@ impl EventLoop { &self.target, &mut control_flow, ); - }, + } ControlFlow::WaitUntil(deadline) => { let start = ::std::time::Instant::now(); // compute the blocking duration @@ -353,7 +353,7 @@ impl EventLoop { &mut control_flow, ); } - }, + } } } @@ -588,8 +588,8 @@ impl Device { position: 0.0, }, )); - }, - _ => {}, + } + _ => {} } } } @@ -619,8 +619,8 @@ impl Device { { axis.position = info.value; } - }, - _ => {}, + } + _ => {} } } } diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index 602db789..5e973e93 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -384,7 +384,7 @@ impl UnownedWindow { ImeContextCreationError::XError(err) => OsError::XError(err), ImeContextCreationError::Null => { OsError::XMisc("IME Context creation failed") - }, + } }; return Err(os_error!(e)); } @@ -558,7 +558,7 @@ impl UnownedWindow { self.set_position_inner(position.0, position.1).queue(); } flusher - }, + } Some(RootMonitorHandle { inner: PlatformMonitorHandle::X(monitor), }) => { @@ -568,7 +568,7 @@ impl UnownedWindow { self.set_position_inner(monitor_origin.0, monitor_origin.1) .queue(); self.set_fullscreen_hint(true) - }, + } _ => unreachable!(), } } @@ -1190,11 +1190,11 @@ impl UnownedWindow { ffi::GrabSuccess => Ok(()), ffi::AlreadyGrabbed => { Err("Cursor could not be grabbed: already grabbed by another client") - }, + } ffi::GrabInvalidTime => Err("Cursor could not be grabbed: invalid time"), ffi::GrabNotViewable => { Err("Cursor could not be grabbed: grab location not viewable") - }, + } ffi::GrabFrozen => Err("Cursor could not be grabbed: frozen by another client"), _ => unreachable!(), } diff --git a/src/platform_impl/macos/app.rs b/src/platform_impl/macos/app.rs index cac7e5bc..7aad8d9d 100644 --- a/src/platform_impl/macos/app.rs +++ b/src/platform_impl/macos/app.rs @@ -100,7 +100,7 @@ unsafe fn maybe_dispatch_device_event(event: id) { } AppState::queue_events(events); - }, + } _ => (), } } diff --git a/src/platform_impl/macos/app_state.rs b/src/platform_impl/macos/app_state.rs index 470cf996..cccbb098 100644 --- a/src/platform_impl/macos/app_state.rs +++ b/src/platform_impl/macos/app_state.rs @@ -213,11 +213,9 @@ impl AppState { let start = HANDLER.get_start_time().unwrap(); let cause = match HANDLER.get_control_flow_and_update_prev() { ControlFlow::Poll => StartCause::Poll, - ControlFlow::Wait => { - StartCause::WaitCancelled { - start, - requested_resume: None, - } + ControlFlow::Wait => StartCause::WaitCancelled { + start, + requested_resume: None, }, ControlFlow::WaitUntil(requested_resume) => { if Instant::now() >= requested_resume { @@ -231,7 +229,7 @@ impl AppState { requested_resume: Some(requested_resume), } } - }, + } ControlFlow::Exit => StartCause::Poll, //panic!("unexpected `ControlFlow::Exit`"), }; HANDLER.set_in_callback(true); diff --git a/src/platform_impl/macos/observer.rs b/src/platform_impl/macos/observer.rs index bd6f46e9..ddd20a8f 100644 --- a/src/platform_impl/macos/observer.rs +++ b/src/platform_impl/macos/observer.rs @@ -121,7 +121,7 @@ extern "C" fn control_flow_begin_handler( //trace!("Triggered `CFRunLoopAfterWaiting`"); AppState::wakeup(); //trace!("Completed `CFRunLoopAfterWaiting`"); - }, + } kCFRunLoopEntry => unimplemented!(), // not expected to ever happen _ => unreachable!(), } @@ -140,7 +140,7 @@ extern "C" fn control_flow_end_handler( //trace!("Triggered `CFRunLoopBeforeWaiting`"); AppState::cleared(); //trace!("Completed `CFRunLoopBeforeWaiting`"); - }, + } kCFRunLoopExit => (), //unimplemented!(), // not expected to ever happen _ => unreachable!(), } diff --git a/src/platform_impl/macos/util/cursor.rs b/src/platform_impl/macos/util/cursor.rs index c7d767ef..e3e3bcf0 100644 --- a/src/platform_impl/macos/util/cursor.rs +++ b/src/platform_impl/macos/util/cursor.rs @@ -25,7 +25,7 @@ impl From for Cursor { CursorIcon::Alias => Cursor::Native("dragLinkCursor"), CursorIcon::NotAllowed | CursorIcon::NoDrop => { Cursor::Native("operationNotAllowedCursor") - }, + } CursorIcon::ContextMenu => Cursor::Native("contextualMenuCursor"), CursorIcon::Crosshair => Cursor::Native("crosshairCursor"), CursorIcon::EResize => Cursor::Native("resizeRightCursor"), @@ -57,7 +57,7 @@ impl From for Cursor { // what's used in Safari and Chrome. CursorIcon::Wait | CursorIcon::Progress => { Cursor::Undocumented("busyButClickableCursor") - }, + } // For the rest, we can just snatch the cursors from WebKit... // They fit the style of the native cursors, and will seem @@ -81,7 +81,7 @@ impl Cursor { Cursor::Native(cursor_name) => { let sel = Sel::register(cursor_name); msg_send![class!(NSCursor), performSelector: sel] - }, + } Cursor::Undocumented(cursor_name) => { let class = class!(NSCursor); let sel = Sel::register(cursor_name); @@ -92,7 +92,7 @@ impl Cursor { sel!(arrowCursor) }; msg_send![class, performSelector: sel] - }, + } Cursor::WebKit(cursor_name) => load_webkit_cursor(cursor_name), } } diff --git a/src/platform_impl/macos/view.rs b/src/platform_impl/macos/view.rs index 7dd099c7..5a0fff9a 100644 --- a/src/platform_impl/macos/view.rs +++ b/src/platform_impl/macos/view.rs @@ -900,7 +900,7 @@ extern "C" fn scroll_wheel(this: &Object, _sel: Sel, event: id) { let phase = match event.phase() { NSEventPhase::NSEventPhaseMayBegin | NSEventPhase::NSEventPhaseBegan => { TouchPhase::Started - }, + } NSEventPhase::NSEventPhaseEnded => TouchPhase::Ended, _ => TouchPhase::Moved, }; diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index 3649caa7..67469b12 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -116,7 +116,7 @@ fn create_window( Some(ref monitor_id) => { let monitor_screen = monitor_id.inner.ns_screen(); Some(monitor_screen.unwrap_or(appkit::NSScreen::mainScreen(nil))) - }, + } _ => None, }; let frame = match screen { @@ -127,7 +127,7 @@ fn create_window( .map(|logical| (logical.width, logical.height)) .unwrap_or_else(|| (800.0, 600.0)); NSRect::new(NSPoint::new(0.0, 0.0), NSSize::new(width, height)) - }, + } }; let mut masks = if !attrs.decorations && !screen.is_some() { @@ -649,7 +649,7 @@ impl UnownedWindow { // Our best bet is probably to move to the origin of the // target monitor. unimplemented!() - }, + } (&None, None) | (&Some(_), Some(_)) => return, _ => (), } diff --git a/src/platform_impl/windows/event.rs b/src/platform_impl/windows/event.rs index 105121e3..89171874 100644 --- a/src/platform_impl/windows/event.rs +++ b/src/platform_impl/windows/event.rs @@ -285,14 +285,14 @@ pub fn handle_extended_keys( } else { winuser::VK_LCONTROL } - }, + } winuser::VK_MENU => { if extended { winuser::VK_RMENU } else { winuser::VK_LMENU } - }, + } _ => { match scancode { // This is only triggered when using raw input. Without this check, we get two events whenever VK_PAUSE is @@ -308,10 +308,10 @@ pub fn handle_extended_keys( } else { winuser::VK_SCROLL } - }, + } _ => vkey, } - }, + } }; Some((vkey, scancode)) } diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index 929a0e0f..4520e34b 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -162,7 +162,7 @@ impl EventLoop { match event { Some(e) => { runner.process_event(e); - }, + } None => break, } } @@ -210,10 +210,10 @@ impl EventLoop { break 'main; } msg_unprocessed = true; - }, + } ControlFlow::WaitUntil(resume_time) => { wait_until_time_or_msg(resume_time); - }, + } ControlFlow::Poll => (), } } @@ -335,7 +335,7 @@ impl EventLoopRunner { RunnerState::New => { self.call_event_handler(Event::NewEvents(StartCause::Init)); RunnerState::HandlingEvents - }, + } // When `NewEvents` gets sent after an idle depends on the control flow... RunnerState::Idle(wait_start) => { @@ -371,7 +371,7 @@ impl EventLoopRunner { // `Exit` shouldn't really ever get sent here, but if it does do something somewhat sane. ControlFlow::Exit => RunnerState::DeferredNewEvents(wait_start), } - }, + } }; } @@ -405,27 +405,23 @@ impl EventLoopRunner { start: wait_start, requested_resume: None, })) - }, + } ControlFlow::WaitUntil(resume_time) => { let start_cause = match Instant::now() >= resume_time { // If the current time is later than the requested resume time, the resume time // has been reached. - true => { - StartCause::ResumeTimeReached { - start: wait_start, - requested_resume: resume_time, - } + true => StartCause::ResumeTimeReached { + start: wait_start, + requested_resume: resume_time, }, // Otherwise, the requested resume time HASN'T been reached and we send a WaitCancelled. - false => { - StartCause::WaitCancelled { - start: wait_start, - requested_resume: Some(resume_time), - } + false => StartCause::WaitCancelled { + start: wait_start, + requested_resume: Some(resume_time), }, }; self.call_event_handler(Event::NewEvents(start_cause)); - }, + } // This can be reached if the control flow is changed to poll during a `RedrawRequested` // that was sent after `EventsCleared`. ControlFlow::Poll => self.call_event_handler(Event::NewEvents(StartCause::Poll)), @@ -442,7 +438,7 @@ impl EventLoopRunner { RunnerState::HandlingEvents => { self.call_event_handler(Event::EventsCleared); self.runner_state = RunnerState::Idle(Instant::now()); - }, + } // If we *weren't* handling events, we don't have to do anything. RunnerState::New | RunnerState::Idle(..) => (), @@ -455,7 +451,7 @@ impl EventLoopRunner { ControlFlow::Poll => { self.call_event_handler(Event::NewEvents(StartCause::Poll)); self.call_event_handler(Event::EventsCleared); - }, + } // If we had deferred a WaitUntil and the resume time has since been reached, // send the resume notification and EventsCleared event. ControlFlow::WaitUntil(resume_time) => { @@ -468,27 +464,25 @@ impl EventLoopRunner { )); self.call_event_handler(Event::EventsCleared); } - }, + } // If we deferred a wait and no events were received, the user doesn't have to // get an event. ControlFlow::Wait | ControlFlow::Exit => (), } // Mark that we've entered an idle state. self.runner_state = RunnerState::Idle(wait_start) - }, + } } } fn call_event_handler(&mut self, event: Event) { match event { - Event::NewEvents(_) => { - self.trigger_newevents_on_redraw - .store(true, Ordering::Relaxed) - }, - Event::EventsCleared => { - self.trigger_newevents_on_redraw - .store(false, Ordering::Relaxed) - }, + Event::NewEvents(_) => self + .trigger_newevents_on_redraw + .store(true, Ordering::Relaxed), + Event::EventsCleared => self + .trigger_newevents_on_redraw + .store(false, Ordering::Relaxed), _ => (), } @@ -825,18 +819,18 @@ unsafe extern "system" fn public_window_callback( runner.in_modal_loop = true; } 0 - }, + } winuser::WM_EXITSIZEMOVE => { let mut runner = subclass_input.event_loop_runner.runner.borrow_mut(); if let Some(ref mut runner) = *runner { runner.in_modal_loop = false; } 0 - }, + } winuser::WM_NCCREATE => { enable_non_client_dpi_scaling(window); commctrl::DefSubclassProc(window, msg, wparam, lparam) - }, + } winuser::WM_NCLBUTTONDOWN => { // jumpstart the modal loop @@ -850,7 +844,7 @@ unsafe extern "system" fn public_window_callback( winuser::PostMessageW(window, winuser::WM_MOUSEMOVE, 0, 0); } commctrl::DefSubclassProc(window, msg, wparam, lparam) - }, + } winuser::WM_CLOSE => { use crate::event::WindowEvent::CloseRequested; @@ -859,7 +853,7 @@ unsafe extern "system" fn public_window_callback( event: CloseRequested, }); 0 - }, + } winuser::WM_DESTROY => { use crate::event::WindowEvent::Destroyed; @@ -872,7 +866,7 @@ unsafe extern "system" fn public_window_callback( Box::from_raw(subclass_input); drop(subclass_input); 0 - }, + } _ if msg == *REQUEST_REDRAW_NO_NEWEVENTS_MSG_ID => { use crate::event::WindowEvent::RedrawRequested; @@ -892,22 +886,20 @@ unsafe extern "system" fn public_window_callback( }; match runner_state { RunnerState::Idle(..) | RunnerState::DeferredNewEvents(..) => request_redraw(), - RunnerState::HandlingEvents => { - match control_flow { - ControlFlow::Poll => request_redraw(), - ControlFlow::WaitUntil(resume_time) => { - if resume_time <= Instant::now() { - request_redraw() - } - }, - _ => (), + RunnerState::HandlingEvents => match control_flow { + ControlFlow::Poll => request_redraw(), + ControlFlow::WaitUntil(resume_time) => { + if resume_time <= Instant::now() { + request_redraw() + } } + _ => (), }, _ => (), } } 0 - }, + } winuser::WM_PAINT => { use crate::event::WindowEvent::RedrawRequested; subclass_input.send_event(Event::WindowEvent { @@ -915,7 +907,7 @@ unsafe extern "system" fn public_window_callback( event: RedrawRequested, }); commctrl::DefSubclassProc(window, msg, wparam, lparam) - }, + } // WM_MOVE supplies client area positions, so we send Moved here instead. winuser::WM_WINDOWPOSCHANGED => { @@ -934,7 +926,7 @@ unsafe extern "system" fn public_window_callback( // This is necessary for us to still get sent WM_SIZE. commctrl::DefSubclassProc(window, msg, wparam, lparam) - }, + } winuser::WM_SIZE => { use crate::event::WindowEvent::Resized; @@ -962,7 +954,7 @@ unsafe extern "system" fn public_window_callback( subclass_input.send_event(event); 0 - }, + } winuser::WM_CHAR => { use crate::event::WindowEvent::ReceivedCharacter; @@ -972,7 +964,7 @@ unsafe extern "system" fn public_window_callback( event: ReceivedCharacter(chr), }); 0 - }, + } // Prevents default windows menu hotkeys playing unwanted // "ding" sounds. Alternatively could check for WM_SYSCOMMAND @@ -1024,7 +1016,7 @@ unsafe extern "system" fn public_window_callback( }); 0 - }, + } winuser::WM_MOUSELEAVE => { use crate::event::WindowEvent::CursorLeft; @@ -1043,7 +1035,7 @@ unsafe extern "system" fn public_window_callback( }); 0 - }, + } winuser::WM_MOUSEWHEEL => { use crate::event::MouseScrollDelta::LineDelta; @@ -1063,7 +1055,7 @@ unsafe extern "system" fn public_window_callback( }); 0 - }, + } winuser::WM_MOUSEHWHEEL => { use crate::event::MouseScrollDelta::LineDelta; @@ -1083,7 +1075,7 @@ unsafe extern "system" fn public_window_callback( }); 0 - }, + } winuser::WM_KEYDOWN | winuser::WM_SYSKEYDOWN => { use crate::event::{ElementState::Pressed, VirtualKeyCode}; @@ -1114,7 +1106,7 @@ unsafe extern "system" fn public_window_callback( } 0 } - }, + } winuser::WM_KEYUP | winuser::WM_SYSKEYUP => { use crate::event::ElementState::Released; @@ -1133,7 +1125,7 @@ unsafe extern "system" fn public_window_callback( }); } 0 - }, + } winuser::WM_LBUTTONDOWN => { use crate::event::{ElementState::Pressed, MouseButton::Left, WindowEvent::MouseInput}; @@ -1150,7 +1142,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_LBUTTONUP => { use crate::event::{ @@ -1169,7 +1161,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_RBUTTONDOWN => { use crate::event::{ @@ -1188,7 +1180,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_RBUTTONUP => { use crate::event::{ @@ -1207,7 +1199,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_MBUTTONDOWN => { use crate::event::{ @@ -1226,7 +1218,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_MBUTTONUP => { use crate::event::{ @@ -1245,7 +1237,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_XBUTTONDOWN => { use crate::event::{ @@ -1265,7 +1257,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_XBUTTONUP => { use crate::event::{ @@ -1285,7 +1277,7 @@ unsafe extern "system" fn public_window_callback( }, }); 0 - }, + } winuser::WM_INPUT_DEVICE_CHANGE => { let event = match wparam as _ { @@ -1300,7 +1292,7 @@ unsafe extern "system" fn public_window_callback( }); 0 - }, + } winuser::WM_INPUT => { use crate::event::{ @@ -1399,7 +1391,7 @@ unsafe extern "system" fn public_window_callback( } commctrl::DefSubclassProc(window, msg, wparam, lparam) - }, + } winuser::WM_TOUCH => { let pcount = LOWORD(wparam as DWORD) as usize; @@ -1439,7 +1431,7 @@ unsafe extern "system" fn public_window_callback( } winuser::CloseTouchInputHandle(htouch); 0 - }, + } winuser::WM_SETFOCUS => { use crate::event::WindowEvent::Focused; @@ -1449,7 +1441,7 @@ unsafe extern "system" fn public_window_callback( }); 0 - }, + } winuser::WM_KILLFOCUS => { use crate::event::WindowEvent::Focused; @@ -1458,7 +1450,7 @@ unsafe extern "system" fn public_window_callback( event: Focused(false), }); 0 - }, + } winuser::WM_SETCURSOR => { let set_cursor_to = { @@ -1479,15 +1471,15 @@ unsafe extern "system" fn public_window_callback( let cursor = winuser::LoadCursorW(ptr::null_mut(), cursor.to_windows_cursor()); winuser::SetCursor(cursor); 0 - }, + } None => winuser::DefWindowProcW(window, msg, wparam, lparam), } - }, + } winuser::WM_DROPFILES => { // See `FileDropHandler` for implementation. 0 - }, + } winuser::WM_GETMINMAXINFO => { let mmi = lparam as *mut winuser::MINMAXINFO; @@ -1516,7 +1508,7 @@ unsafe extern "system" fn public_window_callback( } 0 - }, + } // Only sent on Windows 8.1 or newer. On Windows 7 and older user has to log out to change // DPI, therefore all applications are closed while DPI is changing. @@ -1560,7 +1552,7 @@ unsafe extern "system" fn public_window_callback( }); 0 - }, + } _ => { if msg == *DESTROY_MSG_ID { @@ -1613,7 +1605,7 @@ unsafe extern "system" fn public_window_callback( } else { commctrl::DefSubclassProc(window, msg, wparam, lparam) } - }, + } } } @@ -1631,7 +1623,7 @@ unsafe extern "system" fn thread_event_target_callback( Box::from_raw(subclass_input); drop(subclass_input); 0 - }, + } // Because WM_PAINT comes after all other messages, we use it during modal loops to detect // when the event queue has been emptied. See `process_event` for more details. winuser::WM_PAINT => { @@ -1669,13 +1661,13 @@ unsafe extern "system" fn thread_event_target_callback( winuser::TranslateMessage(&mut msg); winuser::DispatchMessageW(&mut msg); } - }, + } // If the message isn't one of those three, it may be handled by the modal // loop so we should return control flow to it. _ => { queue_call_again(); return 0; - }, + } } } @@ -1689,27 +1681,27 @@ unsafe extern "system" fn thread_event_target_callback( wait_until_time_or_msg(resume_time); runner.new_events(); queue_call_again(); - }, + } ControlFlow::Poll => { runner.new_events(); queue_call_again(); - }, + } } } } 0 - }, + } _ if msg == *USER_EVENT_MSG_ID => { if let Ok(event) = subclass_input.user_event_receiver.recv() { subclass_input.send_event(Event::UserEvent(event)); } 0 - }, + } _ if msg == *EXEC_MSG_ID => { let mut function: ThreadExecFn = Box::from_raw(wparam as usize as *mut _); function(); 0 - }, + } _ => commctrl::DefSubclassProc(window, msg, wparam, lparam), } } diff --git a/src/platform_impl/windows/util.rs b/src/platform_impl/windows/util.rs index a02964b3..edb5769e 100644 --- a/src/platform_impl/windows/util.rs +++ b/src/platform_impl/windows/util.rs @@ -129,7 +129,7 @@ impl CursorIcon { CursorIcon::NotAllowed | CursorIcon::NoDrop => winuser::IDC_NO, CursorIcon::Grab | CursorIcon::Grabbing | CursorIcon::Move | CursorIcon::AllScroll => { winuser::IDC_SIZEALL - }, + } CursorIcon::EResize | CursorIcon::WResize | CursorIcon::EwResize @@ -140,10 +140,10 @@ impl CursorIcon { | CursorIcon::RowResize => winuser::IDC_SIZENS, CursorIcon::NeResize | CursorIcon::SwResize | CursorIcon::NeswResize => { winuser::IDC_SIZENESW - }, + } CursorIcon::NwResize | CursorIcon::SeResize | CursorIcon::NwseResize => { winuser::IDC_SIZENWSE - }, + } CursorIcon::Wait => winuser::IDC_WAIT, CursorIcon::Progress => winuser::IDC_APPSTARTING, CursorIcon::Help => winuser::IDC_HELP, diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 01a559b5..64419204 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -464,7 +464,7 @@ impl Window { mark_fullscreen(window.0, true); }); - }, + } &None => { self.thread_executor.execute_in_thread(move || { let mut window_state_lock = window_state.lock(); @@ -487,7 +487,7 @@ impl Window { mark_fullscreen(window.0, false); }); - }, + } } } } diff --git a/src/platform_impl/windows/window_state.rs b/src/platform_impl/windows/window_state.rs index 22d5ae06..ee9d953b 100644 --- a/src/platform_impl/windows/window_state.rs +++ b/src/platform_impl/windows/window_state.rs @@ -170,7 +170,7 @@ impl MouseProperties { Err(e) => { self.cursor_flags = old_flags; return Err(e); - }, + } } Ok(()) @@ -309,7 +309,7 @@ impl WindowFlags { h, winuser::SWP_NOZORDER | winuser::SWP_FRAMECHANGED, ); - }, + } None => { // Refresh the window frame. winuser::SetWindowPos( @@ -324,7 +324,7 @@ impl WindowFlags { | winuser::SWP_NOSIZE | winuser::SWP_FRAMECHANGED, ); - }, + } } winuser::SendMessageW(window, *event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID, 0, 0); }