evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
{
int32_t cx, cy;
+ li_fixed_t x, y;
int slot;
int seat_slot;
struct libinput_device *base = &device->base;
break;
seat->slot_map |= 1 << seat_slot;
+ x = li_fixed_from_int(device->mt.slots[slot].x);
+ y = li_fixed_from_int(device->mt.slots[slot].y);
- touch_notify_touch(base,
- time,
- slot,
- seat_slot,
- li_fixed_from_int(device->mt.slots[slot].x),
- li_fixed_from_int(device->mt.slots[slot].y),
- LIBINPUT_TOUCH_TYPE_DOWN);
+ touch_notify_touch_down(base, time, slot, seat_slot, x, y);
break;
case EVDEV_ABSOLUTE_MT_MOTION:
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
break;
seat_slot = device->mt.slots[slot].seat_slot;
+ x = li_fixed_from_int(device->mt.slots[slot].x);
+ y = li_fixed_from_int(device->mt.slots[slot].y);
if (seat_slot == -1)
break;
- touch_notify_touch(base,
- time,
- slot,
- seat_slot,
- li_fixed_from_int(device->mt.slots[slot].x),
- li_fixed_from_int(device->mt.slots[slot].y),
- LIBINPUT_TOUCH_TYPE_MOTION);
+ touch_notify_touch_motion(base, time, slot, seat_slot, x, y);
break;
case EVDEV_ABSOLUTE_MT_UP:
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
seat->slot_map &= ~(1 << seat_slot);
- touch_notify_touch(base,
- time,
- slot,
- seat_slot,
- 0, 0,
- LIBINPUT_TOUCH_TYPE_UP);
+ touch_notify_touch_up(base, time, slot, seat_slot);
break;
case EVDEV_ABSOLUTE_TOUCH_DOWN:
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
seat->slot_map |= 1 << seat_slot;
transform_absolute(device, &cx, &cy);
- touch_notify_touch(base,
- time,
- -1,
- seat_slot,
- li_fixed_from_int(cx),
- li_fixed_from_int(cy),
- LIBINPUT_TOUCH_TYPE_DOWN);
+ x = li_fixed_from_int(cx);
+ y = li_fixed_from_int(cy);
+
+ touch_notify_touch_down(base, time, -1, seat_slot, x, y);
break;
case EVDEV_ABSOLUTE_MOTION:
transform_absolute(device, &cx, &cy);
+ x = li_fixed_from_int(cx);
+ y = li_fixed_from_int(cy);
+
if (device->seat_caps & EVDEV_DEVICE_TOUCH) {
seat_slot = device->abs.seat_slot;
if (seat_slot == -1)
break;
- touch_notify_touch(base,
- time,
- -1,
- seat_slot,
- li_fixed_from_int(cx),
- li_fixed_from_int(cy),
- LIBINPUT_TOUCH_TYPE_DOWN);
+ touch_notify_touch_motion(base, time, -1, seat_slot, x, y);
} else if (device->seat_caps & EVDEV_DEVICE_POINTER) {
- pointer_notify_motion_absolute(base,
- time,
- li_fixed_from_int(cx),
- li_fixed_from_int(cy));
+ pointer_notify_motion_absolute(base, time, x, y);
}
break;
case EVDEV_ABSOLUTE_TOUCH_UP:
seat->slot_map &= ~(1 << seat_slot);
- touch_notify_touch(base,
- time,
- -1,
- seat_slot,
- 0, 0,
- LIBINPUT_TOUCH_TYPE_UP);
+ touch_notify_touch_up(base, time, -1, seat_slot);
break;
default:
assert(0 && "Unknown pending event type");
li_fixed_t value);
void
-touch_notify_touch(struct libinput_device *device,
- uint32_t time,
- int32_t slot,
- int32_t seat_slot,
- li_fixed_t x,
- li_fixed_t y,
- enum libinput_touch_type touch_type);
+touch_notify_touch_down(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot,
+ li_fixed_t x,
+ li_fixed_t y);
+
+void
+touch_notify_touch_motion(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot,
+ li_fixed_t x,
+ li_fixed_t y);
+
+void
+touch_notify_touch_up(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot);
void
touch_notify_frame(struct libinput_device *device,
int32_t seat_slot;
li_fixed_t x;
li_fixed_t y;
- enum libinput_touch_type touch_type;
};
static void
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
return (struct libinput_event_pointer *) event;
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
break;
}
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
break;
}
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
break;
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
return (struct libinput_event_touch *) event;
}
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
break;
}
return event->y;
}
-LIBINPUT_EXPORT enum libinput_touch_type
-libinput_event_touch_get_touch_type(struct libinput_event_touch *event)
-{
- return event->touch_type;
-}
-
struct libinput_source *
libinput_add_fd(struct libinput *libinput,
int fd,
}
void
-touch_notify_touch(struct libinput_device *device,
- uint32_t time,
- int32_t slot,
- int32_t seat_slot,
- li_fixed_t x,
- li_fixed_t y,
- enum libinput_touch_type touch_type)
+touch_notify_touch_down(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot,
+ li_fixed_t x,
+ li_fixed_t y)
+{
+ struct libinput_event_touch *touch_event;
+
+ touch_event = zalloc(sizeof *touch_event);
+ if (!touch_event)
+ return;
+
+ *touch_event = (struct libinput_event_touch) {
+ .time = time,
+ .slot = slot,
+ .seat_slot = seat_slot,
+ .x = x,
+ .y = y,
+ };
+
+ post_device_event(device,
+ LIBINPUT_EVENT_TOUCH_DOWN,
+ &touch_event->base);
+}
+
+void
+touch_notify_touch_motion(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot,
+ li_fixed_t x,
+ li_fixed_t y)
{
struct libinput_event_touch *touch_event;
.seat_slot = seat_slot,
.x = x,
.y = y,
- .touch_type = touch_type,
};
post_device_event(device,
- LIBINPUT_EVENT_TOUCH_TOUCH,
+ LIBINPUT_EVENT_TOUCH_MOTION,
+ &touch_event->base);
+}
+
+void
+touch_notify_touch_up(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot)
+{
+ struct libinput_event_touch *touch_event;
+
+ touch_event = zalloc(sizeof *touch_event);
+ if (!touch_event)
+ return;
+
+ *touch_event = (struct libinput_event_touch) {
+ .time = time,
+ .slot = slot,
+ .seat_slot = seat_slot,
+ };
+
+ post_device_event(device,
+ LIBINPUT_EVENT_TOUCH_UP,
&touch_event->base);
}
};
/**
- * @ingroup device
- *
- * Logical touch state of a touch point. A touch point usually follows the
- * sequence down, motion, up, with the number of motion events being zero or
- * greater. If a touch point was used for gesture interpretation internally
- * and will not generate any further events, the touchpoint is cancelled.
- */
-enum libinput_touch_type {
- LIBINPUT_TOUCH_TYPE_DOWN = 0,
- LIBINPUT_TOUCH_TYPE_UP = 1,
- LIBINPUT_TOUCH_TYPE_MOTION = 2,
- LIBINPUT_TOUCH_TYPE_CANCEL = 4
-};
-
-/**
* @ingroup base
*
* Event type for events returned by libinput_get_event().
LIBINPUT_EVENT_POINTER_BUTTON,
LIBINPUT_EVENT_POINTER_AXIS,
- LIBINPUT_EVENT_TOUCH_TOUCH = 500,
+ LIBINPUT_EVENT_TOUCH_DOWN = 500,
+ LIBINPUT_EVENT_TOUCH_UP,
+ LIBINPUT_EVENT_TOUCH_MOTION,
+ LIBINPUT_EVENT_TOUCH_CANCEL,
/**
* Signals the end of a set of touchpoints at one device sample
* time. This event has no coordinate information attached.
*
* Touch event representing a touch down, move or up, as well as a touch
* cancel and touch frame events. Valid event types for this event are @ref
- * LIBINPUT_EVENT_TOUCH_TOUCH and @ref LIBINPUT_EVENT_TOUCH_FRAME.
+ * LIBINPUT_EVENT_TOUCH_DOWN, @ref LIBINPUT_EVENT_TOUCH_MOTION, @ref
+ * LIBINPUT_EVENT_TOUCH_UP, @ref LIBINPUT_EVENT_TOUCH_CANCEL and @ref
+ * LIBINPUT_EVENT_TOUCH_FRAME.
*/
struct libinput_event_touch;
* If the touch event has no assigned slot, for example if it is from a
* single touch device, this function returns -1.
*
- * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
+ * @note this function should not be called for LIBINPUT_EVENT_TOUCH_CANCEL or
+ * LIBINPUT_EVENT_TOUCH_FRAME.
*
* @return The slot of this touch event
*/
* Events from single touch devices will be represented as one individual
* touch point per device.
*
- * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
+ * @note this function should not be called for LIBINPUT_EVENT_TOUCH_CANCEL or
+ * LIBINPUT_EVENT_TOUCH_FRAME.
*
* @return The seat slot of the touch event
*/
* corresponding output screen coordinate, use
* libinput_event_touch_get_x_transformed().
*
- * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
+ * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
+ * LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @return the current absolute x coordinate
* corresponding output screen coordinate, use
* libinput_event_touch_get_y_transformed().
*
- * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
+ * For LIBINPUT_EVENT_TOUCH_UP 0 is returned.
+ *
+ * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
+ * LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @return the current absolute y coordinate
* Return the current absolute x coordinate of the touch event, transformed to
* screen coordinates.
*
- * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
+ * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
+ * LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @param width The current output screen width
* Return the current absolute y coordinate of the touch event, transformed to
* screen coordinates.
*
- * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
+ * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
+ * LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @param height The current output screen height
uint32_t height);
/**
- * @ingroup event_touch
- *
- * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
- *
- * @return the type of touch that occured on the device
- */
-enum libinput_touch_type
-libinput_event_touch_get_touch_type(struct libinput_event_touch *event);
-
-/**
* @defgroup base Initialization and manipulation of libinput contexts
*/
libinput_dispatch(libinput);
while ((ev = libinput_get_event(libinput))) {
- if (libinput_event_get_type(ev) != LIBINPUT_EVENT_TOUCH_TOUCH)
+ if (libinput_event_get_type(ev) != LIBINPUT_EVENT_TOUCH_DOWN)
continue;
tev = libinput_event_get_touch_event(ev);
- if (libinput_event_touch_get_touch_type(tev) !=
- LIBINPUT_TOUCH_TYPE_DOWN)
- continue;
-
fx = libinput_event_touch_get_x_transformed(tev, 1920);
ck_assert_int_eq(li_fixed_to_int(fx), 1919);
fy = libinput_event_touch_get_y_transformed(tev, 720);
case LIBINPUT_EVENT_POINTER_AXIS:
type = "POINTER_AXIS";
break;
- case LIBINPUT_EVENT_TOUCH_TOUCH:
- type = "TOUCH_TOUCH";
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ type = "TOUCH_DOWN";
+ break;
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ type = "TOUCH_MOTION";
+ break;
+ case LIBINPUT_EVENT_TOUCH_UP:
+ type = "TOUCH_UP";
+ break;
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
+ type = "TOUCH_CANCEL";
break;
case LIBINPUT_EVENT_TOUCH_FRAME:
type = "TOUCH_FRAME";
}
static void
-print_touch_frame_event(struct libinput_event *ev)
+print_touch_event_without_coords(struct libinput_event *ev)
{
struct libinput_event_touch *t = libinput_event_get_touch_event(ev);
}
static void
-print_touch_event(struct libinput_event *ev)
+print_touch_event_with_coords(struct libinput_event *ev)
{
struct libinput_event_touch *t = libinput_event_get_touch_event(ev);
li_fixed_t x = libinput_event_touch_get_x_transformed(t, screen_width),
y = libinput_event_touch_get_y_transformed(t, screen_height);
- const char *type;
-
- switch (libinput_event_touch_get_touch_type(t)) {
- case LIBINPUT_TOUCH_TYPE_DOWN: type = "down"; break;
- case LIBINPUT_TOUCH_TYPE_UP: type = "up"; break;
- case LIBINPUT_TOUCH_TYPE_MOTION: type = "motion"; break;
- case LIBINPUT_TOUCH_TYPE_CANCEL: type = "cancel"; break;
- default:
- abort();
- }
print_event_time(libinput_event_touch_get_time(t));
- printf("%6s %d (%d) %5.2f/%5.2f\n",
- type,
+ printf("%d (%d) %5.2f/%5.2f\n",
libinput_event_touch_get_slot(t),
libinput_event_touch_get_seat_slot(t),
li_fixed_to_double(x),
case LIBINPUT_EVENT_POINTER_AXIS:
print_axis_event(ev);
break;
- case LIBINPUT_EVENT_TOUCH_TOUCH:
- print_touch_event(ev);
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ print_touch_event_with_coords(ev);
+ break;
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ print_touch_event_with_coords(ev);
+ break;
+ case LIBINPUT_EVENT_TOUCH_UP:
+ print_touch_event_without_coords(ev);
+ break;
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
+ print_touch_event_without_coords(ev);
break;
case LIBINPUT_EVENT_TOUCH_FRAME:
- print_touch_frame_event(ev);
+ print_touch_event_without_coords(ev);
break;
}