From 5735786f42ba45da789d35a74e28f16c2c057b4d Mon Sep 17 00:00:00 2001 From: daxpedda Date: Thu, 25 Jul 2024 15:15:21 +0200 Subject: [PATCH] Fix CI for Rust v1.80 (#3822) `clippy::doc_lazy_continuation` was added, which needed some fixing from our side. --- src/changelog/v0.20.md | 2 +- src/changelog/v0.9.md | 6 +-- src/event.rs | 17 ++++--- src/platform/pump_events.rs | 26 +++++------ src/platform_impl/windows/raw_input.rs | 64 +++++++++++++------------- src/window.rs | 18 ++++---- 6 files changed, 65 insertions(+), 68 deletions(-) diff --git a/src/changelog/v0.20.md b/src/changelog/v0.20.md index 55ad78e81b..eb4ba6a1de 100644 --- a/src/changelog/v0.20.md +++ b/src/changelog/v0.20.md @@ -137,7 +137,7 @@ - On X11, non-resizable windows now have maximize explicitly disabled. - On Windows, support paths longer than MAX_PATH (260 characters) in `WindowEvent::DroppedFile` -and `WindowEvent::HoveredFile`. + and `WindowEvent::HoveredFile`. - On Mac, implement `DeviceEvent::Button`. - Change `Event::Suspended(true / false)` to `Event::Suspended` and `Event::Resumed`. - On X11, fix sanity check which checks that a monitor's reported width and height (in millimeters) are non-zero when calculating the DPI factor. diff --git a/src/changelog/v0.9.md b/src/changelog/v0.9.md index ff36cf3f6d..2a9e8cc320 100644 --- a/src/changelog/v0.9.md +++ b/src/changelog/v0.9.md @@ -3,20 +3,20 @@ - Added event `WindowEvent::HiDPIFactorChanged`. - Added method `MonitorId::get_hidpi_factor`. - Deprecated `get_inner_size_pixels` and `get_inner_size_points` methods of `Window` in favor of -`get_inner_size`. + `get_inner_size`. - **Breaking:** `EventsLoop` is `!Send` and `!Sync` because of platform-dependant constraints, but `Window`, `WindowId`, `DeviceId` and `MonitorId` guaranteed to be `Send`. - `MonitorId::get_position` now returns `(i32, i32)` instead of `(u32, u32)`. - Rewrite of the wayland backend to use wayland-client-0.11 - Support for dead keys on wayland for keyboard utf8 input - Monitor enumeration on Windows is now implemented using `EnumDisplayMonitors` instead of -`EnumDisplayDevices`. This changes the value returned by `MonitorId::get_name()`. + `EnumDisplayDevices`. This changes the value returned by `MonitorId::get_name()`. - On Windows added `MonitorIdExt::hmonitor` method - Impl `Clone` for `EventsLoopProxy` - `EventsLoop::get_primary_monitor()` on X11 will fallback to any available monitor if no primary is found - Support for touch event on wayland - `WindowEvent`s `MouseMoved`, `MouseEntered`, and `MouseLeft` have been renamed to -`CursorMoved`, `CursorEntered`, and `CursorLeft`. + `CursorMoved`, `CursorEntered`, and `CursorLeft`. - New `DeviceEvent`s added, `MouseMotion` and `MouseWheel`. - Send `CursorMoved` event after `CursorEntered` and `Focused` events. - Add support for `ModifiersState`, `MouseMove`, `MouseInput`, `MouseMotion` for emscripten backend. diff --git a/src/event.rs b/src/event.rs index d05d35c853..1d14259de4 100644 --- a/src/event.rs +++ b/src/event.rs @@ -532,11 +532,11 @@ pub struct KeyEvent { /// ## Caveats /// /// - Certain niche hardware will shuffle around physical key positions, e.g. a keyboard that - /// implements DVORAK in hardware (or firmware) + /// implements DVORAK in hardware (or firmware) /// - Your application will likely have to handle keyboards which are missing keys that your - /// own keyboard has. + /// own keyboard has. /// - Certain `KeyCode`s will move between a couple of different positions depending on what - /// layout the keyboard was manufactured to support. + /// layout the keyboard was manufactured to support. /// /// **Because of these caveats, it is important that you provide users with a way to configure /// most (if not all) keybinds in your application.** @@ -558,8 +558,7 @@ pub struct KeyEvent { /// /// This has two use cases: /// - Allows querying whether the current input is a Dead key. - /// - Allows handling key-bindings on platforms which don't - /// support [`key_without_modifiers`]. + /// - Allows handling key-bindings on platforms which don't support [`key_without_modifiers`]. /// /// If you use this field (or [`key_without_modifiers`] for that matter) for keyboard /// shortcuts, **it is important that you provide users with a way to configure your @@ -567,8 +566,8 @@ pub struct KeyEvent { /// incompatible keyboard layout.** /// /// ## Platform-specific - /// - **Web:** Dead keys might be reported as the real key instead - /// of `Dead` depending on the browser/OS. + /// - **Web:** Dead keys might be reported as the real key instead of `Dead` depending on the + /// browser/OS. /// /// [`key_without_modifiers`]: crate::platform::modifier_supplement::KeyEventExtModifierSupplement::key_without_modifiers pub logical_key: keyboard::Key, @@ -850,8 +849,8 @@ pub struct Touch { /// /// - Only available on **iOS** 9.0+, **Windows** 8+, **Web**, and **Android**. /// - **Android**: This will never be [None]. If the device doesn't support pressure - /// sensitivity, force will either be 0.0 or 1.0. Also see the - /// [android documentation](https://developer.android.com/reference/android/view/MotionEvent#AXIS_PRESSURE). + /// sensitivity, force will either be 0.0 or 1.0. Also see the + /// [android documentation](https://developer.android.com/reference/android/view/MotionEvent#AXIS_PRESSURE). pub force: Option, /// Unique identifier of a finger. pub id: u64, diff --git a/src/platform/pump_events.rs b/src/platform/pump_events.rs index 7eedda2816..dbe14f6fac 100644 --- a/src/platform/pump_events.rs +++ b/src/platform/pump_events.rs @@ -52,18 +52,18 @@ pub trait EventLoopExtPumpEvents { /// - `RedrawRequested` events, used to schedule rendering. /// /// macOS for example uses a `drawRect` callback to drive rendering - /// within applications and expects rendering to be finished before - /// the `drawRect` callback returns. + /// within applications and expects rendering to be finished before + /// the `drawRect` callback returns. /// /// For portability it's strongly recommended that applications should - /// keep their rendering inside the closure provided to Winit. + /// keep their rendering inside the closure provided to Winit. /// - Any lifecycle events, such as `Suspended` / `Resumed`. /// /// The handling of these events needs to be synchronized with the - /// operating system and it would never be appropriate to buffer a - /// notification that your application has been suspended or resumed and - /// then handled that later since there would always be a chance that - /// other lifecycle events occur while the event is buffered. + /// operating system and it would never be appropriate to buffer a + /// notification that your application has been suspended or resumed and + /// then handled that later since there would always be a chance that + /// other lifecycle events occur while the event is buffered. /// /// ## Supported Platforms /// @@ -74,13 +74,13 @@ pub trait EventLoopExtPumpEvents { /// /// ## Unsupported Platforms /// - /// - **Web:** This API is fundamentally incompatible with the event-based way in which - /// Web browsers work because it's not possible to have a long-running external - /// loop that would block the browser and there is nothing that can be - /// polled to ask for new new events. Events are delivered via callbacks based - /// on an event loop that is internal to the browser itself. + /// - **Web:** This API is fundamentally incompatible with the event-based way in which Web + /// browsers work because it's not possible to have a long-running external loop that would + /// block the browser and there is nothing that can be polled to ask for new new events. + /// Events are delivered via callbacks based on an event loop that is internal to the browser + /// itself. /// - **iOS:** It's not possible to stop and start an `NSApplication` repeatedly on iOS so - /// there's no way to support the same approach to polling as on MacOS. + /// there's no way to support the same approach to polling as on MacOS. /// /// ## Platform-specific /// diff --git a/src/platform_impl/windows/raw_input.rs b/src/platform_impl/windows/raw_input.rs index 44c7c95a73..87d16750ea 100644 --- a/src/platform_impl/windows/raw_input.rs +++ b/src/platform_impl/windows/raw_input.rs @@ -263,39 +263,37 @@ pub fn get_keyboard_physical_key(keyboard: RAWKEYBOARD) -> Option { scancode_to_physicalkey(scancode as u32) }; if keyboard.VKey == VK_SHIFT { - if let PhysicalKey::Code(code) = physical_key { - match code { - KeyCode::NumpadDecimal - | KeyCode::Numpad0 - | KeyCode::Numpad1 - | KeyCode::Numpad2 - | KeyCode::Numpad3 - | KeyCode::Numpad4 - | KeyCode::Numpad5 - | KeyCode::Numpad6 - | KeyCode::Numpad7 - | KeyCode::Numpad8 - | KeyCode::Numpad9 => { - // On Windows, holding the Shift key makes numpad keys behave as if NumLock - // wasn't active. The way this is exposed to applications by the system is that - // the application receives a fake key release event for the shift key at the - // moment when the numpad key is pressed, just before receiving the numpad key - // as well. - // - // The issue is that in the raw device event (here), the fake shift release - // event reports the numpad key as the scancode. Unfortunately, the event - // doesn't have any information to tell whether it's the - // left shift or the right shift that needs to get the fake - // release (or press) event so we don't forward this - // event to the application at all. - // - // For more on this, read the article by Raymond Chen, titled: - // "The shift key overrides NumLock" - // https://devblogs.microsoft.com/oldnewthing/20040906-00/?p=37953 - return None; - }, - _ => (), - } + if let PhysicalKey::Code( + KeyCode::NumpadDecimal + | KeyCode::Numpad0 + | KeyCode::Numpad1 + | KeyCode::Numpad2 + | KeyCode::Numpad3 + | KeyCode::Numpad4 + | KeyCode::Numpad5 + | KeyCode::Numpad6 + | KeyCode::Numpad7 + | KeyCode::Numpad8 + | KeyCode::Numpad9, + ) = physical_key + { + // On Windows, holding the Shift key makes numpad keys behave as if NumLock + // wasn't active. The way this is exposed to applications by the system is that + // the application receives a fake key release event for the shift key at the + // moment when the numpad key is pressed, just before receiving the numpad key + // as well. + // + // The issue is that in the raw device event (here), the fake shift release + // event reports the numpad key as the scancode. Unfortunately, the event + // doesn't have any information to tell whether it's the + // left shift or the right shift that needs to get the fake + // release (or press) event so we don't forward this + // event to the application at all. + // + // For more on this, read the article by Raymond Chen, titled: + // "The shift key overrides NumLock" + // https://devblogs.microsoft.com/oldnewthing/20040906-00/?p=37953 + return None; } } diff --git a/src/window.rs b/src/window.rs index 7c4812c560..31ef19a330 100644 --- a/src/window.rs +++ b/src/window.rs @@ -417,8 +417,8 @@ impl WindowAttributes { /// /// ## Platform-specific /// - /// - **macOS**: if `false`, [`NSWindowSharingNone`] is used but doesn't completely - /// prevent all apps from reading the window content, for instance, QuickTime. + /// - **macOS**: if `false`, [`NSWindowSharingNone`] is used but doesn't completely prevent all + /// apps from reading the window content, for instance, QuickTime. /// - **iOS / Android / Web / x11 / Orbital:** Ignored. /// /// [`NSWindowSharingNone`]: https://developer.apple.com/documentation/appkit/nswindowsharingtype/nswindowsharingnone @@ -466,8 +466,8 @@ impl WindowAttributes { /// ## Platform-specific /// /// - **Windows** : A child window has the WS_CHILD style and is confined - /// to the client area of its parent window. For more information, see - /// + /// to the client area of its parent window. For more information, see + /// /// - **X11**: A child window is confined to the client area of its parent window. /// - **Android / iOS / Wayland / Web:** Unsupported. #[cfg(feature = "rwh_06")] @@ -530,9 +530,9 @@ impl Window { /// provided by XRandR. /// /// If `WINIT_X11_SCALE_FACTOR` is set to `randr`, it'll ignore the `Xft.dpi` field and use - /// the XRandR scaling method. Generally speaking, you should try to configure the - /// standard system variables to do what you want before resorting to - /// `WINIT_X11_SCALE_FACTOR`. + /// the XRandR scaling method. Generally speaking, you should try to configure the + /// standard system variables to do what you want before resorting to + /// `WINIT_X11_SCALE_FACTOR`. /// - **Wayland:** The scale factor is suggested by the compositor for each window individually /// by using the wp-fractional-scale protocol if available. Falls back to integer-scale /// factors otherwise. @@ -1389,8 +1389,8 @@ impl Window { /// /// ## Platform-specific /// - /// - **macOS**: if `false`, [`NSWindowSharingNone`] is used but doesn't completely - /// prevent all apps from reading the window content, for instance, QuickTime. + /// - **macOS**: if `false`, [`NSWindowSharingNone`] is used but doesn't completely prevent all + /// apps from reading the window content, for instance, QuickTime. /// - **iOS / Android / x11 / Wayland / Web / Orbital:** Unsupported. /// /// [`NSWindowSharingNone`]: https://developer.apple.com/documentation/appkit/nswindowsharingtype/nswindowsharingnone