diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-29 22:48:24 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-30 12:30:57 +0400 |
| commit | deef52519a237a290bee6ded8aec7dbaac1e8e9a (patch) | |
| tree | f07b19c52096e7ea811dc4d8705a76dfe9b33a8d /src/protocols | |
| parent | 59ff331597633dc66113e5070d672ba70035421b (diff) | |
| download | niri-deef52519a237a290bee6ded8aec7dbaac1e8e9a.tar.gz niri-deef52519a237a290bee6ded8aec7dbaac1e8e9a.tar.bz2 niri-deef52519a237a290bee6ded8aec7dbaac1e8e9a.zip | |
foreign_toplevel: Change activated to mean keyboard focus
Diffstat (limited to 'src/protocols')
| -rw-r--r-- | src/protocols/foreign_toplevel.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/protocols/foreign_toplevel.rs b/src/protocols/foreign_toplevel.rs index 88e2f13f..f628dc0d 100644 --- a/src/protocols/foreign_toplevel.rs +++ b/src/protocols/foreign_toplevel.rs @@ -100,7 +100,8 @@ pub fn refresh(state: &mut State) { .lock() .unwrap(); - let states = foreign_toplevel_state(&role.current.states); + let has_focus = state.niri.keyboard_focus.as_ref() == Some(wl_surface); + let states = to_state_vec(&role.current.states, has_focus); match protocol_state.toplevels.entry(wl_surface.clone()) { Entry::Occupied(entry) => { @@ -387,17 +388,27 @@ where } } -fn foreign_toplevel_state(states: &ToplevelStateSet) -> ArrayVec<u32, 3> { +fn to_state_vec(states: &ToplevelStateSet, has_focus: bool) -> ArrayVec<u32, 3> { let mut rv = ArrayVec::new(); if states.contains(xdg_toplevel::State::Maximized) { rv.push(zwlr_foreign_toplevel_handle_v1::State::Maximized as u32); } - if states.contains(xdg_toplevel::State::Activated) { - rv.push(zwlr_foreign_toplevel_handle_v1::State::Activated as u32); - } if states.contains(xdg_toplevel::State::Fullscreen) { rv.push(zwlr_foreign_toplevel_handle_v1::State::Fullscreen as u32); } + + // HACK: wlr-foreign-toplevel-management states: + // + // These have the same meaning as the states with the same names defined in xdg-toplevel + // + // However, clients such as sfwbar and fcitx seem to treat the activated state as keyboard + // focus, i.e. they don't expect multiple windows to have it set at once. Even Waybar which + // handles multiple activated windows correctly uses it in its design in such a way that + // keyboard focus would make more sense. Let's do what the clients expect. + if has_focus { + rv.push(zwlr_foreign_toplevel_handle_v1::State::Activated as u32); + } + rv } |
