GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
fix: restore maximized windows on redraw; add some config defaults
Lars Bergerba78afa9ab82
diff --git a/packages/wm/src/app_command.rs b/packages/wm/src/app_command.rsindex 5a6b25c6..0a5dc105 100644--- a/packages/wm/src/app_command.rs+++ b/packages/wm/src/app_command.rs@@ -173,7 +173,7 @@ pub enum InvokeCommand {WmExit,WmRedraw,WmReloadConfig,- WmToggleFocusMode,+ WmToggleFocusState,}impl InvokeCommand {@@ -363,7 +363,7 @@ impl InvokeCommand {Ok(())}InvokeCommand::WmReloadConfig => todo!(),- InvokeCommand::WmToggleFocusMode => todo!(),+ InvokeCommand::WmToggleFocusState => todo!(),}}}diff --git a/packages/wm/src/containers/commands/redraw.rs b/packages/wm/src/containers/commands/redraw.rsindex 9e0c64c8..be130b74 100644--- a/packages/wm/src/containers/commands/redraw.rs+++ b/packages/wm/src/containers/commands/redraw.rs@@ -27,12 +27,25 @@ pub fn redraw(state: &mut WmState) -> anyhow::Result<()> {},);- // Restore window if it's minimized and shouldn't be. This is needed to- // be able to move and resize it.- if window.state() != WindowState::Minimized- && window.native().is_minimized()- {- let _ = window.native().restore();+ // Restore window if it's minimized/maximized and shouldn't be. This is+ // needed to be able to move and resize it.+ match window.state() {+ // Need to restore window if transitioning from maximized fullscreen+ // to non-maximized fullscreen.+ WindowState::Fullscreen(s) => {+ if !s.maximized && window.native().is_maximized() {+ let _ = window.native().restore();+ }+ }+ // No need to restore window if it'll be minimized. Transitioning+ // from maximized to minimized works without restoring.+ WindowState::Minimized => {}+ _ => {+ if window.native().is_minimized() || window.native().is_maximized()+ {+ let _ = window.native().restore();+ }+ }}// Avoid adjusting the borders of non-tiling windows. Otherwise thediff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rsindex 034b7656..6196afd1 100644--- a/packages/wm/src/user_config.rs+++ b/packages/wm/src/user_config.rs@@ -172,28 +172,17 @@ pub struct GapsConfig {#[derive(Clone, Debug, Deserialize)]pub struct GeneralConfig {/// Center the cursor in the middle of a newly focused window.+ #[serde(default = "default_bool::<false>")]pub cursor_follows_focus: bool,/// Focus the window directly under the cursor at all times.+ #[serde(default = "default_bool::<false>")]pub focus_follows_cursor: bool,- /// Amount by which to move floating windows- pub floating_window_move_amount: LengthValue,-/// If activated, by switching to the current workspace the previous/// focused workspace is activated.+ #[serde(default = "default_bool::<true>")]pub toggle_workspace_on_refocus: bool,-- /// Whether to enable window transition animations (on minimize, close).- pub window_animations: WindowAnimations,-}--#[derive(Clone, Debug, Deserialize)]-#[serde(rename_all = "snake_case")]-pub enum WindowAnimations {- Enabled,- Disabled,- Unchanged,}#[derive(Clone, Debug, Deserialize)]@@ -222,21 +211,26 @@ pub struct WindowStateDefaultsConfig {#[derive(Clone, Debug, Deserialize, PartialEq)]pub struct FloatingStateConfig {/// Whether to center new floating windows.+ #[serde(default = "default_bool::<true>")]pub centered: bool,/// Whether to show floating windows as always on top.+ #[serde(default = "default_bool::<false>")]pub show_on_top: bool,}#[derive(Clone, Debug, Deserialize, PartialEq)]pub struct FullscreenStateConfig {/// Whether to prefer fullscreen windows to be maximized.+ #[serde(default = "default_bool::<true>")]pub maximized: bool,/// Whether to show fullscreen windows as always on top.+ #[serde(default = "default_bool::<false>")]pub show_on_top: bool,/// Whether to remove the window's title bar when fullscreen.+ #[serde(default = "default_bool::<false>")]pub remove_title_bar: bool,}@@ -245,5 +239,11 @@ pub struct WorkspaceConfig {pub name: String,pub display_name: Option<String>,pub bind_to_monitor: Option<String>,- pub keep_alive: Option<bool>,+ #[serde(default = "default_bool::<false>")]+ pub keep_alive: bool,+}++/// Helper function for setting a default value for a boolean field.+const fn default_bool<const V: bool>() -> bool {+ V}diff --git a/resources/sample-config.yaml b/resources/sample-config.yamlindex 6f0a08f5..10df1223 100644--- a/resources/sample-config.yaml+++ b/resources/sample-config.yaml@@ -32,14 +32,14 @@ window_state_defaults:centered: true# Whether to show floating windows as always on top.- show_on_top: true+ show_on_top: falsefullscreen:# Whether to prefer fullscreen windows to be maximized.maximized: true# Whether to show fullscreen windows as always on top.- show_on_top: true+ show_on_top: false# Whether to remove the window's title bar when fullscreen.remove_title_bar: false@@ -137,7 +137,7 @@ keybindings:bindings: ['Alt+V']# Change focus between tiling windows and floating/fullscreen windows.- - commands: ['wm_toggle_focus_mode']+ - commands: ['wm_toggle_focus_state']bindings: ['Alt+Space']# Change the focused window to be floating.