fix(wm): smooth transitions to monocle workspaces

This commit adds hiding and restoring of other containers on a workspace
with monocle on/off, and exits early when a monocle container is found
on workspace restores to avoid flashing of other containers before the
workspace focus operation completes.

Focus is also restored when focusing a monocle container on another
monitor as part of a cross-monitor focus operation.

The border rendering for monocle containers has also been tightened up.

re #819
This commit is contained in:
LGUG2Z
2024-05-18 08:30:35 -07:00
parent d2470b1f08
commit 27cd1736aa
3 changed files with 26 additions and 16 deletions

View File

@@ -181,18 +181,6 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
// Handle the monocle container separately
if let Some(monocle) = ws.monocle_container() {
let mut to_remove = vec![];
for (id, border) in borders.iter() {
if borders_monitors.get(id).copied().unwrap_or_default() == monitor_idx {
border.destroy()?;
to_remove.push(id.clone());
}
}
for id in &to_remove {
borders.remove(id);
}
let border = match borders.entry(monocle.id().clone()) {
Entry::Occupied(entry) => entry.into_mut(),
Entry::Vacant(entry) => {
@@ -223,6 +211,21 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
)?;
border.update(&rect)?;
let border_hwnd = border.hwnd;
let mut to_remove = vec![];
for (id, b) in borders.iter() {
if borders_monitors.get(id).copied().unwrap_or_default() == monitor_idx
&& border_hwnd != b.hwnd
{
b.destroy()?;
to_remove.push(id.clone());
}
}
for id in &to_remove {
borders.remove(id);
}
continue 'monitors;
}

View File

@@ -1297,6 +1297,7 @@ impl WindowManager {
if let Ok(focused_workspace) = self.focused_workspace() {
if let Some(monocle) = focused_workspace.monocle_container() {
if let Some(window) = monocle.focused_window() {
window.focus(self.mouse_follows_focus)?;
WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect(
window.hwnd(),
)?)?;
@@ -1756,6 +1757,7 @@ impl WindowManager {
for container in workspace.containers_mut() {
container.set_stackbar_mode(StackbarMode::Never);
container.hide(None);
}
Ok(())
@@ -1773,6 +1775,7 @@ impl WindowManager {
for container in workspace.containers_mut() {
container.set_stackbar_mode(STACKBAR_MODE.load());
container.restore();
}
workspace.reintegrate_monocle_container()

View File

@@ -179,6 +179,14 @@ impl Workspace {
}
pub fn restore(&mut self, mouse_follows_focus: bool) -> Result<()> {
if let Some(container) = self.monocle_container_mut() {
if let Some(window) = container.focused_window() {
container.restore();
window.focus(mouse_follows_focus)?;
return Ok(());
}
}
let idx = self.focused_container_idx();
let mut to_focus = None;
@@ -196,10 +204,6 @@ impl Workspace {
container.restore();
}
if let Some(container) = self.monocle_container_mut() {
container.restore();
}
for window in self.floating_windows() {
window.restore();
}