GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: pass window state to `set_position`; remove app bar logic; add config for floating + fullscreen states
Lars Bergere2c7c129e339
diff --git a/packages/wm/src/app_command.rs b/packages/wm/src/app_command.rsindex a13fdbff..74ce4996 100644--- a/packages/wm/src/app_command.rs+++ b/packages/wm/src/app_command.rs@@ -8,7 +8,7 @@ use tracing::Level;use crate::{common::{Direction, LengthValue},containers::{traits::CommonGetters, Container},- user_config::UserConfig,+ user_config::{FloatingStateConfig, FullscreenStateConfig, UserConfig},windows::{commands::update_window_state, traits::WindowGetters, WindowState,},@@ -118,12 +118,21 @@ pub enum InvokeCommand {},Resize(InvokeResizeCommand),SetFloating {- #[clap(long)]- centered: bool,+ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ show_on_top: Option<bool>,++ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ centered: Option<bool>,},SetFullscreen {- #[clap(long)]- maximized: bool,+ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ show_on_top: Option<bool>,++ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ maximized: Option<bool>,++ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ remove_title_bar: Option<bool>,},SetMinimized,SetTiling,@@ -132,12 +141,21 @@ pub enum InvokeCommand {command: Vec<String>,},ToggleFloating {- #[clap(long)]- centered: bool,+ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ show_on_top: Option<bool>,++ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ centered: Option<bool>,},ToggleFullscreen {- #[clap(long)]- maximized: bool,+ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ show_on_top: Option<bool>,++ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ maximized: Option<bool>,++ #[clap(long, default_missing_value = "true", require_equals = true, num_args = 0..=1)]+ remove_title_bar: Option<bool>,},ToggleMinimized,ToggleTiling,@@ -146,11 +164,11 @@ pub enum InvokeCommand {#[clap(long)]name: String,},- WmExit,WmEnableBindingMode {#[clap(long)]name: String,},+ WmExit,WmRedraw,WmReloadConfig,WmToggleFocusMode,@@ -175,72 +193,109 @@ impl InvokeCommand {_ => Ok(()),}}- InvokeCommand::Focus(_) => todo!(),+ InvokeCommand::Focus(args) => {+ if let Some(direction) = &args.direction {+ todo!()+ }++ if let Some(workspace) = &args.workspace {+ todo!()+ }++ if args.next_workspace {+ todo!()+ }++ if args.prev_workspace {+ todo!()+ }++ if args.recent_workspace {+ todo!()+ }++ Ok(())+ }InvokeCommand::Ignore => todo!(),InvokeCommand::Move(_) => todo!(),InvokeCommand::MoveWorkspace { direction } => todo!(),InvokeCommand::Resize(_) => todo!(),- InvokeCommand::SetFloating { centered } => {- match subject_container.as_window_container() {- Ok(window) => update_window_state(+ InvokeCommand::SetFloating {+ centered,+ show_on_top,+ } => match subject_container.as_window_container() {+ Ok(window) => {+ let floating_defaults =+ &config.value.window_state_defaults.floating;++ update_window_state(window,- WindowState::Floating,+ WindowState::Floating(FloatingStateConfig {+ centered: centered.unwrap_or(floating_defaults.centered),+ show_on_top: show_on_top+ .unwrap_or(floating_defaults.show_on_top),+ }),state,config,- ),- _ => Ok(()),+ )}- }- InvokeCommand::SetFullscreen { maximized } => {- match subject_container.as_window_container() {- Ok(window) => match maximized {- true => window.native().maximize(),- // false => window.native().set_position(),- false => Ok(()),- },- _ => Ok(()),+ _ => Ok(()),+ },+ InvokeCommand::SetFullscreen {+ maximized,+ show_on_top,+ remove_title_bar,+ } => match subject_container.as_window_container() {+ Ok(window) => {+ let fullscreen_defaults =+ &config.value.window_state_defaults.fullscreen;++ update_window_state(+ window,+ WindowState::Fullscreen(FullscreenStateConfig {+ maximized: maximized+ .unwrap_or(fullscreen_defaults.maximized),+ show_on_top: show_on_top+ .unwrap_or(fullscreen_defaults.show_on_top),+ remove_title_bar: remove_title_bar+ .unwrap_or(fullscreen_defaults.remove_title_bar),+ }),+ state,+ config,+ )}- }+ _ => Ok(()),+ },InvokeCommand::SetMinimized => {match subject_container.as_window_container() {- Ok(window) => window.native().minimize(),- _ => Ok(()),- }- }- InvokeCommand::SetTiling => {- match subject_container.as_window_container() {- Ok(window) => {- update_window_state(window, WindowState::Tiling, state, config)- }- _ => Ok(()),- }- }- InvokeCommand::ShellExec { command } => todo!(),- InvokeCommand::ToggleFloating { centered } => {- match subject_container.as_window_container() {- // TODO: Toggle floating.Ok(window) => update_window_state(window,- WindowState::Floating,+ WindowState::Minimized,state,config,),_ => Ok(()),}}- InvokeCommand::ToggleFullscreen { maximized } => todo!(),- InvokeCommand::ToggleMinimized => {+ InvokeCommand::SetTiling => {match subject_container.as_window_container() {Ok(window) => {- if window.native().is_minimized() {- window.native().restore()- } else {- window.native().minimize()- }+ update_window_state(window, WindowState::Tiling, state, config)}_ => Ok(()),}}+ InvokeCommand::ShellExec { command } => todo!(),+ InvokeCommand::ToggleFloating {+ centered,+ show_on_top,+ } => todo!(),+ InvokeCommand::ToggleFullscreen {+ maximized,+ show_on_top,+ remove_title_bar,+ } => todo!(),+ InvokeCommand::ToggleMinimized => todo!(),InvokeCommand::ToggleTiling => todo!(),InvokeCommand::ToggleTilingDirection => todo!(),InvokeCommand::WmDisableBindingMode { name } => todo!(),diff --git a/packages/wm/src/common/events/handle_window_destroyed.rs b/packages/wm/src/common/events/handle_window_destroyed.rsindex 9dee5a41..0dfb919b 100644--- a/packages/wm/src/common/events/handle_window_destroyed.rs+++ b/packages/wm/src/common/events/handle_window_destroyed.rs@@ -9,12 +9,6 @@ pub fn handle_window_destroyed(native_window: NativeWindow,state: &mut WmState,) -> anyhow::Result<()> {- // TODO: Refresh monitor state.- if native_window.is_app_bar() {- state.app_bar_windows.retain(|w| w != &native_window);- return Ok(());- }-let found_window = state.window_from_native(&native_window);// Unmanage the window if it's currently managed.diff --git a/packages/wm/src/common/events/handle_window_hidden.rs b/packages/wm/src/common/events/handle_window_hidden.rsindex a9425fda..835ff515 100644--- a/packages/wm/src/common/events/handle_window_hidden.rs+++ b/packages/wm/src/common/events/handle_window_hidden.rs@@ -12,12 +12,6 @@ pub fn handle_window_hidden(state: &mut WmState,config: &UserConfig,) -> anyhow::Result<()> {- // TODO: Refresh monitor state.- if native_window.is_app_bar() {- state.app_bar_windows.retain(|w| w != &native_window);- return Ok(());- }-let found_window = state.window_from_native(&native_window);if let Some(window) = found_window {diff --git a/packages/wm/src/common/events/handle_window_shown.rs b/packages/wm/src/common/events/handle_window_shown.rsindex 779a2ff0..7bbc4acb 100644--- a/packages/wm/src/common/events/handle_window_shown.rs+++ b/packages/wm/src/common/events/handle_window_shown.rs@@ -12,12 +12,6 @@ pub fn handle_window_shown(state: &mut WmState,config: &UserConfig,) -> anyhow::Result<()> {- // TODO: Refresh monitor state.- if native_window.is_app_bar() {- state.app_bar_windows.push(native_window);- return Ok(());- }-let found_window = state.window_from_native(&native_window);// Manage the window if it's manageable.diff --git a/packages/wm/src/common/platform/native_window.rs b/packages/wm/src/common/platform/native_window.rsindex 559e8879..96323626 100644--- a/packages/wm/src/common/platform/native_window.rs+++ b/packages/wm/src/common/platform/native_window.rs@@ -31,7 +31,7 @@ use windows::{},};-use crate::common::Rect;+use crate::{common::Rect, windows::WindowState};pub type WindowHandle = HWND;@@ -196,7 +196,7 @@ impl NativeWindow {self.has_window_style(WS_THICKFRAME)}- pub fn is_app_bar(&self) -> bool {+ pub fn is_fullscreen(&self) -> bool {// TODOfalse}@@ -269,7 +269,9 @@ impl NativeWindow {pub fn set_position(&self,- args: &SetPositionArgs,+ state: &WindowState,+ is_visible: bool,+ rect: &Rect,) -> anyhow::Result<()> {let mut swp_flags = SWP_FRAMECHANGED| SWP_NOACTIVATE@@ -278,32 +280,27 @@ impl NativeWindow {| SWP_ASYNCWINDOWPOS;// Whether to show or hide the window.- if args.visible {+ if is_visible {swp_flags |= SWP_SHOWWINDOW;} else {swp_flags |= SWP_HIDEWINDOW;};- // Whether to actually move and resize the window.- if !args.move_and_resize {- swp_flags |= SWP_NOSIZE;- swp_flags |= SWP_NOMOVE;- }-// Whether the window should be shown above all other windows.- let z_order = match args.show_on_top {- true => HWND_TOPMOST,- false => HWND_NOTOPMOST,+ let z_order = match state {+ WindowState::Floating(s) if s.show_on_top => HWND_TOPMOST,+ WindowState::Fullscreen(s) if s.show_on_top => HWND_TOPMOST,+ _ => HWND_NOTOPMOST,};unsafe {SetWindowPos(- args.window_handle,+ self.handle,z_order,- args.rect.x(),- args.rect.y(),- args.rect.width(),- args.rect.height(),+ rect.x(),+ rect.y(),+ rect.width(),+ rect.height(),swp_flags,)}?;@@ -320,16 +317,6 @@ impl PartialEq for NativeWindow {impl Eq for NativeWindow {}-/// Arguments to pass to `NativeWindow::set_position`.-#[derive(Debug)]-pub struct SetPositionArgs {- pub window_handle: WindowHandle,- pub visible: bool,- pub show_on_top: bool,- pub move_and_resize: bool,- pub rect: Rect,-}-pub fn available_windows() -> anyhow::Result<Vec<NativeWindow>> {available_window_handles()?.into_iter()diff --git a/packages/wm/src/containers/commands/redraw.rs b/packages/wm/src/containers/commands/redraw.rsindex 8511a92e..9e0c64c8 100644--- a/packages/wm/src/containers/commands/redraw.rs+++ b/packages/wm/src/containers/commands/redraw.rs@@ -1,40 +1,14 @@use anyhow::Context;use crate::{- common::{platform::SetPositionArgs, DisplayState},- containers::{- traits::{CommonGetters, PositionGetters},- WindowContainer,- },- user_config::UserConfig,+ common::DisplayState,+ containers::traits::{CommonGetters, PositionGetters},windows::{traits::WindowGetters, WindowState},wm_state::WmState,};-pub fn redraw(- state: &mut WmState,- config: &UserConfig,-) -> anyhow::Result<()> {- let windows_to_redraw = state.windows_to_redraw();-- // Get windows that are minimized/maximized and shouldn't be.- let windows_to_restore = windows_to_redraw- .iter()- .filter(|window| match window.state() {- WindowState::Minimized | WindowState::Fullscreen => false,- _ => {- window.native().is_maximized() || window.native().is_minimized()- }- })- .collect::<Vec<_>>();-- // Restore minimized and maximized windows. Needed to be able to move and- // resize them.- for window in &windows_to_restore {- let _ = window.native().restore();- }-- for window in &windows_to_redraw {+pub fn redraw(state: &mut WmState) -> anyhow::Result<()> {+ for window in &state.windows_to_redraw() {let workspace = window.parent_workspace().context("Window has no workspace.")?;@@ -53,54 +27,48 @@ pub fn redraw(},);- let position_args = get_position_args(- &window,- config.value.general.show_floating_on_top,- )?;+ // 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();+ }++ // Avoid adjusting the borders of non-tiling windows. Otherwise the+ // window will increase in size from its original placement.+ let rect = match window.state() {+ WindowState::Tiling => {+ window.to_rect()?.apply_delta(&window.border_delta())+ }+ _ => window.to_rect()?,+ };++ let is_visible = match window.display_state() {+ DisplayState::Showing | DisplayState::Shown => true,+ _ => false,+ };- let _ = window.native().set_position(&position_args);+ let _ =+ window+ .native()+ .set_position(&window.state(), is_visible, &rect);// When there's a mismatch between the DPI of the monitor and the// window, the window might be sized incorrectly after the first move.// If we set the position twice, inconsistencies after the first move// are resolved.if window.has_pending_dpi_adjustment() {- let _ = window.native().set_position(&position_args);+ let _ =+ window+ .native()+ .set_position(&window.state(), is_visible, &rect);+window.set_has_pending_dpi_adjustment(false);}}state.clear_containers_to_redraw();- Ok(())-}--fn get_position_args(- window: &WindowContainer,- show_floating_on_top: bool,-) -> anyhow::Result<SetPositionArgs> {- // Avoid adjusting the borders of non-tiling windows. Otherwise the- // window will increase in size from its original placement.- let rect = match window.state() {- WindowState::Tiling => {- window.to_rect()?.apply_delta(&window.border_delta())- }- _ => window.to_rect()?,- };- Ok(SetPositionArgs {- window_handle: window.native().handle,- visible: match window.display_state() {- DisplayState::Showing | DisplayState::Shown => true,- _ => false,- },- show_on_top: match window.state() {- WindowState::Floating => show_floating_on_top,- _ => false,- },- move_and_resize: match window.state() {- WindowState::Floating | WindowState::Tiling => true,- _ => false,- },- rect,- })+ Ok(())}diff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rsindex bc0a789f..034b7656 100644--- a/packages/wm/src/user_config.rs+++ b/packages/wm/src/user_config.rs@@ -14,113 +14,8 @@ use crate::{workspaces::Workspace,};-#[derive(Clone, Debug, Deserialize)]-pub struct KeybindingConfig {- /// Keyboard shortcut to trigger the keybinding.- pub bindings: Vec<String>,-- /// WM commands to run when the keybinding is triggered.- pub commands: Vec<InvokeCommand>,-}--#[derive(Clone, Debug, Deserialize)]-pub struct BindingModeConfig {- /// Name of the binding mode.- pub name: String,-- /// Display name of the binding mode.- pub display_name: Option<String>,-- /// Keybindings that will be active when the binding mode is active.- pub keybindings: Vec<KeybindingConfig>,-}--#[derive(Clone, Debug, Deserialize)]-pub struct GapsConfig {- /// Gap between adjacent windows.- pub inner_gap: LengthValue,-- /// Gap between windows and the screen edge.- pub outer_gap: RectDelta,-}--#[derive(Clone, Debug, Deserialize)]-pub struct GeneralConfig {- /// Whether to show floating windows as always on top.- pub show_floating_on_top: bool,-- /// Center the cursor in the middle of a newly focused window.- pub cursor_follows_focus: bool,-- /// Focus the window directly under the cursor at all times.- 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.- pub toggle_workspace_on_refocus: bool,-- /// Whether to enable window transition animations (on minimize, close).- pub window_animations: WindowAnimations,-- /// Whether to center new floating windows- pub center_new_floating_windows: bool,-}--#[derive(Clone, Debug, Deserialize)]-#[serde(rename_all = "snake_case")]-pub enum WindowAnimations {- Enabled,- Disabled,- Unchanged,-}--#[derive(Clone, Debug, Deserialize)]-pub struct FocusBorder {- /// Whether to use a custom border color.- pub enabled: bool,-- /// Border color of the window.- pub color: String,-}--#[derive(Clone, Debug, Deserialize)]-pub struct FocusBordersConfig {- /// Border of the focused window.- pub active: FocusBorder,-- /// Border of non-focused windows.- pub inactive: FocusBorder,-}--#[derive(Clone, Debug, Deserialize)]-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)]-pub struct WorkspaceConfig {- pub name: String,- pub display_name: Option<String>,- pub bind_to_monitor: Option<String>,- pub keep_alive: Option<bool>,-}--#[derive(Clone, Debug, Deserialize)]-pub struct ParsedConfig {- pub binding_modes: Vec<BindingModeConfig>,- pub focus_borders: FocusBordersConfig,- pub gaps: GapsConfig,- pub general: GeneralConfig,- pub keybindings: Vec<KeybindingConfig>,- pub window_rules: Vec<WindowRuleConfig>,- pub workspaces: Vec<WorkspaceConfig>,-}+const SAMPLE_CONFIG: &str =+ include_str!("../../../resources/sample-config.yaml");#[derive(Debug)]pub struct UserConfig {@@ -129,9 +24,6 @@ pub struct UserConfig {pub changes_tx: mpsc::UnboundedSender<()>,}-const SAMPLE_CONFIG: &str =- include_str!("../../../resources/sample-config.yaml");-impl UserConfig {/// Read and validate the user config from the given path.pub async fn read(@@ -183,8 +75,8 @@ impl UserConfig {Ok(())}- // TODO: Maybe this should be on the impl of `UserConfig` instead.async fn refresh(&self) -> Result<()> {+ // TODOOk(())}@@ -225,3 +117,133 @@ impl UserConfig {.cloned()}}++#[derive(Clone, Debug, Deserialize)]+pub struct ParsedConfig {+ pub binding_modes: Vec<BindingModeConfig>,+ pub focus_borders: FocusBordersConfig,+ pub gaps: GapsConfig,+ pub general: GeneralConfig,+ pub keybindings: Vec<KeybindingConfig>,+ pub window_rules: Vec<WindowRuleConfig>,+ pub window_state_defaults: WindowStateDefaultsConfig,+ pub workspaces: Vec<WorkspaceConfig>,+}++#[derive(Clone, Debug, Deserialize)]+pub struct BindingModeConfig {+ /// Name of the binding mode.+ pub name: String,++ /// Display name of the binding mode.+ pub display_name: Option<String>,++ /// Keybindings that will be active when the binding mode is active.+ pub keybindings: Vec<KeybindingConfig>,+}++#[derive(Clone, Debug, Deserialize)]+pub struct FocusBordersConfig {+ /// Border of the focused window.+ pub active: FocusBorder,++ /// Border of non-focused windows.+ pub inactive: FocusBorder,+}++#[derive(Clone, Debug, Deserialize)]+pub struct FocusBorder {+ /// Whether to use a custom border color.+ pub enabled: bool,++ /// Border color of the window.+ pub color: String,+}++#[derive(Clone, Debug, Deserialize)]+pub struct GapsConfig {+ /// Gap between adjacent windows.+ pub inner_gap: LengthValue,++ /// Gap between windows and the screen edge.+ pub outer_gap: RectDelta,+}++#[derive(Clone, Debug, Deserialize)]+pub struct GeneralConfig {+ /// Center the cursor in the middle of a newly focused window.+ pub cursor_follows_focus: bool,++ /// Focus the window directly under the cursor at all times.+ 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.+ 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)]+pub struct KeybindingConfig {+ /// Keyboard shortcut to trigger the keybinding.+ pub bindings: Vec<String>,++ /// WM commands to run when the keybinding is triggered.+ pub commands: Vec<InvokeCommand>,+}++#[derive(Clone, Debug, Deserialize)]+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)]+pub struct WindowStateDefaultsConfig {+ pub floating: FloatingStateConfig,+ pub fullscreen: FullscreenStateConfig,+}++#[derive(Clone, Debug, Deserialize, PartialEq)]+pub struct FloatingStateConfig {+ /// Whether to center new floating windows.+ pub centered: bool,++ /// Whether to show floating windows as always on top.+ pub show_on_top: bool,+}++#[derive(Clone, Debug, Deserialize, PartialEq)]+pub struct FullscreenStateConfig {+ /// Whether to prefer fullscreen windows to be maximized.+ pub maximized: bool,++ /// Whether to show fullscreen windows as always on top.+ pub show_on_top: bool,++ /// Whether to remove the window's title bar when fullscreen.+ pub remove_title_bar: bool,+}++#[derive(Clone, Debug, Deserialize)]+pub struct WorkspaceConfig {+ pub name: String,+ pub display_name: Option<String>,+ pub bind_to_monitor: Option<String>,+ pub keep_alive: Option<bool>,+}diff --git a/packages/wm/src/windows/commands/manage_window.rs b/packages/wm/src/windows/commands/manage_window.rsindex 791f0a0b..944d7d83 100644--- a/packages/wm/src/windows/commands/manage_window.rs+++ b/packages/wm/src/windows/commands/manage_window.rs@@ -89,11 +89,12 @@ fn create_window(.displayed_workspace().context("No nearest workspace.")?;- // 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.+ // 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 floating_placement = if nearest_workspace.id()== target_workspace.id()- && !config.value.general.center_new_floating_windows+ && !config.value.window_state_defaults.floating.centered{native_window.placement()} else {@@ -102,20 +103,7 @@ fn create_window(.translate_to_center(&target_workspace.to_rect()?)};- let window_state = window_state_to_create(&native_window);-- // TODO: Instead always use None and move this logic to handler for- // toggling minimized state.- let prev_window_state = match window_state {- WindowState::Minimized => {- if native_window.is_resizable() {- Some(WindowState::Tiling)- } else {- Some(WindowState::Floating)- }- }- _ => None,- };+ let window_state = window_state_to_create(&native_window, config);let window_container: WindowContainer = match window_state {WindowState::Tiling => TilingWindow::new(@@ -129,7 +117,7 @@ fn create_window(None,native_window,window_state,- prev_window_state,+ None,None,floating_placement,)@@ -153,16 +141,28 @@ fn create_window(Ok(window_container)}+/// Gets the initial state for a window based on its native state.+////// Note that maximized windows are initialized as tiling.-/// TODO: Handle detection of fullscreen windows.-fn window_state_to_create(native_window: &NativeWindow) -> WindowState {+fn window_state_to_create(+ native_window: &NativeWindow,+ config: &UserConfig,+) -> WindowState {if native_window.is_minimized() {return WindowState::Minimized;}+ if native_window.is_fullscreen() {+ return WindowState::Fullscreen(+ config.value.window_state_defaults.fullscreen.clone(),+ );+ }+// Initialize windows that can't be resized as floating.if !native_window.is_resizable() {- return WindowState::Floating;+ return WindowState::Floating(+ config.value.window_state_defaults.floating.clone(),+ );}WindowState::Tiling@@ -174,12 +174,11 @@ fn insertion_target(let focused_container =state.focused_container().context("No focused container.")?;- if focused_container.is_workspace() {- Ok((focused_container, 0))- } else {- Ok((+ match focused_container.is_workspace() {+ true => Ok((focused_container, 0)),+ false => Ok((focused_container.parent().context("No insertion target.")?,focused_container.index() + 1,- ))+ )),}}diff --git a/packages/wm/src/windows/commands/update_window_state.rs b/packages/wm/src/windows/commands/update_window_state.rsindex 1517087a..1d8672da 100644--- a/packages/wm/src/windows/commands/update_window_state.rs+++ b/packages/wm/src/windows/commands/update_window_state.rs@@ -15,7 +15,7 @@ pub fn update_window_state(window: WindowContainer,window_state: WindowState,state: &mut WmState,- config: &mut UserConfig,+ config: &UserConfig,) -> anyhow::Result<()> {if window.state() == window_state {return Ok(());@@ -30,7 +30,7 @@ pub fn update_window_state(fn set_tiling(window: WindowContainer,state: &mut WmState,- config: &mut UserConfig,+ config: &UserConfig,) -> anyhow::Result<()> {if let WindowContainer::NonTilingWindow(window) = window {let workspace = windowdiff --git a/packages/wm/src/windows/window_state.rs b/packages/wm/src/windows/window_state.rsindex 4e4f4a44..1d641dcf 100644--- a/packages/wm/src/windows/window_state.rs+++ b/packages/wm/src/windows/window_state.rs@@ -1,8 +1,10 @@+use crate::user_config::{FloatingStateConfig, FullscreenStateConfig};+/// Represents the various states a window can be in.#[derive(Clone, Debug, PartialEq)]pub enum WindowState {- Floating,- Fullscreen,+ Floating(FloatingStateConfig),+ Fullscreen(FullscreenStateConfig),Minimized,Tiling,}diff --git a/packages/wm/src/wm.rs b/packages/wm/src/wm.rsindex 07af8615..9255ce31 100644--- a/packages/wm/src/wm.rs+++ b/packages/wm/src/wm.rs@@ -82,7 +82,7 @@ impl WindowManager {_ => Ok(()),}?;- redraw(&mut state, config)?;+ redraw(&mut state)?;sync_native_focus(&mut state)?;Ok(())@@ -118,7 +118,7 @@ impl WindowManager {}}- redraw(&mut state, config)?;+ redraw(&mut state)?;sync_native_focus(&mut state)?;Ok(())diff --git a/packages/wm/src/wm_state.rs b/packages/wm/src/wm_state.rsindex c175aa6c..a51f0bd9 100644--- a/packages/wm/src/wm_state.rs+++ b/packages/wm/src/wm_state.rs@@ -44,11 +44,6 @@ pub struct WmState {/// Names of any currently enabled binding modes.pub binding_modes: Vec<String>,- /// Any appbar windows (application desktop toolbars) that have been- /// detected. Positioning changes of appbars can affect the working area- /// of the parent monitor, and requires windows to be redrawn.- pub app_bar_windows: Vec<NativeWindow>,-/// Sender for emitting WM-related events.event_tx: mpsc::UnboundedSender<WmEvent>,}@@ -62,7 +57,6 @@ impl WmState {active_border_window: None,unmanaged_or_minimized_timestamp: None,binding_modes: Vec::new(),- app_bar_windows: Vec::new(),event_tx,}}@@ -80,11 +74,6 @@ impl WmState {}for native_window in Platform::manageable_windows()? {- // Register appbar windows.- if native_window.is_app_bar() {- self.app_bar_windows.push(native_window.clone());- }-let nearest_workspace = self.nearest_monitor(&native_window).and_then(|m| m.displayed_workspace());@@ -109,7 +98,7 @@ impl WmState {set_focused_descendant(container_to_focus, None);self.has_pending_focus_sync = true;- redraw(self, config)?;+ redraw(self)?;sync_native_focus(self)?;Ok(())@@ -179,7 +168,7 @@ impl WmState {/// Gets windows that should be redrawn.///- /// When redrawing after a command that changes a window's type (eg.+ /// When redrawing after a command that changes a window's type (e.g./// tiling -> floating), the original detached window might still be/// queued for a redraw and should be ignored.pub fn windows_to_redraw(&self) -> Vec<WindowContainer> {diff --git a/resources/sample-config.yaml b/resources/sample-config.yamlindex a69179f2..7b0abc50 100644--- a/resources/sample-config.yaml+++ b/resources/sample-config.yaml@@ -5,24 +5,10 @@ general:# Whether to jump the cursor between windows focused by the WM.cursor_follows_focus: false- # Whether to switch back and forth between the previously focused workspace- # when focusing the current workspace.+ # Whether to switch back and forth between the previously focused+ # workspace when focusing the current workspace.toggle_workspace_on_refocus: true- # Whether to show floating windows as always on top.- show_floating_on_top: false-- # Amount to move floating windows by (eg. when using `alt+<hjkl>` on a floating window)- floating_window_move_amount: '5%'-- # Whether to center new floating windows by default.- center_new_floating_windows: true-- # *Strongly* recommended to set to 'false'. Whether to globally enable/disable- # window transition animations (on minimize, close, etc). Set to 'unchanged'- # to make no setting changes.- window_animations: 'unchanged'-gaps:# Gap between adjacent windows.inner_gap: '20px'@@ -36,7 +22,6 @@ focus_borders:active:enabled: truecolor: '#0000ff'-inactive:enabled: falsecolor: '#ff0000'@@ -53,22 +38,25 @@ workspaces:- name: '9'window_rules:- # Task Manager requires admin privileges to manage and should be ignored unless running- # the WM as admin.+ # Task Manager requires admin privileges to manage and should be ignored+ # unless running the WM as admin.- commands: ['ignore']match_process_name: '/Taskmgr|ScreenClippingHost/'- # Launches system dialogs as floating by default (eg. File Explorer save/open dialog).+ # Launches system dialogs as floating by default (e.g. File Explorer save+ # and open dialog).- commands: ['set_floating']match_class_name: '#32770'- # Do not manage picture-in-picture windows for browsers. Note that the default is for- # English; change `match_title` to the window's title if you use another language.+ # Do not manage picture-in-picture windows for browsers. Note that the+ # default is for English; change `match_title` to the window's title if+ # you use another language.- commands: ['ignore']match_title: '[Pp]icture.in.[Pp]icture'match_class_name: 'Chrome_WidgetWin_1|MozillaDialogClass'- # Some applications (eg. Steam) have borders that extend past the normal border size.+ # Some applications (e.g. Steam) have borders that extend past the normal+ # border size.- commands: ['adjust_borders --right -7px --bottom -7px --left -7px']match_process_name: 'steam'@@ -119,12 +107,14 @@ keybindings:- commands: ['resize --height -2%']bindings: ['Alt+I']- # As an alternative to the resize keybindings above, resize mode enables resizing via- # HJKL or arrow keys. The binding mode is defined above with the name 'resize'.+ # As an alternative to the resize keybindings above, resize mode enables+ # resizing via HJKL or arrow keys. The binding mode is defined above with+ # the name 'resize'.- commands: ['wm_enable_binding_mode --name resize']bindings: ['Alt+R']- # Change tiling direction. This determines where new tiling windows will be inserted.+ # Change tiling direction. This determines where new tiling windows will+ # be inserted.- commands: ['toggle_tiling_direction']bindings: ['Alt+V']@@ -156,8 +146,9 @@ keybindings:- commands: ['wm_reload_config']bindings: ['Alt+Shift+R']- # Launch CMD terminal (alternatively `exec wt` or `exec %ProgramFiles%/Git/git-bash.exe`- # to start Windows Terminal and Git Bash respectively.+ # Launch CMD terminal. Alternatively `shell_exec --command wt` or+ # `shell_exec --command %ProgramFiles%/Git/git-bash.exe` to start Windows+ # Terminal and Git Bash respectively.- commands: ['shell_exec --command cmd']bindings: ['Alt+Enter']@@ -191,7 +182,8 @@ keybindings:- commands: ['focus --workspace 9']bindings: ['Alt+9']- # Move the focused window's parent workspace to a monitor in a given direction.+ # Move the focused window's parent workspace to a monitor in a given+ # direction.- commands: ['move_workspace --dir left']bindings: ['Alt+A']- commands: ['move_workspace --dir right']