File 0000-ignore-password-submission-before-locked-event.patch of Package waylock

From 75b8dbec79c3276a6a95b8581ae463e61a919be8 Mon Sep 17 00:00:00 2001
From: Isaac Freund <mail@isaacfreund.com>
Date: Wed, 18 Jan 2023 12:53:16 +0100
Subject: [PATCH] Lock: ignore password submission before locked event

---
 src/Seat.zig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/Seat.zig b/src/Seat.zig
index 9656e90..e7bcc38 100644
--- a/src/Seat.zig
+++ b/src/Seat.zig
@@ -157,7 +157,14 @@ fn keyboard_listener(_: *wl.Keyboard, event: wl.Keyboard.Event, seat: *Seat) voi
 
             switch (@enumToInt(keysym)) {
                 xkb.Keysym.Return => {
-                    lock.submit_password();
+                    // Ignore the attempt to submit the password if the locked event has not yet
+                    // been received. This should be pretty much impossible to happen in practice
+                    // as the compositor should send the locked event in a matter of milliseconds.
+                    // However if the compositor is behaving strangely it is better to ignore this
+                    // than crash on an assertion failure or commit a protocol error.
+                    if (lock.state == .locked) {
+                        lock.submit_password();
+                    }
                     return;
                 },
                 xkb.Keysym.Escape => {
openSUSE Build Service is sponsored by