/* When tap-and-dragging, or a clickpad is clicked force 1fg mode */
if (tp_tap_dragging(tp) || (tp->buttons.is_clickpad && tp->buttons.state)) {
- tp_gesture_stop(tp, time);
+ tp_gesture_stop(tp, time, 1);
tp->gesture.finger_count = 1;
tp->gesture.finger_count_pending = 0;
}
}
void
-tp_gesture_stop(struct tp_dispatch *tp, uint64_t time)
+tp_gesture_stop(struct tp_dispatch *tp, uint64_t time, int cancelled)
{
struct libinput *libinput = tp->device->base.seat->libinput;
enum tp_gesture_2fg_state twofinger_state = tp->gesture.twofinger_state;
- const struct normalized_coords zero = { 0.0, 0.0 };
tp->gesture.twofinger_state = GESTURE_2FG_STATE_NONE;
tp_gesture_stop_twofinger_scroll(tp, time);
break;
case GESTURE_2FG_STATE_PINCH:
- gesture_notify_pinch(&tp->device->base, time,
- LIBINPUT_EVENT_GESTURE_PINCH_END,
- &zero, &zero, 0.0, 0.0);
+ gesture_notify_pinch_end(&tp->device->base, time,
+ cancelled);
break;
}
break;
case 3:
case 4:
- gesture_notify_swipe(&tp->device->base, time,
- LIBINPUT_EVENT_GESTURE_SWIPE_END,
- tp->gesture.finger_count,
- &zero, &zero);
+ gesture_notify_swipe_end(&tp->device->base, time,
+ tp->gesture.finger_count, cancelled);
break;
}
tp->gesture.started = false;
if (!tp->gesture.finger_count_pending)
return;
- tp_gesture_stop(tp, now); /* End current gesture */
+ tp_gesture_stop(tp, now, 1); /* End current gesture */
tp->gesture.finger_count = tp->gesture.finger_count_pending;
tp->gesture.finger_count_pending = 0;
}
if (active_touches != tp->gesture.finger_count) {
/* If all fingers are lifted immediately end the gesture */
if (active_touches == 0) {
- tp_gesture_stop(tp, time);
+ tp_gesture_stop(tp, time, 0);
tp->gesture.finger_count = 0;
tp->gesture.finger_count_pending = 0;
/* Immediately switch to new mode to avoid initial latency */
tp->palm.trackpoint_active ||
tp->dwt.keyboard_active) {
tp_edge_scroll_stop_events(tp, time);
- tp_gesture_stop(tp, time);
+ tp_gesture_stop(tp, time, 1);
return;
}
if (!tp->palm.trackpoint_active) {
tp_edge_scroll_stop_events(tp, time);
- tp_gesture_stop(tp, time);
+ tp_gesture_stop(tp, time, 1);
tp_tap_suspend(tp, time);
tp->palm.trackpoint_active = true;
}
if (!tp->dwt.keyboard_active) {
tp_edge_scroll_stop_events(tp, time);
- tp_gesture_stop(tp, time);
+ tp_gesture_stop(tp, time, 1);
tp_tap_suspend(tp, time);
tp->dwt.keyboard_active = true;
timeout = DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1;
tp_remove_gesture(struct tp_dispatch *tp);
void
-tp_gesture_stop(struct tp_dispatch *tp, uint64_t time);
+tp_gesture_stop(struct tp_dispatch *tp, uint64_t time, int cancelled);
void
tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time);
const struct normalized_coords *unaccel);
void
+gesture_notify_swipe_end(struct libinput_device *device,
+ uint64_t time,
+ int finger_count,
+ int cancelled);
+
+void
gesture_notify_pinch(struct libinput_device *device,
uint64_t time,
enum libinput_event_type type,
double angle);
void
+gesture_notify_pinch_end(struct libinput_device *device,
+ uint64_t time,
+ int cancelled);
+
+void
touch_notify_frame(struct libinput_device *device,
uint64_t time);
struct libinput_event base;
uint32_t time;
int finger_count;
+ int cancelled;
struct normalized_coords delta;
struct normalized_coords delta_unaccel;
double scale;
return event->finger_count;
}
+LIBINPUT_EXPORT int
+libinput_event_gesture_get_cancelled(struct libinput_event_gesture *event)
+{
+ return event->cancelled;
+}
+
LIBINPUT_EXPORT double
libinput_event_gesture_get_dx(struct libinput_event_gesture *event)
{
uint64_t time,
enum libinput_event_type type,
int finger_count,
+ int cancelled,
const struct normalized_coords *delta,
const struct normalized_coords *unaccel,
double scale,
*gesture_event = (struct libinput_event_gesture) {
.time = time,
.finger_count = finger_count,
+ .cancelled = cancelled,
.delta = *delta,
.delta_unaccel = *unaccel,
.scale = scale,
const struct normalized_coords *delta,
const struct normalized_coords *unaccel)
{
- gesture_notify(device, time, type, finger_count, delta, unaccel,
+ gesture_notify(device, time, type, finger_count, 0, delta, unaccel,
0.0, 0.0);
}
void
+gesture_notify_swipe_end(struct libinput_device *device,
+ uint64_t time,
+ int finger_count,
+ int cancelled)
+{
+ const struct normalized_coords zero = { 0.0, 0.0 };
+
+ gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_SWIPE_END,
+ finger_count, cancelled, &zero, &zero, 0.0, 0.0);
+}
+
+void
gesture_notify_pinch(struct libinput_device *device,
uint64_t time,
enum libinput_event_type type,
double scale,
double angle)
{
- gesture_notify(device, time, type, 2, delta, unaccel, scale, angle);
+ gesture_notify(device, time, type, 2, 0, delta, unaccel,
+ scale, angle);
+}
+
+void
+gesture_notify_pinch_end(struct libinput_device *device,
+ uint64_t time,
+ int cancelled)
+{
+ const struct normalized_coords zero = { 0.0, 0.0 };
+
+ gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_PINCH_END,
+ 2, cancelled, &zero, &zero, 0.0, 0.0);
}
static void
/**
* @ingroup event_gesture
*
+ * Return if the gesture ended normally, or if it was cancelled.
+ * For gesture events that are not of type
+ * @ref LIBINPUT_EVENT_GESTURE_SWIPE_END or
+ * @ref LIBINPUT_EVENT_GESTURE_PINCH_END, this function returns 0.
+ *
+ * @note It is an application bug to call this function for events other than
+ * @ref LIBINPUT_EVENT_GESTURE_SWIPE_END or
+ * @ref LIBINPUT_EVENT_GESTURE_PINCH_END.
+ *
+ * @return 0 or 1, with 1 indicating that the gesture was cancelled.
+ */
+int
+libinput_event_gesture_get_cancelled(struct libinput_event_gesture *event);
+
+/**
+ * @ingroup event_gesture
+ *
* Return the delta between the last event and the current event. For gesture
* events that are not of type @ref LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE or
* @ref LIBINPUT_EVENT_GESTURE_PINCH_UPDATE, this function returns 0.
TOUCHPAD_GESTURES {
libinput_event_gesture_get_angle_delta;
libinput_event_gesture_get_base_event;
+ libinput_event_gesture_get_cancelled;
libinput_event_gesture_get_dx;
libinput_event_gesture_get_dx_unaccelerated;
libinput_event_gesture_get_dy;
print_gesture_event_without_coords(struct libinput_event *ev)
{
struct libinput_event_gesture *t = libinput_event_get_gesture_event(ev);
+ int finger_count = libinput_event_gesture_get_finger_count(t);
+ int cancelled = libinput_event_gesture_get_cancelled(t);
print_event_time(libinput_event_gesture_get_time(t));
- printf("%d\n", libinput_event_gesture_get_finger_count(t));
+ printf("%d%s\n", finger_count, cancelled ? " cancelled" : "");
}
static void