From 2175a9fdab7cbce54f743ed117de85049a89c014 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Mon, 17 Feb 2025 21:57:45 -0300 Subject: [PATCH] start update --- Cargo.lock | 2 +- docs/docs/releases.md | 2 ++ rio-window/Cargo.toml | 2 +- rio-window/src/platform/windows.rs | 6 +++--- rio-window/src/platform_impl/windows/dark_mode.rs | 2 +- rio-window/src/platform_impl/windows/definitions.rs | 12 ++++++++---- rio-window/src/platform_impl/windows/dpi.rs | 4 ++-- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f5e08b2ed..d70ecac420 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2833,7 +2833,7 @@ dependencies = [ "wayland-protocols-plasma", "web-sys", "web-time", - "windows-sys 0.52.0", + "windows-sys 0.59.0", "x11-dl", "x11rb", "xkbcommon-dl", diff --git a/docs/docs/releases.md b/docs/docs/releases.md index 60aeb4f3e1..240cb23334 100644 --- a/docs/docs/releases.md +++ b/docs/docs/releases.md @@ -11,6 +11,8 @@ language: 'en' - OSC 7 Escape sequences to advise the terminal of the working directory. - OSC 133 Escape sequence to define Input, Output and Prompt zones. - OSC 1337 Escape sequences to set user vars for tracking additional shell state. +- Updated `windows-sys` to `v0.59`. + - To match the corresponding changes in `windows-sys`, the `HWND`, `HMONITOR`, and `HMENU` types now alias to `*mut c_void` instead of `isize`. ## 0.2.7 diff --git a/rio-window/Cargo.toml b/rio-window/Cargo.toml index bd583b4ce3..beae2412ce 100644 --- a/rio-window/Cargo.toml +++ b/rio-window/Cargo.toml @@ -116,7 +116,7 @@ features = [ unicode-segmentation = "1.7.1" [target.'cfg(target_os = "windows")'.dependencies.windows-sys] -version = "0.52.0" +version = "0.59.0" features = [ "Win32_Devices_HumanInterfaceDevice", "Win32_Foundation", diff --git a/rio-window/src/platform/windows.rs b/rio-window/src/platform/windows.rs index 0bc502a135..8e032fa9ba 100644 --- a/rio-window/src/platform/windows.rs +++ b/rio-window/src/platform/windows.rs @@ -13,11 +13,11 @@ use crate::monitor::MonitorHandle; use crate::window::{BadIcon, Icon, Window, WindowAttributes}; /// Window Handle type used by Win32 API -pub type HWND = isize; +pub type HWND = *mut c_void; /// Menu Handle type used by Win32 API -pub type HMENU = isize; +pub type HMENU = *mut c_void; /// Monitor Handle type used by Win32 API -pub type HMONITOR = isize; +pub type HMONITOR = *mut c_void; /// Describes a system-drawn backdrop material of a window. /// diff --git a/rio-window/src/platform_impl/windows/dark_mode.rs b/rio-window/src/platform_impl/windows/dark_mode.rs index c84a1bce66..298e98241c 100644 --- a/rio-window/src/platform_impl/windows/dark_mode.rs +++ b/rio-window/src/platform_impl/windows/dark_mode.rs @@ -142,7 +142,7 @@ fn should_apps_use_dark_mode() -> bool { let module = LoadLibraryA("uxtheme.dll\0".as_ptr()); - if module == 0 { + if module.is_null() { return None; } diff --git a/rio-window/src/platform_impl/windows/definitions.rs b/rio-window/src/platform_impl/windows/definitions.rs index f5e127f4f2..9ec575b90c 100644 --- a/rio-window/src/platform_impl/windows/definitions.rs +++ b/rio-window/src/platform_impl/windows/definitions.rs @@ -3,11 +3,15 @@ use std::ffi::c_void; -use windows_sys::core::{IUnknown, GUID, HRESULT}; +use windows_sys::core::{GUID, HRESULT}; use windows_sys::Win32::Foundation::{BOOL, HWND, POINTL}; -use windows_sys::Win32::System::Com::{ - IAdviseSink, IDataObject, IEnumFORMATETC, IEnumSTATDATA, FORMATETC, STGMEDIUM, -}; +use windows_sys::Win32::System::Com::{FORMATETC, STGMEDIUM}; + +pub type IUnknown = *mut c_void; +pub type IAdviseSink = *mut c_void; +pub type IDataObject = *mut c_void; +pub type IEnumFORMATETC = *mut c_void; +pub type IEnumSTATDATA = *mut c_void; #[repr(C)] pub struct IUnknownVtbl { diff --git a/rio-window/src/platform_impl/windows/dpi.rs b/rio-window/src/platform_impl/windows/dpi.rs index b6e87da76c..7defe675e7 100644 --- a/rio-window/src/platform_impl/windows/dpi.rs +++ b/rio-window/src/platform_impl/windows/dpi.rs @@ -81,7 +81,7 @@ pub fn dpi_to_scale_factor(dpi: u32) -> f64 { pub unsafe fn hwnd_dpi(hwnd: HWND) -> u32 { let hdc = unsafe { GetDC(hwnd) }; - if hdc == 0 { + if hdc.is_null() { panic!("[winit] `GetDC` returned null!"); } if let Some(GetDpiForWindow) = *GET_DPI_FOR_WINDOW { @@ -93,7 +93,7 @@ pub unsafe fn hwnd_dpi(hwnd: HWND) -> u32 { } else if let Some(GetDpiForMonitor) = *GET_DPI_FOR_MONITOR { // We are on Windows 8.1 or later. let monitor = unsafe { MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST) }; - if monitor == 0 { + if monitor.is_null() { return BASE_DPI; }