diff --git a/.changes/windows-rs-0.56.md b/.changes/windows-rs-0.56.md new file mode 100644 index 000000000..0c9ef434a --- /dev/null +++ b/.changes/windows-rs-0.56.md @@ -0,0 +1,5 @@ +--- +"tao": "patch" +--- + +Update `windows` crate to `0.56` diff --git a/Cargo.toml b/Cargo.toml index 74348db46..2225cc9d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,25 +42,26 @@ serde = { version = "1", optional = true, features = [ "serde_derive" ] } rwh_04 = { package = "raw-window-handle", version = "0.4", optional = true } rwh_05 = { package = "raw-window-handle", version = "0.5", features = [ "std" ], optional = true } rwh_06 = { package = "raw-window-handle", version = "0.6", features = [ "std" ], optional = true } -bitflags = "1" +bitflags = "2" crossbeam-channel = "0.5" url = "2" dpi = "0.1" [dev-dependencies] -image = "0.24" -env_logger = "0.10" +image = "0.25" +env_logger = "0.11" [target."cfg(target_os = \"windows\")".dev-dependencies] -softbuffer = "0.4.1" +softbuffer = "0.4" [target."cfg(target_os = \"windows\")".dependencies] parking_lot = "0.12" -unicode-segmentation = "1.10" +unicode-segmentation = "1.11" windows-version = "0.1" +windows-core = "0.56" [target."cfg(target_os = \"windows\")".dependencies.windows] - version = "0.54" + version = "0.56" features = [ "implement", "Win32_Devices_HumanInterfaceDevice", diff --git a/src/keyboard.rs b/src/keyboard.rs index 27afaa997..29b193774 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -106,7 +106,7 @@ bitflags! { /// Represents the current state of the keyboard modifiers /// /// Each flag represents a modifier and is set if this modifier is active. - #[derive(Default)] + #[derive(Clone, Copy, Default, Debug, PartialEq)] pub struct ModifiersState: u32 { // left and right modifiers are currently commented out, but we should be able to support // them in a future release diff --git a/src/platform/ios.rs b/src/platform/ios.rs index a70f0eed6..6b9141c3a 100644 --- a/src/platform/ios.rs +++ b/src/platform/ios.rs @@ -312,14 +312,14 @@ bitflags! { /// The [edges] of a screen. /// /// [edges]: https://developer.apple.com/documentation/uikit/uirectedge?language=objc - #[derive(Default)] + #[derive(Clone, Copy ,Default)] pub struct ScreenEdge: u8 { const NONE = 0; const TOP = 1 << 0; const LEFT = 1 << 1; const BOTTOM = 1 << 2; const RIGHT = 1 << 3; - const ALL = ScreenEdge::TOP.bits | ScreenEdge::LEFT.bits - | ScreenEdge::BOTTOM.bits | ScreenEdge::RIGHT.bits; + const ALL = ScreenEdge::TOP.bits() | ScreenEdge::LEFT.bits() + | ScreenEdge::BOTTOM.bits() | ScreenEdge::RIGHT.bits(); } } diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 6a508c578..06c38628c 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -199,7 +199,7 @@ impl WindowExtWindows for Window { #[inline] fn set_enable(&self, enabled: bool) { unsafe { - EnableWindow(self.window.hwnd(), enabled); + let _ = EnableWindow(self.window.hwnd(), enabled); } } diff --git a/src/platform_impl/windows/dark_mode.rs b/src/platform_impl/windows/dark_mode.rs index 52b9e50ab..c36d257a0 100644 --- a/src/platform_impl/windows/dark_mode.rs +++ b/src/platform_impl/windows/dark_mode.rs @@ -205,7 +205,7 @@ fn refresh_titlebar_theme_color(hwnd: HWND, is_dark_mode: bool) { pvData: &mut is_dark_mode_bigbool as *mut _ as _, cbData: std::mem::size_of_val(&is_dark_mode_bigbool) as _, }; - unsafe { set_window_composition_attribute(hwnd, &mut data as *mut _) }; + let _ = unsafe { set_window_composition_attribute(hwnd, &mut data as *mut _) }; } } } diff --git a/src/platform_impl/windows/dpi.rs b/src/platform_impl/windows/dpi.rs index 04350a948..7b185ac90 100644 --- a/src/platform_impl/windows/dpi.rs +++ b/src/platform_impl/windows/dpi.rs @@ -26,14 +26,14 @@ pub fn become_dpi_aware() { if !SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2).as_bool() { // V2 only works with Windows 10 Creators Update (1703). Try using the older // V1 if we can't set V2. - SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); + let _ = SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); } } else if let Some(SetProcessDpiAwareness) = *SET_PROCESS_DPI_AWARENESS { // We are on Windows 8.1 or later. let _ = SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); } else if let Some(SetProcessDPIAware) = *SET_PROCESS_DPI_AWARE { // We are on Vista or later. - SetProcessDPIAware(); + let _ = SetProcessDPIAware(); } } }); @@ -42,7 +42,7 @@ pub fn become_dpi_aware() { pub fn enable_non_client_dpi_scaling(hwnd: HWND) { unsafe { if let Some(EnableNonClientDpiScaling) = *ENABLE_NON_CLIENT_DPI_SCALING { - EnableNonClientDpiScaling(hwnd); + let _ = EnableNonClientDpiScaling(hwnd); } } } diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index d7ab42f06..4ffcb2e3a 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -255,7 +255,7 @@ impl EventLoop { false }; if !handled { - TranslateMessage(&msg); + let _ = TranslateMessage(&msg); DispatchMessageW(&msg); } @@ -386,13 +386,13 @@ fn wait_thread(parent_thread_id: u32, msg_window_id: HWND) { if wait_until_opt.is_some() { if PeekMessageW(&mut msg, HWND::default(), 0, 0, PM_REMOVE).as_bool() { - TranslateMessage(&msg); + let _ = TranslateMessage(&msg); DispatchMessageW(&msg); } } else if !GetMessageW(&mut msg, HWND::default(), 0, 0).as_bool() { break 'main; } else { - TranslateMessage(&msg); + let _ = TranslateMessage(&msg); DispatchMessageW(&msg); } @@ -805,7 +805,7 @@ unsafe fn flush_paint_messages( return; } - TranslateMessage(&msg); + let _ = TranslateMessage(&msg); DispatchMessageW(&msg); }); true @@ -935,7 +935,7 @@ unsafe fn public_window_callback_inner( _: usize, subclass_input: &SubclassInput, ) -> LRESULT { - RedrawWindow( + let _ = RedrawWindow( subclass_input.event_loop_runner.thread_msg_target(), None, HRGN::default(), @@ -1081,7 +1081,7 @@ unsafe fn public_window_callback_inner( if subclass_input.event_loop_runner.should_buffer() { // this branch can happen in response to `UpdateWindow`, if win32 decides to // redraw the window outside the normal flow of the event loop. - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); } else { let managing_redraw = flush_paint_messages(Some(window), &subclass_input.event_loop_runner); subclass_input.send_event(Event::RedrawRequested(RootWindowId(WindowId(window.0)))); @@ -1716,7 +1716,7 @@ unsafe fn public_window_callback_inner( }); } - SkipPointerFrameMessages(pointer_id); + let _ = SkipPointerFrameMessages(pointer_id); } result = ProcResult::Value(LRESULT(0)); @@ -1893,7 +1893,7 @@ unsafe fn public_window_callback_inner( let mut old_physical_inner_rect = RECT::default(); let _ = GetClientRect(window, &mut old_physical_inner_rect); let mut origin = POINT::default(); - ClientToScreen(window, &mut origin); + let _ = ClientToScreen(window, &mut origin); old_physical_inner_rect.left += origin.x; old_physical_inner_rect.right += origin.x; @@ -1996,7 +1996,7 @@ unsafe fn public_window_callback_inner( cbSize: mem::size_of::() as _, ..Default::default() }; - GetMonitorInfoW(monitor, &mut monitor_info); + let _ = GetMonitorInfoW(monitor, &mut monitor_info); monitor_info.rcMonitor }; let wrong_monitor = conservative_rect_monitor; @@ -2235,13 +2235,13 @@ unsafe extern "system" fn thread_event_target_callback( win32wm::WM_NCDESTROY => { remove_event_target_window_subclass::(window); subclass_removed = true; - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); LRESULT(0) } // Because WM_PAINT comes after all other messages, we use it during modal loops to detect // when the event queue has been emptied. See `process_event` for more details. win32wm::WM_PAINT => { - ValidateRect(window, None); + let _ = ValidateRect(window, None); // If the WM_PAINT handler in `public_window_callback` has already flushed the redraw // events, `handling_events` will return false and we won't emit a second // `RedrawEventsCleared` event. @@ -2249,7 +2249,7 @@ unsafe extern "system" fn thread_event_target_callback( if subclass_input.event_loop_runner.should_buffer() { // This branch can be triggered when a nested win32 event loop is triggered // inside of the `event_handler` callback. - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); } else { // This WM_PAINT handler will never be re-entrant because `flush_paint_messages` // doesn't call WM_PAINT for the thread event target (i.e. this window). @@ -2277,7 +2277,7 @@ unsafe extern "system" fn thread_event_target_callback( device_id: wrap_device_id(lparam.0), event, }); - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); LRESULT(0) } @@ -2285,7 +2285,7 @@ unsafe extern "system" fn thread_event_target_callback( win32wm::WM_INPUT => { if let Some(data) = raw_input::get_raw_input_data(HRAWINPUT(lparam.0)) { handle_raw_input(&subclass_input, data); - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); } DefSubclassProc(window, msg, wparam, lparam) @@ -2295,13 +2295,13 @@ unsafe extern "system" fn thread_event_target_callback( if let Ok(event) = subclass_input.user_event_receiver.recv() { subclass_input.send_event(Event::UserEvent(event)); } - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); LRESULT(0) } _ if msg == *EXEC_MSG_ID => { let mut function: ThreadExecFn = Box::from_raw(wparam.0 as *mut _); function(); - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); LRESULT(0) } _ if msg == *PROCESS_NEW_EVENTS_MSG_ID => { @@ -2327,7 +2327,7 @@ unsafe extern "system" fn thread_event_target_callback( if msg.message == WM_PAINT { let mut rect = RECT::default(); if !GetUpdateRect(msg.hwnd, Some(&mut rect), false).as_bool() { - RedrawWindow(msg.hwnd, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(msg.hwnd, None, HRGN::default(), RDW_INTERNALPAINT); } } @@ -2336,7 +2336,7 @@ unsafe extern "system" fn thread_event_target_callback( } } subclass_input.event_loop_runner.poll(); - RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT); LRESULT(0) } _ => DefSubclassProc(window, msg, wparam, lparam), diff --git a/src/platform_impl/windows/event_loop/runner.rs b/src/platform_impl/windows/event_loop/runner.rs index 7782ab59f..3eaa59f93 100644 --- a/src/platform_impl/windows/event_loop/runner.rs +++ b/src/platform_impl/windows/event_loop/runner.rs @@ -395,7 +395,7 @@ impl EventLoopRunner { }; self.call_event_handler(Event::NewEvents(start_cause)); self.dispatch_buffered_events(); - RedrawWindow( + let _ = RedrawWindow( self.thread_msg_target, None, HRGN::default(), diff --git a/src/platform_impl/windows/keyboard_layout.rs b/src/platform_impl/windows/keyboard_layout.rs index ba2cf8ede..232242d71 100644 --- a/src/platform_impl/windows/keyboard_layout.rs +++ b/src/platform_impl/windows/keyboard_layout.rs @@ -72,6 +72,7 @@ lazy_static! { } bitflags! { + #[derive(Clone, Copy, Eq, PartialEq, Hash)] pub struct WindowsModifiers : u8 { const SHIFT = 1 << 0; const CONTROL = 1 << 1; @@ -333,11 +334,11 @@ impl LayoutCache { } // Iterate through every combination of modifiers - let mods_end = WindowsModifiers::FLAGS_END.bits; + let mods_end = WindowsModifiers::FLAGS_END.bits(); for mod_state in 0..mods_end { let mut keys_for_this_mod = HashMap::with_capacity(256); - let mod_state = unsafe { WindowsModifiers::from_bits_unchecked(mod_state) }; + let mod_state = WindowsModifiers::from_bits_truncate(mod_state); mod_state.apply_to_kbd_state(&mut key_state); // Virtual key values are in the domain [0, 255]. @@ -414,7 +415,7 @@ impl LayoutCache { // Second pass: replace right alt keys with AltGr if the layout has alt graph if layout.has_alt_graph { for mod_state in 0..mods_end { - let mod_state = unsafe { WindowsModifiers::from_bits_unchecked(mod_state) }; + let mod_state = WindowsModifiers::from_bits_truncate(mod_state); if let Some(keys) = layout.keys.get_mut(&mod_state) { if let Some(key) = keys.get_mut(&KeyCode::AltRight) { *key = Key::AltGraph; diff --git a/src/platform_impl/windows/monitor.rs b/src/platform_impl/windows/monitor.rs index 9896a87f0..0d70474fc 100644 --- a/src/platform_impl/windows/monitor.rs +++ b/src/platform_impl/windows/monitor.rs @@ -102,7 +102,7 @@ unsafe extern "system" fn monitor_enum_proc( pub fn available_monitors() -> VecDeque { let mut monitors: VecDeque = VecDeque::new(); unsafe { - EnumDisplayMonitors( + let _ = EnumDisplayMonitors( HDC::default(), None, Some(monitor_enum_proc), diff --git a/src/platform_impl/windows/util.rs b/src/platform_impl/windows/util.rs index 0a5b3954e..864117882 100644 --- a/src/platform_impl/windows/util.rs +++ b/src/platform_impl/windows/util.rs @@ -121,7 +121,7 @@ pub(crate) fn set_inner_size_physical(window: HWND, x: u32, y: u32, is_decorated outer_y, SWP_ASYNCWINDOWPOS | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOMOVE | SWP_NOACTIVATE, ); - InvalidateRgn(window, HRGN::default(), BOOL::default()); + let _ = InvalidateRgn(window, HRGN::default(), BOOL::default()); } } diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index d78ee1b42..e7a23c7f2 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -178,7 +178,7 @@ impl Window { #[inline] pub fn request_redraw(&self) { unsafe { - RedrawWindow(self.window.0, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(self.window.0, None, HRGN::default(), RDW_INTERNALPAINT); } } @@ -220,7 +220,7 @@ impl Window { 0, SWP_ASYNCWINDOWPOS | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE, ); - InvalidateRgn(self.window.0, HRGN::default(), false); + let _ = InvalidateRgn(self.window.0, HRGN::default(), false); } } @@ -703,7 +703,7 @@ impl Window { // fine, taking control back from the DWM and ensuring that the `SetWindowPos` call // below goes through. let mut msg = MSG::default(); - PeekMessageW(&mut msg, HWND::default(), 0, 0, PM_NOREMOVE); + let _ = PeekMessageW(&mut msg, HWND::default(), 0, 0, PM_NOREMOVE); } // Update window style @@ -751,7 +751,7 @@ impl Window { size.1 as i32, SWP_ASYNCWINDOWPOS | SWP_NOZORDER, ); - InvalidateRgn(window.0, HRGN::default(), false); + let _ = InvalidateRgn(window.0, HRGN::default(), false); } } None => { @@ -760,7 +760,7 @@ impl Window { drop(window_state_lock); unsafe { let _ = SetWindowPlacement(window.0, &placement); - InvalidateRgn(window.0, HRGN::default(), false); + let _ = InvalidateRgn(window.0, HRGN::default(), false); } } } @@ -859,8 +859,8 @@ impl Window { }; unsafe { let himc = ImmGetContext(self.window.0); - ImmSetCompositionWindow(himc, &composition_form); - ImmReleaseContext(self.window.0, himc); + let _ = ImmSetCompositionWindow(himc, &composition_form); + let _ = ImmReleaseContext(self.window.0, himc); } } } @@ -894,7 +894,7 @@ impl Window { uCount: count, dwTimeout: 0, }; - FlashWindowEx(&flash_info); + let _ = FlashWindowEx(&flash_info); }); } @@ -1121,7 +1121,7 @@ unsafe fn init( }; let _ = DwmEnableBlurBehindWindow(real_window.0, &bb); - DeleteObject(region); + let _ = DeleteObject(region); } // If the system theme is dark, we need to set the window theme now @@ -1232,7 +1232,7 @@ unsafe extern "system" fn window_proc( win32wm::WM_NCCALCSIZE => { let userdata = util::GetWindowLongPtrW(window, GWL_USERDATA); if userdata != 0 { - let window_flags = WindowFlags::from_bits_unchecked(userdata as _); + let window_flags = WindowFlags::from_bits_truncate(userdata as _); if wparam == WPARAM(0) || window_flags.contains(WindowFlags::MARKER_DECORATIONS) { return DefWindowProcW(window, msg, wparam, lparam); @@ -1358,7 +1358,7 @@ unsafe fn force_window_active(handle: HWND) { // Simulate a key press and release SendInput(&inputs, mem::size_of::() as _); - SetForegroundWindow(handle); + let _ = SetForegroundWindow(handle); } pub(crate) unsafe fn set_skip_taskbar(hwnd: HWND, skip: bool) { diff --git a/src/platform_impl/windows/window_state.rs b/src/platform_impl/windows/window_state.rs index 563d7116b..4c24bb3bf 100644 --- a/src/platform_impl/windows/window_state.rs +++ b/src/platform_impl/windows/window_state.rs @@ -63,6 +63,7 @@ pub struct MouseProperties { } bitflags! { + #[derive(Clone, Copy)] pub struct CursorFlags: u8 { const GRABBED = 1 << 0; const HIDDEN = 1 << 1; @@ -70,6 +71,7 @@ bitflags! { } } bitflags! { + #[derive(Clone, Copy, PartialEq)] pub struct WindowFlags: u32 { const RESIZABLE = 1 << 0; const VISIBLE = 1 << 1; @@ -111,7 +113,7 @@ bitflags! { const RIGHT_TO_LEFT_LAYOUT = 1 << 22; - const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits; + const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits(); } } @@ -300,7 +302,7 @@ impl WindowFlags { if new.contains(WindowFlags::VISIBLE) { unsafe { - ShowWindow( + let _ = ShowWindow( window, if self.contains(WindowFlags::MARKER_DONT_FOCUS) { self.set(WindowFlags::MARKER_DONT_FOCUS, false); @@ -326,7 +328,7 @@ impl WindowFlags { 0, SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE, ); - InvalidateRgn(window, HRGN::default(), false); + let _ = InvalidateRgn(window, HRGN::default(), false); } } @@ -344,13 +346,13 @@ impl WindowFlags { 0, SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE, ); - InvalidateRgn(window, HRGN::default(), false); + let _ = InvalidateRgn(window, HRGN::default(), false); } } if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) { unsafe { - ShowWindow( + let _ = ShowWindow( window, match new.contains(WindowFlags::MAXIMIZED) { true => SW_MAXIMIZE, @@ -363,7 +365,7 @@ impl WindowFlags { // Minimize operations should execute after maximize for proper window animations if diff.contains(WindowFlags::MINIMIZED) { unsafe { - ShowWindow( + let _ = ShowWindow( window, match new.contains(WindowFlags::MINIMIZED) { true => SW_MINIMIZE, @@ -378,7 +380,7 @@ impl WindowFlags { if diff.contains(WindowFlags::CLOSABLE) || new.contains(WindowFlags::CLOSABLE) { unsafe { let system_menu = GetSystemMenu(window, false); - EnableMenuItem( + let _ = EnableMenuItem( system_menu, SC_CLOSE, MF_BYCOMMAND @@ -393,7 +395,7 @@ impl WindowFlags { if !new.contains(WindowFlags::VISIBLE) { unsafe { - ShowWindow(window, SW_HIDE); + let _ = ShowWindow(window, SW_HIDE); } } diff --git a/tao-macros/Cargo.toml b/tao-macros/Cargo.toml index ebc511f07..5db4f24e7 100644 --- a/tao-macros/Cargo.toml +++ b/tao-macros/Cargo.toml @@ -19,4 +19,4 @@ default = [ ] [dependencies] proc-macro2 = "1" quote = "1" -syn = { version = "1", features = [ "full" ] } +syn = { version = "2", features = [ "full" ] } diff --git a/tao-macros/src/lib.rs b/tao-macros/src/lib.rs index 67a573467..b212e26d2 100644 --- a/tao-macros/src/lib.rs +++ b/tao-macros/src/lib.rs @@ -46,7 +46,7 @@ impl Parse for AndroidFnInput { let args; let _: syn::token::Bracket = bracketed!(args in input); - let args = args.parse_terminated::(Type::parse)?; + let args = args.parse_terminated(Type::parse, Token![,])?; let _: syn::Result = input.parse(); let ret = if input.peek(Ident) { @@ -64,7 +64,7 @@ impl Parse for AndroidFnInput { let non_jni_args = if input.peek(syn::token::Bracket) { let non_jni_args; let _: syn::token::Bracket = bracketed!(non_jni_args in input); - let non_jni_args = non_jni_args.parse_terminated::(Type::parse)?; + let non_jni_args = non_jni_args.parse_terminated(Type::parse, Token![,])?; let _: syn::Result = input.parse(); non_jni_args } else {