input: store the grab serial of the keyboard

The serial can be checked against the one passed to wl_shell.set_popup
or equivalent.
Reviewed-by: Daniel Stone <daniels@collabora.com>
diff --git a/src/input.c b/src/input.c
index c039af0..3867de2 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1321,8 +1321,6 @@
 
 	if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
 		weston_compositor_idle_inhibit(compositor);
-		keyboard->grab_key = key;
-		keyboard->grab_time = time;
 	} else {
 		weston_compositor_idle_release(compositor);
 	}
@@ -1361,6 +1359,13 @@
 				      key,
 				      state);
 	}
+
+	if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+		keyboard->grab_serial =
+			wl_display_get_serial(compositor->wl_display);
+		keyboard->grab_time = time;
+		keyboard->grab_key = key;
+	}
 }
 
 WL_EXPORT void