Skip to content

Commit

Permalink
chore(deps): update windows crate to 0.58
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Aug 16, 2024
1 parent 1113935 commit 44011a1
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 143 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ softbuffer = "0.4"
parking_lot = "0.12"
unicode-segmentation = "1.11"
windows-version = "0.1"
windows-core = "0.57"
windows-core = "0.58"

[target."cfg(target_os = \"windows\")".dependencies.windows]
version = "0.57"
version = "0.58"
features = [
"implement",
"Win32_Devices_HumanInterfaceDevice",
Expand Down
6 changes: 3 additions & 3 deletions src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ pub trait WindowExtWindows {
impl WindowExtWindows for Window {
#[inline]
fn hinstance(&self) -> isize {
self.window.hinstance().0
self.window.hinstance().0 as _
}

#[inline]
fn hwnd(&self) -> isize {
self.window.hwnd().0
self.window.hwnd().0 as _
}

#[inline]
Expand Down Expand Up @@ -380,7 +380,7 @@ impl MonitorHandleExtWindows for MonitorHandle {

#[inline]
fn hmonitor(&self) -> isize {
self.inner.hmonitor().0
self.inner.hmonitor().0 as _
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/platform_impl/windows/dark_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use std::ffi::c_void;

use crate::window::Theme;

static HUXTHEME: Lazy<HMODULE> =
Lazy::new(|| unsafe { LoadLibraryA(s!("uxtheme.dll")).unwrap_or_default() });
static HUXTHEME: Lazy<isize> =
Lazy::new(|| unsafe { LoadLibraryA(s!("uxtheme.dll")).unwrap_or_default().0 as _ });

static WIN10_BUILD_VERSION: Lazy<Option<u32>> = Lazy::new(|| {
let version = windows_version::OsVersion::current();
Expand All @@ -44,12 +44,12 @@ pub fn allow_dark_mode_for_app(is_dark_mode: bool) {
const UXTHEME_ALLOWDARKMODEFORAPP_ORDINAL: u16 = 135;
type AllowDarkModeForApp = unsafe extern "system" fn(bool) -> bool;
static ALLOW_DARK_MODE_FOR_APP: Lazy<Option<AllowDarkModeForApp>> = Lazy::new(|| unsafe {
if HUXTHEME.is_invalid() {
if HMODULE(*HUXTHEME as _).is_invalid() {
return None;
}

GetProcAddress(
*HUXTHEME,
HMODULE(*HUXTHEME as _),
PCSTR::from_raw(UXTHEME_ALLOWDARKMODEFORAPP_ORDINAL as usize as *mut _),
)
.map(|handle| std::mem::transmute(handle))
Expand All @@ -66,12 +66,12 @@ pub fn allow_dark_mode_for_app(is_dark_mode: bool) {
const UXTHEME_SETPREFERREDAPPMODE_ORDINAL: u16 = 135;
type SetPreferredAppMode = unsafe extern "system" fn(PreferredAppMode) -> PreferredAppMode;
static SET_PREFERRED_APP_MODE: Lazy<Option<SetPreferredAppMode>> = Lazy::new(|| unsafe {
if HUXTHEME.is_invalid() {
if HMODULE(*HUXTHEME as _).is_invalid() {
return None;
}

GetProcAddress(
*HUXTHEME,
HMODULE(*HUXTHEME as _),
PCSTR::from_raw(UXTHEME_SETPREFERREDAPPMODE_ORDINAL as usize as *mut _),
)
.map(|handle| std::mem::transmute(handle))
Expand Down Expand Up @@ -100,12 +100,12 @@ fn refresh_immersive_color_policy_state() {
type RefreshImmersiveColorPolicyState = unsafe extern "system" fn();
static REFRESH_IMMERSIVE_COLOR_POLICY_STATE: Lazy<Option<RefreshImmersiveColorPolicyState>> =
Lazy::new(|| unsafe {
if HUXTHEME.is_invalid() {
if HMODULE(*HUXTHEME as _).is_invalid() {
return None;
}

GetProcAddress(
*HUXTHEME,
HMODULE(*HUXTHEME as _),
PCSTR::from_raw(UXTHEME_REFRESHIMMERSIVECOLORPOLICYSTATE_ORDINAL as usize as *mut _),
)
.map(|handle| std::mem::transmute(handle))
Expand Down Expand Up @@ -142,12 +142,12 @@ pub fn allow_dark_mode_for_window(hwnd: HWND, is_dark_mode: bool) {
const UXTHEME_ALLOWDARKMODEFORWINDOW_ORDINAL: u16 = 133;
type AllowDarkModeForWindow = unsafe extern "system" fn(HWND, bool) -> bool;
static ALLOW_DARK_MODE_FOR_WINDOW: Lazy<Option<AllowDarkModeForWindow>> = Lazy::new(|| unsafe {
if HUXTHEME.is_invalid() {
if HMODULE(*HUXTHEME as _).is_invalid() {
return None;
}

GetProcAddress(
*HUXTHEME,
HMODULE(*HUXTHEME as _),
PCSTR::from_raw(UXTHEME_ALLOWDARKMODEFORWINDOW_ORDINAL as usize as *mut _),
)
.map(|handle| std::mem::transmute(handle))
Expand Down Expand Up @@ -206,12 +206,12 @@ fn should_apps_use_dark_mode() -> bool {
const UXTHEME_SHOULDAPPSUSEDARKMODE_ORDINAL: u16 = 132;
type ShouldAppsUseDarkMode = unsafe extern "system" fn() -> bool;
static SHOULD_APPS_USE_DARK_MODE: Lazy<Option<ShouldAppsUseDarkMode>> = Lazy::new(|| unsafe {
if HUXTHEME.is_invalid() {
if HMODULE(*HUXTHEME as _).is_invalid() {
return None;
}

GetProcAddress(
*HUXTHEME,
HMODULE(*HUXTHEME as _),
PCSTR::from_raw(UXTHEME_SHOULDAPPSUSEDARKMODE_ORDINAL as usize as *mut _),
)
.map(|handle| std::mem::transmute(handle))
Expand Down
12 changes: 6 additions & 6 deletions src/platform_impl/windows/drop_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl FileDropHandler {
}

#[allow(non_snake_case)]
impl IDropTarget_Impl for FileDropHandler {
impl IDropTarget_Impl for FileDropHandler_Impl {
fn DragEnter(
&self,
pDataObj: Option<&IDataObject>,
Expand All @@ -112,9 +112,9 @@ impl IDropTarget_Impl for FileDropHandler {
) -> windows::core::Result<()> {
use crate::event::WindowEvent::HoveredFile;
unsafe {
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
let hdrop = FileDropHandler::iterate_filenames(pDataObj, |filename| {
(self.send_event)(Event::WindowEvent {
window_id: SuperWindowId(WindowId(self.window.0)),
window_id: SuperWindowId(WindowId(self.window.0 as _)),
event: HoveredFile(filename),
});
});
Expand Down Expand Up @@ -147,7 +147,7 @@ impl IDropTarget_Impl for FileDropHandler {
use crate::event::WindowEvent::HoveredFileCancelled;
if unsafe { *self.hovered_is_valid.get() } {
(self.send_event)(Event::WindowEvent {
window_id: SuperWindowId(WindowId(self.window.0)),
window_id: SuperWindowId(WindowId(self.window.0 as _)),
event: HoveredFileCancelled,
});
}
Expand All @@ -163,9 +163,9 @@ impl IDropTarget_Impl for FileDropHandler {
) -> windows::core::Result<()> {
use crate::event::WindowEvent::DroppedFile;
unsafe {
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
let hdrop = FileDropHandler::iterate_filenames(pDataObj, |filename| {
(self.send_event)(Event::WindowEvent {
window_id: SuperWindowId(WindowId(self.window.0)),
window_id: SuperWindowId(WindowId(self.window.0 as _)),
event: DroppedFile(filename),
});
});
Expand Down
Loading

0 comments on commit 44011a1

Please sign in to comment.