Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: bump windows-sys to 0.52 #3639

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ features = [
unicode-segmentation = "1.7.1"

[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
version = "0.48"
version = "0.52.0"
features = [
"Win32_Devices_HumanInterfaceDevice",
"Win32_Foundation",
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub unsafe fn hwnd_dpi(hwnd: HWND) -> u32 {
if unsafe { IsProcessDPIAware() } != false.into() {
// If the process is DPI aware, then scaling must be handled by the application using
// this DPI value.
unsafe { GetDeviceCaps(hdc, LOGPIXELSX) as u32 }
unsafe { GetDeviceCaps(hdc, LOGPIXELSX as i32) as u32 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should ask for upstream clarification about these. At least in the windows crate where these are newtyped, the underlying ABI is "kept in sync" (IIRC by casting in the wrapper implementation).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that casting small u32 to positive i32 have the same binary repr, it's safe to do it here.

In general, a lot of casts seems to be that way because sometimes they accept enum but enum itself is i32 and not u32, and so on.

You can still ask though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not saying that it's unsafe, just that it's inconvenient after these Windows crates already have all the type information they need; looks like it's all reserved for the high-level windows crate though.

} else {
// If the process is DPI unaware, then scaling is performed by the OS; we thus return
// 96 (scale factor 1.0) to prevent the window from being re-scaled by both the
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/drop_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl FileDropHandler {
let get_data_fn = unsafe { (*(*data_obj).cast::<IDataObjectVtbl>()).GetData };
let get_data_result = unsafe { get_data_fn(data_obj as *mut _, &drop_format, &mut medium) };
if get_data_result >= 0 {
let hdrop = unsafe { medium.Anonymous.hGlobal };
let hdrop = unsafe { medium.u.hGlobal as HDROP };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could someone verify that it's a correct change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the docs, I think windows-sys changed internal unions from being called Anonymous to being called u.

Additionally, HGLOBAL changed from isize to *mut c_void, I assume that's intentional too, at least that's what I'm getting from reading microsoft/windows-rs#1643 (comment).


// The second parameter (0xFFFFFFFF) instructs the function to return the item count
let item_count = unsafe { DragQueryFileW(hdrop, 0xFFFFFFFF, ptr::null_mut(), 0) };
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl RgbaIcon {
let pixels =
unsafe { std::slice::from_raw_parts_mut(rgba.as_ptr() as *mut Pixel, pixel_count) };
for pixel in pixels {
and_mask.push(pixel.a.wrapping_sub(std::u8::MAX)); // invert alpha channel
and_mask.push(pixel.a.wrapping_sub(u8::MAX)); // invert alpha channel
pixel.convert_to_bgra();
}
assert_eq!(and_mask.len(), pixel_count);
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 @@ -99,7 +99,7 @@ pub fn is_maximized(window: HWND) -> bool {
let mut placement: WINDOWPLACEMENT = mem::zeroed();
placement.length = mem::size_of::<WINDOWPLACEMENT>() as u32;
GetWindowPlacement(window, &mut placement);
placement.showCmd == SW_MAXIMIZE
placement.showCmd == SW_MAXIMIZE as u32
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ impl Window {
unsafe {
DwmSetWindowAttribute(
self.hwnd(),
DWMWA_SYSTEMBACKDROP_TYPE,
DWMWA_SYSTEMBACKDROP_TYPE as u32,
&(backdrop_type as i32) as *const _ as _,
mem::size_of::<DWM_SYSTEMBACKDROP_TYPE>() as _,
);
Expand Down Expand Up @@ -1089,7 +1089,7 @@ impl Window {
unsafe {
DwmSetWindowAttribute(
self.hwnd(),
DWMWA_BORDER_COLOR,
DWMWA_BORDER_COLOR as u32,
&color as *const _ as _,
mem::size_of::<Color>() as _,
);
Expand All @@ -1101,7 +1101,7 @@ impl Window {
unsafe {
DwmSetWindowAttribute(
self.hwnd(),
DWMWA_CAPTION_COLOR,
DWMWA_CAPTION_COLOR as u32,
&color as *const _ as _,
mem::size_of::<Color>() as _,
);
Expand All @@ -1113,7 +1113,7 @@ impl Window {
unsafe {
DwmSetWindowAttribute(
self.hwnd(),
DWMWA_TEXT_COLOR,
DWMWA_TEXT_COLOR as u32,
&color as *const _ as _,
mem::size_of::<Color>() as _,
);
Expand All @@ -1125,7 +1125,7 @@ impl Window {
unsafe {
DwmSetWindowAttribute(
self.hwnd(),
DWMWA_WINDOW_CORNER_PREFERENCE,
DWMWA_WINDOW_CORNER_PREFERENCE as u32,
&(preference as DWM_WINDOW_CORNER_PREFERENCE) as *const _ as _,
mem::size_of::<DWM_WINDOW_CORNER_PREFERENCE>() as _,
);
Expand Down Expand Up @@ -1494,7 +1494,7 @@ impl Drop for ComInitialized {
thread_local! {
static COM_INITIALIZED: ComInitialized = {
unsafe {
CoInitializeEx(ptr::null(), COINIT_APARTMENTTHREADED);
CoInitializeEx(ptr::null(), COINIT_APARTMENTTHREADED as u32);
ComInitialized(ptr::null_mut())
}
};
Expand Down
Loading