Skip to content

Commit

Permalink
Update to windows-sys 0.32
Browse files Browse the repository at this point in the history
  • Loading branch information
clemenswasser committed Feb 4, 2022
1 parent 35216a1 commit d289b1e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ default_features = false
features = ["display_link"]

[target.'cfg(target_os = "windows")'.dependencies]
parking_lot = "0.11"
parking_lot = "0.12"

[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
version = "0.29"
version = "0.32"
features = [
"Win32_Devices_HumanInterfaceDevice",
"Win32_Foundation",
Expand Down Expand Up @@ -93,7 +93,7 @@ sctk = { package = "smithay-client-toolkit", version = "0.15.1", default_feature
mio = { version = "0.8", features = ["os-ext"], optional = true }
x11-dl = { version = "2.18.5", optional = true }
percent-encoding = { version = "2.0", optional = true }
parking_lot = { version = "0.11.0", optional = true }
parking_lot = { version = "0.12.0", optional = true }
libc = "0.2.64"

[target.'cfg(target_arch = "wasm32")'.dependencies.web_sys]
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/windows/dark_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{ffi, ptr};

use windows_sys::Win32::{
Foundation::{BOOL, HWND, NTSTATUS, PSTR, PWSTR, S_OK},
Foundation::{BOOL, HWND, NTSTATUS, PSTR, S_OK},
System::{
LibraryLoader::{GetProcAddress, LoadLibraryA},
SystemInformation::OSVERSIONINFOW,
Expand Down Expand Up @@ -80,7 +80,7 @@ pub fn try_theme(hwnd: HWND, preferred_theme: Option<Theme>) -> Theme {
Theme::Light => LIGHT_THEME_NAME.as_ptr(),
};

let status = unsafe { SetWindowTheme(hwnd, theme_name as PWSTR, ptr::null_mut()) };
let status = unsafe { SetWindowTheme(hwnd, theme_name, ptr::null_mut()) };

if status == S_OK && set_dark_mode_for_window(hwnd, is_dark_mode) {
return theme;
Expand Down Expand Up @@ -146,7 +146,7 @@ fn should_apps_use_dark_mode() -> bool {
unsafe {
const UXTHEME_SHOULDAPPSUSEDARKMODE_ORDINAL: PSTR = 132 as PSTR;

let module = LoadLibraryA("uxtheme.dll\0".as_ptr() as PSTR);
let module = LoadLibraryA("uxtheme.dll\0".as_ptr());

if module == 0 {
return None;
Expand Down
20 changes: 10 additions & 10 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,51 +580,51 @@ lazy_static! {
// WPARAM and LPARAM are unused.
static ref USER_EVENT_MSG_ID: u32 = {
unsafe {
RegisterWindowMessageA("Winit::WakeupMsg\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::WakeupMsg\0".as_ptr())
}
};
// Message sent when we want to execute a closure in the thread.
// WPARAM contains a Box<Box<dyn FnMut()>> that must be retrieved with `Box::from_raw`,
// and LPARAM is unused.
static ref EXEC_MSG_ID: u32 = {
unsafe {
RegisterWindowMessageA("Winit::ExecMsg\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::ExecMsg\0".as_ptr())
}
};
static ref PROCESS_NEW_EVENTS_MSG_ID: u32 = {
unsafe {
RegisterWindowMessageA("Winit::ProcessNewEvents\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::ProcessNewEvents\0".as_ptr())
}
};
/// lparam is the wait thread's message id.
static ref SEND_WAIT_THREAD_ID_MSG_ID: u32 = {
unsafe {
RegisterWindowMessageA("Winit::SendWaitThreadId\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::SendWaitThreadId\0".as_ptr())
}
};
/// lparam points to a `Box<Instant>` signifying the time `PROCESS_NEW_EVENTS_MSG_ID` should
/// be sent.
static ref WAIT_UNTIL_MSG_ID: u32 = {
unsafe {
RegisterWindowMessageA("Winit::WaitUntil\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::WaitUntil\0".as_ptr())
}
};
static ref CANCEL_WAIT_UNTIL_MSG_ID: u32 = {
unsafe {
RegisterWindowMessageA("Winit::CancelWaitUntil\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::CancelWaitUntil\0".as_ptr())
}
};
// Message sent by a `Window` when it wants to be destroyed by the main thread.
// WPARAM and LPARAM are unused.
pub static ref DESTROY_MSG_ID: u32 = {
unsafe {
RegisterWindowMessageA("Winit::DestroyMsg\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::DestroyMsg\0".as_ptr())
}
};
// WPARAM is a bool specifying the `WindowFlags::MARKER_RETAIN_STATE_ON_SIZE` flag. See the
// documentation in the `window_state` module for more information.
pub static ref SET_RETAIN_STATE_ON_SIZE_MSG_ID: u32 = unsafe {
RegisterWindowMessageA("Winit::SetRetainMaximized\0".as_ptr() as PSTR)
RegisterWindowMessageA("Winit::SetRetainMaximized\0".as_ptr())
};
static ref THREAD_EVENT_TARGET_WINDOW_CLASS: Vec<u16> = util::encode_wide("Winit Thread Event Target");
}
Expand All @@ -642,7 +642,7 @@ fn create_event_target_window<T: 'static>() -> HWND {
hCursor: 0, // must be null in order for cursor state to work properly
hbrBackground: 0,
lpszMenuName: ptr::null_mut(),
lpszClassName: THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr() as PWSTR,
lpszClassName: THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr(),
hIconSm: 0,
};

Expand All @@ -662,7 +662,7 @@ fn create_event_target_window<T: 'static>() -> HWND {
// `explorer.exe` and then starting the process back up.
// It is unclear why the bug is triggered by waiting for several hours.
| WS_EX_TOOLWINDOW,
THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr() as PWSTR,
THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr(),
ptr::null_mut(),
WS_OVERLAPPED,
0,
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/windows/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl WinIcon {
LR_DEFAULTSIZE | LR_LOADFROMFILE,
)
};
if !handle.is_null() {
if handle != 0 {
Ok(WinIcon::from_handle(handle as HICON))
} else {
Err(BadIcon::OsError(io::Error::last_os_error()))
Expand All @@ -116,7 +116,7 @@ impl WinIcon {
LR_DEFAULTSIZE,
)
};
if !handle.is_null() {
if handle != 0 {
Ok(WinIcon::from_handle(handle as HICON))
} else {
Err(BadIcon::OsError(io::Error::last_os_error()))
Expand Down

0 comments on commit d289b1e

Please sign in to comment.