changed stuff

This commit is contained in:
Thomas Hain
2025-04-09 22:40:54 +02:00
parent ee37e61be5
commit c1262d296a
3 changed files with 46 additions and 17 deletions
Regular → Executable
View File
+32 -3
View File
@@ -42,15 +42,15 @@ async fn main() {
.unwrap();
while let Some(event) = workspace_event_rx.recv().await {
if let SwayEvent::Window(window_event) = event {
if let WindowChangeType::New = window_event.change {
let sway_ipc_clone = sway_ipc.clone();
// Handle the new layout setup
let root = sway_ipc_clone.get_tree().await.unwrap();
let workspaces = sway_ipc_clone.get_workspaces().await.unwrap();
let leaves = get_current_leaves_here(&root, &workspaces);
if let SwayEvent::Window(window_event) = event {
match window_event.change {
WindowChangeType::New => {
if let (Some(first), Some(second)) = (leaves.first(), leaves.get(1)) {
let mut command = format!("[con_id={}] splith", first.id);
match leaves.get(2) {
@@ -67,6 +67,35 @@ async fn main() {
sway_ipc_clone.run_command(command).await.unwrap();
}
}
WindowChangeType::Close => {
println!("❌ Window closed: ID {}", window_event.container.id);
if let Some(master) = leaves.first() {
println!("🔍 Current Master ID before closing: {}", master.id);
} else {
println!("⚠️ No Master found in current workspace!");
}
if leaves
.first()
.map_or(false, |master| master.id == window_event.container.id)
{
println!("🔥 Master was closed! Promoting next container...");
let command = "
focus right;
layout splitv;
focus left;
move up;
layout splith;
";
sway_ipc_clone.run_command(command.to_string()).await.unwrap();
} else {
println!("✅ Closed window was NOT the Master. No action needed.");
}
}
_ => {}
}
}
}
}
Regular → Executable
View File