aboutsummaryrefslogtreecommitdiff
path: root/example/shared.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-06-13 12:38:57 -0400
committerDrew DeVault <sir@cmpwn.com>2017-06-13 12:38:57 -0400
commit7dfc2c28f1870a38357d6adbb48040151f3166b1 (patch)
tree2f5129542b3a2b58270f509e1435463dea2aa00d /example/shared.c
parent8f284ec0b23953ccc274291eeb612d782d391b07 (diff)
Add axis events to pointer example
Diffstat (limited to 'example/shared.c')
-rw-r--r--example/shared.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/example/shared.c b/example/shared.c
index 6a676343..6de16074 100644
--- a/example/shared.c
+++ b/example/shared.c
@@ -88,6 +88,15 @@ static void pointer_button_notify(struct wl_listener *listener, void *data) {
}
}
+static void pointer_axis_notify(struct wl_listener *listener, void *data) {
+ struct wlr_pointer_axis *event = data;
+ struct pointer_state *pstate = wl_container_of(listener, pstate, axis);
+ if (pstate->compositor->pointer_axis_cb) {
+ pstate->compositor->pointer_axis_cb(pstate,
+ event->source, event->orientation, event->delta);
+ }
+}
+
static void pointer_add(struct wlr_input_device *device, struct compositor_state *state) {
struct pointer_state *pstate = calloc(sizeof(struct pointer_state), 1);
pstate->device = device;
@@ -98,8 +107,10 @@ static void pointer_add(struct wlr_input_device *device, struct compositor_state
wl_list_init(&pstate->axis.link);
pstate->motion.notify = pointer_motion_notify;
pstate->button.notify = pointer_button_notify;
+ pstate->axis.notify = pointer_axis_notify;
wl_signal_add(&device->pointer->events.motion, &pstate->motion);
wl_signal_add(&device->pointer->events.button, &pstate->button);
+ wl_signal_add(&device->pointer->events.axis, &pstate->axis);
wl_list_insert(&state->pointers, &pstate->link);
}