From c333003514de904c14766f28235ad0d050300572 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sun, 19 Oct 2025 12:58:12 +0900 Subject: [PATCH] Bump MSRV to 1.85 and edition to 2024 --- .github/workflows/ci.yml | 24 ++-- Cargo.toml | 4 +- README.md | 2 +- winit-android/src/keycodes.rs | 2 +- winit-appkit/src/app.rs | 2 +- winit-appkit/src/app_state.rs | 2 +- winit-appkit/src/cursor.rs | 6 +- winit-appkit/src/event_loop.rs | 6 +- winit-appkit/src/ffi.rs | 8 +- winit-appkit/src/lib.rs | 2 +- winit-appkit/src/menu.rs | 4 +- winit-appkit/src/monitor.rs | 8 +- winit-appkit/src/observer.rs | 6 +- winit-appkit/src/util.rs | 10 +- winit-appkit/src/view.rs | 2 +- winit-appkit/src/window.rs | 4 +- winit-appkit/src/window_delegate.rs | 32 +++-- .../src/core_foundation/event_loop_proxy.rs | 2 +- winit-common/src/event_handler.rs | 2 +- winit-common/src/xkb/compose.rs | 2 +- winit-common/src/xkb/keymap.rs | 14 +-- winit-common/src/xkb/mod.rs | 14 +-- winit-common/src/xkb/state.rs | 4 +- winit-core/src/error.rs | 16 +-- winit-core/src/event.rs | 8 +- winit-core/src/event_loop/mod.rs | 4 +- winit-core/src/event_loop/run_on_demand.rs | 2 +- winit-core/src/keyboard.rs | 10 +- winit-core/src/window.rs | 96 ++++++++------ winit-orbital/src/event_loop.rs | 8 +- winit-orbital/src/lib.rs | 16 +-- winit-uikit/src/app_state.rs | 6 +- winit-uikit/src/event_loop.rs | 6 +- winit-uikit/src/monitor.rs | 8 +- winit-uikit/src/view.rs | 2 +- winit-uikit/src/view_controller.rs | 2 +- winit-uikit/src/window.rs | 2 +- winit-wayland/src/event_loop/mod.rs | 6 +- winit-wayland/src/lib.rs | 6 +- winit-wayland/src/output.rs | 2 +- winit-wayland/src/seat/keyboard/mod.rs | 2 +- .../src/seat/pointer/pointer_gesture.rs | 6 +- winit-wayland/src/seat/text_input/mod.rs | 2 +- winit-wayland/src/state.rs | 8 +- winit-wayland/src/types/kwin_blur.rs | 2 +- .../src/types/wp_fractional_scaling.rs | 2 +- winit-wayland/src/types/wp_tablet_input_v2.rs | 2 +- winit-wayland/src/types/wp_viewporter.rs | 2 +- winit-wayland/src/types/xdg_activation.rs | 4 +- .../src/types/xdg_toplevel_icon_manager.rs | 2 +- winit-wayland/src/window/mod.rs | 12 +- winit-wayland/src/window/state.rs | 14 +-- winit-web/src/async/abortable.rs | 2 +- winit-web/src/async/channel.rs | 2 +- winit-web/src/async/concurrent_queue.rs | 11 +- winit-web/src/async/dispatcher.rs | 2 +- winit-web/src/async/mod.rs | 2 +- winit-web/src/cursor.rs | 10 +- winit-web/src/event_loop/mod.rs | 2 +- winit-web/src/event_loop/proxy.rs | 4 +- winit-web/src/event_loop/runner.rs | 12 +- winit-web/src/event_loop/window_target.rs | 9 +- winit-web/src/lib.rs | 4 +- winit-web/src/lock.rs | 2 +- winit-web/src/monitor.rs | 26 ++-- winit-web/src/web_sys/animation_frame.rs | 2 +- winit-web/src/web_sys/canvas.rs | 7 +- winit-web/src/web_sys/event_handle.rs | 2 +- winit-web/src/web_sys/fullscreen.rs | 2 +- winit-web/src/web_sys/intersection_handle.rs | 2 +- winit-web/src/web_sys/media_query_handle.rs | 2 +- winit-web/src/web_sys/mod.rs | 2 +- winit-web/src/web_sys/resize_scaling.rs | 2 +- winit-web/src/window.rs | 19 +-- winit-win32/src/dark_mode.rs | 6 +- winit-win32/src/definitions.rs | 2 +- winit-win32/src/dpi.rs | 2 +- winit-win32/src/drop_handler.rs | 4 +- winit-win32/src/event_loop.rs | 118 ++++++++---------- winit-win32/src/event_loop/runner.rs | 2 +- winit-win32/src/icon.rs | 6 +- winit-win32/src/ime.rs | 10 +- winit-win32/src/keyboard.rs | 14 +-- winit-win32/src/keyboard_layout.rs | 12 +- winit-win32/src/lib.rs | 6 +- winit-win32/src/monitor.rs | 14 +-- winit-win32/src/raw_input.rs | 12 +- winit-win32/src/util.rs | 24 ++-- winit-win32/src/window.rs | 59 +++++---- winit-win32/src/window_state.rs | 21 ++-- winit-x11/src/event_loop.rs | 4 +- winit-x11/src/event_processor.rs | 4 +- winit-x11/src/ime/callbacks.rs | 2 +- winit-x11/src/ime/context.rs | 2 +- winit-x11/src/ime/inner.rs | 2 +- winit-x11/src/ime/input_method.rs | 6 +- winit-x11/src/ime/mod.rs | 4 +- winit-x11/src/lib.rs | 4 +- winit-x11/src/util/cursor.rs | 6 +- winit-x11/src/util/hint.rs | 6 +- winit-x11/src/util/memory.rs | 6 +- winit-x11/src/util/randr.rs | 6 +- winit-x11/src/window.rs | 62 ++++----- winit-x11/src/xdisplay.rs | 6 +- winit-x11/src/xsettings.rs | 4 +- winit/examples/application.rs | 2 +- winit/src/changelog/unreleased.md | 2 +- winit/src/os_error.rs | 4 +- winit/src/platform/startup_notify.rs | 12 +- winit/src/platform_impl/linux/mod.rs | 2 +- 110 files changed, 432 insertions(+), 574 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 342f1013..3aa59dce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: strategy: fail-fast: false matrix: - toolchain: [stable, nightly, '1.80'] + toolchain: [stable, nightly, '1.85'] platform: # Note: Make sure that we test all the `docs.rs` targets defined in Cargo.toml! - { name: 'Windows 64bit MSVC', target: x86_64-pc-windows-msvc, os: windows-latest, } @@ -82,13 +82,13 @@ jobs: - toolchain: nightly platform: { name: 'Windows 32bit GNU' } # Android is tested on stable-3 - - toolchain: '1.80' + - toolchain: '1.85' platform: { name: 'Android' } # Redox OS doesn't follow MSRV - - toolchain: '1.80' + - toolchain: '1.85' platform: { name: 'Redox OS' } include: - - toolchain: '1.80' + - toolchain: '1.85' platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package winit --features=android-native-activity', cmd: 'apk -- ' } - toolchain: 'nightly' platform: { name: 'Web', target: wasm32-unknown-unknown, os: ubuntu-latest, test-options: -Zdoctest-xcompile } @@ -134,10 +134,6 @@ jobs: key: cargo-${{ matrix.toolchain }}-${{ matrix.platform.name }}-never-intended-to-be-found restore-keys: cargo-${{ matrix.toolchain }}-${{ matrix.platform.name }} - - name: Generate lockfile - # Also updates the crates.io index - run: cargo generate-lockfile && cargo update -p ahash --precise 0.8.7 && cargo update -p bumpalo --precise 3.14.0 - - name: Install GCC Multilib if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686') run: sudo apt-get update && sudo apt-get install gcc-multilib @@ -230,19 +226,19 @@ jobs: - name: Test dpi crate if: > contains(matrix.platform.name, 'Linux 64bit') && - matrix.toolchain != '1.80' + matrix.toolchain != '1.85' run: cargo test -p dpi - name: Check dpi crate (no_std) if: > contains(matrix.platform.name, 'Linux 64bit') && - matrix.toolchain != '1.80' + matrix.toolchain != '1.85' run: cargo check -p dpi --no-default-features - name: Build tests if: > !contains(matrix.platform.target, 'redox') && - matrix.toolchain != '1.80' + matrix.toolchain != '1.85' run: cargo $CMD test --no-run $OPTIONS - name: Run tests @@ -251,7 +247,7 @@ jobs: !contains(matrix.platform.target, 'ios') && (!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') && !contains(matrix.platform.target, 'redox') && - matrix.toolchain != '1.80' + matrix.toolchain != '1.85' run: cargo $CMD test $OPTIONS - name: Lint with clippy @@ -261,7 +257,7 @@ jobs: - name: Build tests with serde enabled if: > !contains(matrix.platform.target, 'redox') && - matrix.toolchain != '1.80' + matrix.toolchain != '1.85' run: cargo $CMD test --no-run $OPTIONS $TEST_OPTIONS --features serde - name: Run tests with serde enabled @@ -270,7 +266,7 @@ jobs: !contains(matrix.platform.target, 'ios') && (!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') && !contains(matrix.platform.target, 'redox') && - matrix.toolchain != '1.80' + matrix.toolchain != '1.85' run: cargo $CMD test $OPTIONS $TEST_OPTIONS --features serde - name: Check docs.rs documentation diff --git a/Cargo.toml b/Cargo.toml index a1e8ba1b..284c1cac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,10 +4,10 @@ members = ["dpi", "winit*"] resolver = "2" [workspace.package] -edition = "2021" +edition = "2024" license = "Apache-2.0" repository = "https://github.com/rust-windowing/winit" -rust-version = "1.80" +rust-version = "1.85" version = "0.30.12" [workspace.dependencies] diff --git a/README.md b/README.md index 89d51458..50b1f975 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ For contributing guidelines see [CONTRIBUTING.md](./CONTRIBUTING.md). ## MSRV Policy -This crate's Minimum Supported Rust Version (MSRV) is **1.80**. Changes to +This crate's Minimum Supported Rust Version (MSRV) is **1.85**. Changes to the MSRV will be accompanied by a minor version bump. As a **tentative** policy, the upper bound of the MSRV is given by the following diff --git a/winit-android/src/keycodes.rs b/winit-android/src/keycodes.rs index d8027f44..75f4fb2b 100644 --- a/winit-android/src/keycodes.rs +++ b/winit-android/src/keycodes.rs @@ -1,5 +1,5 @@ -use android_activity::input::{KeyAction, KeyEvent, KeyMapChar, Keycode}; use android_activity::AndroidApp; +use android_activity::input::{KeyAction, KeyEvent, KeyMapChar, Keycode}; use winit_core::keyboard::{ Key, KeyCode, KeyLocation, NamedKey, NativeKey, NativeKeyCode, PhysicalKey, }; diff --git a/winit-appkit/src/app.rs b/winit-appkit/src/app.rs index 00c672cd..25cd3839 100644 --- a/winit-appkit/src/app.rs +++ b/winit-appkit/src/app.rs @@ -141,7 +141,7 @@ fn maybe_dispatch_device_event(app_state: &Rc, event: &NSEvent) { #[cfg(test)] mod tests { use objc2::rc::Retained; - use objc2::{define_class, msg_send, ClassType}; + use objc2::{ClassType, define_class, msg_send}; use objc2_app_kit::NSResponder; use objc2_foundation::NSObject; diff --git a/winit-appkit/src/app_state.rs b/winit-appkit/src/app_state.rs index e0e65417..7caf45fb 100644 --- a/winit-appkit/src/app_state.rs +++ b/winit-appkit/src/app_state.rs @@ -15,7 +15,7 @@ use winit_core::event::{StartCause, WindowEvent}; use winit_core::event_loop::ControlFlow; use winit_core::window::WindowId; -use super::event_loop::{notify_windows_of_exit, stop_app_immediately, ActiveEventLoop}; +use super::event_loop::{ActiveEventLoop, notify_windows_of_exit, stop_app_immediately}; use super::menu; use super::observer::{EventLoopWaker, RunLoop}; diff --git a/winit-appkit/src/cursor.rs b/winit-appkit/src/cursor.rs index d358885c..9c86c55d 100644 --- a/winit-appkit/src/cursor.rs +++ b/winit-appkit/src/cursor.rs @@ -4,10 +4,10 @@ use std::sync::OnceLock; use objc2::rc::Retained; use objc2::runtime::Sel; -use objc2::{available, msg_send, sel, AllocAnyThread, ClassType}; +use objc2::{AllocAnyThread, ClassType, available, msg_send, sel}; use objc2_app_kit::{NSBitmapImageRep, NSCursor, NSDeviceRGBColorSpace, NSImage}; use objc2_foundation::{ - ns_string, NSData, NSDictionary, NSNumber, NSObject, NSPoint, NSSize, NSString, + NSData, NSDictionary, NSNumber, NSObject, NSPoint, NSSize, NSString, ns_string, }; use winit_core::cursor::{CursorIcon, CursorImage, CustomCursorProvider, CustomCursorSource}; use winit_core::error::{NotSupportedError, RequestError}; @@ -31,7 +31,7 @@ impl CustomCursor { let cursor = match cursor { CustomCursorSource::Image(cursor_image) => cursor_image, CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => { - return Err(NotSupportedError::new("unsupported cursor kind").into()) + return Err(NotSupportedError::new("unsupported cursor kind").into()); }, }; diff --git a/winit-appkit/src/event_loop.rs b/winit-appkit/src/event_loop.rs index 88c33a36..4b5e48dd 100644 --- a/winit-appkit/src/event_loop.rs +++ b/winit-appkit/src/event_loop.rs @@ -2,9 +2,9 @@ use std::rc::Rc; use std::sync::Arc; use std::time::{Duration, Instant}; -use objc2::rc::{autoreleasepool, Retained}; +use objc2::rc::{Retained, autoreleasepool}; use objc2::runtime::ProtocolObject; -use objc2::{available, MainThreadMarker}; +use objc2::{MainThreadMarker, available}; use objc2_app_kit::{ NSApplication, NSApplicationActivationPolicy, NSApplicationDidFinishLaunchingNotification, NSApplicationWillTerminateNotification, NSWindow, @@ -29,8 +29,8 @@ use super::event::dummy_event; use super::monitor; use super::notification_center::create_observer; use super::observer::setup_control_flow_observers; -use crate::window::Window; use crate::ActivationPolicy; +use crate::window::Window; #[derive(Debug)] pub struct ActiveEventLoop { diff --git a/winit-appkit/src/ffi.rs b/winit-appkit/src/ffi.rs index 0a07499b..7f7cec0b 100644 --- a/winit-appkit/src/ffi.rs +++ b/winit-appkit/src/ffi.rs @@ -6,7 +6,7 @@ use std::ffi::c_void; use objc2::ffi::NSInteger; use objc2::runtime::AnyObject; -use objc2_core_foundation::{cf_type, CFString, CFUUID}; +use objc2_core_foundation::{CFString, CFUUID, cf_type}; use objc2_core_graphics::CGDirectDisplayID; pub const IO16BitDirectPixels: &str = "-RRRRRGGGGGBBBBB"; @@ -22,14 +22,14 @@ pub const kIO64BitDirectPixels: &str = "-16R16G16B16"; // `ApplicationServices`, see: // https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG #[link(name = "ApplicationServices", kind = "framework")] -extern "C" { +unsafe extern "C" { pub fn CGDisplayCreateUUIDFromDisplayID(display: CGDirectDisplayID) -> *mut CFUUID; pub fn CGDisplayGetDisplayIDFromUUID(uuid: &CFUUID) -> CGDirectDisplayID; } #[link(name = "CoreGraphics", kind = "framework")] -extern "C" { +unsafe extern "C" { // Wildly used private APIs; Apple uses them for their Terminal.app. pub fn CGSMainConnectionID() -> *mut AnyObject; pub fn CGSSetWindowBackgroundBlurRadius( @@ -60,7 +60,7 @@ pub const kUCKeyActionDisplay: u16 = 3; pub const kUCKeyTranslateNoDeadKeysMask: OptionBits = 1; #[link(name = "Carbon", kind = "framework")] -extern "C" { +unsafe extern "C" { pub static kTISPropertyUnicodeKeyLayoutData: &'static CFString; #[allow(non_snake_case)] diff --git a/winit-appkit/src/lib.rs b/winit-appkit/src/lib.rs index 546e768c..949e2f79 100644 --- a/winit-appkit/src/lib.rs +++ b/winit-appkit/src/lib.rs @@ -20,7 +20,7 @@ //! ``` //! use objc2::rc::Retained; //! use objc2::runtime::ProtocolObject; -//! use objc2::{define_class, msg_send, DefinedClass, MainThreadMarker, MainThreadOnly}; +//! use objc2::{DefinedClass, MainThreadMarker, MainThreadOnly, define_class, msg_send}; //! use objc2_app_kit::{NSApplication, NSApplicationDelegate}; //! use objc2_foundation::{NSArray, NSObject, NSObjectProtocol, NSURL}; //! use winit::event_loop::EventLoop; diff --git a/winit-appkit/src/menu.rs b/winit-appkit/src/menu.rs index 976edc9c..10b0075b 100644 --- a/winit-appkit/src/menu.rs +++ b/winit-appkit/src/menu.rs @@ -1,8 +1,8 @@ use objc2::rc::Retained; use objc2::runtime::Sel; -use objc2::{sel, MainThreadMarker}; +use objc2::{MainThreadMarker, sel}; use objc2_app_kit::{NSApplication, NSEventModifierFlags, NSMenu, NSMenuItem}; -use objc2_foundation::{ns_string, NSBundle, NSProcessInfo, NSString}; +use objc2_foundation::{NSBundle, NSProcessInfo, NSString, ns_string}; struct KeyEquivalent<'a> { key: &'a NSString, diff --git a/winit-appkit/src/monitor.rs b/winit-appkit/src/monitor.rs index b08e9087..edec6868 100644 --- a/winit-appkit/src/monitor.rs +++ b/winit-appkit/src/monitor.rs @@ -7,16 +7,16 @@ use std::{fmt, ptr}; use dispatch2::run_on_main; use dpi::{LogicalPosition, PhysicalPosition, PhysicalSize}; -use objc2::rc::Retained; use objc2::MainThreadMarker; +use objc2::rc::Retained; use objc2_app_kit::NSScreen; use objc2_core_foundation::{CFArray, CFRetained, CFUUID}; use objc2_core_graphics::{ CGDirectDisplayID, CGDisplayBounds, CGDisplayCopyAllDisplayModes, CGDisplayCopyDisplayMode, CGDisplayMode, CGDisplayModelNumber, CGGetActiveDisplayList, CGMainDisplayID, }; -use objc2_core_video::{kCVReturnSuccess, CVDisplayLink, CVTimeFlags}; -use objc2_foundation::{ns_string, NSNumber, NSPoint, NSRect}; +use objc2_core_video::{CVDisplayLink, CVTimeFlags, kCVReturnSuccess}; +use objc2_foundation::{NSNumber, NSPoint, NSRect, ns_string}; use tracing::warn; use winit_core::monitor::{MonitorHandleProvider, VideoMode}; @@ -139,7 +139,7 @@ impl MonitorHandle { refresh_rate_millihertz(self.display_id(), ¤t_display_mode) } - pub fn video_mode_handles(&self) -> impl Iterator { + pub fn video_mode_handles(&self) -> impl Iterator + 'static { let refresh_rate_millihertz = self.refresh_rate_millihertz(); let monitor = self.clone(); diff --git a/winit-appkit/src/observer.rs b/winit-appkit/src/observer.rs index 3629187c..48c93449 100644 --- a/winit-appkit/src/observer.rs +++ b/winit-appkit/src/observer.rs @@ -9,9 +9,9 @@ use std::time::Instant; use objc2::MainThreadMarker; use objc2_core_foundation::{ - kCFRunLoopCommonModes, kCFRunLoopDefaultMode, CFAbsoluteTimeGetCurrent, CFIndex, CFRetained, - CFRunLoop, CFRunLoopActivity, CFRunLoopObserver, CFRunLoopObserverCallBack, - CFRunLoopObserverContext, CFRunLoopTimer, + CFAbsoluteTimeGetCurrent, CFIndex, CFRetained, CFRunLoop, CFRunLoopActivity, CFRunLoopObserver, + CFRunLoopObserverCallBack, CFRunLoopObserverContext, CFRunLoopTimer, kCFRunLoopCommonModes, + kCFRunLoopDefaultMode, }; use tracing::error; diff --git a/winit-appkit/src/util.rs b/winit-appkit/src/util.rs index 3cb7ef1d..faf993b6 100644 --- a/winit-appkit/src/util.rs +++ b/winit-appkit/src/util.rs @@ -3,9 +3,7 @@ use tracing::trace; use winit_core::error::OsError; macro_rules! os_error { - ($error:expr) => {{ - winit_core::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }}; } macro_rules! trace_scope { @@ -36,9 +34,5 @@ impl Drop for TraceGuard { #[track_caller] pub(crate) fn cgerr(err: CGError) -> Result<(), OsError> { - if err == CGError::Success { - Ok(()) - } else { - Err(os_error!(format!("CGError {err:?}"))) - } + if err == CGError::Success { Ok(()) } else { Err(os_error!(format!("CGError {err:?}"))) } } diff --git a/winit-appkit/src/view.rs b/winit-appkit/src/view.rs index 17bb40e3..249489f4 100644 --- a/winit-appkit/src/view.rs +++ b/winit-appkit/src/view.rs @@ -7,7 +7,7 @@ use std::rc::Rc; use dpi::{LogicalPosition, LogicalSize}; use objc2::rc::Retained; use objc2::runtime::{AnyObject, Sel}; -use objc2::{define_class, msg_send, DefinedClass, MainThreadMarker}; +use objc2::{DefinedClass, MainThreadMarker, define_class, msg_send}; use objc2_app_kit::{ NSApplication, NSCursor, NSEvent, NSEventPhase, NSResponder, NSTextInputClient, NSTrackingRectTag, NSView, NSWindow, diff --git a/winit-appkit/src/window.rs b/winit-appkit/src/window.rs index 515ac55f..860119b7 100644 --- a/winit-appkit/src/window.rs +++ b/winit-appkit/src/window.rs @@ -4,8 +4,8 @@ use std::sync::Arc; use dispatch2::MainThreadBound; use dpi::{Position, Size}; -use objc2::rc::{autoreleasepool, Retained}; -use objc2::{define_class, MainThreadMarker, Message}; +use objc2::rc::{Retained, autoreleasepool}; +use objc2::{MainThreadMarker, Message, define_class}; use objc2_app_kit::{NSPanel, NSResponder, NSWindow}; use objc2_foundation::NSObject; use winit_core::cursor::Cursor; diff --git a/winit-appkit/src/window_delegate.rs b/winit-appkit/src/window_delegate.rs index 3d59bd3b..980ad632 100644 --- a/winit-appkit/src/window_delegate.rs +++ b/winit-appkit/src/window_delegate.rs @@ -10,11 +10,11 @@ use dpi::{ LogicalInsets, LogicalPosition, LogicalSize, PhysicalInsets, PhysicalPosition, PhysicalSize, Position, Size, }; -use objc2::rc::{autoreleasepool, Retained}; +use objc2::rc::{Retained, autoreleasepool}; use objc2::runtime::{AnyObject, ProtocolObject}; use objc2::{ - available, define_class, msg_send, sel, ClassType, DefinedClass, MainThreadMarker, - MainThreadOnly, Message, + ClassType, DefinedClass, MainThreadMarker, MainThreadOnly, Message, available, define_class, + msg_send, sel, }; use objc2_app_kit::{ NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSAppearanceCustomization, @@ -29,17 +29,17 @@ use objc2_app_kit::{ use objc2_app_kit::{NSFilenamesPboardType, NSWindowFullScreenButton}; use objc2_core_foundation::{CGFloat, CGPoint}; use objc2_core_graphics::{ - kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, kCGDisplayFadeReservationInvalidToken, - kCGFloatingWindowLevel, kCGNormalWindowLevel, CGAcquireDisplayFadeReservation, - CGAssociateMouseAndMouseCursorPosition, CGDisplayCapture, CGDisplayFade, CGDisplayRelease, - CGDisplaySetDisplayMode, CGReleaseDisplayFadeReservation, + CGAcquireDisplayFadeReservation, CGAssociateMouseAndMouseCursorPosition, CGDisplayCapture, + CGDisplayFade, CGDisplayRelease, CGDisplaySetDisplayMode, CGReleaseDisplayFadeReservation, CGRestorePermanentDisplayConfiguration, CGShieldingWindowLevel, CGWarpMouseCursorPosition, + kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, kCGDisplayFadeReservationInvalidToken, + kCGFloatingWindowLevel, kCGNormalWindowLevel, }; use objc2_foundation::{ - ns_string, NSArray, NSDictionary, NSEdgeInsets, NSKeyValueChangeKey, NSKeyValueChangeNewKey, + NSArray, NSDictionary, NSEdgeInsets, NSKeyValueChangeKey, NSKeyValueChangeNewKey, NSKeyValueChangeOldKey, NSKeyValueObservingOptions, NSNotificationCenter, NSObject, NSObjectNSDelayedPerforming, NSObjectNSKeyValueObserverRegistration, NSObjectProtocol, NSPoint, - NSRect, NSSize, NSString, + NSRect, NSSize, NSString, ns_string, }; use tracing::{trace, warn}; use winit_core::cursor::Cursor; @@ -53,13 +53,13 @@ use winit_core::window::{ }; use super::app_state::AppState; -use super::cursor::{cursor_from_icon, CustomCursor}; +use super::cursor::{CustomCursor, cursor_from_icon}; use super::ffi; -use super::monitor::{self, flip_window_screen_coordinates, get_display_id, MonitorHandle}; +use super::monitor::{self, MonitorHandle, flip_window_screen_coordinates, get_display_id}; use super::observer::RunLoop; use super::util::cgerr; use super::view::WinitView; -use super::window::{window_id, WinitPanel, WinitWindow}; +use super::window::{WinitPanel, WinitWindow, window_id}; use crate::{OptionAsAlt, WindowAttributesMacOS, WindowExtMacOS}; #[derive(Debug)] @@ -1237,7 +1237,7 @@ impl WindowDelegate { CursorGrabMode::Locked => false, CursorGrabMode::None => true, CursorGrabMode::Confined => { - return Err(NotSupportedError::new("confined cursor is not supported").into()) + return Err(NotSupportedError::new("confined cursor is not supported").into()); }, }; @@ -2039,11 +2039,7 @@ pub fn appearance_to_theme(appearance: &NSAppearance) -> Theme { dark_appearance_name(), ])); if let Some(best_match) = best_match { - if *best_match == *dark_appearance_name() { - Theme::Dark - } else { - Theme::Light - } + if *best_match == *dark_appearance_name() { Theme::Dark } else { Theme::Light } } else { warn!(?appearance, "failed to determine the theme of the appearance"); // Default to light in this case diff --git a/winit-common/src/core_foundation/event_loop_proxy.rs b/winit-common/src/core_foundation/event_loop_proxy.rs index 290a557d..c9840053 100644 --- a/winit-common/src/core_foundation/event_loop_proxy.rs +++ b/winit-common/src/core_foundation/event_loop_proxy.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use objc2::MainThreadMarker; use objc2_core_foundation::{ - kCFRunLoopCommonModes, CFIndex, CFRetained, CFRunLoop, CFRunLoopSource, CFRunLoopSourceContext, + CFIndex, CFRetained, CFRunLoop, CFRunLoopSource, CFRunLoopSourceContext, kCFRunLoopCommonModes, }; use winit_core::event_loop::EventLoopProxyProvider; diff --git a/winit-common/src/event_handler.rs b/winit-common/src/event_handler.rs index 9520b2cd..51d1b12c 100644 --- a/winit-common/src/event_handler.rs +++ b/winit-common/src/event_handler.rs @@ -114,7 +114,7 @@ impl EventHandler { pub fn handle(&self, callback: impl FnOnce(&mut (dyn ApplicationHandler + '_))) { match self.inner.try_borrow_mut().as_deref_mut() { - Ok(Some(ref mut user_app)) => { + Ok(Some(user_app)) => { // It is important that we keep the reference borrowed here, // so that `in_use` can properly detect that the handler is // still in use. diff --git a/winit-common/src/xkb/compose.rs b/winit-common/src/xkb/compose.rs index 3b5ddca1..37830ca8 100644 --- a/winit-common/src/xkb/compose.rs +++ b/winit-common/src/xkb/compose.rs @@ -12,7 +12,7 @@ use xkbcommon_dl::{ xkb_compose_status, xkb_compose_table, xkb_keysym_t, }; -use super::{XkbContext, XKBCH}; +use super::{XKBCH, XkbContext}; #[derive(Debug)] pub struct XkbComposeTable { diff --git a/winit-common/src/xkb/keymap.rs b/winit-common/src/xkb/keymap.rs index 61464e46..81922e74 100644 --- a/winit-common/src/xkb/keymap.rs +++ b/winit-common/src/xkb/keymap.rs @@ -19,7 +19,7 @@ use {memmap2::MmapOptions, std::os::unix::io::OwnedFd}; #[cfg(feature = "x11")] use super::XKBXH; -use super::{XkbContext, XKBH}; +use super::{XKBH, XkbContext}; /// Map the raw X11-style keycode to the `KeyCode` enum. /// @@ -1052,11 +1052,7 @@ impl XkbKeymap { &mut keysyms, ); - if count == 1 { - *keysyms - } else { - 0 - } + if count == 1 { *keysyms } else { 0 } } } @@ -1100,10 +1096,6 @@ fn mod_index_for_name(keymap: NonNull, name: &[u8]) -> Option KeyEventResults<'a, 'b> { fn keysym_to_key(&self, keysym: u32) -> Result<(Key, KeyLocation), (Key, KeyLocation)> { let location = keymap::keysym_location(keysym); let key = keymap::keysym_to_key(keysym); - if matches!(key, Key::Unidentified(_)) { - Err((key, location)) - } else { - Ok((key, location)) - } + if matches!(key, Key::Unidentified(_)) { Err((key, location)) } else { Ok((key, location)) } } pub fn text(&mut self) -> Option { diff --git a/winit-common/src/xkb/state.rs b/winit-common/src/xkb/state.rs index 6334f785..c193d562 100644 --- a/winit-common/src/xkb/state.rs +++ b/winit-common/src/xkb/state.rs @@ -10,10 +10,10 @@ use xkbcommon_dl::{ self as xkb, xkb_keycode_t, xkb_keysym_t, xkb_layout_index_t, xkb_state, xkb_state_component, }; -use super::keymap::XkbKeymap; #[cfg(feature = "x11")] use super::XKBXH; -use super::{make_string_with, XKBH}; +use super::keymap::XkbKeymap; +use super::{XKBH, make_string_with}; #[derive(Debug)] pub struct XkbState { diff --git a/winit-core/src/error.rs b/winit-core/src/error.rs index 3a6e1b83..d9857acd 100644 --- a/winit-core/src/error.rs +++ b/winit-core/src/error.rs @@ -35,11 +35,7 @@ impl fmt::Display for EventLoopError { impl Error for EventLoopError { fn source(&self) -> Option<&(dyn Error + 'static)> { - if let Self::Os(err) = self { - err.source() - } else { - None - } + if let Self::Os(err) = self { err.source() } else { None } } } @@ -78,11 +74,7 @@ impl Display for RequestError { } impl Error for RequestError { fn source(&self) -> Option<&(dyn Error + 'static)> { - if let Self::Os(err) = self { - err.source() - } else { - None - } + if let Self::Os(err) = self { err.source() } else { None } } } @@ -149,7 +141,5 @@ impl Error for OsError { #[allow(unused_macros)] macro_rules! os_error { - ($error:expr) => {{ - crate::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ crate::error::OsError::new(line!(), file!(), $error) }}; } diff --git a/winit-core/src/event.rs b/winit-core/src/event.rs index 7ad984ef..a787c1e2 100644 --- a/winit-core/src/event.rs +++ b/winit-core/src/event.rs @@ -10,13 +10,13 @@ use dpi::{PhysicalPosition, PhysicalSize}; use serde::{Deserialize, Serialize}; use smol_str::SmolStr; +use crate::Instant; use crate::error::RequestError; use crate::event_loop::AsyncRequestSerial; use crate::keyboard::{self, ModifiersKeyState, ModifiersKeys, ModifiersState}; #[cfg(doc)] use crate::window::Window; use crate::window::{ActivationToken, Theme}; -use crate::Instant; /// Describes the reason the event loop is resuming. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -1117,11 +1117,7 @@ pub struct TabletToolData { impl TabletToolData { /// Returns [`TabletToolTilt`] if present or calculates it from [`TabletToolAngle`]. pub fn tilt(self) -> Option { - if let Some(tilt) = self.tilt { - Some(tilt) - } else { - self.angle.map(TabletToolAngle::tilt) - } + if let Some(tilt) = self.tilt { Some(tilt) } else { self.angle.map(TabletToolAngle::tilt) } } /// Returns [`TabletToolAngle`] if present or calculates it from [`TabletToolTilt`]. diff --git a/winit-core/src/event_loop/mod.rs b/winit-core/src/event_loop/mod.rs index 71307ee7..edc06dc6 100644 --- a/winit-core/src/event_loop/mod.rs +++ b/winit-core/src/event_loop/mod.rs @@ -2,18 +2,18 @@ pub mod pump_events; pub mod run_on_demand; use std::fmt::{self, Debug}; -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::Duration; use rwh_06::{DisplayHandle, HandleError, HasDisplayHandle}; +use crate::Instant; use crate::as_any::AsAny; use crate::cursor::{CustomCursor, CustomCursorSource}; use crate::error::RequestError; use crate::monitor::MonitorHandle; use crate::window::{Theme, Window, WindowAttributes}; -use crate::Instant; pub trait ActiveEventLoop: AsAny + fmt::Debug { /// Creates an [`EventLoopProxy`] that can be used to dispatch user events diff --git a/winit-core/src/event_loop/run_on_demand.rs b/winit-core/src/event_loop/run_on_demand.rs index 4fa5a019..556be393 100644 --- a/winit-core/src/event_loop/run_on_demand.rs +++ b/winit-core/src/event_loop/run_on_demand.rs @@ -2,7 +2,7 @@ use crate::application::ApplicationHandler; use crate::error::EventLoopError; #[cfg(doc)] use crate::{ - event_loop::{pump_events::EventLoopExtPumpEvents, ActiveEventLoop}, + event_loop::{ActiveEventLoop, pump_events::EventLoopExtPumpEvents}, window::Window, }; diff --git a/winit-core/src/keyboard.rs b/winit-core/src/keyboard.rs index 01f82043..af92c430 100644 --- a/winit-core/src/keyboard.rs +++ b/winit-core/src/keyboard.rs @@ -193,7 +193,7 @@ impl PartialEq for PhysicalKey { #[inline] fn eq(&self, rhs: &KeyCode) -> bool { match self { - PhysicalKey::Code(ref code) => code == rhs, + PhysicalKey::Code(code) => code == rhs, _ => false, } } @@ -210,7 +210,7 @@ impl PartialEq for PhysicalKey { #[inline] fn eq(&self, rhs: &NativeKeyCode) -> bool { match self { - PhysicalKey::Unidentified(ref code) => code == rhs, + PhysicalKey::Unidentified(code) => code == rhs, _ => false, } } @@ -275,7 +275,7 @@ impl PartialEq for Key { #[inline] fn eq(&self, rhs: &NamedKey) -> bool { match self { - Key::Named(ref a) => a == rhs, + Key::Named(a) => a == rhs, _ => false, } } @@ -285,7 +285,7 @@ impl> PartialEq for Key { #[inline] fn eq(&self, rhs: &str) -> bool { match self { - Key::Character(ref s) => s == rhs, + Key::Character(s) => s == rhs, _ => false, } } @@ -302,7 +302,7 @@ impl PartialEq for Key { #[inline] fn eq(&self, rhs: &NativeKey) -> bool { match self { - Key::Unidentified(ref code) => code == rhs, + Key::Unidentified(code) => code == rhs, _ => false, } } diff --git a/winit-core/src/window.rs b/winit-core/src/window.rs index 36631604..1cfe833c 100644 --- a/winit-core/src/window.rs +++ b/winit-core/src/window.rs @@ -2091,52 +2091,66 @@ mod tests { let position: Position = LogicalPosition::new(0, 0).into(); let size: Size = LogicalSize::new(0, 0).into(); - assert!(ImeEnableRequest::new( - ImeCapabilities::new().with_cursor_area(), - ImeRequestData::default() - ) - .is_none()); - assert!(ImeEnableRequest::new( - ImeCapabilities::new().with_hint_and_purpose(), - ImeRequestData::default() - ) - .is_none()); + assert!( + ImeEnableRequest::new( + ImeCapabilities::new().with_cursor_area(), + ImeRequestData::default() + ) + .is_none() + ); + assert!( + ImeEnableRequest::new( + ImeCapabilities::new().with_hint_and_purpose(), + ImeRequestData::default() + ) + .is_none() + ); - assert!(ImeEnableRequest::new( - ImeCapabilities::new().with_cursor_area(), - ImeRequestData::default().with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) - ) - .is_none()); + assert!( + ImeEnableRequest::new( + ImeCapabilities::new().with_cursor_area(), + ImeRequestData::default().with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) + ) + .is_none() + ); - assert!(ImeEnableRequest::new( - ImeCapabilities::new(), - ImeRequestData::default() - .with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) - .with_cursor_area(position, size) - ) - .is_none()); + assert!( + ImeEnableRequest::new( + ImeCapabilities::new(), + ImeRequestData::default() + .with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) + .with_cursor_area(position, size) + ) + .is_none() + ); - assert!(ImeEnableRequest::new( - ImeCapabilities::new().with_cursor_area(), - ImeRequestData::default() - .with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) - .with_cursor_area(position, size) - ) - .is_none()); + assert!( + ImeEnableRequest::new( + ImeCapabilities::new().with_cursor_area(), + ImeRequestData::default() + .with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) + .with_cursor_area(position, size) + ) + .is_none() + ); - assert!(ImeEnableRequest::new( - ImeCapabilities::new().with_cursor_area(), - ImeRequestData::default().with_cursor_area(position, size) - ) - .is_some()); + assert!( + ImeEnableRequest::new( + ImeCapabilities::new().with_cursor_area(), + ImeRequestData::default().with_cursor_area(position, size) + ) + .is_some() + ); - assert!(ImeEnableRequest::new( - ImeCapabilities::new().with_hint_and_purpose().with_cursor_area(), - ImeRequestData::default() - .with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) - .with_cursor_area(position, size) - ) - .is_some()); + assert!( + ImeEnableRequest::new( + ImeCapabilities::new().with_hint_and_purpose().with_cursor_area(), + ImeRequestData::default() + .with_hint_and_purpose(ImeHint::NONE, ImePurpose::Normal) + .with_cursor_area(position, size) + ) + .is_some() + ); let text: &[u8] = ['a' as u8; 8000].as_slice(); let text = std::str::from_utf8(text).unwrap(); diff --git a/winit-orbital/src/event_loop.rs b/winit-orbital/src/event_loop.rs index 77f1aaea..e3331347 100644 --- a/winit-orbital/src/event_loop.rs +++ b/winit-orbital/src/event_loop.rs @@ -1,7 +1,7 @@ use std::cell::Cell; use std::collections::VecDeque; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{mpsc, Arc, Mutex}; +use std::sync::{Arc, Mutex, mpsc}; use std::time::Instant; use std::{iter, mem, slice}; @@ -133,11 +133,7 @@ fn convert_scancode(scancode: u8) -> (PhysicalKey, Option) { } fn element_state(pressed: bool) -> event::ElementState { - if pressed { - event::ElementState::Pressed - } else { - event::ElementState::Released - } + if pressed { event::ElementState::Pressed } else { event::ElementState::Released } } bitflags! { diff --git a/winit-orbital/src/lib.rs b/winit-orbital/src/lib.rs index 9b8d56d5..71efc821 100644 --- a/winit-orbital/src/lib.rs +++ b/winit-orbital/src/lib.rs @@ -8,9 +8,7 @@ use std::{fmt, str}; pub use self::event_loop::{EventLoop, PlatformSpecificEventLoopAttributes}; macro_rules! os_error { - ($error:expr) => {{ - winit_core::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }}; } pub mod event_loop; @@ -41,20 +39,12 @@ impl RedoxSocket { fn read(&self, buf: &mut [u8]) -> syscall::Result<()> { let count = syscall::read(self.fd, buf)?; - if count == buf.len() { - Ok(()) - } else { - Err(syscall::Error::new(syscall::EINVAL)) - } + if count == buf.len() { Ok(()) } else { Err(syscall::Error::new(syscall::EINVAL)) } } fn write(&self, buf: &[u8]) -> syscall::Result<()> { let count = syscall::write(self.fd, buf)?; - if count == buf.len() { - Ok(()) - } else { - Err(syscall::Error::new(syscall::EINVAL)) - } + if count == buf.len() { Ok(()) } else { Err(syscall::Error::new(syscall::EINVAL)) } } fn fpath<'a>(&self, buf: &'a mut [u8]) -> syscall::Result<&'a str> { diff --git a/winit-uikit/src/app_state.rs b/winit-uikit/src/app_state.rs index 52ad2346..7876e34f 100644 --- a/winit-uikit/src/app_state.rs +++ b/winit-uikit/src/app_state.rs @@ -9,11 +9,11 @@ use std::{fmt, ptr}; use dispatch2::MainThreadBound; use dpi::PhysicalSize; -use objc2::rc::Retained; use objc2::MainThreadMarker; +use objc2::rc::Retained; use objc2_core_foundation::{ - kCFRunLoopCommonModes, CFAbsoluteTimeGetCurrent, CFRetained, CFRunLoop, CFRunLoopTimer, CGRect, - CGSize, + CFAbsoluteTimeGetCurrent, CFRetained, CFRunLoop, CFRunLoopTimer, CGRect, CGSize, + kCFRunLoopCommonModes, }; use objc2_ui_kit::{UIApplication, UICoordinateSpace, UIView}; use winit_common::core_foundation::EventLoopProxy; diff --git a/winit-uikit/src/event_loop.rs b/winit-uikit/src/event_loop.rs index f73b9440..bc3e1fcb 100644 --- a/winit-uikit/src/event_loop.rs +++ b/winit-uikit/src/event_loop.rs @@ -4,9 +4,9 @@ use std::sync::Arc; use objc2::rc::Retained; use objc2::runtime::ProtocolObject; -use objc2::{msg_send, ClassType, MainThreadMarker}; +use objc2::{ClassType, MainThreadMarker, msg_send}; use objc2_core_foundation::{ - kCFRunLoopDefaultMode, CFIndex, CFRunLoop, CFRunLoopActivity, CFRunLoopObserver, + CFIndex, CFRunLoop, CFRunLoopActivity, CFRunLoopObserver, kCFRunLoopDefaultMode, }; use objc2_foundation::{NSNotificationCenter, NSObjectProtocol}; use objc2_ui_kit::{ @@ -26,7 +26,7 @@ use winit_core::event_loop::{ use winit_core::monitor::MonitorHandle as CoreMonitorHandle; use winit_core::window::{Theme, Window as CoreWindow}; -use super::app_state::{send_occluded_event_for_all_windows, AppState}; +use super::app_state::{AppState, send_occluded_event_for_all_windows}; use super::notification_center::create_observer; use crate::monitor::MonitorHandle; use crate::window::Window; diff --git a/winit-uikit/src/monitor.rs b/winit-uikit/src/monitor.rs index 8742f1ec..c2d79353 100644 --- a/winit-uikit/src/monitor.rs +++ b/winit-uikit/src/monitor.rs @@ -4,10 +4,10 @@ use std::collections::VecDeque; use std::num::NonZeroU32; use std::{fmt, hash, ptr}; -use dispatch2::{run_on_main, MainThreadBound}; +use dispatch2::{MainThreadBound, run_on_main}; use dpi::PhysicalPosition; use objc2::rc::Retained; -use objc2::{available, MainThreadMarker, Message}; +use objc2::{MainThreadMarker, Message, available}; use objc2_foundation::NSInteger; use objc2_ui_kit::{UIScreen, UIScreenMode}; use winit_core::monitor::{MonitorHandleProvider, VideoMode}; @@ -190,7 +190,7 @@ impl MonitorHandle { Self { ui_screen: MainThreadBound::new(ui_screen, mtm) } } - pub fn video_modes_handles(&self) -> impl Iterator { + pub fn video_modes_handles(&self) -> impl Iterator + 'static { run_on_main(|mtm| { let ui_screen = self.ui_screen(mtm); @@ -203,7 +203,7 @@ impl MonitorHandle { }) } - pub fn video_modes(&self) -> impl Iterator { + pub fn video_modes(&self) -> impl Iterator + 'static { self.video_modes_handles().map(|handle| handle.mode) } diff --git a/winit-uikit/src/view.rs b/winit-uikit/src/view.rs index 8ec238f9..39058bd0 100644 --- a/winit-uikit/src/view.rs +++ b/winit-uikit/src/view.rs @@ -4,7 +4,7 @@ use std::cell::{Cell, RefCell}; use dpi::PhysicalPosition; use objc2::rc::Retained; use objc2::runtime::{NSObjectProtocol, ProtocolObject}; -use objc2::{available, define_class, msg_send, sel, DefinedClass, MainThreadMarker}; +use objc2::{DefinedClass, MainThreadMarker, available, define_class, msg_send, sel}; use objc2_core_foundation::{CGFloat, CGPoint, CGRect}; use objc2_foundation::{NSObject, NSSet, NSString}; use objc2_ui_kit::{ diff --git a/winit-uikit/src/view_controller.rs b/winit-uikit/src/view_controller.rs index 56d7d53a..bc8607c2 100644 --- a/winit-uikit/src/view_controller.rs +++ b/winit-uikit/src/view_controller.rs @@ -1,7 +1,7 @@ use std::cell::Cell; use objc2::rc::Retained; -use objc2::{available, define_class, msg_send, DefinedClass, MainThreadMarker}; +use objc2::{DefinedClass, MainThreadMarker, available, define_class, msg_send}; use objc2_foundation::NSObject; use objc2_ui_kit::{ UIDevice, UIInterfaceOrientationMask, UIRectEdge, UIResponder, UIStatusBarStyle, diff --git a/winit-uikit/src/window.rs b/winit-uikit/src/window.rs index 5af70aaf..788babcb 100644 --- a/winit-uikit/src/window.rs +++ b/winit-uikit/src/window.rs @@ -9,7 +9,7 @@ use dpi::{ Position, Size, }; use objc2::rc::Retained; -use objc2::{available, class, define_class, msg_send, MainThreadMarker}; +use objc2::{MainThreadMarker, available, class, define_class, msg_send}; use objc2_core_foundation::{CGFloat, CGPoint, CGRect, CGSize}; use objc2_foundation::{NSObject, NSObjectProtocol}; use objc2_ui_kit::{ diff --git a/winit-wayland/src/event_loop/mod.rs b/winit-wayland/src/event_loop/mod.rs index ee6b4e8e..780239c9 100644 --- a/winit-wayland/src/event_loop/mod.rs +++ b/winit-wayland/src/event_loop/mod.rs @@ -15,7 +15,7 @@ use dpi::LogicalSize; use rustix::event::{PollFd, PollFlags}; use rustix::pipe::{self, PipeFlags}; use sctk::reexports::calloop_wayland_source::WaylandSource; -use sctk::reexports::client::{globals, Connection, QueueHandle}; +use sctk::reexports::client::{Connection, QueueHandle, globals}; use tracing::warn; use winit_core::application::ApplicationHandler; use winit_core::cursor::{CustomCursor as CoreCustomCursor, CustomCursorSource}; @@ -41,7 +41,7 @@ pub use winit_core::event_loop::EventLoopProxy as CoreEventLoopProxy; use super::output::MonitorHandle; use super::state::{WindowCompositorUpdate, WinitState}; use super::window::state::FrameCallbackState; -use super::{logical_to_physical_rounded, WindowId}; +use super::{WindowId, logical_to_physical_rounded}; type WaylandDispatcher = calloop::Dispatcher<'static, WaylandSource, WinitState>; @@ -639,7 +639,7 @@ impl RootActiveEventLoop for ActiveEventLoop { let cursor_image = match cursor { CustomCursorSource::Image(cursor_image) => cursor_image, CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => { - return Err(NotSupportedError::new("unsupported cursor kind").into()) + return Err(NotSupportedError::new("unsupported cursor kind").into()); }, }; diff --git a/winit-wayland/src/lib.rs b/winit-wayland/src/lib.rs index b7926974..d13b3064 100644 --- a/winit-wayland/src/lib.rs +++ b/winit-wayland/src/lib.rs @@ -18,8 +18,8 @@ use std::ffi::c_void; use std::ptr::NonNull; use dpi::{LogicalSize, PhysicalSize}; -use sctk::reexports::client::protocol::wl_surface::WlSurface; use sctk::reexports::client::Proxy; +use sctk::reexports::client::protocol::wl_surface::WlSurface; use sctk::shm::slot::{Buffer, CreateBufferError, SlotPool}; use wayland_client::protocol::wl_shm::Format; use winit_core::event_loop::ActiveEventLoop as CoreActiveEventLoop; @@ -28,9 +28,7 @@ use winit_core::window::{ }; macro_rules! os_error { - ($error:expr) => {{ - winit_core::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }}; } mod event_loop; diff --git a/winit-wayland/src/output.rs b/winit-wayland/src/output.rs index 5ee6b3fb..72ac253f 100644 --- a/winit-wayland/src/output.rs +++ b/winit-wayland/src/output.rs @@ -3,8 +3,8 @@ use std::num::NonZeroU32; use dpi::{LogicalPosition, PhysicalPosition}; use sctk::output::{Mode, OutputData}; -use sctk::reexports::client::protocol::wl_output::WlOutput; use sctk::reexports::client::Proxy; +use sctk::reexports::client::protocol::wl_output::WlOutput; use winit_core::monitor::{MonitorHandleProvider as CoreMonitorHandle, VideoMode}; #[derive(Clone, Debug)] diff --git a/winit-wayland/src/seat/keyboard/mod.rs b/winit-wayland/src/seat/keyboard/mod.rs index 22700685..f3af9149 100644 --- a/winit-wayland/src/seat/keyboard/mod.rs +++ b/winit-wayland/src/seat/keyboard/mod.rs @@ -15,9 +15,9 @@ use winit_common::xkb::Context; use winit_core::event::{ElementState, WindowEvent}; use winit_core::keyboard::ModifiersState; +use crate::WindowId; use crate::event_loop::sink::EventSink; use crate::state::WinitState; -use crate::WindowId; impl Dispatch for WinitState { fn event( diff --git a/winit-wayland/src/seat/pointer/pointer_gesture.rs b/winit-wayland/src/seat/pointer/pointer_gesture.rs index d46f3706..87b97d5d 100644 --- a/winit-wayland/src/seat/pointer/pointer_gesture.rs +++ b/winit-wayland/src/seat/pointer/pointer_gesture.rs @@ -5,7 +5,7 @@ use dpi::{LogicalPosition, PhysicalPosition}; use sctk::compositor::SurfaceData; use sctk::globals::GlobalData; use sctk::reexports::client::globals::{BindError, GlobalList}; -use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle}; +use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch}; use sctk::reexports::protocols::wp::pointer_gestures::zv1::client::zwp_pointer_gesture_pinch_v1::{ Event, ZwpPointerGesturePinchV1, }; @@ -88,9 +88,7 @@ impl Dispatch for Poin } // Don't handle events from a subsurface. - if !surface - .data::() - .is_some_and(|data| data.parent_surface().is_none()) + if surface.data::().is_none_or(|data| data.parent_surface().is_some()) { return; } diff --git a/winit-wayland/src/seat/text_input/mod.rs b/winit-wayland/src/seat/text_input/mod.rs index 36149cf2..c4566a8e 100644 --- a/winit-wayland/src/seat/text_input/mod.rs +++ b/winit-wayland/src/seat/text_input/mod.rs @@ -4,7 +4,7 @@ use dpi::{LogicalPosition, LogicalSize}; use sctk::globals::GlobalData; use sctk::reexports::client::globals::{BindError, GlobalList}; use sctk::reexports::client::protocol::wl_surface::WlSurface; -use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle}; +use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch}; use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_manager_v3::ZwpTextInputManagerV3; use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::{ ContentHint, ContentPurpose, Event as TextInputEvent, ZwpTextInputV3, diff --git a/winit-wayland/src/state.rs b/winit-wayland/src/state.rs index c254c872..d6090599 100644 --- a/winit-wayland/src/state.rs +++ b/winit-wayland/src/state.rs @@ -12,16 +12,17 @@ use sctk::reexports::client::protocol::wl_output::WlOutput; use sctk::reexports::client::protocol::wl_surface::WlSurface; use sctk::reexports::client::{Connection, Proxy, QueueHandle}; use sctk::registry::{ProvidesRegistryState, RegistryState}; -use sctk::seat::pointer::ThemedPointer; use sctk::seat::SeatState; -use sctk::shell::xdg::window::{Window, WindowConfigure, WindowHandler}; -use sctk::shell::xdg::XdgShell; +use sctk::seat::pointer::ThemedPointer; use sctk::shell::WaylandSurface; +use sctk::shell::xdg::XdgShell; +use sctk::shell::xdg::window::{Window, WindowConfigure, WindowHandler}; use sctk::shm::slot::SlotPool; use sctk::shm::{Shm, ShmHandler}; use sctk::subcompositor::SubcompositorState; use winit_core::error::OsError; +use crate::WindowId; use crate::event_loop::sink::EventSink; use crate::output::MonitorHandle; use crate::seat::{ @@ -35,7 +36,6 @@ use crate::types::wp_viewporter::ViewporterState; use crate::types::xdg_activation::XdgActivationState; use crate::types::xdg_toplevel_icon_manager::XdgToplevelIconManagerState; use crate::window::{WindowRequests, WindowState}; -use crate::WindowId; /// Winit's Wayland state. #[derive(Debug)] diff --git a/winit-wayland/src/types/kwin_blur.rs b/winit-wayland/src/types/kwin_blur.rs index 0478ba03..29ef5d68 100644 --- a/winit-wayland/src/types/kwin_blur.rs +++ b/winit-wayland/src/types/kwin_blur.rs @@ -3,7 +3,7 @@ use sctk::globals::GlobalData; use sctk::reexports::client::globals::{BindError, GlobalList}; use sctk::reexports::client::protocol::wl_surface::WlSurface; -use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle}; +use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch}; use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur; use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager; diff --git a/winit-wayland/src/types/wp_fractional_scaling.rs b/winit-wayland/src/types/wp_fractional_scaling.rs index a59af987..13c0aef9 100644 --- a/winit-wayland/src/types/wp_fractional_scaling.rs +++ b/winit-wayland/src/types/wp_fractional_scaling.rs @@ -3,7 +3,7 @@ use sctk::globals::GlobalData; use sctk::reexports::client::globals::{BindError, GlobalList}; use sctk::reexports::client::protocol::wl_surface::WlSurface; -use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle}; +use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch}; use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1; use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::{ Event as FractionalScalingEvent, WpFractionalScaleV1, diff --git a/winit-wayland/src/types/wp_tablet_input_v2.rs b/winit-wayland/src/types/wp_tablet_input_v2.rs index 0d7e5a1e..e7f9830c 100644 --- a/winit-wayland/src/types/wp_tablet_input_v2.rs +++ b/winit-wayland/src/types/wp_tablet_input_v2.rs @@ -10,7 +10,7 @@ use sctk::reexports::client::globals::{BindError, GlobalList}; use sctk::reexports::client::protocol::wl_seat::WlSeat; use sctk::reexports::client::protocol::wl_surface::WlSurface; use sctk::reexports::client::{ - delegate_dispatch, event_created_child, Connection, Dispatch, Proxy, QueueHandle, WEnum, + Connection, Dispatch, Proxy, QueueHandle, WEnum, delegate_dispatch, event_created_child, }; use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_manager_v2::ZwpTabletManagerV2; use sctk::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_pad_v2::ZwpTabletPadV2; diff --git a/winit-wayland/src/types/wp_viewporter.rs b/winit-wayland/src/types/wp_viewporter.rs index 033bcf40..4bfa4646 100644 --- a/winit-wayland/src/types/wp_viewporter.rs +++ b/winit-wayland/src/types/wp_viewporter.rs @@ -3,7 +3,7 @@ use sctk::globals::GlobalData; use sctk::reexports::client::globals::{BindError, GlobalList}; use sctk::reexports::client::protocol::wl_surface::WlSurface; -use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle}; +use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch}; use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport; use sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter; diff --git a/winit-wayland/src/types/xdg_activation.rs b/winit-wayland/src/types/xdg_activation.rs index 9e9998cb..7c2cbd5f 100644 --- a/winit-wayland/src/types/xdg_activation.rs +++ b/winit-wayland/src/types/xdg_activation.rs @@ -1,12 +1,12 @@ //! Handling of xdg activation, which is used for user attention requests. -use std::sync::atomic::AtomicBool; use std::sync::Weak; +use std::sync::atomic::AtomicBool; use sctk::globals::GlobalData; use sctk::reexports::client::globals::{BindError, GlobalList}; use sctk::reexports::client::protocol::wl_surface::WlSurface; -use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle}; +use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch}; use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_token_v1::{ Event as ActivationTokenEvent, XdgActivationTokenV1, }; diff --git a/winit-wayland/src/types/xdg_toplevel_icon_manager.rs b/winit-wayland/src/types/xdg_toplevel_icon_manager.rs index df692c30..c898e07e 100644 --- a/winit-wayland/src/types/xdg_toplevel_icon_manager.rs +++ b/winit-wayland/src/types/xdg_toplevel_icon_manager.rs @@ -7,7 +7,7 @@ use sctk::globals::GlobalData; use sctk::shm::slot::{Buffer, SlotPool}; use wayland_client::globals::{BindError, GlobalList}; use wayland_client::protocol::wl_shm::Format; -use wayland_client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle}; +use wayland_client::{Connection, Dispatch, Proxy, QueueHandle, delegate_dispatch}; use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_manager_v1::XdgToplevelIconManagerV1; use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_v1::XdgToplevelIconV1; use winit_core::icon::{Icon, RgbaIcon}; diff --git a/winit-wayland/src/window/mod.rs b/winit-wayland/src/window/mod.rs index fb5f22fe..b3bdaa71 100644 --- a/winit-wayland/src/window/mod.rs +++ b/winit-wayland/src/window/mod.rs @@ -11,8 +11,8 @@ use sctk::reexports::client::protocol::wl_display::WlDisplay; use sctk::reexports::client::protocol::wl_surface::WlSurface; use sctk::reexports::client::{Proxy, QueueHandle}; use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_v1::XdgActivationV1; -use sctk::shell::xdg::window::{Window as SctkWindow, WindowDecorations}; use sctk::shell::WaylandSurface; +use sctk::shell::xdg::window::{Window as SctkWindow, WindowDecorations}; use tracing::warn; use winit_core::cursor::Cursor; use winit_core::error::{NotSupportedError, RequestError}; @@ -25,12 +25,12 @@ use winit_core::window::{ WindowLevel, }; +use super::ActiveEventLoop; use super::event_loop::sink::EventSink; use super::output::MonitorHandle; use super::state::WinitState; use super::types::xdg_activation::XdgActivationTokenData; -use super::ActiveEventLoop; -use crate::{output, WindowAttributesWayland}; +use crate::{WindowAttributesWayland, output}; pub(crate) mod state; @@ -431,11 +431,7 @@ impl CoreWindow for Window { } fn set_maximized(&self, maximized: bool) { - if maximized { - self.window.set_maximized() - } else { - self.window.unset_maximized() - } + if maximized { self.window.set_maximized() } else { self.window.unset_maximized() } } fn is_maximized(&self) -> bool { diff --git a/winit-wayland/src/window/state.rs b/winit-wayland/src/window/state.rs index f917b6d5..8e3f52da 100644 --- a/winit-wayland/src/window/state.rs +++ b/winit-wayland/src/window/state.rs @@ -21,11 +21,11 @@ use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3:: use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport; use sctk::reexports::protocols::xdg::shell::client::xdg_toplevel::ResizeEdge as XdgResizeEdge; use sctk::seat::pointer::{PointerDataExt, ThemedPointer}; -use sctk::shell::xdg::window::{DecorationMode, Window, WindowConfigure}; -use sctk::shell::xdg::XdgSurface; use sctk::shell::WaylandSurface; -use sctk::shm::slot::SlotPool; +use sctk::shell::xdg::XdgSurface; +use sctk::shell::xdg::window::{DecorationMode, Window, WindowConfigure}; use sctk::shm::Shm; +use sctk::shm::slot::SlotPool; use sctk::subcompositor::SubcompositorState; use tracing::{info, warn}; use wayland_protocols::xdg::toplevel_icon::v1::client::xdg_toplevel_icon_manager_v1::XdgToplevelIconManagerV1; @@ -852,7 +852,7 @@ impl WindowState { None => { return Err( NotSupportedError::new("zwp_pointer_constraints is not available").into() - ) + ); }, }; @@ -1037,11 +1037,7 @@ impl WindowState { text_input.set_state(self.text_input_state.as_ref(), state_change); } - if state_change { - Ok(Some(self.text_input_state.is_some())) - } else { - Ok(None) - } + if state_change { Ok(Some(self.text_input_state.is_some())) } else { Ok(None) } } /// Set the scale factor for the given window. diff --git a/winit-web/src/async/abortable.rs b/winit-web/src/async/abortable.rs index 671ae879..158cbbc8 100644 --- a/winit-web/src/async/abortable.rs +++ b/winit-web/src/async/abortable.rs @@ -2,8 +2,8 @@ use std::error::Error; use std::fmt::{self, Display, Formatter}; use std::future::Future; use std::pin::Pin; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; use std::task::{Context, Poll}; use pin_project::pin_project; diff --git a/winit-web/src/async/channel.rs b/winit-web/src/async/channel.rs index 380b7cb8..757e65f3 100644 --- a/winit-web/src/async/channel.rs +++ b/winit-web/src/async/channel.rs @@ -1,7 +1,7 @@ use std::future; +use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{self, RecvError, SendError, TryRecvError}; -use std::sync::Arc; use std::task::Poll; use super::AtomicWaker; diff --git a/winit-web/src/async/concurrent_queue.rs b/winit-web/src/async/concurrent_queue.rs index 70afb3dd..638d0fce 100644 --- a/winit-web/src/async/concurrent_queue.rs +++ b/winit-web/src/async/concurrent_queue.rs @@ -32,13 +32,10 @@ impl ConcurrentQueue { } pub fn pop(&self) -> Result { - self.queue.borrow_mut().pop().ok_or_else(|| { - if self.closed.get() { - PopError::Closed - } else { - PopError::Empty - } - }) + self.queue + .borrow_mut() + .pop() + .ok_or_else(|| if self.closed.get() { PopError::Closed } else { PopError::Empty }) } pub fn close(&self) -> bool { diff --git a/winit-web/src/async/dispatcher.rs b/winit-web/src/async/dispatcher.rs index 0e85944e..bd38e1c8 100644 --- a/winit-web/src/async/dispatcher.rs +++ b/winit-web/src/async/dispatcher.rs @@ -6,7 +6,7 @@ use std::rc::Rc; use std::sync::{Arc, Condvar, Mutex}; use super::super::main_thread::MainThreadMarker; -use super::{channel, Receiver, Sender, Wrapper}; +use super::{Receiver, Sender, Wrapper, channel}; pub struct Dispatcher(Wrapper>>, Closure>); diff --git a/winit-web/src/async/mod.rs b/winit-web/src/async/mod.rs index d4a09089..7e9e8972 100644 --- a/winit-web/src/async/mod.rs +++ b/winit-web/src/async/mod.rs @@ -12,7 +12,7 @@ pub(crate) use atomic_waker::AtomicWaker; use concurrent_queue::{ConcurrentQueue, PushError}; pub use self::abortable::{AbortHandle, Abortable, DropAbortHandle}; -pub use self::channel::{channel, Receiver, Sender}; +pub use self::channel::{Receiver, Sender, channel}; pub use self::dispatcher::{DispatchRunner, Dispatcher}; pub use self::notifier::{Notified, Notifier}; pub(crate) use self::wrapper::Wrapper; diff --git a/winit-web/src/cursor.rs b/winit-web/src/cursor.rs index 6aeb156b..2bfb5b9d 100644 --- a/winit-web/src/cursor.rs +++ b/winit-web/src/cursor.rs @@ -6,14 +6,14 @@ use std::ops::{Deref, DerefMut}; use std::pin::Pin; use std::rc::Rc; use std::sync::Arc; -use std::task::{ready, Context, Poll, Waker}; +use std::task::{Context, Poll, Waker, ready}; use std::time::Duration; use cursor_icon::CursorIcon; use js_sys::{Array, Object}; +use wasm_bindgen::JsCast; use wasm_bindgen::closure::Closure; use wasm_bindgen::prelude::wasm_bindgen; -use wasm_bindgen::JsCast; use wasm_bindgen_futures::JsFuture; use web_sys::{ Blob, Document, DomException, HtmlCanvasElement, HtmlImageElement, ImageBitmap, @@ -21,11 +21,11 @@ use web_sys::{ }; use winit_core::cursor::{Cursor, CursorImage, CustomCursorProvider, CustomCursorSource}; +use crate::CustomCursorError; +use crate::r#async::{AbortHandle, Abortable, DropAbortHandle, Notified, Notifier}; use crate::backend::Style; use crate::event_loop::ActiveEventLoop; use crate::main_thread::{MainThreadMarker, MainThreadSafe}; -use crate::r#async::{AbortHandle, Abortable, DropAbortHandle, Notified, Notifier}; -use crate::CustomCursorError; #[derive(Clone, Debug)] pub struct CustomCursor { @@ -487,7 +487,7 @@ fn from_rgba( window: &Window, document: Document, image: &CursorImage, -) -> impl Future> { +) -> impl Future> + use<> { // 1. Create an `ImageData` from the RGBA data. // 2. Create an `ImageBitmap` from the `ImageData`. // 3. Draw `ImageBitmap` on an `HTMLCanvasElement`. diff --git a/winit-web/src/event_loop/mod.rs b/winit-web/src/event_loop/mod.rs index 35f64412..156327f1 100644 --- a/winit-web/src/event_loop/mod.rs +++ b/winit-web/src/event_loop/mod.rs @@ -5,7 +5,7 @@ use winit_core::error::{EventLoopError, NotSupportedError}; use winit_core::event_loop::ActiveEventLoop as RootActiveEventLoop; use crate::{ - backend, HasMonitorPermissionFuture, MonitorPermissionFuture, PollStrategy, WaitUntilStrategy, + HasMonitorPermissionFuture, MonitorPermissionFuture, PollStrategy, WaitUntilStrategy, backend, }; mod proxy; diff --git a/winit-web/src/event_loop/proxy.rs b/winit-web/src/event_loop/proxy.rs index b5092c7a..577b91c0 100644 --- a/winit-web/src/event_loop/proxy.rs +++ b/winit-web/src/event_loop/proxy.rs @@ -1,13 +1,13 @@ use std::future; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; use std::task::Poll; use winit_core::event_loop::EventLoopProxyProvider; use super::super::main_thread::MainThreadMarker; -use crate::event_loop::runner::WeakShared; use crate::r#async::{AtomicWaker, Wrapper}; +use crate::event_loop::runner::WeakShared; #[derive(Debug)] pub struct EventLoopProxy(Wrapper, ()>); diff --git a/winit-web/src/event_loop/runner.rs b/winit-web/src/event_loop/runner.rs index 6712df2d..74bddb7e 100644 --- a/winit-web/src/event_loop/runner.rs +++ b/winit-web/src/event_loop/runner.rs @@ -6,8 +6,8 @@ use std::sync::Arc; use std::{fmt, iter}; use dpi::PhysicalSize; -use wasm_bindgen::prelude::Closure; use wasm_bindgen::JsCast; +use wasm_bindgen::prelude::Closure; use web_sys::{Document, KeyboardEvent, Navigator, PageTransitionEvent, PointerEvent, WheelEvent}; use web_time::{Duration, Instant}; use winit_core::application::ApplicationHandler; @@ -19,14 +19,14 @@ use winit_core::window::WindowId; use super::proxy::EventLoopProxy; use super::state::State; +use crate::r#async::DispatchRunner; use crate::backend::{EventListenerHandle, SafeAreaHandle}; use crate::event_loop::ActiveEventLoop; use crate::main_thread::MainThreadMarker; use crate::monitor::MonitorHandler; -use crate::r#async::DispatchRunner; use crate::web_sys::event::ButtonsState; use crate::window::Inner; -use crate::{backend, event, EventLoop, PollStrategy, WaitUntilStrategy}; +use crate::{EventLoop, PollStrategy, WaitUntilStrategy, backend, event}; #[derive(Debug)] pub struct Shared(Rc); @@ -802,11 +802,7 @@ impl Shared { DeviceEvents::Always => true, DeviceEvents::WhenFocused => { self.0.all_canvases.borrow().iter().any(|(_, canvas, _)| { - if let Some(canvas) = canvas.upgrade() { - canvas.has_focus.get() - } else { - false - } + if let Some(canvas) = canvas.upgrade() { canvas.has_focus.get() } else { false } }) }, DeviceEvents::Never => false, diff --git a/winit-web/src/event_loop/window_target.rs b/winit-web/src/event_loop/window_target.rs index 84c080e8..6d2d2be9 100644 --- a/winit-web/src/event_loop/window_target.rs +++ b/winit-web/src/event_loop/window_target.rs @@ -522,13 +522,8 @@ impl RootActiveEventLoop for ActiveEventLoop { } fn system_theme(&self) -> Option { - backend::is_dark_mode(self.runner.window()).map(|is_dark_mode| { - if is_dark_mode { - Theme::Dark - } else { - Theme::Light - } - }) + backend::is_dark_mode(self.runner.window()) + .map(|is_dark_mode| if is_dark_mode { Theme::Dark } else { Theme::Light }) } fn set_control_flow(&self, control_flow: ControlFlow) { diff --git a/winit-web/src/lib.rs b/winit-web/src/lib.rs index 3ea383c7..be020e70 100644 --- a/winit-web/src/lib.rs +++ b/winit-web/src/lib.rs @@ -61,9 +61,7 @@ // compliant way. macro_rules! os_error { - ($error:expr) => {{ - winit_core::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }}; } mod r#async; diff --git a/winit-web/src/lock.rs b/winit-web/src/lock.rs index 2afd2f37..027966a0 100644 --- a/winit-web/src/lock.rs +++ b/winit-web/src/lock.rs @@ -5,7 +5,7 @@ use tracing::error; use wasm_bindgen::closure::Closure; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::{JsCast, JsValue}; -use web_sys::{console, Document, DomException, Element, Navigator}; +use web_sys::{Document, DomException, Element, Navigator, console}; pub(crate) fn is_cursor_lock_raw(navigator: &Navigator, document: &Document) -> bool { thread_local! { diff --git a/winit-web/src/monitor.rs b/winit-web/src/monitor.rs index 102ba488..612f9923 100644 --- a/winit-web/src/monitor.rs +++ b/winit-web/src/monitor.rs @@ -9,7 +9,7 @@ use std::ops::{Deref, DerefMut}; use std::pin::Pin; use std::rc::{Rc, Weak}; use std::sync::{Arc, OnceLock}; -use std::task::{ready, Context, Poll}; +use std::task::{Context, Poll, ready}; use dpi::{LogicalSize, PhysicalPosition, PhysicalSize}; use js_sys::{Object, Promise}; @@ -19,14 +19,14 @@ use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::{JsCast, JsValue}; use wasm_bindgen_futures::JsFuture; use web_sys::{ - console, DomException, Navigator, OrientationLockType, OrientationType, PermissionState, - PermissionStatus, ScreenOrientation, Window, + DomException, Navigator, OrientationLockType, OrientationType, PermissionState, + PermissionStatus, ScreenOrientation, Window, console, }; use winit_core::monitor::{MonitorHandle as CoreMonitorHandle, MonitorHandleProvider, VideoMode}; +use super::r#async::{Dispatcher, Notified, Notifier}; use super::event_loop::runner::WeakShared; use super::main_thread::MainThreadMarker; -use super::r#async::{Dispatcher, Notified, Notifier}; use super::web_sys::{Engine, EventListenerHandle}; use crate::{ MonitorPermissionError, Orientation, OrientationData, OrientationLock, OrientationLockError, @@ -292,11 +292,7 @@ impl Inner { } fn name(&self) -> Option { - if let Screen::Detailed { screen, .. } = &self.screen { - Some(screen.label()) - } else { - None - } + if let Screen::Detailed { screen, .. } = &self.screen { Some(screen.label()) } else { None } } fn orientation_raw(&self) -> &ScreenOrientationExt { @@ -438,11 +434,7 @@ impl Detailed { let internal_screen = internal_screen.upgrade().expect("dropped `MonitorHandle` without cleaning up"); - if *internal_screen == screen { - Some((*id, internal_screen)) - } else { - None - } + if *internal_screen == screen { Some((*id, internal_screen)) } else { None } }); let (id, screen) = if let Some((id, screen)) = found_screen { (id, screen) @@ -664,7 +656,7 @@ impl MonitorHandler { State::Unsupported => { return MonitorPermissionFuture::Ready(Some(Err( MonitorPermissionError::Unsupported, - ))) + ))); }, // If we are currently initializing, wait for initialization to finish before we do our // thing. @@ -676,7 +668,7 @@ impl MonitorHandler { ) .0, notified: notified.clone(), - } + }; }, // If we finished initialization we at least possess `PermissionStatus`. State::Permission { permission, .. } => permission, @@ -688,7 +680,7 @@ impl MonitorHandler { match permission.state() { PermissionState::Granted | PermissionState::Prompt => (), PermissionState::Denied => { - return MonitorPermissionFuture::Ready(Some(Err(MonitorPermissionError::Denied))) + return MonitorPermissionFuture::Ready(Some(Err(MonitorPermissionError::Denied))); }, _ => { error!("encountered unknown permission state: {}", permission.state_string()); diff --git a/winit-web/src/web_sys/animation_frame.rs b/winit-web/src/web_sys/animation_frame.rs index fde7ae28..c3508561 100644 --- a/winit-web/src/web_sys/animation_frame.rs +++ b/winit-web/src/web_sys/animation_frame.rs @@ -1,8 +1,8 @@ use std::cell::Cell; use std::rc::Rc; -use wasm_bindgen::closure::Closure; use wasm_bindgen::JsCast; +use wasm_bindgen::closure::Closure; pub struct AnimationFrameHandler { window: web_sys::Window, diff --git a/winit-web/src/web_sys/canvas.rs b/winit-web/src/web_sys/canvas.rs index 3a9f8ae5..08ce2b8d 100644 --- a/winit-web/src/web_sys/canvas.rs +++ b/winit-web/src/web_sys/canvas.rs @@ -5,8 +5,8 @@ use std::sync::{Arc, Mutex}; use dpi::{LogicalPosition, PhysicalPosition, PhysicalSize}; use smol_str::SmolStr; -use wasm_bindgen::closure::Closure; use wasm_bindgen::JsCast; +use wasm_bindgen::closure::Closure; use web_sys::{ CssStyleDeclaration, Document, Event, FocusEvent, HtmlCanvasElement, KeyboardEvent, Navigator, PointerEvent, WheelEvent, @@ -28,7 +28,7 @@ use super::event_handle::EventListenerHandle; use super::intersection_handle::IntersectionObserverHandle; use super::media_query_handle::MediaQueryListHandle; use super::pointer::PointerHandler; -use super::{event, fullscreen, ResizeScaleHandle}; +use super::{ResizeScaleHandle, event, fullscreen}; use crate::WindowAttributesWeb; #[allow(dead_code)] @@ -502,8 +502,7 @@ impl Canvas { surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&new_size)), }); - let new_size = *new_size.lock().unwrap(); - new_size + *new_size.lock().unwrap() }; if current_size != new_size { diff --git a/winit-web/src/web_sys/event_handle.rs b/winit-web/src/web_sys/event_handle.rs index 4474af3c..1efe8a2f 100644 --- a/winit-web/src/web_sys/event_handle.rs +++ b/winit-web/src/web_sys/event_handle.rs @@ -1,5 +1,5 @@ -use wasm_bindgen::prelude::Closure; use wasm_bindgen::JsCast; +use wasm_bindgen::prelude::Closure; use web_sys::EventTarget; pub struct EventListenerHandle { diff --git a/winit-web/src/web_sys/fullscreen.rs b/winit-web/src/web_sys/fullscreen.rs index 9f3baf93..d5b9112a 100644 --- a/winit-web/src/web_sys/fullscreen.rs +++ b/winit-web/src/web_sys/fullscreen.rs @@ -5,7 +5,7 @@ use tracing::error; use wasm_bindgen::closure::Closure; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::{JsCast, JsValue}; -use web_sys::{console, Document, Element, HtmlCanvasElement, Window}; +use web_sys::{Document, Element, HtmlCanvasElement, Window, console}; use winit_core::monitor::Fullscreen; use crate::main_thread::MainThreadMarker; diff --git a/winit-web/src/web_sys/intersection_handle.rs b/winit-web/src/web_sys/intersection_handle.rs index 9f63e84c..08dddc62 100644 --- a/winit-web/src/web_sys/intersection_handle.rs +++ b/winit-web/src/web_sys/intersection_handle.rs @@ -1,6 +1,6 @@ use js_sys::Array; -use wasm_bindgen::prelude::Closure; use wasm_bindgen::JsCast; +use wasm_bindgen::prelude::Closure; use web_sys::{Element, IntersectionObserver, IntersectionObserverEntry}; pub(super) struct IntersectionObserverHandle { diff --git a/winit-web/src/web_sys/media_query_handle.rs b/winit-web/src/web_sys/media_query_handle.rs index 766157a6..2e6a335f 100644 --- a/winit-web/src/web_sys/media_query_handle.rs +++ b/winit-web/src/web_sys/media_query_handle.rs @@ -1,5 +1,5 @@ -use wasm_bindgen::prelude::Closure; use wasm_bindgen::JsCast; +use wasm_bindgen::prelude::Closure; use web_sys::MediaQueryList; pub(super) struct MediaQueryListHandle { diff --git a/winit-web/src/web_sys/mod.rs b/winit-web/src/web_sys/mod.rs index 3e569d3a..0b1e5c05 100644 --- a/winit-web/src/web_sys/mod.rs +++ b/winit-web/src/web_sys/mod.rs @@ -14,9 +14,9 @@ use std::cell::OnceCell; use dpi::{LogicalPosition, LogicalSize}; use js_sys::Array; +use wasm_bindgen::JsCast; use wasm_bindgen::closure::Closure; use wasm_bindgen::prelude::wasm_bindgen; -use wasm_bindgen::JsCast; use web_sys::{Document, HtmlCanvasElement, Navigator, PageTransitionEvent, VisibilityState}; pub use self::canvas::{Canvas, Style}; diff --git a/winit-web/src/web_sys/resize_scaling.rs b/winit-web/src/web_sys/resize_scaling.rs index 5f8933e1..aa2aac09 100644 --- a/winit-web/src/web_sys/resize_scaling.rs +++ b/winit-web/src/web_sys/resize_scaling.rs @@ -4,7 +4,7 @@ use std::rc::Rc; use dpi::{LogicalSize, PhysicalSize}; use js_sys::{Array, Object}; use tracing::warn; -use wasm_bindgen::prelude::{wasm_bindgen, Closure}; +use wasm_bindgen::prelude::{Closure, wasm_bindgen}; use wasm_bindgen::{JsCast, JsValue}; use web_sys::{ Document, HtmlCanvasElement, MediaQueryList, ResizeObserver, ResizeObserverBoxOptions, diff --git a/winit-web/src/window.rs b/winit-web/src/window.rs index a3579a33..f6d48489 100644 --- a/winit-web/src/window.rs +++ b/winit-web/src/window.rs @@ -16,10 +16,10 @@ use winit_core::window::{ Window as RootWindow, WindowAttributes, WindowButtons, WindowId, WindowLevel, }; +use crate::r#async::Dispatcher; use crate::event_loop::ActiveEventLoop; use crate::main_thread::MainThreadMarker; use crate::monitor::MonitorHandler; -use crate::r#async::Dispatcher; use crate::{backend, lock}; pub struct Window { @@ -284,11 +284,7 @@ impl RootWindow for Window { fn fullscreen(&self) -> Option { self.inner.queue(|inner| { - if inner.canvas.is_fullscreen() { - Some(Fullscreen::Borderless(None)) - } else { - None - } + if inner.canvas.is_fullscreen() { Some(Fullscreen::Borderless(None)) } else { None } }) } @@ -334,13 +330,8 @@ impl RootWindow for Window { fn theme(&self) -> Option { self.inner.queue(|inner| { - backend::is_dark_mode(&inner.window).map(|is_dark_mode| { - if is_dark_mode { - Theme::Dark - } else { - Theme::Light - } - }) + backend::is_dark_mode(&inner.window) + .map(|is_dark_mode| if is_dark_mode { Theme::Dark } else { Theme::Light }) }) } @@ -368,7 +359,7 @@ impl RootWindow for Window { inner.canvas.raw(), ), CursorGrabMode::Confined => { - return Err(NotSupportedError::new("confined cursor mode is not supported")) + return Err(NotSupportedError::new("confined cursor mode is not supported")); }, } diff --git a/winit-win32/src/dark_mode.rs b/winit-win32/src/dark_mode.rs index eb1991f6..be54f168 100644 --- a/winit-win32/src/dark_mode.rs +++ b/winit-win32/src/dark_mode.rs @@ -3,16 +3,16 @@ use std::sync::LazyLock; /// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode use std::{ffi::c_void, ptr}; -use windows_sys::core::{PCSTR, PCWSTR}; -use windows_sys::w; use windows_sys::Win32::Foundation::{BOOL, HWND, LPARAM, S_OK, WPARAM}; use windows_sys::Win32::System::LibraryLoader::{GetProcAddress, LoadLibraryA}; use windows_sys::Win32::UI::Accessibility::{HCF_HIGHCONTRASTON, HIGHCONTRASTA}; use windows_sys::Win32::UI::Controls::SetWindowTheme; use windows_sys::Win32::UI::Input::KeyboardAndMouse::GetActiveWindow; use windows_sys::Win32::UI::WindowsAndMessaging::{ - DefWindowProcW, SystemParametersInfoA, SPI_GETHIGHCONTRAST, WM_NCACTIVATE, + DefWindowProcW, SPI_GETHIGHCONTRAST, SystemParametersInfoA, WM_NCACTIVATE, }; +use windows_sys::core::{PCSTR, PCWSTR}; +use windows_sys::w; use winit_core::window::Theme; use super::util; diff --git a/winit-win32/src/definitions.rs b/winit-win32/src/definitions.rs index be22d60e..743c82c6 100644 --- a/winit-win32/src/definitions.rs +++ b/winit-win32/src/definitions.rs @@ -3,9 +3,9 @@ use std::ffi::c_void; -use windows_sys::core::{GUID, HRESULT}; use windows_sys::Win32::Foundation::{BOOL, HWND, POINTL}; use windows_sys::Win32::System::Com::{FORMATETC, STGMEDIUM}; +use windows_sys::core::{GUID, HRESULT}; pub type IUnknown = *mut c_void; pub type IAdviseSink = *mut c_void; diff --git a/winit-win32/src/dpi.rs b/winit-win32/src/dpi.rs index 6a49c623..0ede553b 100644 --- a/winit-win32/src/dpi.rs +++ b/winit-win32/src/dpi.rs @@ -4,7 +4,7 @@ use std::sync::Once; use windows_sys::Win32::Foundation::{HWND, S_OK}; use windows_sys::Win32::Graphics::Gdi::{ - GetDC, GetDeviceCaps, MonitorFromWindow, HMONITOR, LOGPIXELSX, MONITOR_DEFAULTTONEAREST, + GetDC, GetDeviceCaps, HMONITOR, LOGPIXELSX, MONITOR_DEFAULTTONEAREST, MonitorFromWindow, }; use windows_sys::Win32::UI::HiDpi::{ DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, diff --git a/winit-win32/src/drop_handler.rs b/winit-win32/src/drop_handler.rs index f949f58b..19a23c95 100644 --- a/winit-win32/src/drop_handler.rs +++ b/winit-win32/src/drop_handler.rs @@ -1,4 +1,4 @@ -use std::ffi::{c_void, OsString}; +use std::ffi::{OsString, c_void}; use std::os::windows::ffi::OsStringExt; use std::path::PathBuf; use std::ptr; @@ -6,12 +6,12 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use dpi::PhysicalPosition; use tracing::debug; -use windows_sys::core::{GUID, HRESULT}; use windows_sys::Win32::Foundation::{DV_E_FORMATETC, HWND, POINT, POINTL, S_OK}; use windows_sys::Win32::Graphics::Gdi::ScreenToClient; use windows_sys::Win32::System::Com::{DVASPECT_CONTENT, FORMATETC, TYMED_HGLOBAL}; use windows_sys::Win32::System::Ole::{CF_HDROP, DROPEFFECT_COPY, DROPEFFECT_NONE}; use windows_sys::Win32::UI::Shell::{DragFinish, DragQueryFileW, HDROP}; +use windows_sys::core::{GUID, HRESULT}; use winit_core::event::WindowEvent; use crate::definitions::{ diff --git a/winit-win32/src/event_loop.rs b/winit-win32/src/event_loop.rs index 7c3c3227..bbcde829 100644 --- a/winit-win32/src/event_loop.rs +++ b/winit-win32/src/event_loop.rs @@ -13,21 +13,21 @@ use std::{fmt, mem, panic, ptr}; use dpi::{PhysicalPosition, PhysicalSize}; use windows_sys::Win32::Foundation::{ - GetLastError, FALSE, HANDLE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_FAILED, WPARAM, + FALSE, GetLastError, HANDLE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_FAILED, WPARAM, }; use windows_sys::Win32::Graphics::Gdi::{ - GetMonitorInfoW, MonitorFromRect, MonitorFromWindow, RedrawWindow, ScreenToClient, - ValidateRect, MONITORINFO, MONITOR_DEFAULTTONULL, RDW_INTERNALPAINT, SC_SCREENSAVE, + GetMonitorInfoW, MONITOR_DEFAULTTONULL, MONITORINFO, MonitorFromRect, MonitorFromWindow, + RDW_INTERNALPAINT, RedrawWindow, SC_SCREENSAVE, ScreenToClient, ValidateRect, }; use windows_sys::Win32::System::Ole::RevokeDragDrop; use windows_sys::Win32::System::Threading::{ - CreateWaitableTimerExW, GetCurrentThreadId, SetWaitableTimer, - CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, INFINITE, TIMER_ALL_ACCESS, + CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, CreateWaitableTimerExW, GetCurrentThreadId, INFINITE, + SetWaitableTimer, TIMER_ALL_ACCESS, }; use windows_sys::Win32::UI::Controls::{HOVER_DEFAULT, WM_MOUSELEAVE}; use windows_sys::Win32::UI::Input::Ime::{GCS_COMPSTR, GCS_RESULTSTR, ISC_SHOWUICOMPOSITIONWINDOW}; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - ReleaseCapture, SetCapture, TrackMouseEvent, TME_LEAVE, TRACKMOUSEEVENT, + ReleaseCapture, SetCapture, TME_LEAVE, TRACKMOUSEEVENT, TrackMouseEvent, }; use windows_sys::Win32::UI::Input::Pointer::{ POINTER_FLAG_DOWN, POINTER_FLAG_PRIMARY, POINTER_FLAG_UP, POINTER_FLAG_UPDATE, @@ -40,25 +40,25 @@ use windows_sys::Win32::UI::Input::{ MOUSE_MOVE_RELATIVE, RAWINPUT, RIM_TYPEKEYBOARD, RIM_TYPEMOUSE, }; use windows_sys::Win32::UI::WindowsAndMessaging::{ - CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetClientRect, GetCursorPos, - GetMenu, LoadCursorW, MsgWaitForMultipleObjectsEx, PeekMessageW, PostMessageW, - RegisterClassExW, RegisterWindowMessageA, SetCursor, SetWindowPos, SystemParametersInfoW, - TranslateMessage, CREATESTRUCTW, GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO, - MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE, NCCALCSIZE_PARAMS, PEN_FLAG_BARREL, PEN_FLAG_ERASER, - PEN_MASK_PRESSURE, PEN_MASK_ROTATION, PEN_MASK_TILT_X, PEN_MASK_TILT_Y, PM_REMOVE, PT_PEN, - PT_TOUCH, QS_ALLINPUT, RI_MOUSE_HWHEEL, RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE, - SIZE_MAXIMIZED, SPI_GETWHEELSCROLLCHARS, SPI_GETWHEELSCROLLLINES, SWP_NOACTIVATE, SWP_NOMOVE, - SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS, WMSZ_BOTTOM, WMSZ_BOTTOMLEFT, - WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT, WMSZ_TOPRIGHT, - WM_CAPTURECHANGED, WM_CLOSE, WM_CREATE, WM_DESTROY, WM_DPICHANGED, WM_ENTERSIZEMOVE, - WM_EXITSIZEMOVE, WM_GETMINMAXINFO, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION, - WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION, WM_INPUT, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS, - WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MENUCHAR, WM_MOUSEHWHEEL, - WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCCREATE, WM_NCDESTROY, - WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN, - WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE, WM_SIZE, WM_SIZING, WM_SYSCOMMAND, - WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING, - WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, + CREATESTRUCTW, CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GWL_STYLE, + GWL_USERDATA, GetClientRect, GetCursorPos, GetMenu, HTCAPTION, HTCLIENT, LoadCursorW, + MINMAXINFO, MNC_CLOSE, MSG, MWMO_INPUTAVAILABLE, MsgWaitForMultipleObjectsEx, + NCCALCSIZE_PARAMS, PEN_FLAG_BARREL, PEN_FLAG_ERASER, PEN_MASK_PRESSURE, PEN_MASK_ROTATION, + PEN_MASK_TILT_X, PEN_MASK_TILT_Y, PM_REMOVE, PT_PEN, PT_TOUCH, PeekMessageW, PostMessageW, + QS_ALLINPUT, RI_MOUSE_HWHEEL, RI_MOUSE_WHEEL, RegisterClassExW, RegisterWindowMessageA, + SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED, SPI_GETWHEELSCROLLCHARS, SPI_GETWHEELSCROLLLINES, + SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SetCursor, SetWindowPos, + SystemParametersInfoW, TranslateMessage, WHEEL_DELTA, WINDOWPOS, WM_CAPTURECHANGED, WM_CLOSE, + WM_CREATE, WM_DESTROY, WM_DPICHANGED, WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE, WM_GETMINMAXINFO, + WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION, WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION, + WM_INPUT, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, + WM_MBUTTONUP, WM_MENUCHAR, WM_MOUSEHWHEEL, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE, + WM_NCCALCSIZE, WM_NCCREATE, WM_NCDESTROY, WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, + WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, + WM_SETTINGCHANGE, WM_SIZE, WM_SIZING, WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, + WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING, WM_XBUTTONDOWN, WM_XBUTTONUP, WMSZ_BOTTOM, + WMSZ_BOTTOMLEFT, WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT, + WMSZ_TOPRIGHT, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE, }; use winit_core::application::ApplicationHandler; @@ -79,8 +79,8 @@ use winit_core::monitor::{Fullscreen, MonitorHandle as CoreMonitorHandle}; use winit_core::window::{Theme, Window as CoreWindow, WindowAttributes, WindowId}; pub(super) use self::runner::{Event, EventLoopRunner}; -use super::window::set_skip_taskbar; use super::SelectedCursor; +use super::window::set_skip_taskbar; use crate::dark_mode::try_theme; use crate::dpi::{become_dpi_aware, dpi_to_scale_factor}; use crate::drop_handler::FileDropHandler; @@ -89,7 +89,7 @@ use crate::ime::ImeContext; use crate::keyboard::KeyEventBuilder; use crate::keyboard_layout::LAYOUT_CACHE; use crate::monitor::{self, MonitorHandle}; -use crate::util::{wrap_device_id, WIN10_BUILD_VERSION}; +use crate::util::{WIN10_BUILD_VERSION, wrap_device_id}; use crate::window::{InitData, Window}; use crate::window_state::{CursorFlags, ImeState, WindowFlags, WindowState}; use crate::{raw_input, util}; @@ -279,11 +279,7 @@ impl EventLoop { self.runner.reset_runner(); - if exit_code == 0 { - Ok(()) - } else { - Err(EventLoopError::ExitFailure(exit_code)) - } + if exit_code == 0 { Ok(()) } else { Err(EventLoopError::ExitFailure(exit_code)) } } pub fn pump_app_events( @@ -436,7 +432,7 @@ impl RootActiveEventLoop for ActiveEventLoop { let cursor = match source { CustomCursorSource::Image(cursor) => cursor, CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => { - return Err(NotSupportedError::new("unsupported cursor kind").into()) + return Err(NotSupportedError::new("unsupported cursor kind").into()); }, }; @@ -535,7 +531,7 @@ fn main_thread_id() -> u32 { // main entrypoint. // // See: https://doc.rust-lang.org/stable/reference/abi.html#the-link_section-attribute - #[link_section = ".CRT$XCU"] + #[unsafe(link_section = ".CRT$XCU")] static INIT_MAIN_THREAD_ID: unsafe fn() = { unsafe fn initer() { unsafe { MAIN_THREAD_ID = GetCurrentThreadId() }; @@ -566,11 +562,7 @@ fn dur2timeout(dur: Duration) -> u32 { .and_then(|ms| ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000)) .and_then( |ms| { - if dur.subsec_nanos() % 1_000_000 > 0 { - ms.checked_add(1) - } else { - Some(ms) - } + if dur.subsec_nanos() % 1_000_000 > 0 { ms.checked_add(1) } else { Some(ms) } }, ) .map(|ms| if ms > u32::MAX as u64 { INFINITE } else { ms as u32 }) @@ -597,11 +589,7 @@ fn create_high_resolution_timer() -> Option { // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is supported only after // Win10 1803 but it is already default option for rustc // (std uses it to implement `std::thread::sleep`). - if handle.is_null() { - None - } else { - Some(OwnedHandle::from_raw_handle(handle)) - } + if handle.is_null() { None } else { Some(OwnedHandle::from_raw_handle(handle)) } } } @@ -623,11 +611,7 @@ unsafe fn set_high_resolution_timer(timer: RawHandle, timeout: Duration) -> Resu let due_time: i64 = -(intervals_to_wait as i64); unsafe { let set_result = SetWaitableTimer(timer as HANDLE, &due_time, 0, None, ptr::null(), FALSE); - if set_result != FALSE { - Ok(()) - } else { - Err(GetLastError()) - } + if set_result != FALSE { Ok(()) } else { Err(GetLastError()) } } } @@ -1260,7 +1244,7 @@ unsafe fn public_window_callback_inner( if let Some(new_rect) = new_rect { let new_monitor = unsafe { MonitorFromRect(&new_rect, MONITOR_DEFAULTTONULL) }; match fullscreen { - Fullscreen::Borderless(ref mut fullscreen_monitor) => { + Fullscreen::Borderless(fullscreen_monitor) => { if !new_monitor.is_null() && fullscreen_monitor .as_ref() @@ -1648,12 +1632,14 @@ unsafe fn public_window_callback_inner( let scroll_lines_multiplier = if userdata.window_state_lock().use_system_wheel_speed { let mut scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA; - let _ = SystemParametersInfoW( - SPI_GETWHEELSCROLLLINES, - 0, - &mut scroll_lines as *mut isize as *mut c_void, - 0, - ); + let _ = unsafe { + SystemParametersInfoW( + SPI_GETWHEELSCROLLLINES, + 0, + &mut scroll_lines as *mut isize as *mut c_void, + 0, + ) + }; if scroll_lines as u32 == WHEEL_PAGESCROLL { // TODO: figure out how to handle page scrolls scroll_lines = DEFAULT_SCROLL_LINES_PER_WHEEL_DELTA; @@ -1683,12 +1669,14 @@ unsafe fn public_window_callback_inner( let scroll_characters_multiplier = if userdata.window_state_lock().use_system_wheel_speed { let mut scroll_characters = DEFAULT_SCROLL_CHARACTERS_PER_WHEEL_DELTA; - let _ = SystemParametersInfoW( - SPI_GETWHEELSCROLLCHARS, - 0, - &mut scroll_characters as *mut isize as *mut c_void, - 0, - ); + let _ = unsafe { + SystemParametersInfoW( + SPI_GETWHEELSCROLLCHARS, + 0, + &mut scroll_characters as *mut isize as *mut c_void, + 0, + ) + }; scroll_characters } else { 1 @@ -2218,11 +2206,7 @@ unsafe fn public_window_callback_inner( // provided through the low-order word of lParam. We use that here since // `WM_MOUSEMOVE` seems to come after `WM_SETCURSOR` for a given cursor movement. let in_client_area = util::loword(lparam as u32) as u32 == HTCLIENT; - if in_client_area { - Some(window_state.mouse.selected_cursor.clone()) - } else { - None - } + if in_client_area { Some(window_state.mouse.selected_cursor.clone()) } else { None } }; match set_cursor_to { diff --git a/winit-win32/src/event_loop/runner.rs b/winit-win32/src/event_loop/runner.rs index d128d974..65e60827 100644 --- a/winit-win32/src/event_loop/runner.rs +++ b/winit-win32/src/event_loop/runner.rs @@ -14,7 +14,7 @@ use winit_core::event_loop::ActiveEventLoop as RootActiveEventLoop; use winit_core::window::WindowId; use super::{ActiveEventLoop, ControlFlow, EventLoopThreadExecutor}; -use crate::event_loop::{WindowData, GWL_USERDATA}; +use crate::event_loop::{GWL_USERDATA, WindowData}; use crate::util::get_window_long; type EventHandler = Cell>; diff --git a/winit-win32/src/icon.rs b/winit-win32/src/icon.rs index f38bcf35..8fdf95be 100644 --- a/winit-win32/src/icon.rs +++ b/winit-win32/src/icon.rs @@ -5,14 +5,14 @@ use std::{fmt, io, mem, ptr}; use cursor_icon::CursorIcon; use dpi::PhysicalSize; -use windows_sys::core::PCWSTR; use windows_sys::Win32::Graphics::Gdi::{ CreateBitmap, CreateCompatibleBitmap, DeleteObject, GetDC, ReleaseDC, SetBitmapBits, }; use windows_sys::Win32::UI::WindowsAndMessaging::{ - CreateIcon, CreateIconIndirect, DestroyCursor, DestroyIcon, LoadImageW, HCURSOR, HICON, - ICONINFO, ICON_BIG, ICON_SMALL, IMAGE_ICON, LR_DEFAULTSIZE, LR_LOADFROMFILE, + CreateIcon, CreateIconIndirect, DestroyCursor, DestroyIcon, HCURSOR, HICON, ICON_BIG, + ICON_SMALL, ICONINFO, IMAGE_ICON, LR_DEFAULTSIZE, LR_LOADFROMFILE, LoadImageW, }; +use windows_sys::core::PCWSTR; use winit_core::cursor::{CursorImage, CustomCursorProvider}; use winit_core::error::RequestError; use winit_core::icon::*; diff --git a/winit-win32/src/ime.rs b/winit-win32/src/ime.rs index 6b379c4e..81e40c16 100644 --- a/winit-win32/src/ime.rs +++ b/winit-win32/src/ime.rs @@ -1,14 +1,14 @@ -use std::ffi::{c_void, OsString}; +use std::ffi::{OsString, c_void}; use std::os::windows::prelude::OsStringExt; use std::ptr::null_mut; use dpi::{Position, Size}; use windows_sys::Win32::Foundation::{POINT, RECT}; use windows_sys::Win32::UI::Input::Ime::{ - ImmAssociateContextEx, ImmGetCompositionStringW, ImmGetContext, ImmReleaseContext, - ImmSetCandidateWindow, ImmSetCompositionWindow, ATTR_TARGET_CONVERTED, - ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM, CFS_EXCLUDE, CFS_POINT, COMPOSITIONFORM, GCS_COMPATTR, - GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, HIMC, IACE_CHILDREN, IACE_DEFAULT, + ATTR_TARGET_CONVERTED, ATTR_TARGET_NOTCONVERTED, CANDIDATEFORM, CFS_EXCLUDE, CFS_POINT, + COMPOSITIONFORM, GCS_COMPATTR, GCS_COMPSTR, GCS_CURSORPOS, GCS_RESULTSTR, HIMC, IACE_CHILDREN, + IACE_DEFAULT, ImmAssociateContextEx, ImmGetCompositionStringW, ImmGetContext, + ImmReleaseContext, ImmSetCandidateWindow, ImmSetCompositionWindow, }; use windows_sys::Win32::UI::WindowsAndMessaging::{GetSystemMetrics, SM_IMMENABLED}; diff --git a/winit-win32/src/keyboard.rs b/winit-win32/src/keyboard.rs index 5cdce0f4..be2c3769 100644 --- a/winit-win32/src/keyboard.rs +++ b/winit-win32/src/keyboard.rs @@ -12,8 +12,8 @@ use unicode_segmentation::UnicodeSegmentation; use windows_sys::Win32::Foundation::{HWND, LPARAM, WPARAM}; use windows_sys::Win32::System::SystemServices::LANG_KOREAN; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - GetAsyncKeyState, GetKeyState, GetKeyboardLayout, GetKeyboardState, MapVirtualKeyExW, HKL, - MAPVK_VK_TO_VSC_EX, MAPVK_VSC_TO_VK_EX, VIRTUAL_KEY, VK_ABNT_C2, VK_ADD, VK_CAPITAL, VK_CLEAR, + GetAsyncKeyState, GetKeyState, GetKeyboardLayout, GetKeyboardState, HKL, MAPVK_VK_TO_VSC_EX, + MAPVK_VSC_TO_VK_EX, MapVirtualKeyExW, VIRTUAL_KEY, VK_ABNT_C2, VK_ADD, VK_CAPITAL, VK_CLEAR, VK_CONTROL, VK_DECIMAL, VK_DELETE, VK_DIVIDE, VK_DOWN, VK_END, VK_F4, VK_HOME, VK_INSERT, VK_LCONTROL, VK_LEFT, VK_LMENU, VK_LSHIFT, VK_LWIN, VK_MENU, VK_MULTIPLY, VK_NEXT, VK_NUMLOCK, VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, @@ -21,7 +21,7 @@ use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ VK_RWIN, VK_SCROLL, VK_SHIFT, VK_SUBTRACT, VK_UP, }; use windows_sys::Win32::UI::WindowsAndMessaging::{ - PeekMessageW, MSG, PM_NOREMOVE, WM_CHAR, WM_DEADCHAR, WM_KEYDOWN, WM_KEYFIRST, WM_KEYLAST, + MSG, PM_NOREMOVE, PeekMessageW, WM_CHAR, WM_DEADCHAR, WM_KEYDOWN, WM_KEYFIRST, WM_KEYLAST, WM_KEYUP, WM_KILLFOCUS, WM_SETFOCUS, WM_SYSCHAR, WM_SYSDEADCHAR, WM_SYSKEYDOWN, WM_SYSKEYUP, }; use winit_core::event::{ElementState, KeyEvent}; @@ -30,7 +30,7 @@ use winit_core::keyboard::{ }; use crate::event_loop::ProcResult; -use crate::keyboard_layout::{Layout, LayoutCache, WindowsModifiers, LAYOUT_CACHE}; +use crate::keyboard_layout::{LAYOUT_CACHE, Layout, LayoutCache, WindowsModifiers}; use crate::util::{loword, primarylangid}; pub type ExScancode = u16; @@ -813,11 +813,7 @@ impl PendingEventQueue { } } pending.retain(|m| m.token != token); - if was_first { - Self::drain_pending(&mut *pending) - } else { - Vec::new() - } + if was_first { Self::drain_pending(&mut *pending) } else { Vec::new() } } fn drain_pending(pending: &mut Vec>) -> Vec { diff --git a/winit-win32/src/keyboard_layout.rs b/winit-win32/src/keyboard_layout.rs index 9971028c..7b6a370f 100644 --- a/winit-win32/src/keyboard_layout.rs +++ b/winit-win32/src/keyboard_layout.rs @@ -7,14 +7,14 @@ use std::sync::{LazyLock, Mutex}; use smol_str::SmolStr; use windows_sys::Win32::System::SystemServices::{LANG_JAPANESE, LANG_KOREAN}; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - GetKeyState, GetKeyboardLayout, MapVirtualKeyExW, ToUnicodeEx, HKL, MAPVK_VK_TO_VSC_EX, + GetKeyState, GetKeyboardLayout, HKL, MAPVK_VK_TO_VSC_EX, MapVirtualKeyExW, ToUnicodeEx, VIRTUAL_KEY, VK_ACCEPT, VK_ADD, VK_APPS, VK_ATTN, VK_BACK, VK_BROWSER_BACK, VK_BROWSER_FAVORITES, VK_BROWSER_FORWARD, VK_BROWSER_HOME, VK_BROWSER_REFRESH, VK_BROWSER_SEARCH, VK_BROWSER_STOP, VK_CANCEL, VK_CAPITAL, VK_CLEAR, VK_CONTROL, VK_CONVERT, VK_CRSEL, VK_DECIMAL, VK_DELETE, VK_DIVIDE, VK_DOWN, VK_END, VK_EREOF, VK_ESCAPE, VK_EXECUTE, - VK_EXSEL, VK_F1, VK_F10, VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, - VK_F19, VK_F2, VK_F20, VK_F21, VK_F22, VK_F23, VK_F24, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, - VK_F8, VK_F9, VK_FINAL, VK_GAMEPAD_A, VK_GAMEPAD_B, VK_GAMEPAD_DPAD_DOWN, VK_GAMEPAD_DPAD_LEFT, + VK_EXSEL, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, + VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, VK_F19, VK_F20, VK_F21, VK_F22, VK_F23, + VK_F24, VK_FINAL, VK_GAMEPAD_A, VK_GAMEPAD_B, VK_GAMEPAD_DPAD_DOWN, VK_GAMEPAD_DPAD_LEFT, VK_GAMEPAD_DPAD_RIGHT, VK_GAMEPAD_DPAD_UP, VK_GAMEPAD_LEFT_SHOULDER, VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON, VK_GAMEPAD_LEFT_THUMBSTICK_DOWN, VK_GAMEPAD_LEFT_THUMBSTICK_LEFT, VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT, @@ -30,8 +30,8 @@ use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ VK_NAVIGATION_CANCEL, VK_NAVIGATION_DOWN, VK_NAVIGATION_LEFT, VK_NAVIGATION_MENU, VK_NAVIGATION_RIGHT, VK_NAVIGATION_UP, VK_NAVIGATION_VIEW, VK_NEXT, VK_NONAME, VK_NONCONVERT, VK_NUMLOCK, VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, - VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_OEM_1, VK_OEM_102, VK_OEM_2, VK_OEM_3, VK_OEM_4, - VK_OEM_5, VK_OEM_6, VK_OEM_7, VK_OEM_8, VK_OEM_ATTN, VK_OEM_AUTO, VK_OEM_AX, VK_OEM_BACKTAB, + VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_OEM_1, VK_OEM_2, VK_OEM_3, VK_OEM_4, VK_OEM_5, VK_OEM_6, + VK_OEM_7, VK_OEM_8, VK_OEM_102, VK_OEM_ATTN, VK_OEM_AUTO, VK_OEM_AX, VK_OEM_BACKTAB, VK_OEM_CLEAR, VK_OEM_COMMA, VK_OEM_COPY, VK_OEM_CUSEL, VK_OEM_ENLW, VK_OEM_FINISH, VK_OEM_FJ_LOYA, VK_OEM_FJ_MASSHOU, VK_OEM_FJ_ROYA, VK_OEM_FJ_TOUROKU, VK_OEM_JUMP, VK_OEM_MINUS, VK_OEM_NEC_EQUAL, VK_OEM_PA1, VK_OEM_PA2, VK_OEM_PA3, VK_OEM_PERIOD, VK_OEM_PLUS, diff --git a/winit-win32/src/lib.rs b/winit-win32/src/lib.rs index 8a9474b5..569d1f32 100644 --- a/winit-win32/src/lib.rs +++ b/winit-win32/src/lib.rs @@ -657,11 +657,7 @@ pub trait DeviceIdExtWindows { impl DeviceIdExtWindows for DeviceId { fn persistent_identifier(&self) -> Option { let raw_id = self.into_raw(); - if raw_id != 0 { - raw_input::get_raw_input_device_name(raw_id as HANDLE) - } else { - None - } + if raw_id != 0 { raw_input::get_raw_input_device_name(raw_id as HANDLE) } else { None } } } diff --git a/winit-win32/src/monitor.rs b/winit-win32/src/monitor.rs index 51aa950e..fed4574b 100644 --- a/winit-win32/src/monitor.rs +++ b/winit-win32/src/monitor.rs @@ -6,10 +6,10 @@ use std::{io, iter, mem, ptr}; use dpi::{PhysicalPosition, PhysicalSize}; use windows_sys::Win32::Foundation::{BOOL, HWND, LPARAM, POINT, RECT}; use windows_sys::Win32::Graphics::Gdi::{ - EnumDisplayMonitors, EnumDisplaySettingsExW, GetMonitorInfoW, MonitorFromPoint, - MonitorFromWindow, DEVMODEW, DM_BITSPERPEL, DM_DISPLAYFREQUENCY, DM_PELSHEIGHT, DM_PELSWIDTH, - ENUM_CURRENT_SETTINGS, HDC, HMONITOR, MONITORINFO, MONITORINFOEXW, MONITOR_DEFAULTTONEAREST, - MONITOR_DEFAULTTOPRIMARY, + DEVMODEW, DM_BITSPERPEL, DM_DISPLAYFREQUENCY, DM_PELSHEIGHT, DM_PELSWIDTH, + ENUM_CURRENT_SETTINGS, EnumDisplayMonitors, EnumDisplaySettingsExW, GetMonitorInfoW, HDC, + HMONITOR, MONITOR_DEFAULTTONEAREST, MONITOR_DEFAULTTOPRIMARY, MONITORINFO, MONITORINFOEXW, + MonitorFromPoint, MonitorFromWindow, }; use winit_core::monitor::{MonitorHandleProvider, VideoMode}; @@ -101,11 +101,7 @@ pub(crate) fn get_monitor_info(hmonitor: HMONITOR) -> Result {{ - winit_core::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }}; } pub fn encode_wide(string: impl AsRef) -> Vec { @@ -53,11 +51,7 @@ where } pub(crate) fn win_to_err(result: BOOL) -> Result<(), io::Error> { - if result != false.into() { - Ok(()) - } else { - Err(io::Error::last_os_error()) - } + if result != false.into() { Ok(()) } else { Err(io::Error::last_os_error()) } } pub enum WindowArea { @@ -159,7 +153,7 @@ pub fn get_instance_handle() -> HMODULE { // This is preferred over GetModuleHandle(NULL) because it also works in DLLs: // https://stackoverflow.com/questions/21718027/getmodulehandlenull-vs-hinstance - extern "C" { + unsafe extern "C" { static __ImageBase: IMAGE_DOS_HEADER; } diff --git a/winit-win32/src/window.rs b/winit-win32/src/window.rs index e07384be..a0ffc138 100644 --- a/winit-win32/src/window.rs +++ b/winit-win32/src/window.rs @@ -13,38 +13,39 @@ use windows_sys::Win32::Foundation::{ HWND, LPARAM, OLE_E_WRONGCOMPOBJ, POINT, POINTS, RECT, RPC_E_CHANGED_MODE, S_OK, WPARAM, }; use windows_sys::Win32::Graphics::Dwm::{ - DwmEnableBlurBehindWindow, DwmSetWindowAttribute, DWMWA_BORDER_COLOR, DWMWA_CAPTION_COLOR, - DWMWA_SYSTEMBACKDROP_TYPE, DWMWA_TEXT_COLOR, DWMWA_WINDOW_CORNER_PREFERENCE, DWM_BB_BLURREGION, - DWM_BB_ENABLE, DWM_BLURBEHIND, DWM_SYSTEMBACKDROP_TYPE, DWM_WINDOW_CORNER_PREFERENCE, + DWM_BB_BLURREGION, DWM_BB_ENABLE, DWM_BLURBEHIND, DWM_SYSTEMBACKDROP_TYPE, + DWM_WINDOW_CORNER_PREFERENCE, DWMWA_BORDER_COLOR, DWMWA_CAPTION_COLOR, + DWMWA_SYSTEMBACKDROP_TYPE, DWMWA_TEXT_COLOR, DWMWA_WINDOW_CORNER_PREFERENCE, + DwmEnableBlurBehindWindow, DwmSetWindowAttribute, }; use windows_sys::Win32::Graphics::Gdi::{ - ChangeDisplaySettingsExW, ClientToScreen, CreateRectRgn, DeleteObject, InvalidateRgn, - RedrawWindow, CDS_FULLSCREEN, DISP_CHANGE_BADFLAGS, DISP_CHANGE_BADMODE, DISP_CHANGE_BADPARAM, - DISP_CHANGE_FAILED, DISP_CHANGE_SUCCESSFUL, RDW_INTERNALPAINT, + CDS_FULLSCREEN, ChangeDisplaySettingsExW, ClientToScreen, CreateRectRgn, DISP_CHANGE_BADFLAGS, + DISP_CHANGE_BADMODE, DISP_CHANGE_BADPARAM, DISP_CHANGE_FAILED, DISP_CHANGE_SUCCESSFUL, + DeleteObject, InvalidateRgn, RDW_INTERNALPAINT, RedrawWindow, }; use windows_sys::Win32::System::Com::{ - CoCreateInstance, CoInitializeEx, CoUninitialize, CLSCTX_ALL, COINIT_APARTMENTTHREADED, + CLSCTX_ALL, COINIT_APARTMENTTHREADED, CoCreateInstance, CoInitializeEx, CoUninitialize, }; use windows_sys::Win32::System::Ole::{OleInitialize, RegisterDragDrop}; use windows_sys::Win32::UI::Input::KeyboardAndMouse::{ - EnableWindow, GetActiveWindow, MapVirtualKeyW, ReleaseCapture, SendInput, ToUnicode, INPUT, - INPUT_0, INPUT_KEYBOARD, KEYBDINPUT, KEYEVENTF_EXTENDEDKEY, KEYEVENTF_KEYUP, MAPVK_VK_TO_VSC, - VIRTUAL_KEY, VK_LMENU, VK_MENU, VK_SPACE, + EnableWindow, GetActiveWindow, INPUT, INPUT_0, INPUT_KEYBOARD, KEYBDINPUT, + KEYEVENTF_EXTENDEDKEY, KEYEVENTF_KEYUP, MAPVK_VK_TO_VSC, MapVirtualKeyW, ReleaseCapture, + SendInput, ToUnicode, VIRTUAL_KEY, VK_LMENU, VK_MENU, VK_SPACE, }; use windows_sys::Win32::UI::Input::Touch::{RegisterTouchWindow, TWF_WANTPALM}; use windows_sys::Win32::UI::WindowsAndMessaging::{ - CreateWindowExW, EnableMenuItem, FlashWindowEx, GetClientRect, GetCursorPos, - GetForegroundWindow, GetSystemMenu, GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, - GetWindowTextW, IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, - SendMessageW, SetCursor, SetCursorPos, SetForegroundWindow, SetMenuDefaultItem, - SetWindowDisplayAffinity, SetWindowPlacement, SetWindowPos, SetWindowTextW, TrackPopupMenu, - CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO, FLASHW_ALL, FLASHW_STOP, FLASHW_TIMERNOFG, - FLASHW_TRAY, GWLP_HINSTANCE, HTBOTTOM, HTBOTTOMLEFT, HTBOTTOMRIGHT, HTCAPTION, HTLEFT, HTRIGHT, - HTTOP, HTTOPLEFT, HTTOPRIGHT, MENU_ITEM_STATE, MFS_DISABLED, MFS_ENABLED, MF_BYCOMMAND, - NID_READY, PM_NOREMOVE, SC_CLOSE, SC_MAXIMIZE, SC_MINIMIZE, SC_MOVE, SC_RESTORE, SC_SIZE, - SM_DIGITIZER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE, SWP_NOZORDER, TPM_LEFTALIGN, - TPM_RETURNCMD, WDA_EXCLUDEFROMCAPTURE, WDA_NONE, WM_NCLBUTTONDOWN, WM_SETICON, WM_SYSCOMMAND, - WNDCLASSEXW, + CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, CreateWindowExW, EnableMenuItem, FLASHW_ALL, + FLASHW_STOP, FLASHW_TIMERNOFG, FLASHW_TRAY, FLASHWINFO, FlashWindowEx, GWLP_HINSTANCE, + GetClientRect, GetCursorPos, GetForegroundWindow, GetSystemMenu, GetSystemMetrics, + GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW, HTBOTTOM, HTBOTTOMLEFT, + HTBOTTOMRIGHT, HTCAPTION, HTLEFT, HTRIGHT, HTTOP, HTTOPLEFT, HTTOPRIGHT, IsWindowVisible, + LoadCursorW, MENU_ITEM_STATE, MF_BYCOMMAND, MFS_DISABLED, MFS_ENABLED, NID_READY, PM_NOREMOVE, + PeekMessageW, PostMessageW, RegisterClassExW, SC_CLOSE, SC_MAXIMIZE, SC_MINIMIZE, SC_MOVE, + SC_RESTORE, SC_SIZE, SM_DIGITIZER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE, + SWP_NOZORDER, SendMessageW, SetCursor, SetCursorPos, SetForegroundWindow, SetMenuDefaultItem, + SetWindowDisplayAffinity, SetWindowPlacement, SetWindowPos, SetWindowTextW, TPM_LEFTALIGN, + TPM_RETURNCMD, TrackPopupMenu, WDA_EXCLUDEFROMCAPTURE, WDA_NONE, WM_NCLBUTTONDOWN, WM_SETICON, + WM_SYSCOMMAND, WNDCLASSEXW, }; use winit_core::cursor::Cursor; use winit_core::error::RequestError; @@ -62,15 +63,15 @@ use crate::definitions::{ }; use crate::dpi::{dpi_to_scale_factor, enable_non_client_dpi_scaling, hwnd_dpi}; use crate::drop_handler::FileDropHandler; -use crate::event_loop::{self, ActiveEventLoop, Event, EventLoopRunner, DESTROY_MSG_ID}; +use crate::event_loop::{self, ActiveEventLoop, DESTROY_MSG_ID, Event, EventLoopRunner}; use crate::icon::{IconType, WinCursor}; use crate::ime::ImeContext; use crate::keyboard::KeyEventBuilder; use crate::monitor::MonitorHandle; use crate::window_state::{CursorFlags, SavedWindow, WindowFlags, WindowState}; use crate::{ - monitor, util, BackdropType, Color, CornerPreference, SelectedCursor, WinIcon, - WindowAttributesWindows, + BackdropType, Color, CornerPreference, SelectedCursor, WinIcon, WindowAttributesWindows, + monitor, util, }; #[derive(Clone, Copy, Debug)] @@ -249,11 +250,7 @@ impl Window { } fn enable(b: bool) -> MENU_ITEM_STATE { - if b { - MFS_ENABLED - } else { - MFS_DISABLED - } + if b { MFS_ENABLED } else { MFS_DISABLED } } // Change the menu items according to the current window status. @@ -815,7 +812,7 @@ impl CoreWindow for Window { (Some(Fullscreen::Borderless(Some(monitor))), Some(Fullscreen::Borderless(None))) if monitor.native_id() == monitor::current_monitor(window.hwnd()).native_id() => { - return + return; }, _ => {}, } diff --git a/winit-win32/src/window_state.rs b/winit-win32/src/window_state.rs index 78b36e52..75fa1355 100644 --- a/winit-win32/src/window_state.rs +++ b/winit-win32/src/window_state.rs @@ -6,22 +6,23 @@ use dpi::{PhysicalPosition, PhysicalSize, Size}; use windows_sys::Win32::Foundation::{HWND, RECT}; use windows_sys::Win32::Graphics::Gdi::InvalidateRgn; use windows_sys::Win32::UI::WindowsAndMessaging::{ - AdjustWindowRectEx, EnableMenuItem, GetMenu, GetSystemMenu, GetWindowLongW, SendMessageW, - SetWindowLongW, SetWindowPos, ShowWindow, GWL_EXSTYLE, GWL_STYLE, HWND_BOTTOM, HWND_NOTOPMOST, - HWND_TOPMOST, MF_BYCOMMAND, MF_DISABLED, MF_ENABLED, SC_CLOSE, SWP_ASYNCWINDOWPOS, - SWP_FRAMECHANGED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOREPOSITION, SWP_NOSIZE, SWP_NOZORDER, - SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_RESTORE, SW_SHOW, SW_SHOWNOACTIVATE, WINDOWPLACEMENT, - WINDOW_EX_STYLE, WINDOW_STYLE, WS_BORDER, WS_CAPTION, WS_CHILD, WS_CLIPCHILDREN, - WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES, WS_EX_APPWINDOW, WS_EX_LAYERED, WS_EX_NOREDIRECTIONBITMAP, - WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_EX_WINDOWEDGE, WS_MAXIMIZE, WS_MAXIMIZEBOX, WS_MINIMIZE, - WS_MINIMIZEBOX, WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX, WS_SYSMENU, WS_VISIBLE, + AdjustWindowRectEx, EnableMenuItem, GWL_EXSTYLE, GWL_STYLE, GetMenu, GetSystemMenu, + GetWindowLongW, HWND_BOTTOM, HWND_NOTOPMOST, HWND_TOPMOST, MF_BYCOMMAND, MF_DISABLED, + MF_ENABLED, SC_CLOSE, SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE, SW_RESTORE, SW_SHOW, + SW_SHOWNOACTIVATE, SWP_ASYNCWINDOWPOS, SWP_FRAMECHANGED, SWP_NOACTIVATE, SWP_NOMOVE, + SWP_NOREPOSITION, SWP_NOSIZE, SWP_NOZORDER, SendMessageW, SetWindowLongW, SetWindowPos, + ShowWindow, WINDOW_EX_STYLE, WINDOW_STYLE, WINDOWPLACEMENT, WS_BORDER, WS_CAPTION, WS_CHILD, + WS_CLIPCHILDREN, WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES, WS_EX_APPWINDOW, WS_EX_LAYERED, + WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_EX_WINDOWEDGE, WS_MAXIMIZE, + WS_MAXIMIZEBOX, WS_MINIMIZE, WS_MINIMIZEBOX, WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX, + WS_SYSMENU, WS_VISIBLE, }; use winit_core::icon::Icon; use winit_core::keyboard::ModifiersState; use winit_core::monitor::Fullscreen; use winit_core::window::{ImeCapabilities, Theme, WindowAttributes}; -use crate::{event_loop, util, SelectedCursor}; +use crate::{SelectedCursor, event_loop, util}; /// Contains information about states and the window that the callback is going to use. #[derive(Debug)] diff --git a/winit-x11/src/event_loop.rs b/winit-x11/src/event_loop.rs index cd65c71a..b7b08467 100644 --- a/winit-x11/src/event_loop.rs +++ b/winit-x11/src/event_loop.rs @@ -14,7 +14,7 @@ use std::{fmt, mem, ptr, slice, str}; use calloop::generic::Generic; use calloop::ping::Ping; use calloop::{EventLoop as Loop, Readiness}; -use libc::{setlocale, LC_CTYPE}; +use libc::{LC_CTYPE, setlocale}; use tracing::warn; use winit_common::xkb::Context; use winit_core::application::ApplicationHandler; @@ -43,7 +43,7 @@ use crate::ime::{self, Ime, ImeCreationError, ImeSender}; use crate::util::{self, CustomCursor}; use crate::window::{UnownedWindow, Window}; use crate::xdisplay::{XConnection, XError, XNotSupported}; -use crate::{ffi, xsettings, XlibErrorHook}; +use crate::{XlibErrorHook, ffi, xsettings}; // Xinput constants not defined in x11rb pub(crate) const ALL_DEVICES: u16 = 0; diff --git a/winit-x11/src/event_processor.rs b/winit-x11/src/event_processor.rs index 2274f065..69c99e61 100644 --- a/winit-x11/src/event_processor.rs +++ b/winit-x11/src/event_processor.rs @@ -33,8 +33,8 @@ use xkbcommon_dl::xkb_mod_mask_t; use crate::atoms::*; use crate::dnd::{Dnd, DndState}; use crate::event_loop::{ - mkdid, mkwid, ActiveEventLoop, CookieResultExt, Device, DeviceInfo, DeviceType, - ScrollOrientation, ALL_DEVICES, + ALL_DEVICES, ActiveEventLoop, CookieResultExt, Device, DeviceInfo, DeviceType, + ScrollOrientation, mkdid, mkwid, }; use crate::ime::{ImeEvent, ImeEventReceiver, ImeReceiver, ImeRequest}; use crate::util; diff --git a/winit-x11/src/ime/callbacks.rs b/winit-x11/src/ime/callbacks.rs index fbf2ead1..ffbc70ab 100644 --- a/winit-x11/src/ime/callbacks.rs +++ b/winit-x11/src/ime/callbacks.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use super::context::{ImeContext, ImeContextCreationError}; use super::ffi; -use super::inner::{close_im, ImeInner}; +use super::inner::{ImeInner, close_im}; use super::input_method::PotentialInputMethods; use crate::xdisplay::{XConnection, XError}; diff --git a/winit-x11/src/ime/context.rs b/winit-x11/src/ime/context.rs index 35d1a4de..3c1093b3 100644 --- a/winit-x11/src/ime/context.rs +++ b/winit-x11/src/ime/context.rs @@ -6,7 +6,7 @@ use std::{fmt, mem, ptr}; use x11_dl::xlib::{XIMCallback, XIMPreeditCaretCallbackStruct, XIMPreeditDrawCallbackStruct}; use super::input_method::{InputMethod, Style, XIMStyle}; -use super::{ffi, util, ImeEvent, ImeEventSender}; +use super::{ImeEvent, ImeEventSender, ffi, util}; use crate::xdisplay::{XConnection, XError}; /// IME creation error. diff --git a/winit-x11/src/ime/inner.rs b/winit-x11/src/ime/inner.rs index 20fb7290..c860f46a 100644 --- a/winit-x11/src/ime/inner.rs +++ b/winit-x11/src/ime/inner.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use super::context::ImeContext; use super::input_method::{InputMethod, PotentialInputMethods}; -use super::{ffi, ImeEventSender}; +use super::{ImeEventSender, ffi}; use crate::xdisplay::{XConnection, XError}; pub(crate) unsafe fn close_im(xconn: &Arc, im: ffi::XIM) -> Result<(), XError> { diff --git a/winit-x11/src/ime/input_method.rs b/winit-x11/src/ime/input_method.rs index b3aed061..da084cc4 100644 --- a/winit-x11/src/ime/input_method.rs +++ b/winit-x11/src/ime/input_method.rs @@ -25,11 +25,7 @@ unsafe fn open_im(xconn: &Arc, locale_modifiers: &CStr) -> Option {{ - winit_core::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }}; } mod activation; diff --git a/winit-x11/src/util/cursor.rs b/winit-x11/src/util/cursor.rs index 1204ee07..af602257 100644 --- a/winit-x11/src/util/cursor.rs +++ b/winit-x11/src/util/cursor.rs @@ -97,9 +97,7 @@ impl XConnection { /// Find the render format that corresponds to ARGB32. fn find_argb32_format(&self) -> Result { macro_rules! direct { - ($format:expr, $shift_name:ident, $mask_name:ident, $shift:expr) => {{ - ($format).direct.$shift_name == $shift && ($format).direct.$mask_name == 0xff - }}; + ($format:expr, $shift_name:ident, $mask_name:ident, $shift:expr) => {{ ($format).direct.$shift_name == $shift && ($format).direct.$mask_name == 0xff }}; } self.render_formats() @@ -202,7 +200,7 @@ impl CustomCursor { let mut cursor = match cursor { CustomCursorSource::Image(cursor_image) => cursor_image, CustomCursorSource::Animation { .. } | CustomCursorSource::Url { .. } => { - return Err(NotSupportedError::new("unsupported cursor kind").into()) + return Err(NotSupportedError::new("unsupported cursor kind").into()); }, }; diff --git a/winit-x11/src/util/hint.rs b/winit-x11/src/util/hint.rs index 2f3c692d..7caab59e 100644 --- a/winit-x11/src/util/hint.rs +++ b/winit-x11/src/util/hint.rs @@ -13,11 +13,7 @@ pub enum StateOperation { impl From for StateOperation { fn from(op: bool) -> Self { - if op { - StateOperation::Add - } else { - StateOperation::Remove - } + if op { StateOperation::Add } else { StateOperation::Remove } } } diff --git a/winit-x11/src/util/memory.rs b/winit-x11/src/util/memory.rs index e9d66ba1..11ee8046 100644 --- a/winit-x11/src/util/memory.rs +++ b/winit-x11/src/util/memory.rs @@ -9,11 +9,7 @@ impl<'a, T> XSmartPointer<'a, T> { // You're responsible for only passing things to this that should be XFree'd. // Returns None if ptr is null. pub fn new(xconn: &'a XConnection, ptr: *mut T) -> Option { - if !ptr.is_null() { - Some(XSmartPointer { xconn, ptr }) - } else { - None - } + if !ptr.is_null() { Some(XSmartPointer { xconn, ptr }) } else { None } } } diff --git a/winit-x11/src/util/randr.rs b/winit-x11/src/util/randr.rs index 8dd1fcee..c45de7ee 100644 --- a/winit-x11/src/util/randr.rs +++ b/winit-x11/src/util/randr.rs @@ -31,11 +31,7 @@ pub fn calc_dpi_factor( // Quantize 1/12 step size let dpi_factor = ((ppmm * (12.0 * 25.4 / 96.0)).round() / 12.0).max(1.0); assert!(validate_scale_factor(dpi_factor)); - if dpi_factor <= 20. { - dpi_factor - } else { - 1. - } + if dpi_factor <= 20. { dpi_factor } else { 1. } } impl XConnection { diff --git a/winit-x11/src/window.rs b/winit-x11/src/window.rs index eaec3abd..5aa1dbaf 100644 --- a/winit-x11/src/window.rs +++ b/winit-x11/src/window.rs @@ -34,14 +34,14 @@ use x11rb::protocol::{randr, xinput}; use crate::atoms::*; use crate::event_loop::{ - xinput_fp1616_to_float, ActivationItem, ActiveEventLoop, CookieResultExt, VoidCookie, - WakeSender, X11Error, ALL_MASTER_DEVICES, ICONIC_STATE, + ALL_MASTER_DEVICES, ActivationItem, ActiveEventLoop, CookieResultExt, ICONIC_STATE, VoidCookie, + WakeSender, X11Error, xinput_fp1616_to_float, }; use crate::ime::{ImeRequest, ImeSender}; use crate::monitor::MonitorHandle as X11MonitorHandle; -use crate::util::{self, rgba_to_cardinals, CustomCursor, SelectedCursor}; +use crate::util::{self, CustomCursor, SelectedCursor, rgba_to_cardinals}; use crate::xdisplay::XConnection; -use crate::{ffi, WindowAttributesX11, WindowType}; +use crate::{WindowAttributesX11, WindowType, ffi}; #[derive(Debug)] pub struct Window(Arc); @@ -632,10 +632,10 @@ impl UnownedWindow { // the visual from the parent window, thus we have to query the visual // we've got when we built the window above. if visual == x11rb::COPY_FROM_PARENT { - visual = leap!(leap!(xconn - .xcb_connection() - .get_window_attributes(xwindow as xproto::Window)) - .reply()) + visual = leap!( + leap!(xconn.xcb_connection().get_window_attributes(xwindow as xproto::Window)) + .reply() + ) .visual; } @@ -762,12 +762,14 @@ impl UnownedWindow { aspect: None, win_gravity: None, }; - leap!(leap!(normal_hints.set( - xconn.xcb_connection(), - window.xwindow as xproto::Window, - xproto::AtomEnum::WM_NORMAL_HINTS, - )) - .check()); + leap!( + leap!(normal_hints.set( + xconn.xcb_connection(), + window.xwindow as xproto::Window, + xproto::AtomEnum::WM_NORMAL_HINTS, + )) + .check() + ); // Set window icons if let Some(icon) = @@ -797,9 +799,9 @@ impl UnownedWindow { let sync_counter_id = leap!(xconn.xcb_connection().generate_id()); window.sync_counter_id = NonZeroU32::new(sync_counter_id); - leap!(xconn - .xcb_connection() - .sync_create_counter(sync_counter_id, Int64::default())) + leap!( + xconn.xcb_connection().sync_create_counter(sync_counter_id, Int64::default()) + ) .ignore_error(); let result = xconn.xcb_connection().change_property( @@ -896,14 +898,16 @@ impl UnownedWindow { /// Embed this window into a parent window. pub(super) fn embed_window(&self) -> Result<(), RequestError> { let atoms = self.xconn.atoms(); - leap!(leap!(self.xconn.change_property( - self.xwindow, - atoms[_XEMBED], - atoms[_XEMBED], - xproto::PropMode::REPLACE, - &[0u32, 1u32], - )) - .check()); + leap!( + leap!(self.xconn.change_property( + self.xwindow, + atoms[_XEMBED], + atoms[_XEMBED], + xproto::PropMode::REPLACE, + &[0u32, 1u32], + )) + .check() + ); Ok(()) } @@ -1094,11 +1098,7 @@ impl UnownedWindow { if let Some(native_mode) = video_mode.and_then(|requested| { monitor.video_modes.iter().find_map(|mode| { - if &mode.mode == requested { - Some(mode.native_mode) - } else { - None - } + if &mode.mode == requested { Some(mode.native_mode) } else { None } }) }) { // FIXME: this is actually not correct if we're setting the @@ -1454,7 +1454,7 @@ impl UnownedWindow { match (visible, shared_state.visibility) { (true, Visibility::Yes) | (true, Visibility::YesWait) | (false, Visibility::No) => { - return + return; }, _ => (), } diff --git a/winit-x11/src/xdisplay.rs b/winit-x11/src/xdisplay.rs index a77645c5..a2bd1926 100644 --- a/winit-x11/src/xdisplay.rs +++ b/winit-x11/src/xdisplay.rs @@ -192,11 +192,7 @@ impl XConnection { #[inline] pub fn check_errors(&self) -> Result<(), XError> { let error = self.latest_error.lock().unwrap().take(); - if let Some(error) = error { - Err(error) - } else { - Ok(()) - } + if let Some(error) = error { Err(error) } else { Ok(()) } } #[inline] diff --git a/winit-x11/src/xsettings.rs b/winit-x11/src/xsettings.rs index d197e9b0..d848bb94 100644 --- a/winit-x11/src/xsettings.rs +++ b/winit-x11/src/xsettings.rs @@ -43,10 +43,10 @@ impl XConnection { let base_dpi = match dpi_setting.data { SettingData::Integer(dpi) => dpi as f64, SettingData::String(_) => { - return Err(ParserError::BadType(SettingType::String).into()) + return Err(ParserError::BadType(SettingType::String).into()); }, SettingData::Color(_) => { - return Err(ParserError::BadType(SettingType::Color).into()) + return Err(ParserError::BadType(SettingType::Color).into()); }, }; diff --git a/winit/examples/application.rs b/winit/examples/application.rs index 2abc1b42..8947f1e9 100644 --- a/winit/examples/application.rs +++ b/winit/examples/application.rs @@ -8,8 +8,8 @@ use std::error::Error; use std::fmt::Debug; #[cfg(not(android_platform))] use std::num::NonZeroU32; -use std::sync::mpsc::{self, Receiver, Sender}; use std::sync::Arc; +use std::sync::mpsc::{self, Receiver, Sender}; #[cfg(all(not(android_platform), not(web_platform)))] use std::time::Instant; use std::{fmt, mem}; diff --git a/winit/src/changelog/unreleased.md b/winit/src/changelog/unreleased.md index c2a9e22c..7b166c41 100644 --- a/winit/src/changelog/unreleased.md +++ b/winit/src/changelog/unreleased.md @@ -96,7 +96,7 @@ changelog entry. - `ActiveEventLoop::create_window` now returns `Box`. - `ApplicationHandler` now uses `dyn ActiveEventLoop`. - On Web, let events wake up event loop immediately when using `ControlFlow::Poll`. -- Bump MSRV from `1.70` to `1.80`. +- Bump MSRV from `1.70` to `1.85`. - Changed `ApplicationHandler::user_event` to `user_wake_up`, removing the generic user event. diff --git a/winit/src/os_error.rs b/winit/src/os_error.rs index 30281c8d..017cf7d4 100644 --- a/winit/src/os_error.rs +++ b/winit/src/os_error.rs @@ -1,6 +1,4 @@ #[allow(unused_macros)] macro_rules! os_error { - ($error:expr) => {{ - winit_core::error::OsError::new(line!(), file!(), $error) - }}; + ($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }}; } diff --git a/winit/src/platform/startup_notify.rs b/winit/src/platform/startup_notify.rs index be6c2173..0313cb57 100644 --- a/winit/src/platform/startup_notify.rs +++ b/winit/src/platform/startup_notify.rs @@ -93,8 +93,10 @@ impl WindowExtStartupNotify for dyn Window + '_ { /// This is wise to do before running child processes, /// which may not to support the activation token. pub fn reset_activation_token_env() { - env::remove_var(X11_VAR); - env::remove_var(WAYLAND_VAR); + unsafe { + env::remove_var(X11_VAR); + env::remove_var(WAYLAND_VAR); + } } /// Set environment variables responsible for activation token. @@ -102,6 +104,8 @@ pub fn reset_activation_token_env() { /// This could be used before running daemon processes. pub fn set_activation_token_env(token: ActivationToken) { let token = token.into_raw(); - env::set_var(X11_VAR, &token); - env::set_var(WAYLAND_VAR, token); + unsafe { + env::set_var(X11_VAR, &token); + env::set_var(WAYLAND_VAR, token); + } } diff --git a/winit/src/platform_impl/linux/mod.rs b/winit/src/platform_impl/linux/mod.rs index 47e66520..a771696d 100644 --- a/winit/src/platform_impl/linux/mod.rs +++ b/winit/src/platform_impl/linux/mod.rs @@ -10,8 +10,8 @@ use std::time::Duration; pub(crate) use winit_common::xkb::{physicalkey_to_scancode, scancode_to_physicalkey}; use winit_core::application::ApplicationHandler; use winit_core::error::{EventLoopError, NotSupportedError}; -use winit_core::event_loop::pump_events::PumpStatus; use winit_core::event_loop::ActiveEventLoop; +use winit_core::event_loop::pump_events::PumpStatus; #[cfg(wayland_platform)] pub(crate) use winit_wayland as wayland; #[cfg(x11_platform)]