summaryrefslogtreecommitdiff
path: root/seat.c
diff options
context:
space:
mode:
authorConstantin <40324023+derconno@users.noreply.github.com>2026-07-09 17:47:35 +0200
committerGitHub <noreply@github.com>2026-07-09 17:47:35 +0200
commit8f80ee8cf527b80743b8c0d42f1623181811657c (patch)
tree98a8464c2306ad4600fa782906eac0c5cca98aea /seat.c
parent83319e5ec7ae13794ebf39f753d643a2a439f594 (diff)
Fix stray character in password buffer after suspend/resume cycle
Diffstat (limited to 'seat.c')
-rw-r--r--seat.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/seat.c b/seat.c
index 47d43eb..d503bd4 100644
--- a/seat.c
+++ b/seat.c
@@ -45,6 +45,13 @@ static void keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
state->xkb.state = xkb_state;
}
+static void stop_repeat(struct swaylock_seat *seat) {
+ if (seat->repeat_timer) {
+ loop_remove_timer(seat->state->eventloop, seat->repeat_timer);
+ seat->repeat_timer = NULL;
+ }
+}
+
static void keyboard_enter(void *data, struct wl_keyboard *wl_keyboard,
uint32_t serial, struct wl_surface *surface, struct wl_array *keys) {
// Who cares
@@ -52,7 +59,12 @@ static void keyboard_enter(void *data, struct wl_keyboard *wl_keyboard,
static void keyboard_leave(void *data, struct wl_keyboard *wl_keyboard,
uint32_t serial, struct wl_surface *surface) {
- // Who cares
+ // When focus leaves (e.g. the compositor takes it away across a
+ // suspend/DPMS transition) the protocol guarantees no release events for
+ // currently-held keys, so an armed key-repeat would otherwise linger and
+ // fire on resume, injecting a phantom character into the password buffer.
+ struct swaylock_seat *seat = data;
+ stop_repeat(seat);
}
static void keyboard_repeat(void *data) {
@@ -80,10 +92,7 @@ static void keyboard_key(void *data, struct wl_keyboard *wl_keyboard,
swaylock_handle_key(state, sym, codepoint);
}
- if (seat->repeat_timer) {
- loop_remove_timer(seat->state->eventloop, seat->repeat_timer);
- seat->repeat_timer = NULL;
- }
+ stop_repeat(seat);
if (key_state == WL_KEYBOARD_KEY_STATE_PRESSED && seat->repeat_period_ms > 0) {
seat->repeat_sym = sym;