GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: set foreground window without simulating keypress (#672)
lars-bergerde8450ebb2ce
diff --git a/packages/wm/src/common/platform/native_window.rs b/packages/wm/src/common/platform/native_window.rsindex 906d4c22..22b8898c 100644--- a/packages/wm/src/common/platform/native_window.rs+++ b/packages/wm/src/common/platform/native_window.rs@@ -280,21 +280,24 @@ impl NativeWindow {}pub fn set_foreground(&self) -> anyhow::Result<()> {- // Simulate a key press event to activate the window.- let input = INPUT {- r#type: INPUT_KEYBOARD,- Anonymous: INPUT_0 {- ki: KEYBDINPUT {- wVk: VIRTUAL_KEY(0),- wScan: 0,- dwFlags: KEYBD_EVENT_FLAGS(0),- time: 0,- dwExtraInfo: 0,+ // UIAccess allows for setting the foreground window without needing to+ // send a key press event.+ #[cfg(not(feature = "ui_access"))]+ unsafe {+ let input = INPUT {+ r#type: INPUT_KEYBOARD,+ Anonymous: INPUT_0 {+ ki: KEYBDINPUT {+ wVk: VIRTUAL_KEY(1),+ wScan: 0,+ dwFlags: KEYBD_EVENT_FLAGS(0),+ time: 0,+ dwExtraInfo: 0,+ },},- },- };+ };- unsafe {+ // Simulate a key press event to activate the window.SendInput(&[input], std::mem::size_of::<INPUT>() as i32);}