Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
tinywl: add high-resolution scroll support
Browse files Browse the repository at this point in the history
Demostrate how to use the high-resolution scroll API.
  • Loading branch information
JoseExposito committed Aug 9, 2021
1 parent 7666f7a commit 4e30fb2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tinywl/tinywl.c
Expand Up @@ -45,6 +45,7 @@ struct tinywl_server {
struct wl_listener cursor_motion_absolute;
struct wl_listener cursor_button;
struct wl_listener cursor_axis;
struct wl_listener cursor_axis_v120;
struct wl_listener cursor_frame;

struct wlr_seat *seat;
Expand Down Expand Up @@ -519,6 +520,19 @@ static void server_cursor_axis(struct wl_listener *listener, void *data) {
event->delta_discrete, event->source);
}

static void server_cursor_axis_v120(struct wl_listener *listener, void *data) {
/* This event is forwarded by the cursor when a pointer emits a
* high-resolution axis event, for example when you move the scroll wheel
* using a gamming mouse. */
struct tinywl_server *server =
wl_container_of(listener, server, cursor_axis_v120);
struct wlr_event_pointer_axis_v120 *event = data;
/* Notify the client with pointer focus of the axis event. */
wlr_seat_pointer_notify_axis_v120(server->seat,
event->time_msec, event->orientation, event->delta,
event->delta_v120, event->source);
}

static void server_cursor_frame(struct wl_listener *listener, void *data) {
/* This event is forwarded by the cursor when a pointer emits an frame
* event. Frame events are sent after regular pointer events to group
Expand Down Expand Up @@ -915,6 +929,8 @@ int main(int argc, char *argv[]) {
wl_signal_add(&server.cursor->events.button, &server.cursor_button);
server.cursor_axis.notify = server_cursor_axis;
wl_signal_add(&server.cursor->events.axis, &server.cursor_axis);
server.cursor_axis_v120.notify = server_cursor_axis_v120;
wl_signal_add(&server.cursor->events.axis_v120, &server.cursor_axis_v120);
server.cursor_frame.notify = server_cursor_frame;
wl_signal_add(&server.cursor->events.frame, &server.cursor_frame);

Expand Down

0 comments on commit 4e30fb2

Please sign in to comment.