Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

fix: correctly add non-tiling windows for redraw on state update

Lars Berger7f7775435f97
diff --git a/packages/wm/src/windows/commands/toggle_window_state.rs b/packages/wm/src/windows/commands/toggle_window_state.rs
index 64352dd5..1e69c569 100644
--- a/packages/wm/src/windows/commands/toggle_window_state.rs
+++ b/packages/wm/src/windows/commands/toggle_window_state.rs
@@ -17,27 +17,28 @@ pub fn toggle_window_state(
state: &mut WmState,
config: &UserConfig,
) -> anyhow::Result<()> {
- // If the window is not currently in the given state, update it to that
- // state.
+ // If the window is not currently in the given state, then update it to
+ // the given state. Otherwise, revert to the window's previous state. If
+ // the window doesn't have a previous state, it's updated to be tiling.
if window.state() != window_state {
- return update_window_state(window, window_state, state, config);
+ update_window_state(window.clone(), window_state, state, config)?;
+ } else {
+ match window.prev_state() {
+ Some(prev_state) => {
+ update_window_state(window.clone(), prev_state, state, config)
+ }
+ None if window.state() != WindowState::Tiling => {
+ update_window_state(
+ window.clone(),
+ WindowState::Tiling,
+ state,
+ config,
+ )
+ }
+ None => Ok(()),
+ }?;
}
- // Otherwise, revert to the window's previous state. If it doesn't have
- // a previous state, the window is updated to be tiling.
- match window.prev_state() {
- Some(prev_state) => {
- update_window_state(window.clone(), prev_state, state, config)
- }
- None if window.state() != WindowState::Tiling => update_window_state(
- window.clone(),
- WindowState::Tiling,
- state,
- config,
- ),
- None => Ok(()),
- }?;
-
// The `update_window_state` call will already add the window for redraw
// on tiling <-> non-tiling state changes. However, on toggle, we always
// want to add the window for redraw.
diff --git a/packages/wm/src/windows/commands/update_window_state.rs b/packages/wm/src/windows/commands/update_window_state.rs
index dd6fbc84..331d0186 100644
--- a/packages/wm/src/windows/commands/update_window_state.rs
+++ b/packages/wm/src/windows/commands/update_window_state.rs
@@ -123,8 +123,8 @@ fn set_non_tiling(
// Focus should be reassigned after a window has been minimized.
if window_state == WindowState::Minimized {
- if let Some(focus_target) =
- state.focus_target_after_removal(&non_tiling_window.into())
+ if let Some(focus_target) = state
+ .focus_target_after_removal(&non_tiling_window.clone().into())
{
set_focused_descendant(focus_target, None);
state.has_pending_focus_sync = true;
@@ -133,6 +133,7 @@ fn set_non_tiling(
}
}
+ state.containers_to_redraw.push(non_tiling_window.into());
state
.containers_to_redraw
.extend(workspace.tiling_children().map(Into::into))