Skip to content

Commit

Permalink
Seat: don't set input color if no character input
Browse files Browse the repository at this point in the history
If for example "shift" is pressed, there is no character input
(delta==0), and we avoid setting the input color. Nothing was input.
  • Loading branch information
quite authored and ifreund committed Oct 26, 2023
1 parent b9bd798 commit 5474e48
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Seat.zig
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,14 @@ fn keyboard_listener(_: *wl.Keyboard, event: wl.Keyboard.Event, seat: *Seat) voi

const xkb_state = seat.xkb_state orelse return;

const lock = seat.lock;
lock.set_color(.input);

// The wayland protocol gives us an input event code. To convert this to an xkb
// keycode we must add 8.
const keycode = ev.key + 8;

const keysym = xkb_state.keyGetOneSym(keycode);
if (keysym == .NoSymbol) return;

const lock = seat.lock;
switch (@intFromEnum(keysym)) {
xkb.Keysym.Return => {
// Ignore the attempt to submit the password if the locked event has not yet
Expand Down Expand Up @@ -189,6 +187,9 @@ fn keyboard_listener(_: *wl.Keyboard, event: wl.Keyboard.Event, seat: *Seat) voi
}
// If key was not handled, write to password buffer
const delta = xkb_state.keyGetUtf8(keycode, lock.password.unused_slice());
if (delta > 0) {
lock.set_color(.input);
}
lock.password.grow(delta) catch log.err("password exceeds 1024 byte limit", .{});
},
.repeat_info => {},
Expand Down

0 comments on commit 5474e48

Please sign in to comment.