clutter: Add API for retrieving gesture unaccelerated deltas
This will be useful for better aligning behavior between scrolling and swiping for gnome-shell swipe tracker. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1353>
This commit is contained in:
parent
91d03f1c96
commit
2a71ca373b
@ -2007,6 +2007,42 @@ clutter_event_get_gesture_motion_delta (const ClutterEvent *event,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_event_get_gesture_motion_delta_unaccelerated:
|
||||
* @event: A clutter touchpad gesture event
|
||||
* @dx: (out) (allow-none): the displacement relative to the pointer
|
||||
* position in the X axis, or %NULL
|
||||
* @dy: (out) (allow-none): the displacement relative to the pointer
|
||||
* position in the Y axis, or %NULL
|
||||
*
|
||||
* Returns the unaccelerated gesture motion deltas relative to the current
|
||||
* pointer position. Unlike clutter_event_get_gesture_motion_delta(),
|
||||
* pointer acceleration is ignored.
|
||||
**/
|
||||
void
|
||||
clutter_event_get_gesture_motion_delta_unaccelerated (const ClutterEvent *event,
|
||||
gdouble *dx,
|
||||
gdouble *dy)
|
||||
{
|
||||
g_return_if_fail (event != NULL);
|
||||
g_return_if_fail (event->type == CLUTTER_TOUCHPAD_PINCH ||
|
||||
event->type == CLUTTER_TOUCHPAD_SWIPE);
|
||||
|
||||
if (event->type == CLUTTER_TOUCHPAD_PINCH)
|
||||
{
|
||||
if (dx)
|
||||
*dx = event->touchpad_pinch.dx_unaccel;
|
||||
if (dy)
|
||||
*dy = event->touchpad_pinch.dy_unaccel;
|
||||
}
|
||||
else if (event->type == CLUTTER_TOUCHPAD_SWIPE)
|
||||
{
|
||||
if (dx)
|
||||
*dx = event->touchpad_swipe.dx_unaccel;
|
||||
if (dy)
|
||||
*dy = event->touchpad_swipe.dy_unaccel;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* clutter_event_get_scroll_source:
|
||||
* @event: an scroll event
|
||||
|
@ -414,6 +414,10 @@ struct _ClutterTouchEvent
|
||||
* @y: the Y coordinate of the pointer, relative to the stage
|
||||
* @dx: movement delta of the pinch focal point in the X axis
|
||||
* @dy: movement delta of the pinch focal point in the Y axis
|
||||
* @dx_unaccel: unaccelerated movement delta of the pinch focal
|
||||
* point in the X axis
|
||||
* @dy_unaccel: unaccelerated movement delta of the pinch focal
|
||||
* point in the Y axis
|
||||
* @angle_delta: angle delta in degrees, clockwise rotations are
|
||||
* represented by positive deltas
|
||||
* @scale: the current scale
|
||||
@ -441,6 +445,8 @@ struct _ClutterTouchpadPinchEvent
|
||||
gfloat y;
|
||||
gfloat dx;
|
||||
gfloat dy;
|
||||
gfloat dx_unaccel;
|
||||
gfloat dy_unaccel;
|
||||
gfloat angle_delta;
|
||||
gfloat scale;
|
||||
guint n_fingers;
|
||||
@ -457,8 +463,12 @@ struct _ClutterTouchpadPinchEvent
|
||||
* @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
|
||||
* @dx: movement delta of the pinch focal point in the X axis
|
||||
* @dy: movement delta of the pinch focal point in the Y axis
|
||||
* @dx: movement delta of the swipe center point in the X axis
|
||||
* @dy: movement delta of the swipe center point in the Y axis
|
||||
* @dx_unaccel: unaccelerated movement delta of the swipe center
|
||||
* point in the X axis
|
||||
* @dy_unaccel: unaccelerated movement delta of the swipe center
|
||||
* point in the Y axis
|
||||
*
|
||||
* Used for touchpad swipe gesture events. The current state of the
|
||||
* gesture will be determined by the @phase field.
|
||||
@ -479,6 +489,8 @@ struct _ClutterTouchpadSwipeEvent
|
||||
gfloat y;
|
||||
gfloat dx;
|
||||
gfloat dy;
|
||||
gfloat dx_unaccel;
|
||||
gfloat dy_unaccel;
|
||||
};
|
||||
|
||||
struct _ClutterPadButtonEvent
|
||||
@ -777,6 +789,11 @@ void clutter_event_get_gesture_motion_delta (const Clut
|
||||
gdouble *dx,
|
||||
gdouble *dy);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_event_get_gesture_motion_delta_unaccelerated (const ClutterEvent *event,
|
||||
gdouble *dx,
|
||||
gdouble *dy);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterScrollSource clutter_event_get_scroll_source (const ClutterEvent *event);
|
||||
|
||||
|
@ -1249,6 +1249,8 @@ notify_pinch_gesture_event (ClutterInputDevice *input_device,
|
||||
uint64_t time_us,
|
||||
double dx,
|
||||
double dy,
|
||||
double dx_unaccel,
|
||||
double dy_unaccel,
|
||||
double angle_delta,
|
||||
double scale,
|
||||
uint32_t n_fingers)
|
||||
@ -1268,6 +1270,8 @@ notify_pinch_gesture_event (ClutterInputDevice *input_device,
|
||||
event->touchpad_pinch.time = us2ms (time_us);
|
||||
event->touchpad_pinch.dx = dx;
|
||||
event->touchpad_pinch.dy = dy;
|
||||
event->touchpad_pinch.dx_unaccel = dx_unaccel;
|
||||
event->touchpad_pinch.dy_unaccel = dy_unaccel;
|
||||
event->touchpad_pinch.angle_delta = angle_delta;
|
||||
event->touchpad_pinch.scale = scale;
|
||||
event->touchpad_pinch.n_fingers = n_fingers;
|
||||
@ -1286,7 +1290,9 @@ notify_swipe_gesture_event (ClutterInputDevice *input_device,
|
||||
uint64_t time_us,
|
||||
uint32_t n_fingers,
|
||||
double dx,
|
||||
double dy)
|
||||
double dy,
|
||||
double dx_unaccel,
|
||||
double dy_unaccel)
|
||||
{
|
||||
MetaSeatImpl *seat_impl;
|
||||
ClutterEvent *event = NULL;
|
||||
@ -1303,6 +1309,8 @@ notify_swipe_gesture_event (ClutterInputDevice *input_device,
|
||||
&event->touchpad_swipe.y);
|
||||
event->touchpad_swipe.dx = dx;
|
||||
event->touchpad_swipe.dy = dy;
|
||||
event->touchpad_swipe.dx_unaccel = dx_unaccel;
|
||||
event->touchpad_swipe.dy_unaccel = dy_unaccel;
|
||||
event->touchpad_swipe.n_fingers = n_fingers;
|
||||
|
||||
meta_xkb_translate_state (event, seat_impl->xkb, seat_impl->button_state);
|
||||
@ -2278,14 +2286,14 @@ process_device_event (MetaSeatImpl *seat_impl,
|
||||
n_fingers = libinput_event_gesture_get_finger_count (gesture_event);
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
time_us = libinput_event_gesture_get_time_usec (gesture_event);
|
||||
notify_pinch_gesture_event (device, phase, time_us, 0, 0, 0, 0, n_fingers);
|
||||
notify_pinch_gesture_event (device, phase, time_us, 0, 0, 0, 0, 0, 0, n_fingers);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
|
||||
{
|
||||
struct libinput_event_gesture *gesture_event =
|
||||
libinput_event_get_gesture_event (event);
|
||||
double angle_delta, scale, dx, dy;
|
||||
double angle_delta, scale, dx, dy, dx_unaccel, dy_unaccel;
|
||||
uint32_t n_fingers;
|
||||
uint64_t time_us;
|
||||
|
||||
@ -2296,10 +2304,13 @@ process_device_event (MetaSeatImpl *seat_impl,
|
||||
scale = libinput_event_gesture_get_scale (gesture_event);
|
||||
dx = libinput_event_gesture_get_dx (gesture_event);
|
||||
dy = libinput_event_gesture_get_dy (gesture_event);
|
||||
dx_unaccel = libinput_event_gesture_get_dx_unaccelerated (gesture_event);
|
||||
dy_unaccel = libinput_event_gesture_get_dy_unaccelerated (gesture_event);
|
||||
|
||||
notify_pinch_gesture_event (device,
|
||||
CLUTTER_TOUCHPAD_GESTURE_PHASE_UPDATE,
|
||||
time_us, dx, dy, angle_delta, scale, n_fingers);
|
||||
time_us, dx, dy, dx_unaccel, dy_unaccel,
|
||||
angle_delta, scale, n_fingers);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
|
||||
@ -2321,7 +2332,7 @@ process_device_event (MetaSeatImpl *seat_impl,
|
||||
phase = libinput_event_gesture_get_cancelled (gesture_event) ?
|
||||
CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL : CLUTTER_TOUCHPAD_GESTURE_PHASE_END;
|
||||
|
||||
notify_swipe_gesture_event (device, phase, time_us, n_fingers, 0, 0);
|
||||
notify_swipe_gesture_event (device, phase, time_us, n_fingers, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
|
||||
@ -2330,17 +2341,19 @@ process_device_event (MetaSeatImpl *seat_impl,
|
||||
libinput_event_get_gesture_event (event);
|
||||
uint32_t n_fingers;
|
||||
uint64_t time_us;
|
||||
double dx, dy;
|
||||
double dx, dy, dx_unaccel, dy_unaccel;
|
||||
|
||||
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);
|
||||
dx = libinput_event_gesture_get_dx (gesture_event);
|
||||
dy = libinput_event_gesture_get_dy (gesture_event);
|
||||
dx_unaccel = libinput_event_gesture_get_dx_unaccelerated (gesture_event);
|
||||
dy_unaccel = libinput_event_gesture_get_dy_unaccelerated (gesture_event);
|
||||
|
||||
notify_swipe_gesture_event (device,
|
||||
CLUTTER_TOUCHPAD_GESTURE_PHASE_UPDATE,
|
||||
time_us, n_fingers, dx, dy);
|
||||
time_us, n_fingers, dx, dy, dx_unaccel, dy_unaccel);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
|
||||
|
Loading…
Reference in New Issue
Block a user