clutter/event: Add ClutterEventType.CLUTTER_TOUCHPAD_HOLD

Add a enum for hold gestures in ClutterEventType as well as the
required functions to get information about the event: coordinates,
finger count, event phase, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
This commit is contained in:
JoseExposito 2021-04-16 08:57:55 +02:00 committed by Marge Bot
parent aa5569356e
commit af1f3304e4
5 changed files with 48 additions and 4 deletions

View File

@ -12344,6 +12344,7 @@ clutter_actor_event (ClutterActor *actor,
break;
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_HOLD:
signal_num = -1;
detail = quark_touchpad;
break;

View File

@ -829,6 +829,11 @@ typedef enum /*< flags prefix=CLUTTER_EVENT >*/
* determined by its phase field; event added in 1.24
* @CLUTTER_TOUCHPAD_SWIPE: A swipe gesture event, the current state is
* determined by its phase field; event added in 1.24
* @CLUTTER_TOUCHPAD_HOLD: A hold gesture event, the current state is
* determined by its phase field. A hold gesture starts when the user places a
* finger on the touchpad and ends when all fingers are lifted. It is
* cancelled when the finger(s) move past a certain threshold.
* Event added in 40.4
* @CLUTTER_PROXIMITY_IN: A tool entered in proximity to a tablet;
* event added in 1.28
* @CLUTTER_PROXIMITY_OUT: A tool left from the proximity area of a tablet;
@ -857,6 +862,7 @@ typedef enum /*< prefix=CLUTTER >*/
CLUTTER_TOUCH_CANCEL,
CLUTTER_TOUCHPAD_PINCH,
CLUTTER_TOUCHPAD_SWIPE,
CLUTTER_TOUCHPAD_HOLD,
CLUTTER_PROXIMITY_IN,
CLUTTER_PROXIMITY_OUT,
CLUTTER_PAD_BUTTON_PRESS,

View File

@ -433,6 +433,11 @@ clutter_event_get_position (const ClutterEvent *event,
graphene_point_init (position, event->touchpad_swipe.x,
event->touchpad_swipe.y);
break;
case CLUTTER_TOUCHPAD_HOLD:
graphene_point_init (position, event->touchpad_hold.x,
event->touchpad_hold.y);
break;
}
}
@ -512,6 +517,11 @@ clutter_event_set_coords (ClutterEvent *event,
event->touchpad_swipe.x = x;
event->touchpad_swipe.y = y;
break;
case CLUTTER_TOUCHPAD_HOLD:
event->touchpad_hold.x = x;
event->touchpad_hold.y = y;
break;
}
}
@ -1067,6 +1077,7 @@ clutter_event_set_device (ClutterEvent *event,
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_HOLD:
/* Rely on priv data for these */
break;
@ -1164,6 +1175,7 @@ clutter_event_get_device (const ClutterEvent *event)
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_HOLD:
/* Rely on priv data for these */
break;
@ -1628,6 +1640,7 @@ clutter_event_get_axes (const ClutterEvent *event,
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_HOLD:
case CLUTTER_PAD_BUTTON_PRESS:
case CLUTTER_PAD_BUTTON_RELEASE:
case CLUTTER_PAD_STRIP:
@ -1873,12 +1886,15 @@ clutter_event_get_touchpad_gesture_finger_count (const ClutterEvent *event)
{
g_return_val_if_fail (event != NULL, 0);
g_return_val_if_fail (event->type == CLUTTER_TOUCHPAD_SWIPE ||
event->type == CLUTTER_TOUCHPAD_PINCH, 0);
event->type == CLUTTER_TOUCHPAD_PINCH ||
event->type == CLUTTER_TOUCHPAD_HOLD, 0);
if (event->type == CLUTTER_TOUCHPAD_SWIPE)
return event->touchpad_swipe.n_fingers;
else if (event->type == CLUTTER_TOUCHPAD_PINCH)
return event->touchpad_pinch.n_fingers;
else if (event->type == CLUTTER_TOUCHPAD_HOLD)
return event->touchpad_hold.n_fingers;
return 0;
}
@ -1937,12 +1953,15 @@ clutter_event_get_gesture_phase (const ClutterEvent *event)
{
g_return_val_if_fail (event != NULL, 0);
g_return_val_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH ||
event->type == CLUTTER_TOUCHPAD_SWIPE, 0);
event->type == CLUTTER_TOUCHPAD_SWIPE ||
event->type == CLUTTER_TOUCHPAD_HOLD, 0);
if (event->type == CLUTTER_TOUCHPAD_PINCH)
return event->touchpad_pinch.phase;
else if (event->type == CLUTTER_TOUCHPAD_SWIPE)
return event->touchpad_swipe.phase;
else if (event->type == CLUTTER_TOUCHPAD_HOLD)
return event->touchpad_hold.phase;
/* Shouldn't ever happen */
return CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN;
@ -1968,7 +1987,8 @@ clutter_event_get_gesture_motion_delta (const ClutterEvent *event,
{
g_return_if_fail (event != NULL);
g_return_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH ||
event->type == CLUTTER_TOUCHPAD_SWIPE);
event->type == CLUTTER_TOUCHPAD_SWIPE ||
event->type == CLUTTER_TOUCHPAD_HOLD);
if (event->type == CLUTTER_TOUCHPAD_PINCH)
{
@ -1984,6 +2004,13 @@ clutter_event_get_gesture_motion_delta (const ClutterEvent *event,
if (dy)
*dy = event->touchpad_swipe.dy;
}
else if (event->type == CLUTTER_TOUCHPAD_HOLD)
{
if (dx)
*dx = 0;
if (dy)
*dy = 0;
}
}
/**
@ -2005,7 +2032,8 @@ clutter_event_get_gesture_motion_delta_unaccelerated (const ClutterEvent *event,
{
g_return_if_fail (event != NULL);
g_return_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH ||
event->type == CLUTTER_TOUCHPAD_SWIPE);
event->type == CLUTTER_TOUCHPAD_SWIPE ||
event->type == CLUTTER_TOUCHPAD_HOLD);
if (event->type == CLUTTER_TOUCHPAD_PINCH)
{
@ -2021,6 +2049,13 @@ clutter_event_get_gesture_motion_delta_unaccelerated (const ClutterEvent *event,
if (dy)
*dy = event->touchpad_swipe.dy_unaccel;
}
else if (event->type == CLUTTER_TOUCHPAD_HOLD)
{
if (dx)
*dx = 0;
if (dy)
*dy = 0;
}
}
/**
* clutter_event_get_scroll_source:

View File

@ -1139,6 +1139,7 @@ _clutter_process_event_details (ClutterActor *stage,
case CLUTTER_SCROLL:
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_HOLD:
{
gfloat x, y;

View File

@ -43,6 +43,7 @@
#define IS_GESTURE_EVENT(e) ((e)->type == CLUTTER_TOUCHPAD_SWIPE || \
(e)->type == CLUTTER_TOUCHPAD_PINCH || \
(e)->type == CLUTTER_TOUCHPAD_HOLD || \
(e)->type == CLUTTER_TOUCH_BEGIN || \
(e)->type == CLUTTER_TOUCH_UPDATE || \
(e)->type == CLUTTER_TOUCH_END || \