diff --git a/komorebi/src/border.rs b/komorebi/src/border.rs index 763ba50f..49c8f3da 100644 --- a/komorebi/src/border.rs +++ b/komorebi/src/border.rs @@ -86,11 +86,7 @@ impl Border { } } - pub fn set_position( - self, - window: Window, - activate: bool, - ) -> Result<()> { + pub fn set_position(self, window: Window, activate: bool) -> Result<()> { if self.hwnd == 0 { Ok(()) } else { diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 039fb135..1fb868a8 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -205,7 +205,6 @@ pub static DEFAULT_CONTAINER_PADDING: AtomicI32 = AtomicI32::new(10); pub static INITIAL_CONFIGURATION_LOADED: AtomicBool = AtomicBool::new(false); pub static CUSTOM_FFM: AtomicBool = AtomicBool::new(false); pub static SESSION_ID: AtomicU32 = AtomicU32::new(0); -pub static ALT_FOCUS_HACK: AtomicBool = AtomicBool::new(false); pub static BORDER_ENABLED: AtomicBool = AtomicBool::new(false); pub static BORDER_HWND: AtomicIsize = AtomicIsize::new(0); pub static BORDER_HIDDEN: AtomicBool = AtomicBool::new(false); diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 335efb46..2bb5a955 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -192,10 +192,7 @@ impl Monitor { self.workspaces().len() } - pub fn update_focused_workspace( - &mut self, - offset: Option, - ) -> Result<()> { + pub fn update_focused_workspace(&mut self, offset: Option) -> Result<()> { let work_area = *self.work_area_size(); let offset = if self.work_area_offset().is_some() { self.work_area_offset() diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 03a0d5c0..172f1e41 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -48,7 +48,6 @@ use crate::window_manager::WindowManager; use crate::windows_api::WindowsApi; use crate::Notification; use crate::NotificationEvent; -use crate::ALT_FOCUS_HACK; use crate::BORDER_COLOUR_CURRENT; use crate::BORDER_COLOUR_MONOCLE; use crate::BORDER_COLOUR_SINGLE; @@ -1252,8 +1251,8 @@ impl WindowManager { BORDER_OFFSET.store(offset, Ordering::SeqCst); WindowsApi::invalidate_border_rect()?; } - SocketMessage::AltFocusHack(enable) => { - ALT_FOCUS_HACK.store(enable, Ordering::SeqCst); + SocketMessage::AltFocusHack(_) => { + tracing::info!("this action is deprecated"); } SocketMessage::ApplicationSpecificConfigurationSchema => { let asc = schema_for!(Vec); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 94a3b86b..776e057a 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -376,8 +376,7 @@ impl WindowManager { // If we have moved across the monitors, use that override, otherwise determine // if a move has taken place by ruling out a resize - let is_move = moved_across_monitors - || resize.right == 0 && resize.bottom == 0; + let is_move = moved_across_monitors || resize.right == 0 && resize.bottom == 0; if is_move { tracing::info!("moving with mouse"); diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 3c93366a..5f1ebf98 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -214,7 +214,7 @@ impl From<&Monitor> for MonitorConfig { #[derive(Debug, Serialize, Deserialize, JsonSchema)] /// The `komorebi.json` static configuration file reference for `v0.1.20` pub struct StaticConfig { - /// Dimensions of Windows' own invisible borders; don't set these yourself unless you are told to + /// DEPRECATED from v0.1.22: no longer required #[serde(skip_serializing_if = "Option::is_none")] pub invisible_borders: Option, /// Delta to resize windows by (default 50) @@ -238,12 +238,14 @@ 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) + /// Width of the window border (default: 8) #[serde(skip_serializing_if = "Option::is_none")] - pub active_window_border_width: Option, - /// Offset of the active window border (default: None) + #[serde(alias = "active_window_border_width")] + pub border_width: Option, + /// Offset of the window border (default: -1) #[serde(skip_serializing_if = "Option::is_none")] - pub active_window_border_offset: Option, + #[serde(alias = "active_window_border_offset")] + pub border_offset: Option, /// Display an active window border (default: false) #[serde(skip_serializing_if = "Option::is_none")] pub active_window_border: Option, @@ -259,10 +261,6 @@ pub struct StaticConfig { /// Monitor and workspace configurations #[serde(skip_serializing_if = "Option::is_none")] pub monitors: Option>, - /// DEPRECATED from v0.1.20: no longer required - #[schemars(skip)] - #[serde(skip_serializing)] - pub alt_focus_hack: Option, /// Which Windows signal to use when hiding windows (default: minimize) #[serde(skip_serializing_if = "Option::is_none")] pub window_hiding_behaviour: Option, @@ -377,8 +375,8 @@ 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, - active_window_border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)), - active_window_border_offset: Option::from(BORDER_OFFSET.load(Ordering::SeqCst)), + border_width: Option::from(BORDER_WIDTH.load(Ordering::SeqCst)), + border_offset: Option::from(BORDER_OFFSET.load(Ordering::SeqCst)), active_window_border: Option::from(BORDER_ENABLED.load(Ordering::SeqCst)), active_window_border_colours: border_colours, default_workspace_padding: Option::from( @@ -388,7 +386,6 @@ impl From<&WindowManager> for StaticConfig { DEFAULT_CONTAINER_PADDING.load(Ordering::SeqCst), ), monitors: Option::from(monitors), - alt_focus_hack: None, window_hiding_behaviour: Option::from(*HIDING_BEHAVIOUR.lock()), global_work_area_offset: value.work_area_offset, float_rules: None, @@ -429,7 +426,7 @@ impl StaticConfig { DEFAULT_WORKSPACE_PADDING.store(workspace, Ordering::SeqCst); } - self.active_window_border_width.map_or_else( + self.border_width.map_or_else( || { BORDER_WIDTH.store(8, Ordering::SeqCst); }, @@ -438,7 +435,7 @@ impl StaticConfig { }, ); - BORDER_OFFSET.store(self.active_window_border_offset.unwrap_or(-1), Ordering::SeqCst); + BORDER_OFFSET.store(self.border_offset.unwrap_or(-1), Ordering::SeqCst); if let Some(colours) = &self.active_window_border_colours { BORDER_COLOUR_SINGLE.store(u32::from(colours.single), Ordering::SeqCst); @@ -895,6 +892,12 @@ impl StaticConfig { wm.focus_follows_mouse = value.focus_follows_mouse; + let monitor_count = wm.monitors().len(); + + for i in 0..monitor_count { + wm.update_focused_workspace_by_monitor_idx(i)?; + } + Ok(()) } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 19cf8a42..e0b61036 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -4,7 +4,6 @@ use std::convert::TryFrom; use std::fmt::Display; use std::fmt::Formatter; use std::fmt::Write as _; -use std::sync::atomic::Ordering; use color_eyre::eyre; use color_eyre::eyre::anyhow; @@ -19,9 +18,6 @@ use serde::Deserialize; use serde::Serialize; use serde::Serializer; use windows::Win32::Foundation::HWND; -use winput::press; -use winput::release; -use winput::Vk; use komorebi_core::ApplicationIdentifier; use komorebi_core::HidingBehaviour; @@ -31,7 +27,6 @@ use crate::styles::ExtendedWindowStyle; use crate::styles::WindowStyle; use crate::window_manager_event::WindowManagerEvent; use crate::windows_api::WindowsApi; -use crate::ALT_FOCUS_HACK; use crate::FLOAT_IDENTIFIERS; use crate::HIDDEN_HWNDS; use crate::HIDING_BEHAVIOUR; @@ -143,11 +138,7 @@ impl Window { ) } - pub fn set_position( - &mut self, - layout: &Rect, - top: bool, - ) -> Result<()> { + pub fn set_position(&mut self, layout: &Rect, top: bool) -> Result<()> { let rect = *layout; WindowsApi::position_window(self.hwnd(), &rect, top) } @@ -298,12 +289,7 @@ impl Window { let mut tried_resetting_foreground_access = false; let mut max_attempts = 10; - let hotkey_uses_alt = WindowsApi::alt_is_pressed(); while !foregrounded && max_attempts > 0 { - if ALT_FOCUS_HACK.load(Ordering::SeqCst) { - press(Vk::Alt); - } - match WindowsApi::set_foreground_window(self.hwnd()) { Ok(()) => { foregrounded = true; @@ -324,10 +310,6 @@ impl Window { } } }; - - if ALT_FOCUS_HACK.load(Ordering::SeqCst) && !hotkey_uses_alt { - release(Vk::Alt); - } } // Center cursor in Window diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index 42e7d401..7861d39a 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -352,7 +352,7 @@ impl WindowsApi { | SetWindowPosition::FRAME_CHANGED; let shadow_rect = Self::shadow_rect(hwnd)?; - let rect = Rect{ + let rect = Rect { left: layout.left + shadow_rect.left, top: layout.top + shadow_rect.top, right: layout.right + shadow_rect.right, diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index ab7ed74d..8c06223f 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -203,11 +203,7 @@ impl Workspace { Ok(()) } - pub fn update( - &mut self, - work_area: &Rect, - offset: Option, - ) -> Result<()> { + pub fn update(&mut self, work_area: &Rect, offset: Option) -> Result<()> { if !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) { return Ok(()); } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 9ab0737f..7390e3be 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1077,8 +1077,9 @@ enum SubCommand { WatchConfiguration(WatchConfiguration), /// Signal that the final configuration option has been sent CompleteConfiguration, - /// Enable or disable a hack simulating ALT key presses to ensure focus changes succeed + /// DEPRECATED since v0.1.22 #[clap(arg_required_else_help = true)] + #[clap(hide = true)] AltFocusHack(AltFocusHack), /// Set the window behaviour when switching workspaces / cycling stacks #[clap(arg_required_else_help = true)]