diff --git a/Cargo.lock b/Cargo.lock index e9f01a86..5c04ed55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2224,35 +2224,45 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.48.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ + "windows-core", "windows-implement", "windows-interface", "windows-targets", ] +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-implement" -version = "0.48.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" +checksum = "fb2b158efec5af20d8846836622f50a87e6556b9153a42772fa047f773c0e555" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] name = "windows-interface" -version = "0.48.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" +checksum = "0546e63e1ce64c04403d2311fa0e3ab5ae3a367bd524b4a38d8d8d18c70cfa76" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] @@ -2281,17 +2291,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -2302,9 +2312,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -2314,9 +2324,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -2326,9 +2336,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -2338,9 +2348,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -2350,9 +2360,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -2362,9 +2372,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -2374,9 +2384,9 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winput" diff --git a/Cargo.toml b/Cargo.toml index c22839b4..b60634f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,11 +8,11 @@ members = [ ] [workspace.dependencies] -windows-interface = { version = "0.48" } -windows-implement = { version = "0.48" } +windows-interface = { version = "0.51" } +windows-implement = { version = "0.51" } [workspace.dependencies.windows] -version = "0.48" +version = "0.51" features = [ "implement", "Win32_System_Com", diff --git a/komorebi/src/border.rs b/komorebi/src/border.rs index d1b60229..f39bd5c6 100644 --- a/komorebi/src/border.rs +++ b/komorebi/src/border.rs @@ -46,7 +46,7 @@ impl Border { let class_name = PCSTR(name.as_ptr()); let brush = WindowsApi::create_solid_brush(TRANSPARENCY_COLOUR); let window_class = WNDCLASSA { - hInstance: instance, + hInstance: instance.into(), lpszClassName: class_name, style: CS_HREDRAW | CS_VREDRAW, lpfnWndProc: Some(windows_callbacks::border_window), diff --git a/komorebi/src/hidden.rs b/komorebi/src/hidden.rs index 591f2b81..3fe2ad37 100644 --- a/komorebi/src/hidden.rs +++ b/komorebi/src/hidden.rs @@ -39,7 +39,7 @@ impl Hidden { let class_name = PCSTR(name.as_ptr()); let brush = WindowsApi::create_solid_brush(TRANSPARENCY_COLOUR); let window_class = WNDCLASSA { - hInstance: instance, + hInstance: instance.into(), lpszClassName: class_name, style: CS_HREDRAW | CS_VREDRAW, lpfnWndProc: Some(windows_callbacks::hidden_window), diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 57a5ba9a..9539599a 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -348,8 +348,7 @@ impl Window { let mut ex_style = self.ex_style()?; ex_style.insert(ExtendedWindowStyle::LAYERED); self.update_ex_style(&ex_style)?; - WindowsApi::set_transparent(self.hwnd()); - Ok(()) + WindowsApi::set_transparent(self.hwnd()) } pub fn opaque(self) -> Result<()> { diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index efe585c3..67e1aa55 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -235,7 +235,6 @@ impl WindowsApi { pub fn enum_windows(callback: WNDENUMPROC, callback_data_address: isize) -> Result<()> { unsafe { EnumWindows(callback, LPARAM(callback_data_address)) } - .ok() .process() } @@ -276,7 +275,6 @@ impl WindowsApi { pub fn allow_set_foreground_window(process_id: u32) -> Result<()> { unsafe { AllowSetForegroundWindow(process_id) } - .ok() .process() } @@ -313,7 +311,7 @@ impl WindowsApi { } pub fn bring_window_to_top(hwnd: HWND) -> Result<()> { - unsafe { BringWindowToTop(hwnd) }.ok().process() + unsafe { BringWindowToTop(hwnd) }.process() } pub fn raise_window(hwnd: HWND) -> Result<()> { @@ -353,7 +351,6 @@ impl WindowsApi { SET_WINDOW_POS_FLAGS(flags), ) } - .ok() .process() } @@ -369,7 +366,6 @@ impl WindowsApi { fn post_message(hwnd: HWND, message: u32, wparam: WPARAM, lparam: LPARAM) -> Result<()> { unsafe { PostMessageW(hwnd, message, wparam, lparam) } - .ok() .process() } @@ -436,18 +432,18 @@ impl WindowsApi { pub fn window_rect(hwnd: HWND) -> Result { let mut rect = unsafe { std::mem::zeroed() }; - unsafe { GetWindowRect(hwnd, &mut rect) }.ok().process()?; + unsafe { GetWindowRect(hwnd, &mut rect) }.process()?; Ok(Rect::from(rect)) } fn set_cursor_pos(x: i32, y: i32) -> Result<()> { - unsafe { SetCursorPos(x, y) }.ok().process() + unsafe { SetCursorPos(x, y) }.process() } pub fn cursor_pos() -> Result { let mut cursor_pos = POINT::default(); - unsafe { GetCursorPos(&mut cursor_pos) }.ok().process()?; + unsafe { GetCursorPos(&mut cursor_pos) }.process()?; Ok(cursor_pos) } @@ -489,7 +485,7 @@ impl WindowsApi { let mut session_id = 0; unsafe { - if ProcessIdToSessionId(process_id, &mut session_id).as_bool() { + if ProcessIdToSessionId(process_id, &mut session_id).is_ok() { Ok(session_id) } else { Err(anyhow!("could not determine current session id")) @@ -565,7 +561,7 @@ impl WindowsApi { } pub fn close_process(handle: HANDLE) -> Result<()> { - unsafe { CloseHandle(handle) }.ok().process() + unsafe { CloseHandle(handle) }.process() } pub fn process_handle(process_id: u32) -> Result { @@ -580,7 +576,6 @@ impl WindowsApi { unsafe { QueryFullProcessImageNameW(handle, PROCESS_NAME_WIN32, PWSTR(text_ptr), &mut len) } - .ok() .process()?; Ok(String::from_utf16(&path[..len as usize])?) @@ -673,7 +668,6 @@ impl WindowsApi { pub fn set_process_dpi_awareness_context() -> Result<()> { unsafe { SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) } - .ok() .process() } @@ -685,7 +679,6 @@ impl WindowsApi { update_flags: SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS, ) -> Result<()> { unsafe { SystemParametersInfoW(action, ui_param, Option::from(pv_param), update_flags) } - .ok() .process() } @@ -777,19 +770,21 @@ impl WindowsApi { None, ); - SetLayeredWindowAttributes(hwnd, COLORREF(TRANSPARENCY_COLOUR), 0, LWA_COLORKEY); + SetLayeredWindowAttributes(hwnd, COLORREF(TRANSPARENCY_COLOUR), 0, LWA_COLORKEY)?; hwnd } .process() } - pub fn set_transparent(hwnd: HWND) { + pub fn set_transparent(hwnd: HWND) -> Result<()> { unsafe { #[allow(clippy::cast_sign_loss)] // TODO: alpha should be configurable - SetLayeredWindowAttributes(hwnd, COLORREF(-1i32 as u32), 150, LWA_ALPHA); + SetLayeredWindowAttributes(hwnd, COLORREF(-1i32 as u32), 150, LWA_ALPHA)?; } + + Ok(()) } pub fn create_hidden_window(name: PCSTR, instance: HMODULE) -> Result {