diff options
| author | lualeet <43719546+lualeet@users.noreply.github.com> | 2025-03-29 10:13:59 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-29 10:13:59 +0000 |
| commit | 8d43efe4ac38ddb6ce298d6fbdfc3ec610b8da56 (patch) | |
| tree | 8ae0d0fd527de6f26599d6357ba9c5d11ec2c518 /src | |
| parent | 3bb7e603115d59441a700deadf11d9fd834386ea (diff) | |
| download | niri-8d43efe4ac38ddb6ce298d6fbdfc3ec610b8da56.tar.gz niri-8d43efe4ac38ddb6ce298d6fbdfc3ec610b8da56.tar.bz2 niri-8d43efe4ac38ddb6ce298d6fbdfc3ec610b8da56.zip | |
Add option 'focus-at-startup' to focus a chosen output on start (#1323)
* Implement default-output
* Fix incorrect wiki string
* Center mouse on start
* Move default-output to Output.focus-at-startup
* fixes
---------
Co-authored-by: lualeet <lualeet@null.null>
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/niri.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/niri.rs b/src/niri.rs index 35c8b2d7..14c48f17 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -630,6 +630,8 @@ impl State { state.load_xkb_file(); // Initialize some IPC server state. state.ipc_keyboard_layouts_changed(); + // Focus the default monitor if set by the user. + state.focus_default_monitor(); Ok(state) } @@ -794,6 +796,29 @@ impl State { rv } + pub fn focus_default_monitor(&mut self) { + // Our default target is the first output in sorted order. + let Some(mut target) = self.niri.sorted_outputs.first().cloned() else { + // No outputs are connected. + return; + }; + + let config = self.niri.config.borrow(); + for config in &config.outputs.0 { + if !config.focus_at_startup { + continue; + } + if let Some(output) = self.niri.output_by_name_match(&config.name) { + target = output.clone(); + break; + } + } + drop(config); + + self.niri.layout.focus_output(&target); + self.move_cursor_to_output(&target); + } + /// Focus a specific window, taking care of a potential active output change and cursor /// warp. pub fn focus_window(&mut self, window: &Window) { |
