[PATCH libinput 2/3] Don't post a events for a missing capability
Peter Hutterer
peter.hutterer at who-t.net
Sun Apr 12 17:23:46 PDT 2015
Log a bug instead.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/libinput.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/src/libinput.c b/src/libinput.c
index 8014457..bcb2509 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1065,6 +1065,35 @@ notify_removed_device(struct libinput_device *device)
&removed_device_event->base);
}
+static inline bool
+device_has_cap(struct libinput_device *device,
+ enum libinput_device_capability cap)
+{
+ const char *capability;
+
+ if (libinput_device_has_capability(device, cap))
+ return true;
+
+ switch (cap) {
+ case LIBINPUT_DEVICE_CAP_POINTER:
+ capability = "CAP_POINTER";
+ break;
+ case LIBINPUT_DEVICE_CAP_KEYBOARD:
+ capability = "CAP_KEYBOARD";
+ break;
+ case LIBINPUT_DEVICE_CAP_TOUCH:
+ capability = "CAP_TOUCH";
+ break;
+ }
+
+ log_bug_libinput(device->seat->libinput,
+ "Event for missing capability %s on device \"%s\"\n",
+ capability,
+ libinput_device_get_name(device));
+
+ return false;
+}
+
void
keyboard_notify_key(struct libinput_device *device,
uint64_t time,
@@ -1074,6 +1103,9 @@ keyboard_notify_key(struct libinput_device *device,
struct libinput_event_keyboard *key_event;
uint32_t seat_key_count;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
+ return;
+
key_event = zalloc(sizeof *key_event);
if (!key_event)
return;
@@ -1100,6 +1132,9 @@ pointer_notify_motion(struct libinput_device *device,
{
struct libinput_event_pointer *motion_event;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+ return;
+
motion_event = zalloc(sizeof *motion_event);
if (!motion_event)
return;
@@ -1122,6 +1157,9 @@ pointer_notify_motion_absolute(struct libinput_device *device,
{
struct libinput_event_pointer *motion_absolute_event;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+ return;
+
motion_absolute_event = zalloc(sizeof *motion_absolute_event);
if (!motion_absolute_event)
return;
@@ -1145,6 +1183,9 @@ pointer_notify_button(struct libinput_device *device,
struct libinput_event_pointer *button_event;
int32_t seat_button_count;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+ return;
+
button_event = zalloc(sizeof *button_event);
if (!button_event)
return;
@@ -1175,6 +1216,9 @@ pointer_notify_axis(struct libinput_device *device,
{
struct libinput_event_pointer *axis_event;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+ return;
+
axis_event = zalloc(sizeof *axis_event);
if (!axis_event)
return;
@@ -1201,6 +1245,9 @@ touch_notify_touch_down(struct libinput_device *device,
{
struct libinput_event_touch *touch_event;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+ return;
+
touch_event = zalloc(sizeof *touch_event);
if (!touch_event)
return;
@@ -1226,6 +1273,9 @@ touch_notify_touch_motion(struct libinput_device *device,
{
struct libinput_event_touch *touch_event;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+ return;
+
touch_event = zalloc(sizeof *touch_event);
if (!touch_event)
return;
@@ -1250,6 +1300,9 @@ touch_notify_touch_up(struct libinput_device *device,
{
struct libinput_event_touch *touch_event;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+ return;
+
touch_event = zalloc(sizeof *touch_event);
if (!touch_event)
return;
@@ -1271,6 +1324,9 @@ touch_notify_frame(struct libinput_device *device,
{
struct libinput_event_touch *touch_event;
+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+ return;
+
touch_event = zalloc(sizeof *touch_event);
if (!touch_event)
return;
--
2.3.4
More information about the wayland-devel
mailing list