mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-04 04:01:46 +02:00
fix(cfg,komorebi): remove all uses of invisible borders
This makes the borders pixel-perfect, and border_overflow can be disabled on all applications. Unfortunately this also means we lose the corner rounding, so that may need to be done differently or the offsets refined in some way to address that.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use windows::core::PCWSTR;
|
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::MSG;
|
||||||
use windows::Win32::UI::WindowsAndMessaging::WNDCLASSW;
|
use windows::Win32::UI::WindowsAndMessaging::WNDCLASSW;
|
||||||
|
|
||||||
use komorebi_core::Rect;
|
|
||||||
|
|
||||||
use crate::window::should_act;
|
|
||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
use crate::windows_callbacks;
|
use crate::windows_callbacks;
|
||||||
use crate::WindowsApi;
|
use crate::WindowsApi;
|
||||||
use crate::BORDER_HWND;
|
use crate::BORDER_HWND;
|
||||||
use crate::BORDER_OFFSET;
|
use crate::BORDER_OFFSET;
|
||||||
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
|
||||||
use crate::BORDER_RECT;
|
use crate::BORDER_RECT;
|
||||||
use crate::REGEX_IDENTIFIERS;
|
|
||||||
use crate::TRANSPARENCY_COLOUR;
|
use crate::TRANSPARENCY_COLOUR;
|
||||||
use crate::WINDOWS_11;
|
use crate::WINDOWS_11;
|
||||||
|
|
||||||
@@ -68,7 +62,6 @@ impl Border {
|
|||||||
unsafe {
|
unsafe {
|
||||||
while GetMessageW(&mut message, border.hwnd(), 0, 0).into() {
|
while GetMessageW(&mut message, border.hwnd(), 0, 0).into() {
|
||||||
DispatchMessageW(&message);
|
DispatchMessageW(&message);
|
||||||
std::thread::sleep(Duration::from_millis(10));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +93,6 @@ impl Border {
|
|||||||
pub fn set_position(
|
pub fn set_position(
|
||||||
self,
|
self,
|
||||||
window: Window,
|
window: Window,
|
||||||
invisible_borders: &Rect,
|
|
||||||
activate: bool,
|
activate: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if self.hwnd == 0 {
|
if self.hwnd == 0 {
|
||||||
@@ -111,30 +103,6 @@ impl Border {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut rect = WindowsApi::window_rect(window.hwnd())?;
|
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();
|
let border_offset = BORDER_OFFSET.lock();
|
||||||
if let Some(border_offset) = *border_offset {
|
if let Some(border_offset) = *border_offset {
|
||||||
|
|||||||
@@ -195,7 +195,6 @@ impl Monitor {
|
|||||||
pub fn update_focused_workspace(
|
pub fn update_focused_workspace(
|
||||||
&mut self,
|
&mut self,
|
||||||
offset: Option<Rect>,
|
offset: Option<Rect>,
|
||||||
invisible_borders: &Rect,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let work_area = *self.work_area_size();
|
let work_area = *self.work_area_size();
|
||||||
let offset = if self.work_area_offset().is_some() {
|
let offset = if self.work_area_offset().is_some() {
|
||||||
@@ -206,7 +205,7 @@ impl Monitor {
|
|||||||
|
|
||||||
self.focused_workspace_mut()
|
self.focused_workspace_mut()
|
||||||
.ok_or_else(|| anyhow!("there is no workspace"))?
|
.ok_or_else(|| anyhow!("there is no workspace"))?
|
||||||
.update(&work_area, offset, invisible_borders)?;
|
.update(&work_area, offset)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -305,7 +305,6 @@ impl WindowManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
|
|
||||||
let mut hwnds_to_purge = vec![];
|
let mut hwnds_to_purge = vec![];
|
||||||
@@ -348,7 +347,7 @@ impl WindowManager {
|
|||||||
.ok_or_else(|| anyhow!("there is no focused workspace"))?
|
.ok_or_else(|| anyhow!("there is no focused workspace"))?
|
||||||
.remove_window(hwnd)?;
|
.remove_window(hwnd)?;
|
||||||
|
|
||||||
monitor.update_focused_workspace(offset, &invisible_borders)?;
|
monitor.update_focused_workspace(offset)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SocketMessage::FocusedWorkspaceContainerPadding(adjustment) => {
|
SocketMessage::FocusedWorkspaceContainerPadding(adjustment) => {
|
||||||
@@ -1094,10 +1093,7 @@ impl WindowManager {
|
|||||||
SocketMessage::UnmanageFocusedWindow => {
|
SocketMessage::UnmanageFocusedWindow => {
|
||||||
self.unmanage_focused_window()?;
|
self.unmanage_focused_window()?;
|
||||||
}
|
}
|
||||||
SocketMessage::InvisibleBorders(rect) => {
|
SocketMessage::InvisibleBorders(_rect) => {}
|
||||||
self.invisible_borders = rect;
|
|
||||||
self.retile_all(false)?;
|
|
||||||
}
|
|
||||||
SocketMessage::WorkAreaOffset(rect) => {
|
SocketMessage::WorkAreaOffset(rect) => {
|
||||||
self.work_area_offset = Option::from(rect);
|
self.work_area_offset = Option::from(rect);
|
||||||
self.retile_all(false)?;
|
self.retile_all(false)?;
|
||||||
@@ -1390,9 +1386,6 @@ impl WindowManager {
|
|||||||
| SocketMessage::FocusWorkspaceNumber(_) => {
|
| SocketMessage::FocusWorkspaceNumber(_) => {
|
||||||
let foreground = WindowsApi::foreground_window()?;
|
let foreground = WindowsApi::foreground_window()?;
|
||||||
let foreground_window = Window { hwnd: foreground };
|
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);
|
let monocle = BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst);
|
||||||
if monocle != 0 && self.focused_workspace()?.monocle_container().is_some() {
|
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));
|
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 => {
|
SocketMessage::TogglePause => {
|
||||||
let is_paused = self.is_paused;
|
let is_paused = self.is_paused;
|
||||||
@@ -1419,7 +1412,7 @@ impl WindowManager {
|
|||||||
border.hide()?;
|
border.hide()?;
|
||||||
} else {
|
} else {
|
||||||
let focused = self.focused_window()?;
|
let focused = self.focused_window()?;
|
||||||
border.set_position(*focused, &self.invisible_borders, true)?;
|
border.set_position(*focused, true)?;
|
||||||
focused.focus(false)?;
|
focused.focus(false)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1429,7 +1422,7 @@ impl WindowManager {
|
|||||||
|
|
||||||
if tiling_enabled {
|
if tiling_enabled {
|
||||||
let focused = self.focused_window()?;
|
let focused = self.focused_window()?;
|
||||||
border.set_position(*focused, &self.invisible_borders, true)?;
|
border.set_position(*focused, true)?;
|
||||||
focused.focus(false)?;
|
focused.focus(false)?;
|
||||||
} else {
|
} else {
|
||||||
border.hide()?;
|
border.hide()?;
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ impl WindowManager {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
|
|
||||||
for (i, monitor) in self.monitors_mut().iter_mut().enumerate() {
|
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() {
|
for (j, workspace) in monitor.workspaces_mut().iter_mut().enumerate() {
|
||||||
let reaped_orphans = workspace.reap_orphans()?;
|
let reaped_orphans = workspace.reap_orphans()?;
|
||||||
if reaped_orphans.0 > 0 || reaped_orphans.1 > 0 {
|
if reaped_orphans.0 > 0 || reaped_orphans.1 > 0 {
|
||||||
workspace.update(&work_area, offset, &invisible_borders)?;
|
workspace.update(&work_area, offset)?;
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
"reaped {} orphan window(s) and {} orphaned container(s) on monitor: {}, workspace: {}",
|
"reaped {} orphan window(s) and {} orphaned container(s) on monitor: {}, workspace: {}",
|
||||||
reaped_orphans.0,
|
reaped_orphans.0,
|
||||||
@@ -334,7 +333,6 @@ impl WindowManager {
|
|||||||
.ok_or_else(|| anyhow!("cannot get monitor idx from current position"))?;
|
.ok_or_else(|| anyhow!("cannot get monitor idx from current position"))?;
|
||||||
|
|
||||||
let new_window_behaviour = self.window_container_behaviour;
|
let new_window_behaviour = self.window_container_behaviour;
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
|
|
||||||
let workspace = self.focused_workspace_mut()?;
|
let workspace = self.focused_workspace_mut()?;
|
||||||
if !workspace
|
if !workspace
|
||||||
@@ -344,7 +342,7 @@ impl WindowManager {
|
|||||||
{
|
{
|
||||||
let focused_container_idx = workspace.focused_container_idx();
|
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
|
let old_position = *workspace
|
||||||
.latest_layout()
|
.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 {
|
let resize = Rect {
|
||||||
left: new_position.left - old_position.left,
|
left: new_position.left - old_position.left,
|
||||||
top: new_position.top - old_position.top,
|
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 we have moved across the monitors, use that override, otherwise determine
|
||||||
// if a move has taken place by ruling out a resize
|
// if a move has taken place by ruling out a resize
|
||||||
let is_move = moved_across_monitors
|
let is_move = moved_across_monitors
|
||||||
|| resize.right == 0 && resize.bottom == 0
|
|| resize.right == 0 && resize.bottom == 0;
|
||||||
|| resize.right.abs() == invisible_borders.right
|
|
||||||
&& resize.bottom.abs() == invisible_borders.bottom;
|
|
||||||
|
|
||||||
if is_move {
|
if is_move {
|
||||||
tracing::info!("moving with mouse");
|
tracing::info!("moving with mouse");
|
||||||
@@ -595,15 +585,10 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(target_window) = target_window {
|
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);
|
let activate = BORDER_HIDDEN.load(Ordering::SeqCst);
|
||||||
|
|
||||||
WindowsApi::invalidate_border_rect()?;
|
WindowsApi::invalidate_border_rect()?;
|
||||||
border.set_position(target_window, &self.invisible_borders, activate)?;
|
border.set_position(target_window, activate)?;
|
||||||
|
|
||||||
if activate {
|
if activate {
|
||||||
BORDER_HIDDEN.store(false, Ordering::SeqCst);
|
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 we unmanaged a window, it shouldn't be immediately hidden behind managed windows
|
||||||
if let WindowManagerEvent::Unmanage(window) = event {
|
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
|
// If there are no more windows on the workspace, we shouldn't show the border window
|
||||||
|
|||||||
@@ -298,13 +298,6 @@ pub struct StaticConfig {
|
|||||||
impl From<&WindowManager> for StaticConfig {
|
impl From<&WindowManager> for StaticConfig {
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
fn from(value: &WindowManager) -> Self {
|
fn from(value: &WindowManager) -> Self {
|
||||||
let default_invisible_borders = Rect {
|
|
||||||
left: 7,
|
|
||||||
top: 0,
|
|
||||||
right: 14,
|
|
||||||
bottom: 7,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut monitors = vec![];
|
let mut monitors = vec![];
|
||||||
for m in value.monitors() {
|
for m in value.monitors() {
|
||||||
monitors.push(MonitorConfig::from(m));
|
monitors.push(MonitorConfig::from(m));
|
||||||
@@ -374,11 +367,7 @@ impl From<&WindowManager> for StaticConfig {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
invisible_borders: if value.invisible_borders == default_invisible_borders {
|
invisible_borders: None,
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Option::from(value.invisible_borders)
|
|
||||||
},
|
|
||||||
resize_delta: Option::from(value.resize_delta),
|
resize_delta: Option::from(value.resize_delta),
|
||||||
window_container_behaviour: Option::from(value.window_container_behaviour),
|
window_container_behaviour: Option::from(value.window_container_behaviour),
|
||||||
cross_monitor_move_behaviour: Option::from(value.cross_monitor_move_behaviour),
|
cross_monitor_move_behaviour: Option::from(value.cross_monitor_move_behaviour),
|
||||||
@@ -745,12 +734,6 @@ impl StaticConfig {
|
|||||||
incoming_events: incoming,
|
incoming_events: incoming,
|
||||||
command_listener: listener,
|
command_listener: listener,
|
||||||
is_paused: false,
|
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(),
|
virtual_desktop_id: current_virtual_desktop(),
|
||||||
work_area_offset: value.global_work_area_offset,
|
work_area_offset: value.global_work_area_offset,
|
||||||
window_container_behaviour: value
|
window_container_behaviour: value
|
||||||
@@ -897,10 +880,6 @@ impl StaticConfig {
|
|||||||
wm.hide_border()?;
|
wm.hide_border()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(val) = value.invisible_borders {
|
|
||||||
wm.invisible_borders = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(val) = value.window_container_behaviour {
|
if let Some(val) = value.window_container_behaviour {
|
||||||
wm.window_container_behaviour = val;
|
wm.window_container_behaviour = val;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-29
@@ -32,7 +32,6 @@ use crate::styles::WindowStyle;
|
|||||||
use crate::window_manager_event::WindowManagerEvent;
|
use crate::window_manager_event::WindowManagerEvent;
|
||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
use crate::ALT_FOCUS_HACK;
|
use crate::ALT_FOCUS_HACK;
|
||||||
use crate::BORDER_OVERFLOW_IDENTIFIERS;
|
|
||||||
use crate::FLOAT_IDENTIFIERS;
|
use crate::FLOAT_IDENTIFIERS;
|
||||||
use crate::HIDDEN_HWNDS;
|
use crate::HIDDEN_HWNDS;
|
||||||
use crate::HIDING_BEHAVIOUR;
|
use crate::HIDING_BEHAVIOUR;
|
||||||
@@ -129,7 +128,7 @@ impl Window {
|
|||||||
HWND(self.hwnd)
|
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_width = work_area.right / 2;
|
||||||
let half_weight = work_area.bottom / 2;
|
let half_weight = work_area.bottom / 2;
|
||||||
|
|
||||||
@@ -140,7 +139,6 @@ impl Window {
|
|||||||
right: half_width,
|
right: half_width,
|
||||||
bottom: half_weight,
|
bottom: half_weight,
|
||||||
},
|
},
|
||||||
invisible_borders,
|
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -148,34 +146,9 @@ impl Window {
|
|||||||
pub fn set_position(
|
pub fn set_position(
|
||||||
&mut self,
|
&mut self,
|
||||||
layout: &Rect,
|
layout: &Rect,
|
||||||
invisible_borders: &Rect,
|
|
||||||
top: bool,
|
top: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut rect = *layout;
|
let 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowsApi::position_window(self.hwnd(), &rect, top)
|
WindowsApi::position_window(self.hwnd(), &rect, top)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ pub struct WindowManager {
|
|||||||
pub incoming_events: Receiver<WindowManagerEvent>,
|
pub incoming_events: Receiver<WindowManagerEvent>,
|
||||||
pub command_listener: UnixListener,
|
pub command_listener: UnixListener,
|
||||||
pub is_paused: bool,
|
pub is_paused: bool,
|
||||||
pub invisible_borders: Rect,
|
|
||||||
pub work_area_offset: Option<Rect>,
|
pub work_area_offset: Option<Rect>,
|
||||||
pub resize_delta: i32,
|
pub resize_delta: i32,
|
||||||
pub window_container_behaviour: WindowContainerBehaviour,
|
pub window_container_behaviour: WindowContainerBehaviour,
|
||||||
@@ -89,7 +88,6 @@ pub struct WindowManager {
|
|||||||
pub struct State {
|
pub struct State {
|
||||||
pub monitors: Ring<Monitor>,
|
pub monitors: Ring<Monitor>,
|
||||||
pub is_paused: bool,
|
pub is_paused: bool,
|
||||||
pub invisible_borders: Rect,
|
|
||||||
pub resize_delta: i32,
|
pub resize_delta: i32,
|
||||||
pub new_window_behaviour: WindowContainerBehaviour,
|
pub new_window_behaviour: WindowContainerBehaviour,
|
||||||
pub cross_monitor_move_behaviour: MoveBehaviour,
|
pub cross_monitor_move_behaviour: MoveBehaviour,
|
||||||
@@ -119,7 +117,6 @@ impl From<&WindowManager> for State {
|
|||||||
Self {
|
Self {
|
||||||
monitors: wm.monitors.clone(),
|
monitors: wm.monitors.clone(),
|
||||||
is_paused: wm.is_paused,
|
is_paused: wm.is_paused,
|
||||||
invisible_borders: wm.invisible_borders,
|
|
||||||
work_area_offset: wm.work_area_offset,
|
work_area_offset: wm.work_area_offset,
|
||||||
resize_delta: wm.resize_delta,
|
resize_delta: wm.resize_delta,
|
||||||
new_window_behaviour: wm.window_container_behaviour,
|
new_window_behaviour: wm.window_container_behaviour,
|
||||||
@@ -190,12 +187,6 @@ impl WindowManager {
|
|||||||
incoming_events: incoming,
|
incoming_events: incoming,
|
||||||
command_listener: listener,
|
command_listener: listener,
|
||||||
is_paused: false,
|
is_paused: false,
|
||||||
invisible_borders: Rect {
|
|
||||||
left: 7,
|
|
||||||
top: 0,
|
|
||||||
right: 14,
|
|
||||||
bottom: 7,
|
|
||||||
},
|
|
||||||
virtual_desktop_id: current_virtual_desktop(),
|
virtual_desktop_id: current_virtual_desktop(),
|
||||||
work_area_offset: None,
|
work_area_offset: None,
|
||||||
window_container_behaviour: WindowContainerBehaviour::Create,
|
window_container_behaviour: WindowContainerBehaviour::Create,
|
||||||
@@ -222,12 +213,9 @@ impl WindowManager {
|
|||||||
pub fn show_border(&self) -> Result<()> {
|
pub fn show_border(&self) -> Result<()> {
|
||||||
let foreground = WindowsApi::foreground_window()?;
|
let foreground = WindowsApi::foreground_window()?;
|
||||||
let foreground_window = Window { hwnd: foreground };
|
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));
|
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()
|
WindowsApi::invalidate_border_rect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +391,6 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
|
|
||||||
for monitor in self.monitors_mut() {
|
for monitor in self.monitors_mut() {
|
||||||
@@ -434,7 +421,7 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if should_update {
|
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))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn retile_all(&mut self, preserve_resize_dimensions: bool) -> Result<()> {
|
pub fn retile_all(&mut self, preserve_resize_dimensions: bool) -> Result<()> {
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
|
|
||||||
for monitor in self.monitors_mut() {
|
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(())
|
Ok(())
|
||||||
@@ -830,12 +816,11 @@ impl WindowManager {
|
|||||||
pub fn update_focused_workspace(&mut self, follow_focus: bool) -> Result<()> {
|
pub fn update_focused_workspace(&mut self, follow_focus: bool) -> Result<()> {
|
||||||
tracing::info!("updating");
|
tracing::info!("updating");
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
|
|
||||||
self.focused_monitor_mut()
|
self.focused_monitor_mut()
|
||||||
.ok_or_else(|| anyhow!("there is no monitor"))?
|
.ok_or_else(|| anyhow!("there is no monitor"))?
|
||||||
.update_focused_workspace(offset, &invisible_borders)?;
|
.update_focused_workspace(offset)?;
|
||||||
|
|
||||||
if follow_focus {
|
if follow_focus {
|
||||||
if let Some(window) = self.focused_workspace()?.maximized_window() {
|
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<()> {
|
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;
|
let offset = self.work_area_offset;
|
||||||
|
|
||||||
self.monitors_mut()
|
self.monitors_mut()
|
||||||
.get_mut(idx)
|
.get_mut(idx)
|
||||||
.ok_or_else(|| anyhow!("there is no monitor"))?
|
.ok_or_else(|| anyhow!("there is no monitor"))?
|
||||||
.update_focused_workspace(offset, &invisible_borders)
|
.update_focused_workspace(offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
@@ -1119,7 +1103,6 @@ impl WindowManager {
|
|||||||
|
|
||||||
tracing::info!("moving container");
|
tracing::info!("moving container");
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
let mouse_follows_focus = self.mouse_follows_focus;
|
let mouse_follows_focus = self.mouse_follows_focus;
|
||||||
|
|
||||||
@@ -1138,7 +1121,7 @@ impl WindowManager {
|
|||||||
.remove_focused_container()
|
.remove_focused_container()
|
||||||
.ok_or_else(|| anyhow!("there is no 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
|
let target_monitor = self
|
||||||
.monitors_mut()
|
.monitors_mut()
|
||||||
@@ -1147,7 +1130,7 @@ impl WindowManager {
|
|||||||
|
|
||||||
target_monitor.add_container(container, workspace_idx)?;
|
target_monitor.add_container(container, workspace_idx)?;
|
||||||
target_monitor.load_focused_workspace(mouse_follows_focus)?;
|
target_monitor.load_focused_workspace(mouse_follows_focus)?;
|
||||||
target_monitor.update_focused_workspace(offset, &invisible_borders)?;
|
target_monitor.update_focused_workspace(offset)?;
|
||||||
|
|
||||||
if follow {
|
if follow {
|
||||||
self.focus_monitor(monitor_idx)?;
|
self.focus_monitor(monitor_idx)?;
|
||||||
@@ -1329,12 +1312,11 @@ impl WindowManager {
|
|||||||
// make sure to update the origin monitor workspace layout because it is no
|
// 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
|
// longer focused so it won't get updated at the end of this fn
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
|
|
||||||
self.monitors_mut()
|
self.monitors_mut()
|
||||||
.get_mut(origin_monitor_idx)
|
.get_mut(origin_monitor_idx)
|
||||||
.ok_or_else(|| anyhow!("there is no monitor at this index"))?
|
.ok_or_else(|| anyhow!("there is no monitor at this index"))?
|
||||||
.update_focused_workspace(offset, &invisible_borders)?;
|
.update_focused_workspace(offset)?;
|
||||||
|
|
||||||
let a = self
|
let a = self
|
||||||
.focused_monitor()
|
.focused_monitor()
|
||||||
@@ -1570,7 +1552,6 @@ impl WindowManager {
|
|||||||
tracing::info!("floating window");
|
tracing::info!("floating window");
|
||||||
|
|
||||||
let work_area = self.focused_monitor_work_area()?;
|
let work_area = self.focused_monitor_work_area()?;
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
|
|
||||||
let workspace = self.focused_workspace_mut()?;
|
let workspace = self.focused_workspace_mut()?;
|
||||||
workspace.new_floating_window()?;
|
workspace.new_floating_window()?;
|
||||||
@@ -1580,7 +1561,7 @@ impl WindowManager {
|
|||||||
.last_mut()
|
.last_mut()
|
||||||
.ok_or_else(|| anyhow!("there is no floating window"))?;
|
.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)?;
|
window.focus(self.mouse_follows_focus)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1837,7 +1818,6 @@ impl WindowManager {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
tracing::info!("setting workspace layout");
|
tracing::info!("setting workspace layout");
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
let focused_monitor_idx = self.focused_monitor_idx();
|
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 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 {
|
if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx {
|
||||||
workspace.update(&work_area, offset, &invisible_borders)?;
|
workspace.update(&work_area, offset)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Ok(self.update_focused_workspace(false)?)
|
Ok(self.update_focused_workspace(false)?)
|
||||||
@@ -1886,7 +1866,6 @@ impl WindowManager {
|
|||||||
{
|
{
|
||||||
tracing::info!("setting workspace layout");
|
tracing::info!("setting workspace layout");
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
let focused_monitor_idx = self.focused_monitor_idx();
|
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 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 {
|
if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx {
|
||||||
workspace.update(&work_area, offset, &invisible_borders)?;
|
workspace.update(&work_area, offset)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Ok(self.update_focused_workspace(false)?)
|
Ok(self.update_focused_workspace(false)?)
|
||||||
@@ -1932,7 +1911,6 @@ impl WindowManager {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
tracing::info!("setting workspace layout");
|
tracing::info!("setting workspace layout");
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
let focused_monitor_idx = self.focused_monitor_idx();
|
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 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 {
|
if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx {
|
||||||
workspace.update(&work_area, offset, &invisible_borders)?;
|
workspace.update(&work_area, offset)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Ok(self.update_focused_workspace(false)?)
|
Ok(self.update_focused_workspace(false)?)
|
||||||
@@ -1975,7 +1953,6 @@ impl WindowManager {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
tracing::info!("setting workspace layout");
|
tracing::info!("setting workspace layout");
|
||||||
|
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
let focused_monitor_idx = self.focused_monitor_idx();
|
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 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 {
|
if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx {
|
||||||
workspace.update(&work_area, offset, &invisible_borders)?;
|
workspace.update(&work_area, offset)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Ok(self.update_focused_workspace(false)?)
|
Ok(self.update_focused_workspace(false)?)
|
||||||
@@ -2020,7 +1997,6 @@ impl WindowManager {
|
|||||||
{
|
{
|
||||||
tracing::info!("setting workspace layout");
|
tracing::info!("setting workspace layout");
|
||||||
let layout = CustomLayout::from_path(path)?;
|
let layout = CustomLayout::from_path(path)?;
|
||||||
let invisible_borders = self.invisible_borders;
|
|
||||||
let offset = self.work_area_offset;
|
let offset = self.work_area_offset;
|
||||||
let focused_monitor_idx = self.focused_monitor_idx();
|
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 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 {
|
if focused_monitor_idx != monitor_idx && focused_workspace_idx == workspace_idx {
|
||||||
workspace.update(&work_area, offset, &invisible_borders)?;
|
workspace.update(&work_area, offset)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Ok(self.update_focused_workspace(false)?)
|
Ok(self.update_focused_workspace(false)?)
|
||||||
|
|||||||
@@ -205,7 +205,6 @@ impl Workspace {
|
|||||||
&mut self,
|
&mut self,
|
||||||
work_area: &Rect,
|
work_area: &Rect,
|
||||||
offset: Option<Rect>,
|
offset: Option<Rect>,
|
||||||
invisible_borders: &Rect,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) {
|
if !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -253,7 +252,7 @@ impl Workspace {
|
|||||||
if let Some(container) = self.monocle_container_mut() {
|
if let Some(container) = self.monocle_container_mut() {
|
||||||
if let Some(window) = container.focused_window_mut() {
|
if let Some(window) = container.focused_window_mut() {
|
||||||
adjusted_work_area.add_padding(container_padding);
|
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() {
|
} else if let Some(window) = self.maximized_window_mut() {
|
||||||
window.maximize();
|
window.maximize();
|
||||||
@@ -288,7 +287,7 @@ impl Workspace {
|
|||||||
WindowsApi::restore_window(window.hwnd());
|
WindowsApi::restore_window(window.hwnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
window.set_position(layout, invisible_borders, false)?;
|
window.set_position(layout, false)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user