Skip to content

Commit

Permalink
optimize window state synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamMaoMao committed Nov 7, 2024
1 parent 56de6b5 commit bf1f9ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions packages/wm/src/app_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{iter, path::PathBuf};
use anyhow::{bail, Context};
use clap::{error::KindFormatter, Args, Parser, ValueEnum};
use serde::{Deserialize, Deserializer, Serialize};
use tokio::net::windows;
use tracing::{warn, Level};
use uuid::Uuid;

Expand All @@ -12,13 +11,14 @@ use crate::{
commands::{
cycle_focus, disable_binding_mode, enable_binding_mode,
reload_config, shell_exec,
}, Direction, LengthValue, Rect, RectDelta, TilingDirection
},
Direction, LengthValue, RectDelta, TilingDirection,
},
containers::{
commands::{
focus_in_direction, set_tiling_direction, toggle_tiling_direction,
},
traits::{CommonGetters, PositionGetters},
traits::CommonGetters,
Container,
},
monitors::commands::focus_monitor,
Expand Down Expand Up @@ -476,6 +476,17 @@ impl InvokeCommand {
let is_centered =
centered.unwrap_or(floating_defaults.centered);

let window = update_window_state(
window.clone(),
WindowState::Floating(FloatingStateConfig {
centered: is_centered,
shown_on_top: shown_on_top
.unwrap_or(floating_defaults.shown_on_top),
}),
state,
config,
)?;

if width.is_some() || height.is_some() {
set_window_size(window.clone(),
width.clone(),
Expand All @@ -490,17 +501,6 @@ impl InvokeCommand {
x_pos.clone(),
y_pos.clone(), state)?;
}

update_window_state(
window.clone(),
WindowState::Floating(FloatingStateConfig {
centered: is_centered,
shown_on_top: shown_on_top
.unwrap_or(floating_defaults.shown_on_top),
}),
state,
config,
)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wm/src/windows/commands/set_window_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn set_floating_window_position(
target_y_pos: Option<LengthValue>,
state: &mut WmState,
) -> anyhow::Result<()> {
let window_rect = window.to_rect()?;
let window_rect = window.floating_placement();

match centered {
true => {
Expand Down

0 comments on commit bf1f9ec

Please sign in to comment.