mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
evdev: Handle libinput touchpad swipe/pinch gesture events
The translation from libinput events is fairly straightforward, as they map almost 1:1.
This commit is contained in:
parent
c185a17783
commit
5b8a2a9e15
@ -596,6 +596,94 @@ notify_touch_event (ClutterInputDevice *input_device,
|
||||
queue_event (event);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_pinch_gesture_event (ClutterInputDevice *input_device,
|
||||
ClutterTouchpadGesturePhase phase,
|
||||
guint32 time_,
|
||||
gdouble dx,
|
||||
gdouble dy,
|
||||
gdouble angle_delta,
|
||||
gdouble scale)
|
||||
{
|
||||
ClutterInputDeviceEvdev *device_evdev;
|
||||
ClutterSeatEvdev *seat;
|
||||
ClutterStage *stage;
|
||||
ClutterEvent *event = NULL;
|
||||
ClutterPoint 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)
|
||||
return;
|
||||
|
||||
device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (input_device);
|
||||
seat = _clutter_input_device_evdev_get_seat (device_evdev);
|
||||
|
||||
event = clutter_event_new (CLUTTER_TOUCHPAD_PINCH);
|
||||
|
||||
clutter_input_device_get_coords (seat->core_pointer, NULL, &pos);
|
||||
|
||||
event->touchpad_pinch.phase = phase;
|
||||
event->touchpad_pinch.time = time_;
|
||||
event->touchpad_pinch.stage = CLUTTER_STAGE (stage);
|
||||
event->touchpad_pinch.x = pos.x;
|
||||
event->touchpad_pinch.y = pos.y;
|
||||
event->touchpad_pinch.angle_delta = angle_delta;
|
||||
event->touchpad_pinch.scale = scale;
|
||||
|
||||
_clutter_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_swipe_gesture_event (ClutterInputDevice *input_device,
|
||||
ClutterTouchpadGesturePhase phase,
|
||||
guint32 time_,
|
||||
guint n_fingers,
|
||||
gdouble dx,
|
||||
gdouble dy)
|
||||
{
|
||||
ClutterInputDeviceEvdev *device_evdev;
|
||||
ClutterSeatEvdev *seat;
|
||||
ClutterStage *stage;
|
||||
ClutterEvent *event = NULL;
|
||||
ClutterPoint 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)
|
||||
return;
|
||||
|
||||
device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (input_device);
|
||||
seat = _clutter_input_device_evdev_get_seat (device_evdev);
|
||||
|
||||
event = clutter_event_new (CLUTTER_TOUCHPAD_SWIPE);
|
||||
|
||||
event->touchpad_swipe.phase = phase;
|
||||
event->touchpad_swipe.time = time_;
|
||||
event->touchpad_swipe.stage = CLUTTER_STAGE (stage);
|
||||
|
||||
clutter_input_device_get_coords (seat->core_pointer, NULL, &pos);
|
||||
event->touchpad_swipe.x = pos.x;
|
||||
event->touchpad_swipe.y = pos.y;
|
||||
event->touchpad_swipe.dx = dx;
|
||||
event->touchpad_swipe.dy = dy;
|
||||
event->touchpad_swipe.n_fingers = n_fingers;
|
||||
|
||||
_clutter_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
|
||||
dispatch_libinput (ClutterDeviceManagerEvdev *manager_evdev)
|
||||
{
|
||||
@ -1372,6 +1460,83 @@ process_device_event (ClutterDeviceManagerEvdev *manager_evdev,
|
||||
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
||||
case LIBINPUT_EVENT_GESTURE_PINCH_END:
|
||||
{
|
||||
struct libinput_event_gesture *gesture_event =
|
||||
libinput_event_get_gesture_event (event);
|
||||
ClutterTouchpadGesturePhase phase;
|
||||
guint32 time;
|
||||
|
||||
if (libinput_event_get_type (event) == LIBINPUT_EVENT_GESTURE_PINCH_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;
|
||||
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
time = libinput_event_gesture_get_time (gesture_event);
|
||||
notify_pinch_gesture_event (device, phase, time, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
|
||||
{
|
||||
struct libinput_event_gesture *gesture_event =
|
||||
libinput_event_get_gesture_event (event);
|
||||
gdouble angle_delta, scale, dx, dy;
|
||||
guint32 time;
|
||||
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
time = libinput_event_gesture_get_time (gesture_event);
|
||||
angle_delta = libinput_event_gesture_get_angle_delta (gesture_event);
|
||||
scale = libinput_event_gesture_get_scale (gesture_event);
|
||||
dx = libinput_event_gesture_get_dx (gesture_event);
|
||||
dy = libinput_event_gesture_get_dx (gesture_event);
|
||||
|
||||
notify_pinch_gesture_event (device,
|
||||
CLUTTER_TOUCHPAD_GESTURE_PHASE_UPDATE,
|
||||
time, dx, dy, angle_delta, scale);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
|
||||
{
|
||||
struct libinput_event_gesture *gesture_event =
|
||||
libinput_event_get_gesture_event (event);
|
||||
ClutterTouchpadGesturePhase phase;
|
||||
guint32 time, n_fingers;
|
||||
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
time = libinput_event_gesture_get_time (gesture_event);
|
||||
n_fingers = libinput_event_gesture_get_finger_count (gesture_event);
|
||||
|
||||
if (libinput_event_get_type (event) == LIBINPUT_EVENT_GESTURE_SWIPE_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_swipe_gesture_event (device, phase, time, n_fingers, 0, 0);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
|
||||
{
|
||||
struct libinput_event_gesture *gesture_event =
|
||||
libinput_event_get_gesture_event (event);
|
||||
guint32 time, n_fingers;
|
||||
gdouble dx, dy;
|
||||
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
time = libinput_event_gesture_get_time (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);
|
||||
|
||||
notify_swipe_gesture_event (device,
|
||||
CLUTTER_TOUCHPAD_GESTURE_PHASE_UPDATE,
|
||||
time, n_fingers, dx, dy);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
handled = FALSE;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ m4_define([gi_req_version], [1.39.0])
|
||||
m4_define([gtk_doc_req_version], [1.20])
|
||||
m4_define([xcomposite_req_version], [0.4])
|
||||
m4_define([gdk_req_version], [3.3.18])
|
||||
m4_define([libinput_req_version], [0.8.0])
|
||||
m4_define([libinput_req_version], [0.19.0])
|
||||
m4_define([libudev_req_version], [136])
|
||||
|
||||
AC_SUBST([GLIB_REQ_VERSION], [glib_req_version])
|
||||
|
Loading…
Reference in New Issue
Block a user