Skip to content

Commit

Permalink
chore(deps): bump windows-rs from 0.34 to 0.35
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed Apr 14, 2022
1 parent 4b6a7c0 commit 02a3220
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 54 deletions.
101 changes: 65 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion komorebi-core/Cargo.toml
Expand Up @@ -15,7 +15,7 @@ strum = { version = "0.24", features = ["derive"] }
schemars = "0.8"

[dependencies.windows]
version = "0.34"
version = "0.35"
features = [
"Win32_Foundation",
]
2 changes: 1 addition & 1 deletion komorebi/Cargo.toml
Expand Up @@ -41,7 +41,7 @@ winreg = "0.10"
schemars = "0.8"

[dependencies.windows]
version = "0.34"
version = "0.35"
features = [
"Win32_Foundation",
"Win32_Graphics_Dwm",
Expand Down
29 changes: 14 additions & 15 deletions komorebi/src/windows_api.rs
Expand Up @@ -124,15 +124,16 @@ pub trait ProcessWindowsCrateResult<T> {
fn process(self) -> Result<T>;
}

macro_rules! impl_process_windows_crate_result {
macro_rules! impl_process_windows_crate_integer_wrapper_result {
( $($input:ty => $deref:ty),+ $(,)? ) => (
paste::paste! {
$(
impl ProcessWindowsCrateResult<$deref> for WindowsCrateResult<$input> {
impl ProcessWindowsCrateResult<$deref> for $input {
fn process(self) -> Result<$deref> {
match self {
Ok(value) => Ok(value.0),
Err(error) => Err(error.into()),
if self.0 == 0 {
Ok(self.0)
} else {
Err(std::io::Error::last_os_error().into())
}
}
}
Expand All @@ -141,7 +142,7 @@ macro_rules! impl_process_windows_crate_result {
);
}

impl_process_windows_crate_result!(
impl_process_windows_crate_integer_wrapper_result!(
HWND => isize,
);

Expand Down Expand Up @@ -296,7 +297,7 @@ impl WindowsApi {
}

pub fn foreground_window() -> Result<isize> {
unsafe { GetForegroundWindow() }.ok().process()
unsafe { GetForegroundWindow() }.process()
}

pub fn set_foreground_window(hwnd: HWND) -> Result<()> {
Expand All @@ -305,16 +306,16 @@ impl WindowsApi {

#[allow(dead_code)]
pub fn top_window() -> Result<isize> {
unsafe { GetTopWindow(HWND::default()) }.ok().process()
unsafe { GetTopWindow(HWND::default()) }.process()
}

pub fn desktop_window() -> Result<isize> {
unsafe { GetDesktopWindow() }.ok().process()
unsafe { GetDesktopWindow() }.process()
}

#[allow(dead_code)]
pub fn next_window(hwnd: HWND) -> Result<isize> {
unsafe { GetWindow(hwnd, GW_HWNDNEXT) }.ok().process()
unsafe { GetWindow(hwnd, GW_HWNDNEXT) }.process()
}

#[allow(dead_code)]
Expand Down Expand Up @@ -352,7 +353,7 @@ impl WindowsApi {
}

pub fn window_from_point(point: POINT) -> Result<isize> {
unsafe { WindowFromPoint(point) }.ok().process()
unsafe { WindowFromPoint(point) }.process()
}

pub fn window_at_cursor_pos() -> Result<isize> {
Expand Down Expand Up @@ -401,7 +402,7 @@ impl WindowsApi {
}

pub fn set_focus(hwnd: HWND) -> Result<()> {
unsafe { SetFocus(hwnd) }.ok().map(|_| ()).process()
unsafe { SetFocus(hwnd) }.process().map(|_| ())
}

#[allow(dead_code)]
Expand Down Expand Up @@ -451,9 +452,7 @@ impl WindowsApi {
inherit_handle: bool,
process_id: u32,
) -> Result<HANDLE> {
unsafe { OpenProcess(access_rights, inherit_handle, process_id) }
.ok()
.process()
unsafe { OpenProcess(access_rights, inherit_handle, process_id) }.process()
}

pub fn process_handle(process_id: u32) -> Result<HANDLE> {
Expand Down
2 changes: 1 addition & 1 deletion komorebic/Cargo.toml
Expand Up @@ -27,7 +27,7 @@ serde_json = "1"
uds_windows = "1"

[dependencies.windows]
version = "0.34"
version = "0.35"
features = [
"Win32_Foundation",
"Win32_UI_WindowsAndMessaging"
Expand Down

0 comments on commit 02a3220

Please sign in to comment.