Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix/fix_mouse_drag
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCoduriV committed Aug 12, 2024
2 parents 6c7aded + f87c2b3 commit cfd73a5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@ workspaces:
keep_alive: false
```
### Config: Window rules
Commands can be run when a window is first launched. This is useful for adding window-specific behaviors like always starting a window as fullscreen, or assigning to a specific workspace.
Windows can be targeted by their process, class, and title. Multiple matching criteria can be used together to target a window more precisely.
```yaml
window_rules:
- commands: ["move --workspace 1"]
match:
# Move browsers to workspace 1.
- window_process: { regex: "msedge|brave|chrome" }

- commands: ["ignore"]
match:
# Ignores any Zebar windows.
- window_process: { equals: "zebar" }

# Ignores picture-in-picture windows for browsers.
# Note that *both* the title and class must match for the rule to run.
- window_title: { regex: "[Pp]icture.in.[Pp]icture" }
window_class: { regex: "Chrome_WidgetWin_1|MozillaDialogClass" }
```
### Config: Window effects
Visual effects can be applied to windows via the `window_effects` option. Currently, colored borders are the only effect available with more to come in the future.
Expand Down
29 changes: 16 additions & 13 deletions packages/wm/src/common/platform/native_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit cfd73a5

Please sign in to comment.