Hook up axis events.

dev
Scott Moreau 13 years ago
parent 3c97b9017d
commit 210d079817
  1. 7
      clients/simple-touch.c
  2. 8
      clients/window.c
  3. 11
      src/compositor-wayland.c
  4. 24
      src/compositor-x11.c
  5. 14
      src/compositor.c
  6. 3
      src/compositor.h
  7. 16
      src/evdev.c

@ -111,6 +111,12 @@ input_device_handle_button(void *data,
{ {
} }
static void
input_device_handle_axis(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t axis, int32_t value)
{
}
static void static void
input_device_handle_key(void *data, struct wl_input_device *input_device, input_device_handle_key(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t key, uint32_t state) uint32_t time, uint32_t key, uint32_t state)
@ -227,6 +233,7 @@ input_device_handle_touch_cancel(void *data,
static const struct wl_input_device_listener input_device_listener = { static const struct wl_input_device_listener input_device_listener = {
input_device_handle_motion, input_device_handle_motion,
input_device_handle_button, input_device_handle_button,
input_device_handle_axis,
input_device_handle_key, input_device_handle_key,
input_device_handle_pointer_enter, input_device_handle_pointer_enter,
input_device_handle_pointer_leave, input_device_handle_pointer_leave,

@ -1520,6 +1520,13 @@ input_handle_button(void *data,
input_ungrab(input, time); input_ungrab(input, time);
} }
static void
input_handle_axis(void *data,
struct wl_input_device *input_device,
uint32_t time, uint32_t axis, int32_t value)
{
}
static void static void
input_handle_key(void *data, struct wl_input_device *input_device, input_handle_key(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t key, uint32_t state) uint32_t time, uint32_t key, uint32_t state)
@ -1690,6 +1697,7 @@ input_handle_touch_cancel(void *data,
static const struct wl_input_device_listener input_device_listener = { static const struct wl_input_device_listener input_device_listener = {
input_handle_motion, input_handle_motion,
input_handle_button, input_handle_button,
input_handle_axis,
input_handle_key, input_handle_key,
input_handle_pointer_enter, input_handle_pointer_enter,
input_handle_pointer_leave, input_handle_pointer_leave,

@ -519,6 +519,16 @@ input_handle_button(void *data,
notify_button(c->base.input_device, time, button, state); notify_button(c->base.input_device, time, button, state);
} }
static void
input_handle_axis(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t axis, int32_t value)
{
struct wayland_input *input = data;
struct wayland_compositor *c = input->compositor;
notify_axis(c->base.input_device, time, axis, value);
}
static void static void
input_handle_key(void *data, struct wl_input_device *input_device, input_handle_key(void *data, struct wl_input_device *input_device,
uint32_t time, uint32_t key, uint32_t state) uint32_t time, uint32_t key, uint32_t state)
@ -586,6 +596,7 @@ input_handle_keyboard_leave(void *data,
static const struct wl_input_device_listener input_device_listener = { static const struct wl_input_device_listener input_device_listener = {
input_handle_motion, input_handle_motion,
input_handle_button, input_handle_button,
input_handle_axis,
input_handle_key, input_handle_key,
input_handle_pointer_enter, input_handle_pointer_enter,
input_handle_pointer_leave, input_handle_pointer_leave,

@ -485,14 +485,28 @@ x11_compositor_deliver_button_event(struct x11_compositor *c,
button = BTN_RIGHT; button = BTN_RIGHT;
break; break;
case 4: case 4:
if (state)
notify_axis(c->base.input_device,
weston_compositor_get_time(),
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, 1);
return;
case 5: case 5:
if (state)
notify_axis(c->base.input_device,
weston_compositor_get_time(),
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, -1);
return;
case 6: case 6:
if (state)
notify_axis(c->base.input_device,
weston_compositor_get_time(),
WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, 1);
return;
case 7: case 7:
/* X11 sends wheel events as buttons events. But if (state)
* linux input treats as REL_WHEEL, therefore not notify_axis(c->base.input_device,
* button type at all. When we update the input weston_compositor_get_time(),
* protocol and get the 'axis' event, we'll send WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, -1);
* scroll events as axis events. */
return; return;
} }

@ -1549,6 +1549,20 @@ notify_button(struct wl_input_device *device,
} }
WL_EXPORT void
notify_axis(struct wl_input_device *device,
uint32_t time, uint32_t axis, int32_t value)
{
struct weston_input_device *wd = (struct weston_input_device *) device;
struct weston_compositor *compositor = wd->compositor;
weston_compositor_activity(compositor);
if (device->pointer_focus_resource)
wl_resource_post_event(device->pointer_focus_resource,
WL_INPUT_DEVICE_AXIS, time, axis, value);
}
static void static void
update_modifier_state(struct weston_input_device *device, update_modifier_state(struct weston_input_device *device,
uint32_t key, uint32_t state) uint32_t key, uint32_t state)

@ -370,6 +370,9 @@ void
notify_button(struct wl_input_device *device, notify_button(struct wl_input_device *device,
uint32_t time, int32_t button, int32_t state); uint32_t time, int32_t button, int32_t state);
void void
notify_axis(struct wl_input_device *device,
uint32_t time, uint32_t axis, int32_t value);
void
notify_key(struct wl_input_device *device, notify_key(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t state); uint32_t time, uint32_t key, uint32_t state);

@ -227,8 +227,8 @@ evdev_process_absolute_motion_touchpad(struct evdev_input_device *device,
} }
static inline void static inline void
evdev_process_relative_motion(struct evdev_input_device *device, evdev_process_relative(struct evdev_input_device *device,
struct input_event *e) struct input_event *e, uint32_t time)
{ {
switch (e->code) { switch (e->code) {
case REL_X: case REL_X:
@ -239,6 +239,16 @@ evdev_process_relative_motion(struct evdev_input_device *device,
device->rel.dy += e->value; device->rel.dy += e->value;
device->type |= EVDEV_RELATIVE_MOTION; device->type |= EVDEV_RELATIVE_MOTION;
break; break;
case REL_WHEEL:
notify_axis(&device->master->base.input_device,
time,
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, e->value);
break;
case REL_HWHEEL:
notify_axis(&device->master->base.input_device,
time,
WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, e->value);
break;
} }
} }
@ -344,7 +354,7 @@ evdev_process_events(struct evdev_input_device *device,
evdev_flush_motion(device, time); evdev_flush_motion(device, time);
switch (e->type) { switch (e->type) {
case EV_REL: case EV_REL:
evdev_process_relative_motion(device, e); evdev_process_relative(device, e, time);
break; break;
case EV_ABS: case EV_ABS:
evdev_process_absolute(device, e); evdev_process_absolute(device, e);

Loading…
Cancel
Save