diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-08-28 22:12:35 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-08-28 22:12:35 -0400 |
commit | 30611894f2c411830a57e813c441e901068ff033 (patch) | |
tree | 25954c301fb08d9a2e5e3f6a53be12f83a52a1f7 /examples | |
parent | 4fbe322fa6fcdbfda6b7006869358fdb47caff6e (diff) |
Implement tablet_tool support in pointer example
Diffstat (limited to 'examples')
-rw-r--r-- | examples/pointer.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/pointer.c b/examples/pointer.c index 936bfb6a..f808d9ab 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -51,6 +51,11 @@ struct sample_state { struct wl_listener touch_down; struct wl_listener touch_cancel; list_t *touch_points; + + struct wl_listener tablet_tool_axis; + struct wl_listener tablet_tool_proxmity; + struct wl_listener tablet_tool_tip; + struct wl_listener tablet_tool_button; }; struct touch_point { @@ -306,6 +311,17 @@ static void handle_touch_cancel(struct wl_listener *listener, void *data) { wlr_log(L_DEBUG, "TODO: touch cancel"); } +static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) { + struct sample_state *sample = wl_container_of(listener, sample, tablet_tool_axis); + struct wlr_event_tablet_tool_axis *event = data; + if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) + && (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { + wlr_cursor_warp_absolute(sample->cursor, event->device, + event->x_mm / event->width_mm, + event->y_mm / event->height_mm); + } +} + int main(int argc, char *argv[]) { struct sample_state state = { .default_color = { 0.25f, 0.25f, 0.25f, 1 }, @@ -344,6 +360,10 @@ int main(int argc, char *argv[]) { wl_signal_add(&state.cursor->events.touch_cancel, &state.touch_cancel); state.touch_cancel.notify = handle_touch_cancel; + // tool events + wl_signal_add(&state.cursor->events.tablet_tool_axis, &state.tablet_tool_axis); + state.tablet_tool_axis.notify = handle_tablet_tool_axis; + struct compositor_state compositor = { 0 }; compositor.data = &state; compositor.output_add_cb = handle_output_add; |