Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the --centered parameter does not take effect #809

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions packages/wm/src/app_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::{error::KindFormatter, Args, Parser, ValueEnum};
use serde::{Deserialize, Deserializer, Serialize};
use tracing::{warn, Level};
use uuid::Uuid;
use crate::containers::traits::PositionGetters;

use crate::{
common::{
Expand Down Expand Up @@ -446,10 +447,21 @@ impl InvokeCommand {
let floating_defaults =
&config.value.window_behavior.state_defaults.floating;

let is_centered = centered.unwrap_or(floating_defaults.centered);

if is_centered {
let workspace = window.workspace().context("no workspace find.")?;
window.set_floating_placement(
window
.floating_placement()
.translate_to_center(&workspace.to_rect()?),
);
}

update_window_state(
window.clone(),
WindowState::Floating(FloatingStateConfig {
centered: centered.unwrap_or(floating_defaults.centered),
centered: is_centered,
shown_on_top: shown_on_top
.unwrap_or(floating_defaults.shown_on_top),
}),
Expand Down Expand Up @@ -552,8 +564,19 @@ impl InvokeCommand {
let floating_defaults =
&config.value.window_behavior.state_defaults.floating;

let is_centered = centered.unwrap_or(floating_defaults.centered);

if is_centered {
let workspace = window.workspace().context("no workspace find.")?;
window.set_floating_placement(
window
.floating_placement()
.translate_to_center(&workspace.to_rect()?),
);
}

let target_state = WindowState::Floating(FloatingStateConfig {
centered: centered.unwrap_or(floating_defaults.centered),
centered: is_centered,
shown_on_top: shown_on_top
.unwrap_or(floating_defaults.shown_on_top),
});
Expand Down