input: Don't test keyboard/pointer/touch pointers
Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.
This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
diff --git a/src/main.c b/src/main.c
index 0017ab5..4acb913 100644
--- a/src/main.c
+++ b/src/main.c
@@ -798,8 +798,11 @@
weston_config_section_get_bool(section, "numlock-on", &numlock_on, 0);
if (numlock_on) {
wl_list_for_each(seat, &ec->seat_list, link) {
- if (seat->keyboard)
- weston_keyboard_set_locks(seat->keyboard,
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(seat);
+
+ if (keyboard)
+ weston_keyboard_set_locks(keyboard,
WESTON_NUM_LOCK,
WESTON_NUM_LOCK);
}