mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-09 06:25:23 +02:00
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:
@@ -181,18 +181,6 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
|
|
||||||
// Handle the monocle container separately
|
// Handle the monocle container separately
|
||||||
if let Some(monocle) = ws.monocle_container() {
|
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()) {
|
let border = match borders.entry(monocle.id().clone()) {
|
||||||
Entry::Occupied(entry) => entry.into_mut(),
|
Entry::Occupied(entry) => entry.into_mut(),
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
@@ -223,6 +211,21 @@ pub fn handle_notifications(wm: Arc<Mutex<WindowManager>>) -> color_eyre::Result
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
border.update(&rect)?;
|
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;
|
continue 'monitors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1297,6 +1297,7 @@ impl WindowManager {
|
|||||||
if let Ok(focused_workspace) = self.focused_workspace() {
|
if let Ok(focused_workspace) = self.focused_workspace() {
|
||||||
if let Some(monocle) = focused_workspace.monocle_container() {
|
if let Some(monocle) = focused_workspace.monocle_container() {
|
||||||
if let Some(window) = monocle.focused_window() {
|
if let Some(window) = monocle.focused_window() {
|
||||||
|
window.focus(self.mouse_follows_focus)?;
|
||||||
WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect(
|
WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect(
|
||||||
window.hwnd(),
|
window.hwnd(),
|
||||||
)?)?;
|
)?)?;
|
||||||
@@ -1756,6 +1757,7 @@ impl WindowManager {
|
|||||||
|
|
||||||
for container in workspace.containers_mut() {
|
for container in workspace.containers_mut() {
|
||||||
container.set_stackbar_mode(StackbarMode::Never);
|
container.set_stackbar_mode(StackbarMode::Never);
|
||||||
|
container.hide(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1773,6 +1775,7 @@ impl WindowManager {
|
|||||||
|
|
||||||
for container in workspace.containers_mut() {
|
for container in workspace.containers_mut() {
|
||||||
container.set_stackbar_mode(STACKBAR_MODE.load());
|
container.set_stackbar_mode(STACKBAR_MODE.load());
|
||||||
|
container.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
workspace.reintegrate_monocle_container()
|
workspace.reintegrate_monocle_container()
|
||||||
|
|||||||
@@ -179,6 +179,14 @@ impl Workspace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn restore(&mut self, mouse_follows_focus: bool) -> Result<()> {
|
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 idx = self.focused_container_idx();
|
||||||
let mut to_focus = None;
|
let mut to_focus = None;
|
||||||
|
|
||||||
@@ -196,10 +204,6 @@ impl Workspace {
|
|||||||
container.restore();
|
container.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(container) = self.monocle_container_mut() {
|
|
||||||
container.restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
for window in self.floating_windows() {
|
for window in self.floating_windows() {
|
||||||
window.restore();
|
window.restore();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user