From 27490de0d12799a176a7bbbc02e8677271f4b77b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Sep 2022 14:10:57 +0000 Subject: [PATCH] chore(deps): bump windows from 0.39.0 to 0.40.0 Bumps [windows](https://github.com/microsoft/windows-rs) from 0.39.0 to 0.40.0. - [Release notes](https://github.com/microsoft/windows-rs/releases) - [Commits](https://github.com/microsoft/windows-rs/compare/0.39.0...0.40.0) --- updated-dependencies: - dependency-name: windows dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 48 ++++++++++++------- komorebi-core/Cargo.toml | 2 +- komorebi/Cargo.toml | 2 +- komorebi/src/windows_api.rs | 80 ++++++++----------------------- komorebi/src/windows_callbacks.rs | 11 +++-- komorebic/Cargo.toml | 2 +- 6 files changed, 61 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6507322f..80eb7dee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1501,15 +1501,17 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a" +checksum = "e30acc718a52fb130fec72b1cb5f55ffeeec9253e1b785e94db222178a6acaa1" dependencies = [ - "windows_aarch64_msvc 0.39.0", - "windows_i686_gnu 0.39.0", - "windows_i686_msvc 0.39.0", - "windows_x86_64_gnu 0.39.0", - "windows_x86_64_msvc 0.39.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.40.0", + "windows_i686_gnu 0.40.0", + "windows_i686_msvc 0.40.0", + "windows_x86_64_gnu 0.40.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.40.0", ] [[package]] @@ -1538,6 +1540,12 @@ dependencies = [ "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3caa4a1a16561b714323ca6b0817403738583033a6a92e04c5d10d4ba37ca10" + [[package]] name = "windows_aarch64_msvc" version = "0.28.0" @@ -1552,9 +1560,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" +checksum = "328973c62dfcc50fb1aaa8e7100676e0b642fe56bac6bafff3327902db843ab4" [[package]] name = "windows_i686_gnu" @@ -1570,9 +1578,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" +checksum = "aa5b09fad70f0df85dea2ac2a525537e415e2bf63ee31cf9b8e263645ee9f3c1" [[package]] name = "windows_i686_msvc" @@ -1588,9 +1596,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" +checksum = "2a1ad4031c1a98491fa195d8d43d7489cb749f135f2e5c4eed58da094bd0d876" [[package]] name = "windows_x86_64_gnu" @@ -1606,9 +1614,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" +checksum = "520ff37edd72da8064b49d2281182898e17f0688ae9f4070bca27e4b5c162ac7" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046e5b82215102c44fd75f488f1b9158973d02aa34d06ed85c23d6f5520a2853" [[package]] name = "windows_x86_64_msvc" @@ -1624,9 +1638,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" +checksum = "2a0c9c6df55dd1bfa76e131cef44bdd8ec9c819ef3611f04dfe453fd5bfeda28" [[package]] name = "winput" diff --git a/komorebi-core/Cargo.toml b/komorebi-core/Cargo.toml index 38aba686..849c56a1 100644 --- a/komorebi-core/Cargo.toml +++ b/komorebi-core/Cargo.toml @@ -15,7 +15,7 @@ strum = { version = "0.24", features = ["derive"] } schemars = "0.8" [dependencies.windows] -version = "0.39" +version = "0.40" features = [ "Win32_Foundation", ] diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index 53e397f5..30c062da 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -43,7 +43,7 @@ winput = "0.2" winreg = "0.10" [dependencies.windows] -version = "0.39" +version = "0.40" features = [ "Win32_Foundation", "Win32_Graphics_Dwm", diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index c2e5192c..0d90d577 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -1,6 +1,7 @@ use std::collections::VecDeque; use std::convert::TryFrom; use std::ffi::c_void; +use std::slice; use std::sync::atomic::Ordering; use color_eyre::eyre::anyhow; @@ -10,19 +11,17 @@ use windows::core::Result as WindowsCrateResult; use windows::core::PCSTR; use windows::core::PWSTR; use windows::Win32::Foundation::BOOL; +use windows::Win32::Foundation::COLORREF; use windows::Win32::Foundation::HANDLE; use windows::Win32::Foundation::HINSTANCE; use windows::Win32::Foundation::HWND; use windows::Win32::Foundation::LPARAM; use windows::Win32::Foundation::POINT; -use windows::Win32::Foundation::RECT; use windows::Win32::Graphics::Dwm::DwmGetWindowAttribute; use windows::Win32::Graphics::Dwm::DwmSetWindowAttribute; use windows::Win32::Graphics::Dwm::DWMWA_CLOAKED; -use windows::Win32::Graphics::Dwm::DWMWA_EXTENDED_FRAME_BOUNDS; use windows::Win32::Graphics::Dwm::DWMWA_WINDOW_CORNER_PREFERENCE; use windows::Win32::Graphics::Dwm::DWMWCP_ROUND; -use windows::Win32::Graphics::Dwm::DWMWINDOWATTRIBUTE; use windows::Win32::Graphics::Dwm::DWM_CLOAKED_APP; use windows::Win32::Graphics::Dwm::DWM_CLOAKED_INHERITED; use windows::Win32::Graphics::Dwm::DWM_CLOAKED_SHELL; @@ -193,16 +192,9 @@ impl WindowsApi { callback: MONITORENUMPROC, callback_data_address: isize, ) -> Result<()> { - unsafe { - EnumDisplayMonitors( - HDC(0), - std::ptr::null_mut(), - callback, - LPARAM(callback_data_address), - ) - } - .ok() - .process() + unsafe { EnumDisplayMonitors(HDC(0), None, callback, LPARAM(callback_data_address)) } + .ok() + .process() } pub fn valid_hmonitors() -> Result> { @@ -433,7 +425,7 @@ impl WindowsApi { // Behaviour is undefined if an invalid HWND is given // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowthreadprocessid - let thread_id = unsafe { GetWindowThreadProcessId(hwnd, &mut process_id) }; + let thread_id = unsafe { GetWindowThreadProcessId(hwnd, Option::from(&mut process_id)) }; (process_id, thread_id) } @@ -534,12 +526,7 @@ impl WindowsApi { let text_ptr = path.as_mut_ptr(); unsafe { - QueryFullProcessImageNameW( - handle, - PROCESS_NAME_WIN32, - PWSTR(text_ptr), - std::ptr::addr_of_mut!(len), - ) + QueryFullProcessImageNameW(handle, PROCESS_NAME_WIN32, PWSTR(text_ptr), &mut len) } .ok() .process()?; @@ -566,37 +553,15 @@ impl WindowsApi { Ok(String::from_utf16(&class[0..len as usize])?) } - pub fn dwm_get_window_attribute( - hwnd: HWND, - attribute: DWMWINDOWATTRIBUTE, - value: &mut T, - ) -> Result<()> { + pub fn is_window_cloaked(hwnd: HWND) -> Result { + let mut cloaked = 0_u32.to_be_bytes(); + unsafe { - DwmGetWindowAttribute( - hwnd, - attribute, - (value as *mut T).cast(), - u32::try_from(std::mem::size_of::())?, - )?; + DwmGetWindowAttribute(hwnd, DWMWA_CLOAKED, &mut cloaked)?; } - Ok(()) - } - - #[allow(dead_code)] - pub fn window_rect_with_extended_frame_bounds(hwnd: HWND) -> Result { - let mut rect = RECT::default(); - Self::dwm_get_window_attribute(hwnd, DWMWA_EXTENDED_FRAME_BOUNDS, &mut rect)?; - - Ok(Rect::from(rect)) - } - - pub fn is_window_cloaked(hwnd: HWND) -> Result { - let mut cloaked: u32 = 0; - Self::dwm_get_window_attribute(hwnd, DWMWA_CLOAKED, &mut cloaked)?; - Ok(matches!( - cloaked, + u32::from_be_bytes(cloaked), DWM_CLOAKED_APP | DWM_CLOAKED_SHELL | DWM_CLOAKED_INHERITED )) } @@ -617,7 +582,7 @@ impl WindowsApi { let mut monitor_info: MONITORINFO = unsafe { std::mem::zeroed() }; monitor_info.cbSize = u32::try_from(std::mem::size_of::())?; - unsafe { GetMonitorInfoW(hmonitor, std::ptr::addr_of_mut!(monitor_info).cast()) } + unsafe { GetMonitorInfoW(hmonitor, &mut monitor_info) } .ok() .process()?; @@ -691,7 +656,7 @@ impl WindowsApi { } pub fn create_solid_brush(colour: u32) -> HBRUSH { - unsafe { CreateSolidBrush(colour) } + unsafe { CreateSolidBrush(COLORREF(colour)) } } pub fn register_class_a(window_class: &WNDCLASSA) -> Result { @@ -716,8 +681,7 @@ impl WindowsApi { DwmSetWindowAttribute( HWND(hwnd), DWMWA_WINDOW_CORNER_PREFERENCE, - std::ptr::addr_of!(round).cast(), - 4, + slice::from_raw_parts(std::ptr::addr_of!(round).cast(), 4), ) } .process() @@ -740,7 +704,7 @@ impl WindowsApi { std::ptr::null(), ); - SetLayeredWindowAttributes(hwnd, TRANSPARENCY_COLOUR, 0, LWA_COLORKEY); + SetLayeredWindowAttributes(hwnd, COLORREF(TRANSPARENCY_COLOUR), 0, LWA_COLORKEY); hwnd } @@ -748,14 +712,8 @@ impl WindowsApi { } pub fn invalidate_border_rect() -> Result<()> { - unsafe { - InvalidateRect( - HWND(BORDER_HWND.load(Ordering::SeqCst)), - std::ptr::null(), - false, - ) - } - .ok() - .process() + unsafe { InvalidateRect(HWND(BORDER_HWND.load(Ordering::SeqCst)), None, false) } + .ok() + .process() } } diff --git a/komorebi/src/windows_callbacks.rs b/komorebi/src/windows_callbacks.rs index 9e65dc6c..294ee11f 100644 --- a/komorebi/src/windows_callbacks.rs +++ b/komorebi/src/windows_callbacks.rs @@ -2,6 +2,7 @@ use std::collections::VecDeque; use std::sync::atomic::Ordering; use windows::Win32::Foundation::BOOL; +use windows::Win32::Foundation::COLORREF; use windows::Win32::Foundation::HWND; use windows::Win32::Foundation::LPARAM; use windows::Win32::Foundation::LRESULT; @@ -133,15 +134,19 @@ pub extern "system" fn border_window( WM_PAINT => { let border_rect = *BORDER_RECT.lock(); let mut ps = PAINTSTRUCT::default(); - let hdc = BeginPaint(window, std::ptr::addr_of_mut!(ps).cast()); - let hpen = CreatePen(PS_SOLID, 20, BORDER_COLOUR_CURRENT.load(Ordering::SeqCst)); + let hdc = BeginPaint(window, &mut ps); + let hpen = CreatePen( + PS_SOLID, + 20, + COLORREF(BORDER_COLOUR_CURRENT.load(Ordering::SeqCst)), + ); let hbrush = WindowsApi::create_solid_brush(TRANSPARENCY_COLOUR); SelectObject(hdc, hpen); SelectObject(hdc, hbrush); Rectangle(hdc, 0, 0, border_rect.right, border_rect.bottom); EndPaint(window, &ps); - ValidateRect(window, std::ptr::null()); + ValidateRect(window, None); LRESULT(0) } diff --git a/komorebic/Cargo.toml b/komorebic/Cargo.toml index f65e9d77..f89264db 100644 --- a/komorebic/Cargo.toml +++ b/komorebic/Cargo.toml @@ -29,7 +29,7 @@ sysinfo = "0.26" uds_windows = "1" [dependencies.windows] -version = "0.39" +version = "0.40" features = [ "Win32_Foundation", "Win32_UI_WindowsAndMessaging"