aboutsummaryrefslogtreecommitdiff
path: root/example/shared.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-06-13 12:31:24 -0400
committerDrew DeVault <sir@cmpwn.com>2017-06-13 12:31:24 -0400
commit8f284ec0b23953ccc274291eeb612d782d391b07 (patch)
tree63fa9bc4f7136bb7b95c1658fd42506467221313 /example/shared.c
parent2f9fd72fdcf9249ed16bcc029a86e734ae1487a1 (diff)
Demonstrate pointer button event in example
Diffstat (limited to 'example/shared.c')
-rw-r--r--example/shared.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/example/shared.c b/example/shared.c
index 4657b7fe..6a676343 100644
--- a/example/shared.c
+++ b/example/shared.c
@@ -74,7 +74,17 @@ static void pointer_motion_notify(struct wl_listener *listener, void *data) {
struct wlr_pointer_motion *event = data;
struct pointer_state *pstate = wl_container_of(listener, pstate, motion);
if (pstate->compositor->pointer_motion_cb) {
- pstate->compositor->pointer_motion_cb(pstate, event->delta_x, event->delta_y);
+ pstate->compositor->pointer_motion_cb(pstate,
+ event->delta_x, event->delta_y);
+ }
+}
+
+static void pointer_button_notify(struct wl_listener *listener, void *data) {
+ struct wlr_pointer_button *event = data;
+ struct pointer_state *pstate = wl_container_of(listener, pstate, button);
+ if (pstate->compositor->pointer_button_cb) {
+ pstate->compositor->pointer_button_cb(pstate,
+ event->button, event->state);
}
}
@@ -87,7 +97,9 @@ static void pointer_add(struct wlr_input_device *device, struct compositor_state
wl_list_init(&pstate->button.link);
wl_list_init(&pstate->axis.link);
pstate->motion.notify = pointer_motion_notify;
+ pstate->button.notify = pointer_button_notify;
wl_signal_add(&device->pointer->events.motion, &pstate->motion);
+ wl_signal_add(&device->pointer->events.button, &pstate->button);
wl_list_insert(&state->pointers, &pstate->link);
}