feat(wm): optionally await config completion

This commit introduces a new flag to komorebi and komorebic,
--await-configuration, which when enabled, will stop the process from
processing window manager events and updating the layout until the
'komorebic complete-configuration' command has been sent.

This should typically be added at the end of a user's komorebi.ahk
configuration file if they decide to enable this feature.

resolve #190
This commit is contained in:
LGUG2Z
2022-07-26 12:38:17 -07:00
parent 5b91e22114
commit a6d46dbf45
10 changed files with 90 additions and 29 deletions

View File

@@ -396,8 +396,11 @@ struct FocusFollowsMouse {
#[derive(Parser, AhkFunction)]
struct Start {
/// Allow the use of komorebi's custom focus-follows-mouse implementation
#[clap(long)]
#[clap(action, short, long = "ffm")]
ffm: bool,
/// Wait for 'komorebic complete-configuration' to be sent before processing events
#[clap(action, short, long)]
await_configuration: bool,
}
#[derive(Parser, AhkFunction)]
@@ -627,6 +630,8 @@ enum SubCommand {
/// Enable or disable watching of ~/komorebi.ahk (if it exists)
#[clap(arg_required_else_help = true)]
WatchConfiguration(WatchConfiguration),
/// Signal that the final configuration option has been sent
CompleteConfiguration,
/// Set the window behaviour when switching workspaces / cycling stacks
#[clap(arg_required_else_help = true)]
WindowHidingBehaviour(WindowHidingBehaviour),
@@ -910,19 +915,33 @@ fn main() -> Result<()> {
let script = exec.map_or_else(
|| {
if arg.ffm {
String::from(
"Start-Process komorebi.exe -ArgumentList '--ffm' -WindowStyle hidden",
if arg.ffm | arg.await_configuration {
format!(
"Start-Process komorebi.exe -ArgumentList {} -WindowStyle hidden",
if arg.ffm && arg.await_configuration {
"'--ffm','--await-configuration'"
} else if arg.ffm {
"'--ffm'"
} else {
"'--await-configuration'"
}
)
} else {
String::from("Start-Process komorebi.exe -WindowStyle hidden")
}
},
|exec| {
if arg.ffm {
if arg.ffm | arg.await_configuration {
format!(
"Start-Process '{}' -ArgumentList '--ffm' -WindowStyle hidden",
exec
"Start-Process '{}' -ArgumentList {} -WindowStyle hidden",
exec,
if arg.ffm && arg.await_configuration {
"'--ffm','--await-configuration'"
} else if arg.ffm {
"'--ffm'"
} else {
"'--await-configuration'"
}
)
} else {
format!("Start-Process '{}' -WindowStyle hidden", exec)
@@ -1107,6 +1126,9 @@ fn main() -> Result<()> {
SubCommand::WatchConfiguration(arg) => {
send_message(&SocketMessage::WatchConfiguration(arg.boolean_state.into()).as_bytes()?)?;
}
SubCommand::CompleteConfiguration => {
send_message(&SocketMessage::CompleteConfiguration.as_bytes()?)?;
}
SubCommand::IdentifyObjectNameChangeApplication(target) => {
send_message(
&SocketMessage::IdentifyObjectNameChangeApplication(target.identifier, target.id)