aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyivel <vyivel@posteo.net>2021-07-17 10:20:35 +0300
committerSimon Ser <contact@emersion.fr>2021-07-19 12:00:31 +0200
commita93b18dbd5a43735709c59590fa0bff427dd888d (patch)
tree787b27675189f929ff9d38c611424e1ae7542323
parenta47f89cf7c198153c153c53f52d42810e1c73ed5 (diff)
input/pointer: send axis source once per frame
Only one wl_pointer.axis_source event is permitted per frame, according to the Wayland specification. Fixes https://github.com/swaywm/wlroots/issues/2973
-rw-r--r--include/wlr/types/wlr_seat.h3
-rw-r--r--types/seat/wlr_seat_pointer.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 6ee9e44d..631b7dd3 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -164,6 +164,9 @@ struct wlr_seat_pointer_state {
struct wlr_seat_pointer_grab *grab;
struct wlr_seat_pointer_grab *default_grab;
+ bool sent_axis_source;
+ enum wlr_axis_source cached_axis_source;
+
uint32_t buttons[WLR_POINTER_BUTTONS_CAP];
size_t button_count;
uint32_t grab_button;
diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c
index 1bcbb4cb..c93df4cb 100644
--- a/types/seat/wlr_seat_pointer.c
+++ b/types/seat/wlr_seat_pointer.c
@@ -274,6 +274,15 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
return;
}
+ bool send_source = false;
+ if (wlr_seat->pointer_state.sent_axis_source) {
+ assert(wlr_seat->pointer_state.cached_axis_source == source);
+ } else {
+ wlr_seat->pointer_state.sent_axis_source = true;
+ wlr_seat->pointer_state.cached_axis_source = source;
+ send_source = true;
+ }
+
struct wl_resource *resource;
wl_resource_for_each(resource, &client->pointers) {
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {
@@ -282,7 +291,7 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
uint32_t version = wl_resource_get_version(resource);
- if (version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION) {
+ if (send_source && version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION) {
wl_pointer_send_axis_source(resource, source);
}
if (value) {
@@ -306,6 +315,8 @@ void wlr_seat_pointer_send_frame(struct wlr_seat *wlr_seat) {
return;
}
+ wlr_seat->pointer_state.sent_axis_source = false;
+
struct wl_resource *resource;
wl_resource_for_each(resource, &client->pointers) {
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {