@@ -67,7 +67,7 @@ pub fn apply_acrylic(hwnd: HWND, color: Option<Color>) -> Result<(), Error> {
67
67
unsafe {
68
68
DwmSetWindowAttribute (
69
69
hwnd,
70
- DWMWA_SYSTEMBACKDROP_TYPE ,
70
+ DWMWA_SYSTEMBACKDROP_TYPE as _ ,
71
71
& DWM_SYSTEMBACKDROP_TYPE :: DWMSBT_TRANSIENTWINDOW as * const _ as _ ,
72
72
4 ,
73
73
) ;
@@ -93,7 +93,7 @@ pub fn clear_acrylic(hwnd: HWND) -> Result<(), Error> {
93
93
unsafe {
94
94
DwmSetWindowAttribute (
95
95
hwnd,
96
- DWMWA_SYSTEMBACKDROP_TYPE ,
96
+ DWMWA_SYSTEMBACKDROP_TYPE as _ ,
97
97
& DWM_SYSTEMBACKDROP_TYPE :: DWMSBT_DISABLE as * const _ as _ ,
98
98
4 ,
99
99
) ;
@@ -115,7 +115,7 @@ pub fn apply_mica(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
115
115
unsafe {
116
116
DwmSetWindowAttribute (
117
117
hwnd,
118
- DWMWA_USE_IMMERSIVE_DARK_MODE ,
118
+ DWMWA_USE_IMMERSIVE_DARK_MODE as _ ,
119
119
& ( dark as u32 ) as * const _ as _ ,
120
120
4 ,
121
121
) ;
@@ -126,14 +126,14 @@ pub fn apply_mica(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
126
126
unsafe {
127
127
DwmSetWindowAttribute (
128
128
hwnd,
129
- DWMWA_SYSTEMBACKDROP_TYPE ,
129
+ DWMWA_SYSTEMBACKDROP_TYPE as _ ,
130
130
& DWM_SYSTEMBACKDROP_TYPE :: DWMSBT_MAINWINDOW as * const _ as _ ,
131
131
4 ,
132
132
) ;
133
133
}
134
134
} else if is_undocumented_mica_supported ( ) {
135
135
unsafe {
136
- DwmSetWindowAttribute ( hwnd, DWMWA_MICA_EFFECT , & 1 as * const _ as _ , 4 ) ;
136
+ DwmSetWindowAttribute ( hwnd, DWMWA_MICA_EFFECT as _ , & 1 as * const _ as _ , 4 ) ;
137
137
}
138
138
} else {
139
139
return Err ( Error :: UnsupportedPlatformVersion (
@@ -148,14 +148,14 @@ pub fn clear_mica(hwnd: HWND) -> Result<(), Error> {
148
148
unsafe {
149
149
DwmSetWindowAttribute (
150
150
hwnd,
151
- DWMWA_SYSTEMBACKDROP_TYPE ,
151
+ DWMWA_SYSTEMBACKDROP_TYPE as _ ,
152
152
& DWM_SYSTEMBACKDROP_TYPE :: DWMSBT_DISABLE as * const _ as _ ,
153
153
4 ,
154
154
) ;
155
155
}
156
156
} else if is_undocumented_mica_supported ( ) {
157
157
unsafe {
158
- DwmSetWindowAttribute ( hwnd, DWMWA_MICA_EFFECT , & 0 as * const _ as _ , 4 ) ;
158
+ DwmSetWindowAttribute ( hwnd, DWMWA_MICA_EFFECT as _ , & 0 as * const _ as _ , 4 ) ;
159
159
}
160
160
} else {
161
161
return Err ( Error :: UnsupportedPlatformVersion (
@@ -170,7 +170,7 @@ pub fn apply_tabbed(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
170
170
unsafe {
171
171
DwmSetWindowAttribute (
172
172
hwnd,
173
- DWMWA_USE_IMMERSIVE_DARK_MODE ,
173
+ DWMWA_USE_IMMERSIVE_DARK_MODE as _ ,
174
174
& ( dark as u32 ) as * const _ as _ ,
175
175
4 ,
176
176
) ;
@@ -181,7 +181,7 @@ pub fn apply_tabbed(hwnd: HWND, dark: Option<bool>) -> Result<(), Error> {
181
181
unsafe {
182
182
DwmSetWindowAttribute (
183
183
hwnd,
184
- DWMWA_SYSTEMBACKDROP_TYPE ,
184
+ DWMWA_SYSTEMBACKDROP_TYPE as _ ,
185
185
& DWM_SYSTEMBACKDROP_TYPE :: DWMSBT_TABBEDWINDOW as * const _ as _ ,
186
186
4 ,
187
187
) ;
@@ -199,7 +199,7 @@ pub fn clear_tabbed(hwnd: HWND) -> Result<(), Error> {
199
199
unsafe {
200
200
DwmSetWindowAttribute (
201
201
hwnd,
202
- DWMWA_SYSTEMBACKDROP_TYPE ,
202
+ DWMWA_SYSTEMBACKDROP_TYPE as _ ,
203
203
& DWM_SYSTEMBACKDROP_TYPE :: DWMSBT_DISABLE as * const _ as _ ,
204
204
4 ,
205
205
) ;
@@ -230,34 +230,6 @@ macro_rules! get_function {
230
230
} ;
231
231
}
232
232
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
-
261
233
#[ repr( C ) ]
262
234
struct ACCENT_POLICY {
263
235
AccentState : u32 ,
@@ -322,8 +294,8 @@ unsafe fn SetWindowCompositionAttribute(
322
294
}
323
295
}
324
296
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 ;
327
299
328
300
#[ allow( unused) ]
329
301
#[ repr( C ) ]
@@ -335,8 +307,13 @@ enum DWM_SYSTEMBACKDROP_TYPE {
335
307
}
336
308
337
309
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
340
317
}
341
318
342
319
fn is_swca_supported ( ) -> bool {
@@ -350,8 +327,3 @@ fn is_undocumented_mica_supported() -> bool {
350
327
fn is_backdroptype_supported ( ) -> bool {
351
328
is_at_least_build ( 22523 )
352
329
}
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