[mutter] clutter/event: Add ClutterEventType.CLUTTER_TOUCHPAD_HOLD



commit af1f3304e48d95e71ec6f8a4856d3e9b767698ec
Author: JoseExposito <jose exposito89 gmail com>
Date:   Fri Apr 16 08:57:55 2021 +0200

    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>

 clutter/clutter/clutter-actor.c |  1 +
 clutter/clutter/clutter-enums.h |  6 ++++++
 clutter/clutter/clutter-event.c | 43 +++++++++++++++++++++++++++++++++++++----
 clutter/clutter/clutter-main.c  |  1 +
 src/core/events.c               |  1 +
 5 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 78a2d9eb11..5368804d28 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -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;
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
index 0c889d1482..8165bcf5d0 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
@@ -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,
diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c
index 4f6c7e0b3f..05cd7ba495 100644
--- a/clutter/clutter/clutter-event.c
+++ b/clutter/clutter/clutter-event.c
@@ -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:
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index e5391ae840..0beeb0dcae 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -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;
 
diff --git a/src/core/events.c b/src/core/events.c
index 8afc720efd..9ecf085fd5 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -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 || \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]