diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-01-27 10:22:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-27 10:22:06 -0500 |
commit | 018727b1fc41dcd739ab464c84581c44dd1497ca (patch) | |
tree | 31ae7fc75fdabcdc125bb1b3b29260503ea5b96a /backend | |
parent | 89eacf556a64512a4d6ba8241e91f1d287007ad2 (diff) | |
parent | b45fc24b1893484c02420fbb33d7ebb69bbf1eae (diff) |
Merge pull request #1503 from emersion/pointer-frame
pointer: add a frame event
Diffstat (limited to 'backend')
-rw-r--r-- | backend/libinput/pointer.c | 16 | ||||
-rw-r--r-- | backend/wayland/backend.c | 5 | ||||
-rw-r--r-- | backend/wayland/wl_seat.c | 25 | ||||
-rw-r--r-- | backend/x11/input_device.c | 2 |
4 files changed, 36 insertions, 12 deletions
diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index b9cf1dfe..0df16a10 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -39,6 +39,7 @@ void handle_pointer_motion(struct libinput_event *event, wlr_event.unaccel_dx = libinput_event_pointer_get_dx_unaccelerated(pevent); wlr_event.unaccel_dy = libinput_event_pointer_get_dy_unaccelerated(pevent); wlr_signal_emit_safe(&wlr_dev->pointer->events.motion, &wlr_event); + wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer); } void handle_pointer_motion_abs(struct libinput_event *event, @@ -58,6 +59,7 @@ void handle_pointer_motion_abs(struct libinput_event *event, wlr_event.x = libinput_event_pointer_get_absolute_x_transformed(pevent, 1); wlr_event.y = libinput_event_pointer_get_absolute_y_transformed(pevent, 1); wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event); + wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer); } void handle_pointer_button(struct libinput_event *event, @@ -84,6 +86,7 @@ void handle_pointer_button(struct libinput_event *event, break; } wlr_signal_emit_safe(&wlr_dev->pointer->events.button, &wlr_event); + wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer); } void handle_pointer_axis(struct libinput_event *event, @@ -114,13 +117,13 @@ void handle_pointer_axis(struct libinput_event *event, wlr_event.source = WLR_AXIS_SOURCE_WHEEL_TILT; break; } - enum libinput_pointer_axis axies[] = { + const enum libinput_pointer_axis axes[] = { LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, }; - for (size_t i = 0; i < sizeof(axies) / sizeof(axies[0]); ++i) { - if (libinput_event_pointer_has_axis(pevent, axies[i])) { - switch (axies[i]) { + for (size_t i = 0; i < sizeof(axes) / sizeof(axes[0]); ++i) { + if (libinput_event_pointer_has_axis(pevent, axes[i])) { + switch (axes[i]) { case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: wlr_event.orientation = WLR_AXIS_ORIENTATION_VERTICAL; break; @@ -129,10 +132,11 @@ void handle_pointer_axis(struct libinput_event *event, break; } wlr_event.delta = - libinput_event_pointer_get_axis_value(pevent, axies[i]); + libinput_event_pointer_get_axis_value(pevent, axes[i]); wlr_event.delta_discrete = - libinput_event_pointer_get_axis_value_discrete(pevent, axies[i]); + libinput_event_pointer_get_axis_value_discrete(pevent, axes[i]); wlr_signal_emit_safe(&wlr_dev->pointer->events.axis, &wlr_event); } } + wlr_signal_emit_safe(&wlr_dev->pointer->events.frame, wlr_dev->pointer); } diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index da41af02..2a937de7 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -67,16 +67,13 @@ static void registry_global(void *data, struct wl_registry *registry, if (strcmp(iface, wl_compositor_interface.name) == 0) { wl->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, 4); - } else if (strcmp(iface, wl_seat_interface.name) == 0) { wl->seat = wl_registry_bind(registry, name, - &wl_seat_interface, 2); + &wl_seat_interface, 5); wl_seat_add_listener(wl->seat, &seat_listener, wl); - } else if (strcmp(iface, wl_shm_interface.name) == 0) { wl->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); - } else if (strcmp(iface, xdg_wm_base_interface.name) == 0) { wl->xdg_wm_base = wl_registry_bind(registry, name, &xdg_wm_base_interface, 1); diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index b654197a..1229a0ac 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -126,7 +126,14 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, } static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) { - // This space is intentionally left blank + struct wlr_wl_backend *backend = data; + struct wlr_wl_pointer *pointer = backend->current_pointer; + if (pointer == NULL) { + return; + } + + wlr_signal_emit_safe(&pointer->wlr_pointer.events.frame, + &pointer->wlr_pointer); } static void pointer_handle_axis_source(void *data, @@ -142,7 +149,21 @@ static void pointer_handle_axis_source(void *data, static void pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis) { - // This space is intentionally left blank + struct wlr_wl_backend *backend = data; + struct wlr_wl_pointer *pointer = backend->current_pointer; + if (pointer == NULL) { + return; + } + + struct wlr_event_pointer_axis event = { + .device = &pointer->input_device->wlr_input_device, + .delta = 0, + .delta_discrete = 0, + .orientation = axis, + .time_msec = time, + .source = pointer->axis_source, + }; + wlr_signal_emit_safe(&pointer->wlr_pointer.events.axis, &event); } static void pointer_handle_axis_discrete(void *data, diff --git a/backend/x11/input_device.c b/backend/x11/input_device.c index 915d9958..3a21f69c 100644 --- a/backend/x11/input_device.c +++ b/backend/x11/input_device.c @@ -50,6 +50,7 @@ static void send_axis_event(struct wlr_x11_output *output, int32_t delta, .delta_discrete = delta, }; wlr_signal_emit_safe(&output->pointer.events.axis, &ev); + wlr_signal_emit_safe(&output->pointer.events.frame, &output->pointer); } static void send_pointer_position_event(struct wlr_x11_output *output, @@ -61,6 +62,7 @@ static void send_pointer_position_event(struct wlr_x11_output *output, .y = (double)y / output->wlr_output.height, }; wlr_signal_emit_safe(&output->pointer.events.motion_absolute, &ev); + wlr_signal_emit_safe(&output->pointer.events.frame, &output->pointer); } void handle_x11_xinput_event(struct wlr_x11_backend *x11, |