Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clutter/clutter/clutter-actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -13994,6 +13994,7 @@ clutter_actor_event (ClutterActor *actor,
break;
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_HOLD:
detail = quark_touchpad;
break;
case CLUTTER_PROXIMITY_IN:
Expand Down
6 changes: 6 additions & 0 deletions clutter/clutter/clutter-enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,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 6.5
* @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;
Expand Down Expand Up @@ -928,6 +933,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,
Expand Down
33 changes: 30 additions & 3 deletions clutter/clutter/clutter-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,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;
}

}
Expand Down Expand Up @@ -540,6 +545,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;
}
}

Expand Down Expand Up @@ -1154,6 +1164,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;

Expand Down Expand Up @@ -1259,6 +1270,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;

Expand Down Expand Up @@ -1814,6 +1826,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:
Expand Down Expand Up @@ -2073,12 +2086,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;
}
Expand Down Expand Up @@ -2137,12 +2153,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;
Expand All @@ -2168,7 +2187,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)
{
Expand All @@ -2184,6 +2204,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;
}
}

/**
Expand Down
39 changes: 39 additions & 0 deletions clutter/clutter/clutter-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ typedef struct _ClutterCrossingEvent ClutterCrossingEvent;
typedef struct _ClutterTouchEvent ClutterTouchEvent;
typedef struct _ClutterTouchpadPinchEvent ClutterTouchpadPinchEvent;
typedef struct _ClutterTouchpadSwipeEvent ClutterTouchpadSwipeEvent;
typedef struct _ClutterTouchpadHoldEvent ClutterTouchpadHoldEvent;
typedef struct _ClutterProximityEvent ClutterProximityEvent;
typedef struct _ClutterPadButtonEvent ClutterPadButtonEvent;
typedef struct _ClutterPadStripEvent ClutterPadStripEvent;
Expand Down Expand Up @@ -500,6 +501,43 @@ struct _ClutterTouchpadSwipeEvent
gfloat dy;
};

/**
* ClutterTouchpadHoldEvent
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @phase: the current phase of the gesture
* @n_fingers: the number of fingers triggering the swipe
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
*
* Used for touchpad hold gesture events. The current state of the
* gesture will be determined by the @phase field.
*
* A hold gesture starts when the user places one or many fingers on the
* touchpad and ends when all fingers are lifted. It is cancelled when the
* finger(s) move past a certain threshold.
* Unlike swipe and pinch, @phase can only be
* CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN, CLUTTER_TOUCHPAD_GESTURE_PHASE_END and
* CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL.
*/
struct _ClutterTouchpadHoldEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterStage *stage;
ClutterActor *source;

ClutterTouchpadGesturePhase phase;
uint32_t n_fingers;
float x;
float y;
};


struct _ClutterPadButtonEvent
{
ClutterEventType type;
Expand Down Expand Up @@ -592,6 +630,7 @@ union _ClutterEvent
ClutterTouchEvent touch;
ClutterTouchpadPinchEvent touchpad_pinch;
ClutterTouchpadSwipeEvent touchpad_swipe;
ClutterTouchpadHoldEvent touchpad_hold;
ClutterProximityEvent proximity;
ClutterPadButtonEvent pad_button;
ClutterPadStripEvent pad_strip;
Expand Down
1 change: 1 addition & 0 deletions clutter/clutter/clutter-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,7 @@ _clutter_process_event_details (ClutterActor *stage,
case CLUTTER_SCROLL:
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_HOLD:
{
ClutterActor *actor;
gfloat x, y;
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ gudev_req = '>= 232'

# wayland version requirements
wayland_server_req = '>= 1.13.0'
wayland_protocols_req = '>= 1.19'
wayland_protocols_req = '>= 1.23'

# native backend version requirements
libinput_req = '>= 1.7'
libinput_req = '>= 1.19.0'
gbm_req = '>= 10.3'

# screen cast version requirements
Expand Down
64 changes: 64 additions & 0 deletions src/backends/native/meta-seat-native.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,48 @@ notify_swipe_gesture_event (ClutterInputDevice *input_device,
queue_event (event);
}

static void
notify_hold_gesture_event (ClutterInputDevice *input_device,
ClutterTouchpadGesturePhase phase,
uint64_t time_us,
uint32_t n_fingers)
{
MetaInputDeviceNative *device_evdev;
MetaSeatNative *seat;
ClutterStage *stage;
ClutterEvent *event = NULL;
graphene_point_t pos;

/* We can drop the event on the floor if no stage has been
* associated with the device yet. */
stage = _clutter_input_device_get_stage (input_device);
if (stage == NULL)
return;

device_evdev = META_INPUT_DEVICE_NATIVE (input_device);
seat = meta_input_device_native_get_seat (device_evdev);

event = clutter_event_new (CLUTTER_TOUCHPAD_HOLD);

meta_event_native_set_time_usec (event, time_us);
event->touchpad_hold.phase = phase;
event->touchpad_hold.time = us2ms (time_us);
event->touchpad_hold.stage = CLUTTER_STAGE (stage);

clutter_input_device_get_coords (seat->core_pointer, NULL, &pos);
event->touchpad_hold.x = pos.x;
event->touchpad_hold.y = pos.y;
event->touchpad_hold.n_fingers = n_fingers;

meta_xkb_translate_state (event, seat->xkb, seat->button_state);

clutter_event_set_device (event, seat->core_pointer);
clutter_event_set_source_device (event, input_device);

queue_event (event);
}


static void
notify_proximity (ClutterInputDevice *input_device,
uint64_t time_us,
Expand Down Expand Up @@ -2187,6 +2229,28 @@ process_device_event (MetaSeatNative *seat,
time_us, n_fingers, dx, dy);
break;
}
case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN:
case LIBINPUT_EVENT_GESTURE_HOLD_END:
{
struct libinput_event_gesture *gesture_event =
libinput_event_get_gesture_event (event);
ClutterTouchpadGesturePhase phase;
uint32_t n_fingers;
uint64_t time_us;

device = libinput_device_get_user_data (libinput_device);
time_us = libinput_event_gesture_get_time_usec (gesture_event);
n_fingers = libinput_event_gesture_get_finger_count (gesture_event);

if (libinput_event_get_type (event) == LIBINPUT_EVENT_GESTURE_HOLD_BEGIN)
phase = CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN;
else
phase = libinput_event_gesture_get_cancelled (gesture_event) ?
CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL : CLUTTER_TOUCHPAD_GESTURE_PHASE_END;

notify_hold_gesture_event (device, phase, time_us, n_fingers);
break;
}
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
{
process_tablet_axis (seat, event);
Expand Down
1 change: 1 addition & 0 deletions src/core/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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 || \
Expand Down
2 changes: 2 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ if have_wayland
'wayland/meta-wayland-pointer.c',
'wayland/meta-wayland-pointer-constraints.c',
'wayland/meta-wayland-pointer-constraints.h',
'wayland/meta-wayland-pointer-gesture-hold.c',
'wayland/meta-wayland-pointer-gesture-hold.h',
'wayland/meta-wayland-pointer-gesture-pinch.c',
'wayland/meta-wayland-pointer-gesture-pinch.h',
'wayland/meta-wayland-pointer-gestures.c',
Expand Down
Loading
Loading