Skip to content

Commit 49587a7

Browse files
fix(deps): update rust crate windows-sys to 0.52.0 (#110)
* fix(deps): update rust crate windows-sys to 0.52.0 * fix build * Update Cargo.toml * Create windwos-sys-0-52.md --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: amrbashir <[email protected]>
1 parent 451d9ff commit 49587a7

File tree

3 files changed

+28
-48
lines changed

3 files changed

+28
-48
lines changed

.changes/windwos-sys-0-52.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"window-vibrancy": patch
3+
---
4+
5+
Update `windows-sys` crate to 0.52

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ raw-window-handle = "0.5"
2323
tao = "0.23"
2424
winit = {version = "0.29", default-features = false, features = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita", "rwh_05"] }
2525

26+
[target."cfg(target_os = \"windows\")".dependencies]
27+
windows-version = "0.1"
28+
2629
[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
27-
version = "0.48.0"
30+
version = "0.52.0"
2831
features = [
2932
"Win32_Foundation",
3033
"Win32_System_LibraryLoader",

src/windows.rs

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn apply_acrylic(hwnd: HWND, color: Option<Color>) -> Result<(), Error> {
6767
unsafe {
6868
DwmSetWindowAttribute(
6969
hwnd,
70-
DWMWA_SYSTEMBACKDROP_TYPE,
70+
DWMWA_SYSTEMBACKDROP_TYPE as _,
7171
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_TRANSIENTWINDOW as *const _ as _,
7272
4,
7373
);
@@ -93,7 +93,7 @@ pub fn clear_acrylic(hwnd: HWND) -> Result<(), Error> {
9393
unsafe {
9494
DwmSetWindowAttribute(
9595
hwnd,
96-
DWMWA_SYSTEMBACKDROP_TYPE,
96+
DWMWA_SYSTEMBACKDROP_TYPE as _,
9797
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_DISABLE as *const _ as _,
9898
4,
9999
);
@@ -115,7 +115,7 @@ pub fn apply_mica(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
115115
unsafe {
116116
DwmSetWindowAttribute(
117117
hwnd,
118-
DWMWA_USE_IMMERSIVE_DARK_MODE,
118+
DWMWA_USE_IMMERSIVE_DARK_MODE as _,
119119
&(dark as u32) as *const _ as _,
120120
4,
121121
);
@@ -126,14 +126,14 @@ pub fn apply_mica(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
126126
unsafe {
127127
DwmSetWindowAttribute(
128128
hwnd,
129-
DWMWA_SYSTEMBACKDROP_TYPE,
129+
DWMWA_SYSTEMBACKDROP_TYPE as _,
130130
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_MAINWINDOW as *const _ as _,
131131
4,
132132
);
133133
}
134134
} else if is_undocumented_mica_supported() {
135135
unsafe {
136-
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFECT, &1 as *const _ as _, 4);
136+
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFECT as _, &1 as *const _ as _, 4);
137137
}
138138
} else {
139139
return Err(Error::UnsupportedPlatformVersion(
@@ -148,14 +148,14 @@ pub fn clear_mica(hwnd: HWND) -> Result<(), Error> {
148148
unsafe {
149149
DwmSetWindowAttribute(
150150
hwnd,
151-
DWMWA_SYSTEMBACKDROP_TYPE,
151+
DWMWA_SYSTEMBACKDROP_TYPE as _,
152152
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_DISABLE as *const _ as _,
153153
4,
154154
);
155155
}
156156
} else if is_undocumented_mica_supported() {
157157
unsafe {
158-
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFECT, &0 as *const _ as _, 4);
158+
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFECT as _, &0 as *const _ as _, 4);
159159
}
160160
} else {
161161
return Err(Error::UnsupportedPlatformVersion(
@@ -170,7 +170,7 @@ pub fn apply_tabbed(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
170170
unsafe {
171171
DwmSetWindowAttribute(
172172
hwnd,
173-
DWMWA_USE_IMMERSIVE_DARK_MODE,
173+
DWMWA_USE_IMMERSIVE_DARK_MODE as _,
174174
&(dark as u32) as *const _ as _,
175175
4,
176176
);
@@ -181,7 +181,7 @@ pub fn apply_tabbed(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
181181
unsafe {
182182
DwmSetWindowAttribute(
183183
hwnd,
184-
DWMWA_SYSTEMBACKDROP_TYPE,
184+
DWMWA_SYSTEMBACKDROP_TYPE as _,
185185
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_TABBEDWINDOW as *const _ as _,
186186
4,
187187
);
@@ -199,7 +199,7 @@ pub fn clear_tabbed(hwnd: HWND) -> Result<(), Error> {
199199
unsafe {
200200
DwmSetWindowAttribute(
201201
hwnd,
202-
DWMWA_SYSTEMBACKDROP_TYPE,
202+
DWMWA_SYSTEMBACKDROP_TYPE as _,
203203
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_DISABLE as *const _ as _,
204204
4,
205205
);
@@ -230,34 +230,6 @@ macro_rules! get_function {
230230
};
231231
}
232232

233-
/// Returns a tuple of (major, minor, buildnumber)
234-
fn get_windows_ver() -> Option<(u32, u32, u32)> {
235-
type RtlGetVersion = unsafe extern "system" fn(*mut OSVERSIONINFOW) -> i32;
236-
let handle = unsafe { get_function!("ntdll.dll", RtlGetVersion) };
237-
if let Some(rtl_get_version) = handle {
238-
unsafe {
239-
let mut vi = OSVERSIONINFOW {
240-
dwOSVersionInfoSize: 0,
241-
dwMajorVersion: 0,
242-
dwMinorVersion: 0,
243-
dwBuildNumber: 0,
244-
dwPlatformId: 0,
245-
szCSDVersion: [0; 128],
246-
};
247-
248-
let status = (rtl_get_version)(&mut vi as _);
249-
250-
if status >= 0 {
251-
Some((vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber))
252-
} else {
253-
None
254-
}
255-
}
256-
} else {
257-
None
258-
}
259-
}
260-
261233
#[repr(C)]
262234
struct ACCENT_POLICY {
263235
AccentState: u32,
@@ -322,8 +294,8 @@ unsafe fn SetWindowCompositionAttribute(
322294
}
323295
}
324296

325-
const DWMWA_MICA_EFFECT: DWMWINDOWATTRIBUTE = 1029i32;
326-
const DWMWA_SYSTEMBACKDROP_TYPE: DWMWINDOWATTRIBUTE = 38i32;
297+
const DWMWA_MICA_EFFECT: DWMWINDOWATTRIBUTE = 1029;
298+
const DWMWA_SYSTEMBACKDROP_TYPE: DWMWINDOWATTRIBUTE = 38;
327299

328300
#[allow(unused)]
329301
#[repr(C)]
@@ -335,8 +307,13 @@ enum DWM_SYSTEMBACKDROP_TYPE {
335307
}
336308

337309
fn is_win7() -> bool {
338-
let v = get_windows_ver().unwrap_or_default();
339-
v.0 == 6 && v.1 == 1
310+
let v = windows_version::OsVersion::current();
311+
v.major == 6 && v.minor == 1
312+
}
313+
314+
fn is_at_least_build(build: u32) -> bool {
315+
let v = windows_version::OsVersion::current();
316+
v.build >= build
340317
}
341318

342319
fn is_swca_supported() -> bool {
@@ -350,8 +327,3 @@ fn is_undocumented_mica_supported() -> bool {
350327
fn is_backdroptype_supported() -> bool {
351328
is_at_least_build(22523)
352329
}
353-
354-
fn is_at_least_build(build: u32) -> bool {
355-
let v = get_windows_ver().unwrap_or_default();
356-
v.2 >= build
357-
}

0 commit comments

Comments
 (0)