GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: move window states config under new `window_behavior` property
Lars Bergerc43b95593165
diff --git a/packages/wm/src/app_command.rs b/packages/wm/src/app_command.rsindex 7693be2a..ec029370 100644--- a/packages/wm/src/app_command.rs+++ b/packages/wm/src/app_command.rs@@ -336,7 +336,7 @@ impl InvokeCommand {} => match subject_container.as_window_container() {Ok(window) => {let floating_defaults =- &config.value.window_state_defaults.floating;+ &config.value.window_behavior.state_defaults.floating;update_window_state(window.clone(),@@ -361,7 +361,7 @@ impl InvokeCommand {} => match subject_container.as_window_container() {Ok(window) => {let fullscreen_defaults =- &config.value.window_state_defaults.fullscreen;+ &config.value.window_behavior.state_defaults.fullscreen;update_window_state(window.clone(),@@ -415,7 +415,7 @@ impl InvokeCommand {} => match subject_container.as_window_container() {Ok(window) => {let floating_defaults =- &config.value.window_state_defaults.floating;+ &config.value.window_behavior.state_defaults.floating;toggle_window_state(window,@@ -437,7 +437,7 @@ impl InvokeCommand {} => match subject_container.as_window_container() {Ok(window) => {let fullscreen_defaults =- &config.value.window_state_defaults.fullscreen;+ &config.value.window_behavior.state_defaults.fullscreen;toggle_window_state(window,diff --git a/packages/wm/src/common/events/handle_window_location_changed.rs b/packages/wm/src/common/events/handle_window_location_changed.rsindex f27bd448..1d775436 100644--- a/packages/wm/src/common/events/handle_window_location_changed.rs+++ b/packages/wm/src/common/events/handle_window_location_changed.rs@@ -49,7 +49,7 @@ pub fn handle_window_location_changed(update_window_state(window,WindowState::Fullscreen(FullscreenStateConfig {- ..config.value.window_state_defaults.fullscreen+ ..config.value.window_behavior.state_defaults.fullscreen}),state,config,diff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rsindex cb7c84fb..42d8af4d 100644--- a/packages/wm/src/user_config.rs+++ b/packages/wm/src/user_config.rs@@ -143,9 +143,9 @@ pub struct ParsedConfig {pub gaps: GapsConfig,pub general: GeneralConfig,pub keybindings: Vec<KeybindingConfig>,+ pub window_behavior: WindowBehaviorConfig,pub window_effects: WindowEffectsConfig,pub window_rules: Vec<WindowRuleConfig>,- pub window_state_defaults: WindowStateDefaultsConfig,pub workspaces: Vec<WorkspaceConfig>,}@@ -207,29 +207,21 @@ pub struct KeybindingConfig {#[derive(Clone, Debug, Deserialize, Serialize)]#[serde(rename_all(serialize = "camelCase"))]-pub struct WindowEffectsConfig {- /// Visual effects to apply to the focused window.- pub focused_window: WindowEffectConfig,-- /// Visual effects to apply to non-focused windows.- pub other_windows: WindowEffectConfig,+pub struct WindowBehaviorConfig {+ /// New windows are created in this state whenever possible.+ pub initial_state: InitialWindowState,++ /// Sets the default options for when a new window is created. This also+ /// changes the defaults for when the state change commands, like+ /// `set_floating`, are used without any flags.+ pub state_defaults: WindowStateDefaultsConfig,}-#[derive(Clone, Debug, Deserialize, Serialize)]-#[serde(rename_all(serialize = "camelCase"))]-pub struct WindowEffectConfig {- /// Optional colored border to apply.- #[serde(deserialize_with = "deserialize_option_color")]- pub border_color: Option<Color>,-}--#[derive(Clone, Debug, Deserialize, Serialize)]-#[serde(rename_all(serialize = "camelCase"))]-pub struct WindowRuleConfig {- pub match_process_name: Option<String>,- pub match_class_name: Option<String>,- pub match_title: Option<String>,- pub commands: Vec<InvokeCommand>,+#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]+#[serde(rename_all = "snake_case")]+pub enum InitialWindowState {+ Tiling,+ Floating,}#[derive(Clone, Debug, Deserialize, Serialize)]@@ -267,6 +259,33 @@ pub struct FullscreenStateConfig {pub remove_title_bar: bool,}+#[derive(Clone, Debug, Deserialize, Serialize)]+#[serde(rename_all(serialize = "camelCase"))]+pub struct WindowEffectsConfig {+ /// Visual effects to apply to the focused window.+ pub focused_window: WindowEffectConfig,++ /// Visual effects to apply to non-focused windows.+ pub other_windows: WindowEffectConfig,+}++#[derive(Clone, Debug, Deserialize, Serialize)]+#[serde(rename_all(serialize = "camelCase"))]+pub struct WindowEffectConfig {+ /// Optional colored border to apply.+ #[serde(deserialize_with = "deserialize_option_color")]+ pub border_color: Option<Color>,+}++#[derive(Clone, Debug, Deserialize, Serialize)]+#[serde(rename_all(serialize = "camelCase"))]+pub struct WindowRuleConfig {+ pub match_process_name: Option<String>,+ pub match_class_name: Option<String>,+ pub match_title: Option<String>,+ pub commands: Vec<InvokeCommand>,+}+#[derive(Clone, Debug, Deserialize, Serialize)]#[serde(rename_all(serialize = "camelCase"))]pub struct WorkspaceConfig {diff --git a/packages/wm/src/windows/commands/manage_window.rs b/packages/wm/src/windows/commands/manage_window.rsindex a829128e..5881965d 100644--- a/packages/wm/src/windows/commands/manage_window.rs+++ b/packages/wm/src/windows/commands/manage_window.rs@@ -88,12 +88,19 @@ fn create_window(.displayed_workspace().context("No nearest workspace.")?;+ let prefers_centered = config+ .value+ .window_behavior+ .state_defaults+ .floating+ .centered;+// Calculate where window should be placed when floating is enabled. Use// the original width/height of the window and optionally position it in// the center of the workspace.- let prefer_center = config.value.window_state_defaults.floating.centered;let floating_placement =- if nearest_workspace.id() != target_workspace.id() || prefer_center {+ if nearest_workspace.id() != target_workspace.id() || prefers_centered+ {native_window.frame_position()?.translate_to_center(&target_workspace.to_rect()?)@@ -157,14 +164,19 @@ fn window_state_to_create(if native_window.is_fullscreen() {return WindowState::Fullscreen(- config.value.window_state_defaults.fullscreen.clone(),+ config+ .value+ .window_behavior+ .state_defaults+ .fullscreen+ .clone(),);}// Initialize windows that can't be resized as floating.if !native_window.is_resizable() {return WindowState::Floating(- config.value.window_state_defaults.floating.clone(),+ config.value.window_behavior.state_defaults.floating.clone(),);}diff --git a/resources/sample-config.yaml b/resources/sample-config.yamlindex fc17258f..fed8d1b3 100644--- a/resources/sample-config.yaml+++ b/resources/sample-config.yaml@@ -30,23 +30,25 @@ window_effects:other_windows:border_color: null-window_state_defaults:- floating:- # Whether to center floating windows by default.- centered: true-- # Whether to show floating windows as always on top.- show_on_top: false-- fullscreen:- # Whether to prefer fullscreen windows to be maximized.- maximized: true-- # Whether to show fullscreen windows as always on top.- show_on_top: false-- # Whether to remove the window's title bar when fullscreen.- remove_title_bar: false+window_behavior:+ # New windows are created in this state whenever possible.+ # Possible values: 'tiling', 'floating'.+ initial_state: 'tiling'++ # Sets the default options for when a new window is created. This also+ # changes the defaults for when the state change commands, like+ # `set-floating`, are used without any flags.+ state_defaults:+ floating:+ # Whether to center floating windows by default.+ centered: true++ # Whether to show floating windows as always on top.+ show_on_top: false++ fullscreen:+ # Whether to prefer fullscreen windows to be maximized.+ maximized: trueworkspaces:- name: '1'