diff options
author | Giovanni Campagna <gcampagn@redhat.com> | 2013-08-09 18:43:19 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagn@redhat.com> | 2013-08-14 16:50:45 +0200 |
commit | 0e519e2b3b0de6880533631ddfb85362727524a8 (patch) | |
tree | be36d6c3fffcb4110ee009812a3611a05689d411 | |
parent | 7b780b0c38ea95fa6a79b2cad1b070c245746255 (diff) | |
download | clutter-0e519e2b3b0de6880533631ddfb85362727524a8.tar.gz |
evdev: implement wheel events
Mouse wheel events come as EV_REL/REL_WHEEL, and we can convert
them to clutter events on the assumption that scrolling with
the wheel is always vertical.
https://bugzilla.gnome.org/show_bug.cgi?id=705710
-rw-r--r-- | clutter/evdev/clutter-device-manager-evdev.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c index 5a92e8ea6..cf65fa4ac 100644 --- a/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/evdev/clutter-device-manager-evdev.c @@ -275,6 +275,41 @@ notify_relative_motion (ClutterEventSource *source, } static void +notify_scroll (ClutterEventSource *source, + guint32 time_, + gint32 value) +{ + ClutterInputDevice *input_device = (ClutterInputDevice *) source->device; + ClutterDeviceManagerEvdev *manager_evdev; + ClutterStage *stage; + ClutterEvent *event = NULL; + ClutterPoint point; + + /* 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; + + manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (input_device->device_manager); + + event = clutter_event_new (CLUTTER_SCROLL); + + event->scroll.time = time_; + event->scroll.stage = CLUTTER_STAGE (stage); + event->scroll.device = manager_evdev->priv->core_pointer; + event->motion.modifier_state = xkb_state_serialize_mods (manager_evdev->priv->xkb, XKB_STATE_EFFECTIVE); + event->scroll.modifier_state |= manager_evdev->priv->button_state; + event->scroll.direction = value < 0 ? CLUTTER_SCROLL_DOWN : CLUTTER_SCROLL_UP; + clutter_input_device_get_coords (manager_evdev->priv->core_pointer, NULL, &point); + event->scroll.x = point.x; + event->scroll.y = point.y; + clutter_event_set_source_device (event, (ClutterInputDevice*) source->device); + + queue_event (event); +} + +static void notify_button (ClutterEventSource *source, guint32 time_, guint32 button, @@ -469,6 +504,14 @@ clutter_event_dispatch (GSource *g_source, case REL_Y: dy += e->value; break; + + /* Note: we assume that REL_WHEEL is for *vertical* scroll wheels. + To implement horizontal scroll, we'll need a different enum + value. + */ + case REL_WHEEL: + notify_scroll (source, _time, e->value); + break; } break; |