[PATCH weston 10/17] evdev: don't crash on missing keyboard

Pekka Paalanen ppaalanen at gmail.com
Thu Jul 5 03:33:07 PDT 2012


Weston's notify_keyboard_focus() assumes that a keyboard is present, if
it is called. With evdev, there might not always be a keyboard.

Also clean up the variable definition. I read this function through many
times and finally had to grep where does 'all_keys' come from.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 src/evdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index d6d23a6..185f767 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -532,10 +532,14 @@ evdev_notify_keyboard_focus(struct evdev_seat *seat)
 	struct evdev_input_device *device;
 	struct wl_array keys;
 	unsigned int i, set;
-	char evdev_keys[(KEY_CNT + 7) / 8], all_keys[(KEY_CNT + 7) / 8];
+	char evdev_keys[(KEY_CNT + 7) / 8];
+	char all_keys[(KEY_CNT + 7) / 8];
 	uint32_t *k;
 	int ret;
 
+	if (!seat->base.seat.keyboard)
+		return;
+
 	memset(all_keys, 0, sizeof all_keys);
 	wl_list_for_each(device, &seat->devices_list, link) {
 		memset(evdev_keys, 0, sizeof evdev_keys);
-- 
1.7.8.6



More information about the wayland-devel mailing list