evdev: Expose microsecond timestamps via the clutter evdev API
This is needed by Wayland compositors for certain types of events. https://bugzilla.gnome.org/show_bug.cgi?id=752752
This commit is contained in:
parent
9214d5029c
commit
52e38d1ab7
4 changed files with 44 additions and 0 deletions
|
@ -461,6 +461,7 @@ new_absolute_motion_event (ClutterInputDevice *input_device,
|
|||
y = CLAMP (y, 0.f, stage_height - 1);
|
||||
}
|
||||
|
||||
_clutter_evdev_event_set_time_usec (event, time_us);
|
||||
event->motion.time = us2ms (time_us);
|
||||
event->motion.stage = stage;
|
||||
event->motion.device = seat->core_pointer;
|
||||
|
@ -572,6 +573,7 @@ notify_discrete_scroll (ClutterInputDevice *input_device,
|
|||
|
||||
event = clutter_event_new (CLUTTER_SCROLL);
|
||||
|
||||
_clutter_evdev_event_set_time_usec (event, time_us);
|
||||
event->scroll.time = us2ms (time_us);
|
||||
event->scroll.stage = CLUTTER_STAGE (stage);
|
||||
event->scroll.device = seat->core_pointer;
|
||||
|
@ -616,6 +618,7 @@ notify_scroll (ClutterInputDevice *input_device,
|
|||
|
||||
event = clutter_event_new (CLUTTER_SCROLL);
|
||||
|
||||
_clutter_evdev_event_set_time_usec (event, time_us);
|
||||
event->scroll.time = us2ms (time_us);
|
||||
event->scroll.stage = CLUTTER_STAGE (stage);
|
||||
event->scroll.device = seat->core_pointer;
|
||||
|
@ -708,6 +711,7 @@ notify_button (ClutterInputDevice *input_device,
|
|||
else
|
||||
seat->button_state &= ~maskmap[button - BTN_LEFT];
|
||||
|
||||
_clutter_evdev_event_set_time_usec (event, time_us);
|
||||
event->button.time = us2ms (time_us);
|
||||
event->button.stage = CLUTTER_STAGE (stage);
|
||||
event->button.device = seat->core_pointer;
|
||||
|
@ -749,6 +753,7 @@ notify_touch_event (ClutterInputDevice *input_device,
|
|||
|
||||
event = clutter_event_new (evtype);
|
||||
|
||||
_clutter_evdev_event_set_time_usec (event, time_us);
|
||||
event->touch.time = us2ms (time_us);
|
||||
event->touch.stage = CLUTTER_STAGE (stage);
|
||||
event->touch.device = seat->core_pointer;
|
||||
|
@ -796,6 +801,7 @@ notify_pinch_gesture_event (ClutterInputDevice *input_device,
|
|||
|
||||
clutter_input_device_get_coords (seat->core_pointer, NULL, &pos);
|
||||
|
||||
_clutter_evdev_event_set_time_usec (event, time_us);
|
||||
event->touchpad_pinch.phase = phase;
|
||||
event->touchpad_pinch.time = us2ms (time_us);
|
||||
event->touchpad_pinch.stage = CLUTTER_STAGE (stage);
|
||||
|
@ -839,6 +845,7 @@ notify_swipe_gesture_event (ClutterInputDevice *input_device,
|
|||
|
||||
event = clutter_event_new (CLUTTER_TOUCHPAD_SWIPE);
|
||||
|
||||
_clutter_evdev_event_set_time_usec (event, time_us);
|
||||
event->touchpad_swipe.phase = phase;
|
||||
event->touchpad_swipe.time = us2ms (time_us);
|
||||
event->touchpad_swipe.stage = CLUTTER_STAGE (stage);
|
||||
|
|
|
@ -134,6 +134,9 @@ void clutter_evdev_warp_pointer (ClutterInputDevice *pointer_device,
|
|||
CLUTTER_AVAILABLE_IN_1_26
|
||||
guint32 clutter_evdev_event_get_event_code (const ClutterEvent *event);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_26
|
||||
guint64 clutter_evdev_event_get_time_usec (const ClutterEvent *event);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_26
|
||||
gboolean clutter_evdev_event_get_relative_motion (const ClutterEvent *event,
|
||||
double *dx,
|
||||
|
|
|
@ -33,6 +33,8 @@ struct _ClutterEventEvdev
|
|||
{
|
||||
guint32 evcode;
|
||||
|
||||
guint64 time_usec;
|
||||
|
||||
gboolean has_relative_motion;
|
||||
double dx;
|
||||
double dy;
|
||||
|
@ -86,6 +88,16 @@ _clutter_evdev_event_set_event_code (ClutterEvent *event,
|
|||
event_evdev->evcode = evcode;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_evdev_event_set_time_usec (ClutterEvent *event,
|
||||
guint64 time_usec)
|
||||
{
|
||||
ClutterEventEvdev *event_evdev;
|
||||
|
||||
event_evdev = clutter_evdev_event_ensure_platform_data (event);
|
||||
event_evdev->time_usec = time_usec;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_evdev_event_set_relative_motion (ClutterEvent *event,
|
||||
double dx,
|
||||
|
@ -123,6 +135,25 @@ clutter_evdev_event_get_event_code (const ClutterEvent *event)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_evdev_event_get_time_usec:
|
||||
* @event: a #ClutterEvent
|
||||
*
|
||||
* Returns the time in microsecond granularity, or 0 if unavailable.
|
||||
*
|
||||
* Returns: The time in microsecond granularity, or 0 if unavailable.
|
||||
*/
|
||||
guint64
|
||||
clutter_evdev_event_get_time_usec (const ClutterEvent *event)
|
||||
{
|
||||
ClutterEventEvdev *event_evdev = _clutter_event_get_platform_data (event);
|
||||
|
||||
if (event_evdev)
|
||||
return event_evdev->time_usec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_evdev_event_get_pointer_motion
|
||||
* @event: a #ClutterEvent
|
||||
|
|
|
@ -91,6 +91,9 @@ void _clutter_event_evdev_free (ClutterEv
|
|||
void _clutter_evdev_event_set_event_code (ClutterEvent *event,
|
||||
guint32 evcode);
|
||||
|
||||
void _clutter_evdev_event_set_time_usec (ClutterEvent *event,
|
||||
guint64 time_usec);
|
||||
|
||||
void _clutter_evdev_event_set_relative_motion (ClutterEvent *event,
|
||||
double dx,
|
||||
double dy,
|
||||
|
|
Loading…
Reference in a new issue