diff --git a/Cargo.toml b/Cargo.toml index b60634f6..3e666a86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] +resolver = "2" members = [ "derive-ahk", "komorebi", diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index e00cca34..b05b90f8 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -318,7 +318,7 @@ pub fn current_virtual_desktop() -> Option> { // This is the path on Windows 11 if current.is_none() { current = hkcu - .open_subkey(r#"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops"#) + .open_subkey(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops") .ok() .and_then( |desktops| match desktops.get_raw_value("CurrentVirtualDesktop") { @@ -357,7 +357,7 @@ pub struct Notification { pub fn notify_subscribers(notification: &str) -> Result<()> { let mut stale_subscriptions = vec![]; let mut subscriptions = SUBSCRIPTION_PIPES.lock(); - for (subscriber, pipe) in subscriptions.iter_mut() { + for (subscriber, pipe) in &mut *subscriptions { match writeln!(pipe, "{notification}") { Ok(_) => { tracing::debug!("pushed notification to subscriber: {}", subscriber); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 52083d2b..f4944e22 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -259,9 +259,8 @@ impl WindowManager { .focused_workspace() .ok_or_else(|| anyhow!("there is no workspace"))? .containers() - .iter() { - for window in container.windows().iter() { + for window in container.windows() { match identifier { ApplicationIdentifier::Exe => { if window.exe()? == *id { diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index db0bb644..34fb5d69 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -250,12 +250,18 @@ pub struct StaticConfig { /// Path to applications.yaml from komorebi-application-specific-configurations (default: None) #[serde(skip_serializing_if = "Option::is_none")] pub app_specific_configuration_path: Option, - /// Width of the active window border (default: 20) + /// DEPRECATED from v0.1.19: use active_window_border_width instead #[serde(skip_serializing_if = "Option::is_none")] pub border_width: Option, - /// Offset of the active window border (default: None) + /// DEPRECATED from v0.1.19: use active_window_border_offset instead #[serde(skip_serializing_if = "Option::is_none")] pub border_offset: Option, + /// Width of the active window border (default: 20) + #[serde(skip_serializing_if = "Option::is_none")] + pub active_window_border_width: Option, + /// Offset of the active window border (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub active_window_border_offset: Option, /// Display an active window border (default: false) #[serde(skip_serializing_if = "Option::is_none")] pub active_window_border: Option, @@ -396,8 +402,12 @@ impl From<&WindowManager> for StaticConfig { focus_follows_mouse: value.focus_follows_mouse, mouse_follows_focus: Option::from(value.mouse_follows_focus), app_specific_configuration_path: None, - border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)), - border_offset: *BORDER_OFFSET.lock(), + active_window_border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)), + active_window_border_offset: BORDER_OFFSET + .lock() + .map_or(None, |offset| Option::from(offset.left)), + border_width: None, + border_offset: None, active_window_border: Option::from(BORDER_ENABLED.load(Ordering::SeqCst)), active_window_border_colours: border_colours, default_workspace_padding: Option::from( @@ -446,14 +456,31 @@ impl StaticConfig { DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst); } - if let Some(width) = self.border_width { - BORDER_WIDTH.store(width, Ordering::SeqCst); - } + self.active_window_border_width.map_or_else( + || { + BORDER_WIDTH.store(20, Ordering::SeqCst); + }, + |width| { + BORDER_WIDTH.store(width, Ordering::SeqCst); + }, + ); + self.active_window_border_offset.map_or_else( + || { + let mut border_offset = BORDER_OFFSET.lock(); + *border_offset = None; + }, + |offset| { + let new_border_offset = Rect { + left: offset, + top: offset, + right: offset * 2, + bottom: offset * 2, + }; - if let Some(offset) = self.border_offset { - let mut border_offset = BORDER_OFFSET.lock(); - *border_offset = Some(offset); - } + let mut border_offset = BORDER_OFFSET.lock(); + *border_offset = Some(new_border_offset); + }, + ); if let Some(colours) = &self.active_window_border_colours { BORDER_COLOUR_SINGLE.store( diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index 67e1aa55..e2b129c0 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -234,8 +234,7 @@ impl WindowsApi { } pub fn enum_windows(callback: WNDENUMPROC, callback_data_address: isize) -> Result<()> { - unsafe { EnumWindows(callback, LPARAM(callback_data_address)) } - .process() + unsafe { EnumWindows(callback, LPARAM(callback_data_address)) }.process() } pub fn load_workspace_information(monitors: &mut Ring) -> Result<()> { @@ -274,8 +273,7 @@ impl WindowsApi { } pub fn allow_set_foreground_window(process_id: u32) -> Result<()> { - unsafe { AllowSetForegroundWindow(process_id) } - .process() + unsafe { AllowSetForegroundWindow(process_id) }.process() } pub fn monitor_from_window(hwnd: HWND) -> isize { @@ -365,8 +363,7 @@ impl WindowsApi { } fn post_message(hwnd: HWND, message: u32, wparam: WPARAM, lparam: LPARAM) -> Result<()> { - unsafe { PostMessageW(hwnd, message, wparam, lparam) } - .process() + unsafe { PostMessageW(hwnd, message, wparam, lparam) }.process() } pub fn close_window(hwnd: HWND) -> Result<()> { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 4b51f925..d1316545 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1452,7 +1452,7 @@ fn main() -> Result<()> { "'--config=\"{}\"'", path.as_os_str() .to_string_lossy() - .trim_start_matches(r#"\\?\"#), + .trim_start_matches(r"\\?\"), )); }