GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
added set_active_window_border and center_cursor_on_container.rs
holby56d9e90f525f
diff --git a/Cargo.lock b/Cargo.lockindex f0937869..4f36f839 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1277,5 +1277,6 @@ dependencies = ["tracing-subscriber","uuid","watcher",+ "winapi","windows",]diff --git a/packages/wm/Cargo.toml b/packages/wm/Cargo.tomlindex c9fcc728..a4f0b3a3 100644--- a/packages/wm/Cargo.toml+++ b/packages/wm/Cargo.toml@@ -25,3 +25,4 @@ tokio-tungstenite = "0.21"tracing = "0.1"tracing-subscriber = { version = "0.3", features = ["env-filter"] }windows = { workspace = true }+winapi = { version = "0.3.9", features = ["dwmapi", "windef", "ntdef", "minwindef", "winuser"] }diff --git a/packages/wm/src/containers/commands/center_cursor_on_container.rs b/packages/wm/src/containers/commands/center_cursor_on_container.rsnew file mode 100644index 00000000..eac4b1c6--- /dev/null+++ b/packages/wm/src/containers/commands/center_cursor_on_container.rs@@ -0,0 +1,29 @@+extern crate winapi;++use winapi::um::winuser::SetCursorPos;+use anyhow::{Result, Error};+use crate::containers::{Container, SplitContainer};+use crate::containers::traits::PositionGetters;++pub fn center_cursor_on_container(+ target: &Container+) -> Result<(), Error> {+ // do i pull from user config here or is that handled elsewhere?+ let is_enabled = true;++ // target is currently missing is_detached and focus_index+ // if !is_enabled || target.is_detached() || target.focus_index < 0 {+ if !is_enabled {+ return Ok(());+ }++ // Calculate center point of focused window.+ let center_x = target.x()? + (target.width()? / 2);+ let center_y = target.y()? + (target.height()? / 2);++ unsafe {+ SetCursorPos(center_x, center_y);+ }++ Ok(())+}\ No newline at end of filediff --git a/packages/wm/src/containers/commands/exec_process.rs b/packages/wm/src/containers/commands/exec_process.rsnew file mode 100644index 00000000..cced356d--- /dev/null+++ b/packages/wm/src/containers/commands/exec_process.rs@@ -0,0 +1,21 @@+use std::process::Command;+use std::env;+use anyhow::{Result, Context};++pub fn exec_process(process_name: &str, args: &[String]) -> Result<()> {++ let output = Command::new(process_name)+ .args(args) // pass the args vector directly+ .current_dir(env::var("USERPROFILE")+ .context("Failed to get environment variable for user profile directory")?)+ .output()+ .context("Failed to execute command")?;++ if !output.status.success() {+ eprintln!("Error: {}", String::from_utf8_lossy(&output.stderr));+ return Err(anyhow::anyhow!("Process execution failed"));+ }++ Ok(())+}+diff --git a/packages/wm/src/containers/commands/mod.rs b/packages/wm/src/containers/commands/mod.rsindex 63ebb916..27474cc8 100644--- a/packages/wm/src/containers/commands/mod.rs+++ b/packages/wm/src/containers/commands/mod.rs@@ -1,11 +1,17 @@mod attach_container;+mod center_cursor_on_container;+mod exec_process;mod flatten_split_container;mod redraw;mod resize_tiling_container;+mod set_active_window_border;mod set_focused_descendant;pub use attach_container::*;+pub use center_cursor_on_container::*;+pub use exec_process::*;pub use flatten_split_container::*;pub use redraw::*;pub use resize_tiling_container::*;+pub use set_active_window_border::*;pub use set_focused_descendant::*;diff --git a/packages/wm/src/containers/commands/set_active_window_border.rs b/packages/wm/src/containers/commands/set_active_window_border.rsnew file mode 100644index 00000000..4133d723--- /dev/null+++ b/packages/wm/src/containers/commands/set_active_window_border.rs@@ -0,0 +1,17 @@+extern crate winapi;++use std::convert::TryInto;+use std::ptr;+use winapi::um::dwmapi::DwmSetWindowAttribute;+use winapi::shared::windef::HWND;+use winapi::shared::minwindef::DWORD;+use winapi::shared::ntdef::PVOID;+use anyhow::{Result, Error};+use crate::containers::Container;++pub fn handle_set_active_window_border(+ target: Container+) -> Result<(), Error> {++ Ok(())+}\ No newline at end of file