diff --git a/komorebi/src/border.rs b/komorebi/src/border.rs index c3ecb48e..9b687772 100644 --- a/komorebi/src/border.rs +++ b/komorebi/src/border.rs @@ -1,5 +1,4 @@ use std::sync::atomic::Ordering; -use std::time::Duration; use color_eyre::Result; use windows::core::PCWSTR; @@ -12,17 +11,12 @@ use windows::Win32::UI::WindowsAndMessaging::CS_VREDRAW; use windows::Win32::UI::WindowsAndMessaging::MSG; use windows::Win32::UI::WindowsAndMessaging::WNDCLASSW; -use komorebi_core::Rect; - -use crate::window::should_act; use crate::window::Window; use crate::windows_callbacks; use crate::WindowsApi; use crate::BORDER_HWND; use crate::BORDER_OFFSET; -use crate::BORDER_OVERFLOW_IDENTIFIERS; use crate::BORDER_RECT; -use crate::REGEX_IDENTIFIERS; use crate::TRANSPARENCY_COLOUR; use crate::WINDOWS_11; @@ -68,7 +62,6 @@ impl Border { unsafe { while GetMessageW(&mut message, border.hwnd(), 0, 0).into() { DispatchMessageW(&message); - std::thread::sleep(Duration::from_millis(10)); } } @@ -100,7 +93,6 @@ impl Border { pub fn set_position( self, window: Window, - invisible_borders: &Rect, activate: bool, ) -> Result<()> { if self.hwnd == 0 { @@ -111,30 +103,6 @@ impl Border { } let mut rect = WindowsApi::window_rect(window.hwnd())?; - rect.top -= invisible_borders.bottom; - rect.bottom += invisible_borders.bottom; - - let border_overflows = BORDER_OVERFLOW_IDENTIFIERS.lock(); - let regex_identifiers = REGEX_IDENTIFIERS.lock(); - - let title = &window.title()?; - let exe_name = &window.exe()?; - let class = &window.class()?; - - let should_expand_border = should_act( - title, - exe_name, - class, - &border_overflows, - ®ex_identifiers, - ); - - if should_expand_border { - rect.left -= invisible_borders.left; - rect.top -= invisible_borders.top; - rect.right += invisible_borders.right; - rect.bottom += invisible_borders.bottom; - } let border_offset = BORDER_OFFSET.lock(); if let Some(border_offset) = *border_offset { diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index e03eb46d..335efb46 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -195,7 +195,6 @@ impl Monitor { pub fn update_focused_workspace( &mut self, offset: Option, - invisible_borders: &Rect, ) -> Result<()> { let work_area = *self.work_area_size(); let offset = if self.work_area_offset().is_some() { @@ -206,7 +205,7 @@ impl Monitor { self.focused_workspace_mut() .ok_or_else(|| anyhow!("there is no workspace"))? - .update(&work_area, offset, invisible_borders)?; + .update(&work_area, offset)?; Ok(()) } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7435aac8..5d901296 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -305,7 +305,6 @@ impl WindowManager { }); } - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; let mut hwnds_to_purge = vec![]; @@ -348,7 +347,7 @@ impl WindowManager { .ok_or_else(|| anyhow!("there is no focused workspace"))? .remove_window(hwnd)?; - monitor.update_focused_workspace(offset, &invisible_borders)?; + monitor.update_focused_workspace(offset)?; } } SocketMessage::FocusedWorkspaceContainerPadding(adjustment) => { @@ -1094,10 +1093,7 @@ impl WindowManager { SocketMessage::UnmanageFocusedWindow => { self.unmanage_focused_window()?; } - SocketMessage::InvisibleBorders(rect) => { - self.invisible_borders = rect; - self.retile_all(false)?; - } + SocketMessage::InvisibleBorders(_rect) => {} SocketMessage::WorkAreaOffset(rect) => { self.work_area_offset = Option::from(rect); self.retile_all(false)?; @@ -1390,9 +1386,6 @@ impl WindowManager { | SocketMessage::FocusWorkspaceNumber(_) => { let foreground = WindowsApi::foreground_window()?; let foreground_window = Window { hwnd: foreground }; - let mut rect = WindowsApi::window_rect(foreground_window.hwnd())?; - rect.top -= self.invisible_borders.bottom; - rect.bottom += self.invisible_borders.bottom; let monocle = BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst); if monocle != 0 && self.focused_workspace()?.monocle_container().is_some() { @@ -1409,7 +1402,7 @@ impl WindowManager { } let border = Border::from(BORDER_HWND.load(Ordering::SeqCst)); - border.set_position(foreground_window, &self.invisible_borders, false)?; + border.set_position(foreground_window, false)?; } SocketMessage::TogglePause => { let is_paused = self.is_paused; @@ -1419,7 +1412,7 @@ impl WindowManager { border.hide()?; } else { let focused = self.focused_window()?; - border.set_position(*focused, &self.invisible_borders, true)?; + border.set_position(*focused, true)?; focused.focus(false)?; } } @@ -1429,7 +1422,7 @@ impl WindowManager { if tiling_enabled { let focused = self.focused_window()?; - border.set_position(*focused, &self.invisible_borders, true)?; + border.set_position(*focused, true)?; focused.focus(false)?; } else { border.hide()?; diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 8b8fd189..94a3b86b 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -109,7 +109,6 @@ impl WindowManager { _ => {} } - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; for (i, monitor) in self.monitors_mut().iter_mut().enumerate() { @@ -123,7 +122,7 @@ impl WindowManager { for (j, workspace) in monitor.workspaces_mut().iter_mut().enumerate() { let reaped_orphans = workspace.reap_orphans()?; if reaped_orphans.0 > 0 || reaped_orphans.1 > 0 { - workspace.update(&work_area, offset, &invisible_borders)?; + workspace.update(&work_area, offset)?; tracing::info!( "reaped {} orphan window(s) and {} orphaned container(s) on monitor: {}, workspace: {}", reaped_orphans.0, @@ -334,7 +333,6 @@ impl WindowManager { .ok_or_else(|| anyhow!("cannot get monitor idx from current position"))?; let new_window_behaviour = self.window_container_behaviour; - let invisible_borders = self.invisible_borders; let workspace = self.focused_workspace_mut()?; if !workspace @@ -344,7 +342,7 @@ impl WindowManager { { let focused_container_idx = workspace.focused_container_idx(); - let mut new_position = WindowsApi::window_rect(window.hwnd())?; + let new_position = WindowsApi::window_rect(window.hwnd())?; let old_position = *workspace .latest_layout() @@ -369,12 +367,6 @@ impl WindowManager { } } - // Adjust for the invisible borders - new_position.left += invisible_borders.left; - new_position.top += invisible_borders.top; - new_position.right -= invisible_borders.right; - new_position.bottom -= invisible_borders.bottom; - let resize = Rect { left: new_position.left - old_position.left, top: new_position.top - old_position.top, @@ -385,9 +377,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 - || resize.right.abs() == invisible_borders.right - && resize.bottom.abs() == invisible_borders.bottom; + || resize.right == 0 && resize.bottom == 0; if is_move { tracing::info!("moving with mouse"); @@ -595,15 +585,10 @@ impl WindowManager { } if let Some(target_window) = target_window { - let window = target_window; - let mut rect = WindowsApi::window_rect(window.hwnd())?; - rect.top -= self.invisible_borders.bottom; - rect.bottom += self.invisible_borders.bottom; - let activate = BORDER_HIDDEN.load(Ordering::SeqCst); WindowsApi::invalidate_border_rect()?; - border.set_position(target_window, &self.invisible_borders, activate)?; + border.set_position(target_window, activate)?; if activate { BORDER_HIDDEN.store(false, Ordering::SeqCst); @@ -616,7 +601,7 @@ impl WindowManager { // If we unmanaged a window, it shouldn't be immediately hidden behind managed windows if let WindowManagerEvent::Unmanage(window) = event { - window.center(&self.focused_monitor_work_area()?, &invisible_borders)?; + window.center(&self.focused_monitor_work_area()?)?; } // If there are no more windows on the workspace, we shouldn't show the border window diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 50b012ed..bb563e66 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -298,13 +298,6 @@ pub struct StaticConfig { impl From<&WindowManager> for StaticConfig { #[allow(clippy::too_many_lines)] fn from(value: &WindowManager) -> Self { - let default_invisible_borders = Rect { - left: 7, - top: 0, - right: 14, - bottom: 7, - }; - let mut monitors = vec![]; for m in value.monitors() { monitors.push(MonitorConfig::from(m)); @@ -374,11 +367,7 @@ impl From<&WindowManager> for StaticConfig { }; Self { - invisible_borders: if value.invisible_borders == default_invisible_borders { - None - } else { - Option::from(value.invisible_borders) - }, + invisible_borders: None, resize_delta: Option::from(value.resize_delta), window_container_behaviour: Option::from(value.window_container_behaviour), cross_monitor_move_behaviour: Option::from(value.cross_monitor_move_behaviour), @@ -745,12 +734,6 @@ impl StaticConfig { incoming_events: incoming, command_listener: listener, is_paused: false, - invisible_borders: value.invisible_borders.unwrap_or(Rect { - left: 7, - top: 0, - right: 14, - bottom: 7, - }), virtual_desktop_id: current_virtual_desktop(), work_area_offset: value.global_work_area_offset, window_container_behaviour: value @@ -897,10 +880,6 @@ impl StaticConfig { wm.hide_border()?; } - if let Some(val) = value.invisible_borders { - wm.invisible_borders = val; - } - if let Some(val) = value.window_container_behaviour { wm.window_container_behaviour = val; } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index cb00f79f..19cf8a42 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -32,7 +32,6 @@ use crate::styles::WindowStyle; use crate::window_manager_event::WindowManagerEvent; use crate::windows_api::WindowsApi; use crate::ALT_FOCUS_HACK; -use crate::BORDER_OVERFLOW_IDENTIFIERS; use crate::FLOAT_IDENTIFIERS; use crate::HIDDEN_HWNDS; use crate::HIDING_BEHAVIOUR; @@ -129,7 +128,7 @@ impl Window { HWND(self.hwnd) } - pub fn center(&mut self, work_area: &Rect, invisible_borders: &Rect) -> Result<()> { + pub fn center(&mut self, work_area: &Rect) -> Result<()> { let half_width = work_area.right / 2; let half_weight = work_area.bottom / 2; @@ -140,7 +139,6 @@ impl Window { right: half_width, bottom: half_weight, }, - invisible_borders, true, ) } @@ -148,34 +146,9 @@ impl Window { pub fn set_position( &mut self, layout: &Rect, - invisible_borders: &Rect, top: bool, ) -> Result<()> { - let mut rect = *layout; - - let border_overflows = BORDER_OVERFLOW_IDENTIFIERS.lock(); - let regex_identifiers = REGEX_IDENTIFIERS.lock(); - - let title = &self.title()?; - let class = &self.class()?; - let exe_name = &self.exe()?; - - let should_remove_border = !should_act( - title, - exe_name, - class, - &border_overflows, - ®ex_identifiers, - ); - - if should_remove_border { - // Remove the invisible borders - rect.left -= invisible_borders.left; - rect.top -= invisible_borders.top; - rect.right += invisible_borders.right; - rect.bottom += invisible_borders.bottom; - } - + let rect = *layout; WindowsApi::position_window(self.hwnd(), &rect, top) } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 05589fa2..95343bc1 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -69,7 +69,6 @@ pub struct WindowManager { pub incoming_events: Receiver, pub command_listener: UnixListener, pub is_paused: bool, - pub invisible_borders: Rect, pub work_area_offset: Option, pub resize_delta: i32, pub window_container_behaviour: WindowContainerBehaviour, @@ -89,7 +88,6 @@ pub struct WindowManager { pub struct State { pub monitors: Ring, pub is_paused: bool, - pub invisible_borders: Rect, pub resize_delta: i32, pub new_window_behaviour: WindowContainerBehaviour, pub cross_monitor_move_behaviour: MoveBehaviour, @@ -119,7 +117,6 @@ impl From<&WindowManager> for State { Self { monitors: wm.monitors.clone(), is_paused: wm.is_paused, - invisible_borders: wm.invisible_borders, work_area_offset: wm.work_area_offset, resize_delta: wm.resize_delta, new_window_behaviour: wm.window_container_behaviour, @@ -190,12 +187,6 @@ impl WindowManager { incoming_events: incoming, command_listener: listener, is_paused: false, - invisible_borders: Rect { - left: 7, - top: 0, - right: 14, - bottom: 7, - }, virtual_desktop_id: current_virtual_desktop(), work_area_offset: None, window_container_behaviour: WindowContainerBehaviour::Create, @@ -222,12 +213,9 @@ impl WindowManager { pub fn show_border(&self) -> Result<()> { let foreground = WindowsApi::foreground_window()?; let foreground_window = Window { hwnd: foreground }; - let mut rect = WindowsApi::window_rect(foreground_window.hwnd())?; - rect.top -= self.invisible_borders.bottom; - rect.bottom += self.invisible_borders.bottom; let border = Border::from(BORDER_HWND.load(Ordering::SeqCst)); - border.set_position(foreground_window, &self.invisible_borders, true)?; + border.set_position(foreground_window, true)?; WindowsApi::invalidate_border_rect() } @@ -403,7 +391,6 @@ impl WindowManager { } } - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; for monitor in self.monitors_mut() { @@ -434,7 +421,7 @@ impl WindowManager { } if should_update { - monitor.update_focused_workspace(offset, &invisible_borders)?; + monitor.update_focused_workspace(offset)?; } } @@ -636,7 +623,6 @@ impl WindowManager { #[tracing::instrument(skip(self))] pub fn retile_all(&mut self, preserve_resize_dimensions: bool) -> Result<()> { - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; for monitor in self.monitors_mut() { @@ -658,7 +644,7 @@ impl WindowManager { } } - workspace.update(&work_area, offset, &invisible_borders)?; + workspace.update(&work_area, offset)?; } Ok(()) @@ -830,12 +816,11 @@ impl WindowManager { pub fn update_focused_workspace(&mut self, follow_focus: bool) -> Result<()> { tracing::info!("updating"); - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; self.focused_monitor_mut() .ok_or_else(|| anyhow!("there is no monitor"))? - .update_focused_workspace(offset, &invisible_borders)?; + .update_focused_workspace(offset)?; if follow_focus { if let Some(window) = self.focused_workspace()?.maximized_window() { @@ -1023,13 +1008,12 @@ impl WindowManager { } pub fn update_focused_workspace_by_monitor_idx(&mut self, idx: usize) -> Result<()> { - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; self.monitors_mut() .get_mut(idx) .ok_or_else(|| anyhow!("there is no monitor"))? - .update_focused_workspace(offset, &invisible_borders) + .update_focused_workspace(offset) } #[tracing::instrument(skip(self))] @@ -1119,7 +1103,6 @@ impl WindowManager { tracing::info!("moving container"); - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; let mouse_follows_focus = self.mouse_follows_focus; @@ -1138,7 +1121,7 @@ impl WindowManager { .remove_focused_container() .ok_or_else(|| anyhow!("there is no container"))?; - monitor.update_focused_workspace(offset, &invisible_borders)?; + monitor.update_focused_workspace(offset)?; let target_monitor = self .monitors_mut() @@ -1147,7 +1130,7 @@ impl WindowManager { target_monitor.add_container(container, workspace_idx)?; target_monitor.load_focused_workspace(mouse_follows_focus)?; - target_monitor.update_focused_workspace(offset, &invisible_borders)?; + target_monitor.update_focused_workspace(offset)?; if follow { self.focus_monitor(monitor_idx)?; @@ -1329,12 +1312,11 @@ impl WindowManager { // make sure to update the origin monitor workspace layout because it is no // longer focused so it won't get updated at the end of this fn let offset = self.work_area_offset; - let invisible_borders = self.invisible_borders; self.monitors_mut() .get_mut(origin_monitor_idx) .ok_or_else(|| anyhow!("there is no monitor at this index"))? - .update_focused_workspace(offset, &invisible_borders)?; + .update_focused_workspace(offset)?; let a = self .focused_monitor() @@ -1570,7 +1552,6 @@ impl WindowManager { tracing::info!("floating window"); let work_area = self.focused_monitor_work_area()?; - let invisible_borders = self.invisible_borders; let workspace = self.focused_workspace_mut()?; workspace.new_floating_window()?; @@ -1580,7 +1561,7 @@ impl WindowManager { .last_mut() .ok_or_else(|| anyhow!("there is no floating window"))?; - window.center(&work_area, &invisible_borders)?; + window.center(&work_area)?; window.focus(self.mouse_follows_focus)?; Ok(()) @@ -1837,7 +1818,6 @@ impl WindowManager { ) -> Result<()> { tracing::info!("setting workspace layout"); - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; let focused_monitor_idx = self.focused_monitor_idx(); @@ -1866,7 +1846,7 @@ impl WindowManager { // If this is the focused workspace on a non-focused screen, let's update it if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { - workspace.update(&work_area, offset, &invisible_borders)?; + workspace.update(&work_area, offset)?; Ok(()) } else { Ok(self.update_focused_workspace(false)?) @@ -1886,7 +1866,6 @@ impl WindowManager { { tracing::info!("setting workspace layout"); - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; let focused_monitor_idx = self.focused_monitor_idx(); @@ -1917,7 +1896,7 @@ impl WindowManager { // If this is the focused workspace on a non-focused screen, let's update it if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { - workspace.update(&work_area, offset, &invisible_borders)?; + workspace.update(&work_area, offset)?; Ok(()) } else { Ok(self.update_focused_workspace(false)?) @@ -1932,7 +1911,6 @@ impl WindowManager { ) -> Result<()> { tracing::info!("setting workspace layout"); - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; let focused_monitor_idx = self.focused_monitor_idx(); @@ -1959,7 +1937,7 @@ impl WindowManager { // If this is the focused workspace on a non-focused screen, let's update it if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { - workspace.update(&work_area, offset, &invisible_borders)?; + workspace.update(&work_area, offset)?; Ok(()) } else { Ok(self.update_focused_workspace(false)?) @@ -1975,7 +1953,6 @@ impl WindowManager { ) -> Result<()> { tracing::info!("setting workspace layout"); - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; let focused_monitor_idx = self.focused_monitor_idx(); @@ -2001,7 +1978,7 @@ impl WindowManager { // If this is the focused workspace on a non-focused screen, let's update it if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { - workspace.update(&work_area, offset, &invisible_borders)?; + workspace.update(&work_area, offset)?; Ok(()) } else { Ok(self.update_focused_workspace(false)?) @@ -2020,7 +1997,6 @@ impl WindowManager { { tracing::info!("setting workspace layout"); let layout = CustomLayout::from_path(path)?; - let invisible_borders = self.invisible_borders; let offset = self.work_area_offset; let focused_monitor_idx = self.focused_monitor_idx(); @@ -2047,7 +2023,7 @@ impl WindowManager { // If this is the focused workspace on a non-focused screen, let's update it if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx { - workspace.update(&work_area, offset, &invisible_borders)?; + workspace.update(&work_area, offset)?; Ok(()) } else { Ok(self.update_focused_workspace(false)?) diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index a08c22a7..6449042b 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -205,7 +205,6 @@ impl Workspace { &mut self, work_area: &Rect, offset: Option, - invisible_borders: &Rect, ) -> Result<()> { if !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) { return Ok(()); @@ -253,7 +252,7 @@ impl Workspace { if let Some(container) = self.monocle_container_mut() { if let Some(window) = container.focused_window_mut() { adjusted_work_area.add_padding(container_padding); - window.set_position(&adjusted_work_area, invisible_borders, true)?; + window.set_position(&adjusted_work_area, true)?; }; } else if let Some(window) = self.maximized_window_mut() { window.maximize(); @@ -288,7 +287,7 @@ impl Workspace { WindowsApi::restore_window(window.hwnd()); } - window.set_position(layout, invisible_borders, false)?; + window.set_position(layout, false)?; } }