Use an event struct to pass axis events around. This helps dealing with the
upcoming axis discrete changes.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
Changes to v2:
- new in this series

 desktop-shell/exposay.c    |  2 +-
 desktop-shell/shell.c      | 17 ++++++++++-------
 ivi-shell/hmi-controller.c |  5 +++--
 src/bindings.c             | 10 +++++-----
 src/compositor-wayland.c   |  6 +++++-
 src/compositor-x11.c       | 37 +++++++++++++++++++++++++------------
 src/compositor.h           | 22 +++++++++++++++-------
 src/data-device.c          |  2 +-
 src/input.c                | 21 ++++++++++++---------
 src/libinput-device.c      | 11 +++++++----
 10 files changed, 84 insertions(+), 49 deletions(-)

diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index 8bd55fb..f837859 100644
--- a/desktop-shell/exposay.c
+++ b/desktop-shell/exposay.c
@@ -387,7 +387,7 @@ exposay_button(struct weston_pointer_grab *grab, uint32_t 
time, uint32_t button,
 
 static void
 exposay_axis(struct weston_pointer_grab *grab,
-            uint32_t time, uint32_t axis, wl_fixed_t value)
+            uint32_t time, struct weston_pointer_axis_event *event)
 {
 }
 
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 780902d..8d168ea 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1593,7 +1593,7 @@ noop_grab_focus(struct weston_pointer_grab *grab)
 
 static void
 noop_grab_axis(struct weston_pointer_grab *grab,
-              uint32_t time, uint32_t axis, wl_fixed_t value)
+              uint32_t time, struct weston_pointer_axis_event *event)
 {
 }
 
@@ -3201,9 +3201,10 @@ popup_grab_button(struct weston_pointer_grab *grab,
 
 static void
 popup_grab_axis(struct weston_pointer_grab *grab,
-               uint32_t time, uint32_t axis, wl_fixed_t value)
+               uint32_t time,
+               struct weston_pointer_axis_event *event)
 {
-       weston_pointer_send_axis(grab->pointer, time, axis, value);
+       weston_pointer_send_axis(grab->pointer, time, event);
 }
 
 static void
@@ -4718,7 +4719,8 @@ resize_binding(struct weston_pointer *pointer, uint32_t 
time,
 
 static void
 surface_opacity_binding(struct weston_pointer *pointer, uint32_t time,
-                       uint32_t axis, wl_fixed_t value, void *data)
+                       struct weston_pointer_axis_event *event,
+                       void *data)
 {
        float step = 0.005;
        struct shell_surface *shsurf;
@@ -4734,7 +4736,7 @@ surface_opacity_binding(struct weston_pointer *pointer, 
uint32_t time,
        if (!shsurf)
                return;
 
-       shsurf->view->alpha -= wl_fixed_to_double(value) * step;
+       shsurf->view->alpha -= wl_fixed_to_double(event->value) * step;
 
        if (shsurf->view->alpha > 1.0)
                shsurf->view->alpha = 1.0;
@@ -4797,9 +4799,10 @@ do_zoom(struct weston_seat *seat, uint32_t time, 
uint32_t key, uint32_t axis,
 
 static void
 zoom_axis_binding(struct weston_pointer *pointer, uint32_t time,
-                 uint32_t axis, wl_fixed_t value, void *data)
+                 struct weston_pointer_axis_event *event,
+                 void *data)
 {
-       do_zoom(pointer->seat, time, 0, axis, value);
+       do_zoom(pointer->seat, time, 0, event->axis, event->value);
 }
 
 static void
diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index e10f4ff..354fa4d 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -1324,9 +1324,10 @@ pointer_noop_grab_focus(struct weston_pointer_grab *grab)
 
 static void
 pointer_default_grab_axis(struct weston_pointer_grab *grab,
-                         uint32_t time, uint32_t axis, wl_fixed_t value)
+                         uint32_t time,
+                         struct weston_pointer_axis_event *event)
 {
-       weston_pointer_send_axis(grab->pointer, time, axis, value);
+       weston_pointer_send_axis(grab->pointer, time, event);
 }
 
 static void
diff --git a/src/bindings.c b/src/bindings.c
index 234c034..cc68cfe 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -390,20 +390,20 @@ weston_compositor_run_touch_binding(struct 
weston_compositor *compositor,
 int
 weston_compositor_run_axis_binding(struct weston_compositor *compositor,
                                   struct weston_pointer *pointer,
-                                  uint32_t time, uint32_t axis,
-                                  wl_fixed_t value)
+                                  uint32_t time,
+                                  struct weston_pointer_axis_event *event)
 {
        struct weston_binding *b, *tmp;
 
        /* Invalidate all active modifier bindings. */
        wl_list_for_each(b, &compositor->modifier_binding_list, link)
-               b->key = axis;
+               b->key = event->axis;
 
        wl_list_for_each_safe(b, tmp, &compositor->axis_binding_list, link) {
-               if (b->axis == axis &&
+               if (b->axis == event->axis &&
                    b->modifier == pointer->seat->modifier_state) {
                        weston_axis_binding_handler_t handler = b->handler;
-                       handler(pointer, time, axis, value, b->data);
+                       handler(pointer, time, event, b->data);
                        return 1;
                }
        }
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 792c256..f94d166 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -1427,8 +1427,12 @@ input_handle_axis(void *data, struct wl_pointer *pointer,
                  uint32_t time, uint32_t axis, wl_fixed_t value)
 {
        struct wayland_input *input = data;
+       struct weston_pointer_axis_event weston_event;
 
-       notify_axis(&input->base, time, axis, value);
+       weston_event.axis = axis;
+       weston_event.value = value;
+
+       notify_axis(&input->base, time, &weston_event);
 }
 
 static const struct wl_pointer_listener pointer_listener = {
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 26e387e..93018da 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -1047,6 +1047,7 @@ x11_backend_deliver_button_event(struct x11_backend *b,
                (xcb_button_press_event_t *) event;
        uint32_t button;
        struct x11_output *output;
+       struct weston_pointer_axis_event weston_event;
 
        output = x11_backend_find_output(b, button_event->event);
        if (!output)
@@ -1082,32 +1083,44 @@ x11_backend_deliver_button_event(struct x11_backend *b,
        case 4:
                /* Axis are measured in pixels, but the xcb events are discrete
                 * steps. Therefore move the axis by some pixels every step. */
-               if (state)
+               if (state) {
+                       weston_event.value = -DEFAULT_AXIS_STEP_DISTANCE;
+                       weston_event.axis =
+                               WL_POINTER_AXIS_VERTICAL_SCROLL;
                        notify_axis(&b->core_seat,
                                    weston_compositor_get_time(),
-                                   WL_POINTER_AXIS_VERTICAL_SCROLL,
-                                   -DEFAULT_AXIS_STEP_DISTANCE);
+                                   &weston_event);
+               }
                return;
        case 5:
-               if (state)
+               if (state) {
+                       weston_event.value = DEFAULT_AXIS_STEP_DISTANCE;
+                       weston_event.axis =
+                               WL_POINTER_AXIS_VERTICAL_SCROLL;
                        notify_axis(&b->core_seat,
                                    weston_compositor_get_time(),
-                                   WL_POINTER_AXIS_VERTICAL_SCROLL,
-                                   DEFAULT_AXIS_STEP_DISTANCE);
+                                   &weston_event);
+               }
                return;
        case 6:
-               if (state)
+               if (state) {
+                       weston_event.value = -DEFAULT_AXIS_STEP_DISTANCE;
+                       weston_event.axis =
+                               WL_POINTER_AXIS_HORIZONTAL_SCROLL;
                        notify_axis(&b->core_seat,
                                    weston_compositor_get_time(),
-                                   WL_POINTER_AXIS_HORIZONTAL_SCROLL,
-                                   -DEFAULT_AXIS_STEP_DISTANCE);
+                                   &weston_event);
+               }
                return;
        case 7:
-               if (state)
+               if (state) {
+                       weston_event.value = DEFAULT_AXIS_STEP_DISTANCE;
+                       weston_event.axis =
+                               WL_POINTER_AXIS_HORIZONTAL_SCROLL;
                        notify_axis(&b->core_seat,
                                    weston_compositor_get_time(),
-                                   WL_POINTER_AXIS_HORIZONTAL_SCROLL,
-                                   DEFAULT_AXIS_STEP_DISTANCE);
+                                   &weston_event);
+               }
                return;
        default:
                button = button_event->detail + BTN_SIDE - 8;
diff --git a/src/compositor.h b/src/compositor.h
index 43db92e..bf38784 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -253,6 +253,11 @@ struct weston_pointer_motion_event {
        double dy;
 };
 
+struct weston_pointer_axis_event {
+       uint32_t axis;
+       wl_fixed_t value;
+};
+
 struct weston_pointer_grab;
 struct weston_pointer_grab_interface {
        void (*focus)(struct weston_pointer_grab *grab);
@@ -261,7 +266,8 @@ struct weston_pointer_grab_interface {
        void (*button)(struct weston_pointer_grab *grab,
                       uint32_t time, uint32_t button, uint32_t state);
        void (*axis)(struct weston_pointer_grab *grab,
-                    uint32_t time, uint32_t axis, wl_fixed_t value);
+                    uint32_t time,
+                    struct weston_pointer_axis_event *event);
        void (*cancel)(struct weston_pointer_grab *grab);
 };
 
@@ -397,7 +403,8 @@ void
 weston_pointer_destroy(struct weston_pointer *pointer);
 void
 weston_pointer_send_axis(struct weston_pointer *pointer,
-                        uint32_t time, uint32_t axis, wl_fixed_t value);
+                        uint32_t time,
+                        struct weston_pointer_axis_event *event);
 void
 weston_pointer_set_focus(struct weston_pointer *pointer,
                         struct weston_view *view,
@@ -1133,8 +1140,8 @@ void
 notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
              enum wl_pointer_button_state state);
 void
-notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
-           wl_fixed_t value);
+notify_axis(struct weston_seat *seat, uint32_t time,
+           struct weston_pointer_axis_event *event);
 void
 notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
           enum wl_keyboard_key_state state,
@@ -1255,8 +1262,9 @@ weston_compositor_add_touch_binding(struct 
weston_compositor *compositor,
                                    void *data);
 
 typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
-                                             uint32_t time, uint32_t axis,
-                                             wl_fixed_t value, void *data);
+                                             uint32_t time,
+                                             struct weston_pointer_axis_event 
*event,
+                                             void *data);
 struct weston_binding *
 weston_compositor_add_axis_binding(struct weston_compositor *compositor,
                                   uint32_t axis,
@@ -1302,7 +1310,7 @@ weston_compositor_run_touch_binding(struct 
weston_compositor *compositor,
 int
 weston_compositor_run_axis_binding(struct weston_compositor *compositor,
                                   struct weston_pointer *pointer, uint32_t 
time,
-                                  uint32_t axis, int32_t value);
+                                  struct weston_pointer_axis_event *event);
 int
 weston_compositor_run_debug_binding(struct weston_compositor *compositor,
                                    struct weston_keyboard *keyboard, uint32_t 
time,
diff --git a/src/data-device.c b/src/data-device.c
index d3ead5f..9bb4472 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -412,7 +412,7 @@ drag_grab_button(struct weston_pointer_grab *grab,
 
 static void
 drag_grab_axis(struct weston_pointer_grab *grab,
-              uint32_t time, uint32_t axis, wl_fixed_t value)
+              uint32_t time, struct weston_pointer_axis_event *event)
 {
 }
 
diff --git a/src/input.c b/src/input.c
index 097c8e7..b87c51c 100644
--- a/src/input.c
+++ b/src/input.c
@@ -333,7 +333,8 @@ default_grab_pointer_button(struct weston_pointer_grab 
*grab,
  */
 WL_EXPORT void
 weston_pointer_send_axis(struct weston_pointer *pointer,
-                        uint32_t time, uint32_t axis, wl_fixed_t value)
+                        uint32_t time,
+                        struct weston_pointer_axis_event *event)
 {
        struct wl_resource *resource;
        struct wl_list *resource_list;
@@ -343,14 +344,16 @@ weston_pointer_send_axis(struct weston_pointer *pointer,
 
        resource_list = &pointer->focus_client->pointer_resources;
        wl_resource_for_each(resource, resource_list)
-               wl_pointer_send_axis(resource, time, axis, value);
+               wl_pointer_send_axis(resource, time,
+                                    event->axis, event->value);
 }
 
 static void
 default_grab_pointer_axis(struct weston_pointer_grab *grab,
-                         uint32_t time, uint32_t axis, wl_fixed_t value)
+                         uint32_t time,
+                         struct weston_pointer_axis_event *event)
 {
-       weston_pointer_send_axis(grab->pointer, time, axis, value);
+       weston_pointer_send_axis(grab->pointer, time, event);
 }
 
 static void
@@ -1266,22 +1269,22 @@ notify_button(struct weston_seat *seat, uint32_t time, 
int32_t button,
 }
 
 WL_EXPORT void
-notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
-           wl_fixed_t value)
+notify_axis(struct weston_seat *seat, uint32_t time,
+           struct weston_pointer_axis_event *event)
 {
        struct weston_compositor *compositor = seat->compositor;
        struct weston_pointer *pointer = weston_seat_get_pointer(seat);
 
        weston_compositor_wake(compositor);
 
-       if (!value)
+       if (!event->value)
                return;
 
        if (weston_compositor_run_axis_binding(compositor, pointer,
-                                              time, axis, value))
+                                              time, event))
                return;
 
-       pointer->grab->interface->axis(pointer->grab, time, axis, value);
+       pointer->grab->interface->axis(pointer->grab, time, event);
 }
 
 WL_EXPORT int
diff --git a/src/libinput-device.c b/src/libinput-device.c
index 7cc6a35..9860d6e 100644
--- a/src/libinput-device.c
+++ b/src/libinput-device.c
@@ -199,23 +199,26 @@ handle_pointer_axis(struct libinput_device 
*libinput_device,
                libinput_device_get_user_data(libinput_device);
        double value;
        enum libinput_pointer_axis axis;
+       struct weston_pointer_axis_event weston_event;
 
        axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
        if (libinput_event_pointer_has_axis(pointer_event, axis)) {
                value = normalize_scroll(pointer_event, axis);
+               weston_event.value = wl_fixed_from_double(value);
+               weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
                notify_axis(device->seat,
                            libinput_event_pointer_get_time(pointer_event),
-                           WL_POINTER_AXIS_VERTICAL_SCROLL,
-                           wl_fixed_from_double(value));
+                           &weston_event);
        }
 
        axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
        if (libinput_event_pointer_has_axis(pointer_event, axis)) {
                value = normalize_scroll(pointer_event, axis);
+               weston_event.value = wl_fixed_from_double(value);
+               weston_event.axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
                notify_axis(device->seat,
                            libinput_event_pointer_get_time(pointer_event),
-                           WL_POINTER_AXIS_HORIZONTAL_SCROLL,
-                           wl_fixed_from_double(value));
+                           &weston_event);
        }
 }
 
-- 
2.5.0

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to