Skip to content

Commit

Permalink
chore(deps): update to windows-rs 0.56 and other deps (#909)
Browse files Browse the repository at this point in the history
* chore(deps): update to windows-rs 0.56 and other deps

* fix iOS

* ios again
  • Loading branch information
amrbashir authored Apr 18, 2024
1 parent 9ef1379 commit 5af059b
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .changes/windows-rs-0.56.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

Update `windows` crate to `0.56`
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/platform/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/dark_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _) };
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/windows/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
});
Expand All @@ -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);
}
}
}
Expand Down
36 changes: 18 additions & 18 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<T: 'static> EventLoop<T> {
false
};
if !handled {
TranslateMessage(&msg);
let _ = TranslateMessage(&msg);
DispatchMessageW(&msg);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -805,7 +805,7 @@ unsafe fn flush_paint_messages<T: 'static>(
return;
}

TranslateMessage(&msg);
let _ = TranslateMessage(&msg);
DispatchMessageW(&msg);
});
true
Expand Down Expand Up @@ -935,7 +935,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
_: usize,
subclass_input: &SubclassInput<T>,
) -> LRESULT {
RedrawWindow(
let _ = RedrawWindow(
subclass_input.event_loop_runner.thread_msg_target(),
None,
HRGN::default(),
Expand Down Expand Up @@ -1081,7 +1081,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
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))));
Expand Down Expand Up @@ -1716,7 +1716,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
});
}

SkipPointerFrameMessages(pointer_id);
let _ = SkipPointerFrameMessages(pointer_id);
}

result = ProcResult::Value(LRESULT(0));
Expand Down Expand Up @@ -1893,7 +1893,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
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;
Expand Down Expand Up @@ -1996,7 +1996,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
cbSize: mem::size_of::<MONITORINFO>() as _,
..Default::default()
};
GetMonitorInfoW(monitor, &mut monitor_info);
let _ = GetMonitorInfoW(monitor, &mut monitor_info);
monitor_info.rcMonitor
};
let wrong_monitor = conservative_rect_monitor;
Expand Down Expand Up @@ -2235,21 +2235,21 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
win32wm::WM_NCDESTROY => {
remove_event_target_window_subclass::<T>(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.
if subclass_input.event_loop_runner.handling_events() {
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).
Expand Down Expand Up @@ -2277,15 +2277,15 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
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)
}

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)
Expand All @@ -2295,13 +2295,13 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
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 => {
Expand All @@ -2327,7 +2327,7 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
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);
}
}

Expand All @@ -2336,7 +2336,7 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
}
}
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),
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/event_loop/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl<T> EventLoopRunner<T> {
};
self.call_event_handler(Event::NewEvents(start_cause));
self.dispatch_buffered_events();
RedrawWindow(
let _ = RedrawWindow(
self.thread_msg_target,
None,
HRGN::default(),
Expand Down
7 changes: 4 additions & 3 deletions src/platform_impl/windows/keyboard_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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].
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ unsafe extern "system" fn monitor_enum_proc(
pub fn available_monitors() -> VecDeque<MonitorHandle> {
let mut monitors: VecDeque<MonitorHandle> = VecDeque::new();
unsafe {
EnumDisplayMonitors(
let _ = EnumDisplayMonitors(
HDC::default(),
None,
Some(monitor_enum_proc),
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Loading

0 comments on commit 5af059b

Please sign in to comment.