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/compositor.h b/src/compositor.h
index b74f7e8..2654f8d 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -503,9 +503,9 @@
struct wl_list base_resource_list;
struct wl_global *global;
- struct weston_pointer *pointer;
- struct weston_keyboard *keyboard;
- struct weston_touch *touch;
+ struct weston_pointer *pointer_state;
+ struct weston_keyboard *keyboard_state;
+ struct weston_touch *touch_state;
int pointer_device_count;
int keyboard_device_count;
int touch_device_count;
@@ -1587,6 +1587,15 @@
const char *
weston_transform_to_string(uint32_t output_transform);
+struct weston_keyboard *
+weston_seat_get_keyboard(struct weston_seat *seat);
+
+struct weston_pointer *
+weston_seat_get_pointer(struct weston_seat *seat);
+
+struct weston_touch *
+weston_seat_get_touch(struct weston_seat *seat);
+
#ifdef __cplusplus
}
#endif