Skip to content

Commit

Permalink
actually implement wl_keyboard::modifiers in wayland backend
Browse files Browse the repository at this point in the history
made possible thanks to Smithay/smithay#1597
  • Loading branch information
sodiboo committed Nov 23, 2024
1 parent 3a0fdfb commit 8c1a0c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/backend/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ impl WaylandBackend {
// This is set to false upon wl_pointer::enter.
niri.pointer_hidden = true;

// This disables our interpretation of keyboard modifiers upon keypresses.
// We blindly listen to the outer compositor's keyboard state.
// and only ever update ours on wl_keyboard::modifiers.
niri.seat.get_keyboard().unwrap().set_update_key(false);

let renderer = self.graphics.renderer();
if let Err(err) = renderer.bind_wl_display(&niri.display_handle) {
warn!("error binding renderer wl_display: {err}");
Expand Down
20 changes: 15 additions & 5 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,22 @@ impl ProcessSpecialEvent<WaylandInputBackend> for State {

self.niri.compositor_has_keyboard_focus = false;
}
WaylandInputSpecialEvent::KeyboardModifiers { .. } => {
WaylandInputSpecialEvent::KeyboardModifiers {
depressed,
latched,
locked,
group,
..
} => {
// why is this called "group" in wl_keyboard but "layout" in smithay?
let layout = smithay::input::keyboard::Layout(group);

let keyboard = self.niri.seat.get_keyboard().unwrap();
keyboard.with_xkb_state(self, |ctx| {
// bitch. it's private. can't have shit in detroit
// ctx.state.update_mask()
let _ = ctx;

// called once in the wayland backend's init() method
// keyboard.set_update_key(false);
keyboard.with_xkb_state(self, |mut xkb| {
xkb.update_mask(depressed, latched, locked, layout);
});
}
WaylandInputSpecialEvent::KeyboardKeymap { .. } => {
Expand Down

0 comments on commit 8c1a0c5

Please sign in to comment.