fix(wm): improve floating ws window handling

This commit addresses and number of bugs and improves the experience of
working with floating workspaces (ie. Workspace.tile = false).

- When the user moves or resizes a window on a floating workspace,
  WindowManagerEvent::MoveResizeStart will no longer trigger, which
  prevents the mouse focus from going to the middle of the window rect
  after the resize or move action (if mouse_follows_focus = true)

- If active_window_border = true, it will no longer be shown on focused
  windows in floating workspaces

- When windows are moved using a komorebic command from a floating
  workspace to a tiling workspace and active_window_border = true, the
  active window border will be shown again
This commit is contained in:
LGUG2Z
2024-02-25 08:36:57 -08:00
parent c19f64144a
commit 92359ebaed

View File

@@ -303,21 +303,24 @@ impl WindowManager {
} }
} }
WindowManagerEvent::MoveResizeStart(_, window) => { WindowManagerEvent::MoveResizeStart(_, window) => {
let monitor_idx = self.focused_monitor_idx(); if *self.focused_workspace()?.tile() {
let workspace_idx = self let monitor_idx = self.focused_monitor_idx();
.focused_monitor() let workspace_idx = self
.ok_or_else(|| anyhow!("there is no monitor with this idx"))? .focused_monitor()
.focused_workspace_idx(); .ok_or_else(|| anyhow!("there is no monitor with this idx"))?
let container_idx = self .focused_workspace_idx();
.focused_monitor() let container_idx = self
.ok_or_else(|| anyhow!("there is no monitor with this idx"))? .focused_monitor()
.focused_workspace() .ok_or_else(|| anyhow!("there is no monitor with this idx"))?
.ok_or_else(|| anyhow!("there is no workspace with this idx"))? .focused_workspace()
.focused_container_idx(); .ok_or_else(|| anyhow!("there is no workspace with this idx"))?
.focused_container_idx();
WindowsApi::bring_window_to_top(window.hwnd())?; WindowsApi::bring_window_to_top(window.hwnd())?;
self.pending_move_op = Option::from((monitor_idx, workspace_idx, container_idx)); self.pending_move_op =
Option::from((monitor_idx, workspace_idx, container_idx));
}
} }
WindowManagerEvent::MoveResizeEnd(_, window) => { WindowManagerEvent::MoveResizeEnd(_, window) => {
// We need this because if the event ends on a different monitor, // We need this because if the event ends on a different monitor,
@@ -518,6 +521,12 @@ impl WindowManager {
| WindowManagerEvent::Uncloak(..) => {} | WindowManagerEvent::Uncloak(..) => {}
}; };
if !self.focused_workspace()?.tile() {
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
border.hide()?;
BORDER_HIDDEN.store(true, Ordering::SeqCst);
}
if *self.focused_workspace()?.tile() && BORDER_ENABLED.load(Ordering::SeqCst) { if *self.focused_workspace()?.tile() && BORDER_ENABLED.load(Ordering::SeqCst) {
match event { match event {
WindowManagerEvent::MoveResizeStart(_, _) => { WindowManagerEvent::MoveResizeStart(_, _) => {
@@ -529,6 +538,7 @@ impl WindowManager {
| WindowManagerEvent::Show(_, window) | WindowManagerEvent::Show(_, window)
| WindowManagerEvent::FocusChange(_, window) | WindowManagerEvent::FocusChange(_, window)
| WindowManagerEvent::Hide(_, window) | WindowManagerEvent::Hide(_, window)
| WindowManagerEvent::Uncloak(_, window)
| WindowManagerEvent::Minimize(_, window) => { | WindowManagerEvent::Minimize(_, window) => {
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst)); let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
let mut target_window = None; let mut target_window = None;