mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 19:40:43 -05:00
evdev: use EV_SYN/SYN_REPORT for dispatching motion events
We can't dispatch a motion event for EV_REL (because we don't have yet the other half of the event), but we can't also queue them at the end of processing (because we may lose some history or have button/keys intermixed). Instead, we use EV_SYN, which means "one logical event was completed", and let the winsys-independent code do the actual motion compression. https://bugzilla.gnome.org/show_bug.cgi?id=706494
This commit is contained in:
parent
5e005b4298
commit
15d036ea1e
@ -129,6 +129,8 @@ struct _ClutterEventSource
|
|||||||
ClutterInputDeviceEvdev *device; /* back pointer to the slave evdev device */
|
ClutterInputDeviceEvdev *device; /* back pointer to the slave evdev device */
|
||||||
GPollFD event_poll_fd; /* file descriptor of the /dev node */
|
GPollFD event_poll_fd; /* file descriptor of the /dev node */
|
||||||
struct libevdev *dev;
|
struct libevdev *dev;
|
||||||
|
|
||||||
|
int dx, dy;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -447,9 +449,7 @@ notify_button (ClutterEventSource *source,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
dispatch_one_event (ClutterEventSource *source,
|
dispatch_one_event (ClutterEventSource *source,
|
||||||
struct input_event *e,
|
struct input_event *e)
|
||||||
int *dx,
|
|
||||||
int *dy)
|
|
||||||
{
|
{
|
||||||
guint32 _time;
|
guint32 _time;
|
||||||
|
|
||||||
@ -467,12 +467,26 @@ dispatch_one_event (ClutterEventSource *source,
|
|||||||
notify_button (source, _time, e->code, e->value);
|
notify_button (source, _time, e->code, e->value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* We don't know about this code, ignore */;
|
{
|
||||||
|
/* We don't know about this code, ignore */
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EV_SYN:
|
case EV_SYN:
|
||||||
|
if (e->code == SYN_REPORT)
|
||||||
|
{
|
||||||
|
/* Flush accumulated motion deltas */
|
||||||
|
if (source->dx != 0 || source->dy != 0)
|
||||||
|
{
|
||||||
|
notify_relative_motion (source, _time, source->dx, source->dy);
|
||||||
|
source->dx = 0;
|
||||||
|
source->dy = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EV_MSC:
|
case EV_MSC:
|
||||||
/* Nothing to do here (actually, EV_SYN is handled by libevdev, we shouldn't see it) */
|
/* Nothing to do here */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EV_REL:
|
case EV_REL:
|
||||||
@ -480,10 +494,10 @@ dispatch_one_event (ClutterEventSource *source,
|
|||||||
switch (e->code)
|
switch (e->code)
|
||||||
{
|
{
|
||||||
case REL_X:
|
case REL_X:
|
||||||
*dx += e->value;
|
source->dx += e->value;
|
||||||
break;
|
break;
|
||||||
case REL_Y:
|
case REL_Y:
|
||||||
*dy += e->value;
|
source->dy += e->value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REL_WHEEL:
|
case REL_WHEEL:
|
||||||
@ -507,14 +521,13 @@ sync_source (ClutterEventSource *source)
|
|||||||
{
|
{
|
||||||
struct input_event ev;
|
struct input_event ev;
|
||||||
int err;
|
int err;
|
||||||
int dx = 0, dy = 0;
|
|
||||||
const gchar *device_path;
|
const gchar *device_path;
|
||||||
|
|
||||||
/* We read a SYN_DROPPED, ignore it and sync the device */
|
/* We read a SYN_DROPPED, ignore it and sync the device */
|
||||||
err = libevdev_next_event (source->dev, LIBEVDEV_READ_SYNC, &ev);
|
err = libevdev_next_event (source->dev, LIBEVDEV_READ_SYNC, &ev);
|
||||||
while (err == 1)
|
while (err == 1)
|
||||||
{
|
{
|
||||||
dispatch_one_event (source, &ev, &dx, &dy);
|
dispatch_one_event (source, &ev);
|
||||||
err = libevdev_next_event (source->dev, LIBEVDEV_READ_SYNC, &ev);
|
err = libevdev_next_event (source->dev, LIBEVDEV_READ_SYNC, &ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,12 +537,6 @@ sync_source (ClutterEventSource *source)
|
|||||||
|
|
||||||
CLUTTER_NOTE (EVENT, "Could not sync device (%s).", device_path);
|
CLUTTER_NOTE (EVENT, "Could not sync device (%s).", device_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dx != 0 || dy != 0)
|
|
||||||
{
|
|
||||||
guint32 _time = ev.time.tv_sec * 1000 + ev.time.tv_usec / 1000;
|
|
||||||
notify_relative_motion (source, _time, dx, dy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -565,7 +572,7 @@ clutter_event_dispatch (GSource *g_source,
|
|||||||
struct input_event ev;
|
struct input_event ev;
|
||||||
ClutterEvent *event;
|
ClutterEvent *event;
|
||||||
ClutterStage *stage;
|
ClutterStage *stage;
|
||||||
int err, dx = 0, dy = 0;
|
int err;
|
||||||
|
|
||||||
_clutter_threads_acquire_lock ();
|
_clutter_threads_acquire_lock ();
|
||||||
|
|
||||||
@ -582,7 +589,7 @@ clutter_event_dispatch (GSource *g_source,
|
|||||||
if (err == 1)
|
if (err == 1)
|
||||||
sync_source (source);
|
sync_source (source);
|
||||||
else if (err == 0)
|
else if (err == 0)
|
||||||
dispatch_one_event (source, &ev, &dx, &dy);
|
dispatch_one_event (source, &ev);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fail_source (source, -err);
|
fail_source (source, -err);
|
||||||
@ -592,12 +599,6 @@ clutter_event_dispatch (GSource *g_source,
|
|||||||
err = libevdev_next_event (source->dev, LIBEVDEV_READ_NORMAL, &ev);
|
err = libevdev_next_event (source->dev, LIBEVDEV_READ_NORMAL, &ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dx != 0 || dy != 0)
|
|
||||||
{
|
|
||||||
guint32 _time = ev.time.tv_sec * 1000 + ev.time.tv_usec / 1000;
|
|
||||||
notify_relative_motion (source, _time, dx, dy);
|
|
||||||
}
|
|
||||||
|
|
||||||
queue_event:
|
queue_event:
|
||||||
/* Drop events if we don't have any stage to forward them to */
|
/* Drop events if we don't have any stage to forward them to */
|
||||||
if (stage == NULL)
|
if (stage == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user