diff options
-rw-r--r-- | backend/libinput/pointer.c | 6 | ||||
-rw-r--r-- | backend/wayland/wl_seat.c | 9 | ||||
-rw-r--r-- | backend/x11/input_device.c | 6 | ||||
-rw-r--r-- | include/backend/wayland.h | 1 | ||||
-rw-r--r-- | include/wlr/types/wlr_pointer.h | 1 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 9 | ||||
-rw-r--r-- | rootston/cursor.c | 2 | ||||
-rw-r--r-- | types/data_device/wlr_drag.c | 3 | ||||
-rw-r--r-- | types/seat/wlr_seat_pointer.c | 29 | ||||
-rw-r--r-- | types/wlr_wl_shell.c | 6 | ||||
-rw-r--r-- | types/wlr_xdg_shell.c | 6 | ||||
-rw-r--r-- | types/wlr_xdg_shell_v6.c | 6 |
12 files changed, 62 insertions, 22 deletions
diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 9a39b66b..f628cf22 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -126,8 +126,10 @@ void handle_pointer_axis(struct libinput_event *event, wlr_event.orientation = WLR_AXIS_ORIENTATION_HORIZONTAL; break; } - wlr_event.delta = libinput_event_pointer_get_axis_value( - pevent, axies[i]); + wlr_event.delta = + libinput_event_pointer_get_axis_value(pevent, axies[i]); + wlr_event.delta_discrete = + libinput_event_pointer_get_axis_value_discrete(pevent, axies[i]); wlr_signal_emit_safe(&wlr_dev->pointer->events.axis, &wlr_event); } } diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 8191cb80..cf9b9372 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -111,11 +111,14 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, struct wlr_event_pointer_axis event = { .device = &pointer->input_device->wlr_input_device, .delta = wl_fixed_to_double(value), + .delta_discrete = pointer->axis_discrete, .orientation = axis, .time_msec = time, .source = pointer->axis_source, }; wlr_signal_emit_safe(&pointer->wlr_pointer.events.axis, &event); + + pointer->axis_discrete = 0; } static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) { @@ -140,7 +143,13 @@ static void pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer, static void pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer, uint32_t axis, int32_t discrete) { + struct wlr_wl_backend *backend = data; + struct wlr_wl_pointer *pointer = backend->current_pointer; + if (pointer == NULL) { + return; + } + pointer->axis_discrete = discrete; } static const struct wl_pointer_listener pointer_listener = { diff --git a/backend/x11/input_device.c b/backend/x11/input_device.c index 75cfa76e..a16da1c9 100644 --- a/backend/x11/input_device.c +++ b/backend/x11/input_device.c @@ -73,13 +73,15 @@ void handle_x11_input_event(struct wlr_x11_backend *x11, if (ev->detail == XCB_BUTTON_INDEX_4 || ev->detail == XCB_BUTTON_INDEX_5) { - double delta = (ev->detail == XCB_BUTTON_INDEX_4 ? -15 : 15); + int32_t delta_discrete = ev->detail == XCB_BUTTON_INDEX_4 ? -1 : 1; struct wlr_event_pointer_axis axis = { .device = &output->pointer_dev, .time_msec = ev->time, .source = WLR_AXIS_SOURCE_WHEEL, .orientation = WLR_AXIS_ORIENTATION_VERTICAL, - .delta = delta, + // 15 is a typical value libinput sends for one scroll + .delta = delta_discrete * 15, + .delta_discrete = delta_discrete, }; wlr_signal_emit_safe(&output->pointer.events.axis, &axis); x11->time = ev->time; diff --git a/include/backend/wayland.h b/include/backend/wayland.h index fda27da9..46f18c84 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -72,6 +72,7 @@ struct wlr_wl_pointer { struct wlr_wl_input_device *input_device; struct wl_pointer *wl_pointer; enum wlr_axis_source axis_source; + int32_t axis_discrete; struct wlr_wl_output *output; struct wl_listener output_destroy; diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 45619e0a..48c89151 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -58,6 +58,7 @@ struct wlr_event_pointer_axis { enum wlr_axis_source source; enum wlr_axis_orientation orientation; double delta; + int32_t delta_discrete; }; #endif diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index e1fa27bb..f4840c89 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -60,7 +60,8 @@ struct wlr_pointer_grab_interface { uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state); void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time, - enum wlr_axis_orientation orientation, double value); + enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source); void (*cancel)(struct wlr_seat_pointer_grab *grab); }; @@ -300,7 +301,8 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, * grabs. **/ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, - enum wlr_axis_orientation orientation, double value); + enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source); /** * Start a grab of the pointer of this seat. The grabber is responsible for @@ -341,7 +343,8 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, * Notify the seat of an axis event. */ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time, - enum wlr_axis_orientation orientation, double value); + enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source); /** * Whether or not the pointer has a grab other than the default grab. diff --git a/rootston/cursor.c b/rootston/cursor.c index 61a34db9..55b145e2 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -313,7 +313,7 @@ void roots_cursor_handle_button(struct roots_cursor *cursor, void roots_cursor_handle_axis(struct roots_cursor *cursor, struct wlr_event_pointer_axis *event) { wlr_seat_pointer_notify_axis(cursor->seat->seat, event->time_msec, - event->orientation, event->delta); + event->orientation, event->delta, event->delta_discrete, event->source); } void roots_cursor_handle_touch_down(struct roots_cursor *cursor, diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c index 72a5bc41..331fba2f 100644 --- a/types/data_device/wlr_drag.c +++ b/types/data_device/wlr_drag.c @@ -191,7 +191,8 @@ static uint32_t drag_handle_pointer_button(struct wlr_seat_pointer_grab *grab, } static void drag_handle_pointer_axis(struct wlr_seat_pointer_grab *grab, - uint32_t time, enum wlr_axis_orientation orientation, double value) { + uint32_t time, enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source) { // This space is intentionally left blank } diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index 4a0bcef1..3271c090 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -25,8 +25,10 @@ static uint32_t default_pointer_button(struct wlr_seat_pointer_grab *grab, } static void default_pointer_axis(struct wlr_seat_pointer_grab *grab, - uint32_t time, enum wlr_axis_orientation orientation, double value) { - wlr_seat_pointer_send_axis(grab->seat, time, orientation, value); + uint32_t time, enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source) { + wlr_seat_pointer_send_axis(grab->seat, time, orientation, value, + value_discrete, source); } static void default_pointer_cancel(struct wlr_seat_pointer_grab *grab) { @@ -224,7 +226,8 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, } void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, - enum wlr_axis_orientation orientation, double value) { + enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source) { struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client; if (client == NULL) { return; @@ -236,11 +239,21 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, continue; } + uint32_t version = wl_resource_get_version(resource); + + if (version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION) { + wl_pointer_send_axis_source(resource, source); + } if (value) { + if (value_discrete && + version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) { + wl_pointer_send_axis_discrete(resource, orientation, + value_discrete); + } + wl_pointer_send_axis(resource, time, orientation, wl_fixed_from_double(value)); - } else if (wl_resource_get_version(resource) >= - WL_POINTER_AXIS_STOP_SINCE_VERSION) { + } else if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) { wl_pointer_send_axis_stop(resource, time, orientation); } pointer_send_frame(resource); @@ -304,10 +317,12 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, } void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time, - enum wlr_axis_orientation orientation, double value) { + enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source) { clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event); struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab; - grab->interface->axis(grab, time, orientation, value); + grab->interface->axis(grab, time, orientation, value, value_discrete, + source); } bool wlr_seat_pointer_has_grab(struct wlr_seat *seat) { diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 6010869e..05f9f19c 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -93,8 +93,10 @@ static void shell_pointer_grab_cancel(struct wlr_seat_pointer_grab *grab) { } static void shell_pointer_grab_axis(struct wlr_seat_pointer_grab *grab, - uint32_t time, enum wlr_axis_orientation orientation, double value) { - wlr_seat_pointer_send_axis(grab->seat, time, orientation, value); + uint32_t time, enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source) { + wlr_seat_pointer_send_axis(grab->seat, time, orientation, value, + value_discrete, source); } static const struct wlr_pointer_grab_interface shell_pointer_grab_impl = { diff --git a/types/wlr_xdg_shell.c b/types/wlr_xdg_shell.c index cd612e30..b626b772 100644 --- a/types/wlr_xdg_shell.c +++ b/types/wlr_xdg_shell.c @@ -77,8 +77,10 @@ static uint32_t xdg_pointer_grab_button(struct wlr_seat_pointer_grab *grab, } static void xdg_pointer_grab_axis(struct wlr_seat_pointer_grab *grab, - uint32_t time, enum wlr_axis_orientation orientation, double value) { - wlr_seat_pointer_send_axis(grab->seat, time, orientation, value); + uint32_t time, enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source) { + wlr_seat_pointer_send_axis(grab->seat, time, orientation, value, + value_discrete, source); } static void xdg_pointer_grab_cancel(struct wlr_seat_pointer_grab *grab) { diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 8af6204f..29e4e605 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -87,8 +87,10 @@ static uint32_t xdg_pointer_grab_button(struct wlr_seat_pointer_grab *grab, } static void xdg_pointer_grab_axis(struct wlr_seat_pointer_grab *grab, - uint32_t time, enum wlr_axis_orientation orientation, double value) { - wlr_seat_pointer_send_axis(grab->seat, time, orientation, value); + uint32_t time, enum wlr_axis_orientation orientation, double value, + int32_t value_discrete, enum wlr_axis_source source) { + wlr_seat_pointer_send_axis(grab->seat, time, orientation, value, + value_discrete, source); } static void xdg_pointer_grab_cancel(struct wlr_seat_pointer_grab *grab) { |