summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-01-18 15:58:17 +1000
committerJonas Ådahl <jadahl@gmail.com>2016-01-19 10:53:16 +0800
commit89b6a4931ef40e4524fec9bfc05627be9a974758 (patch)
treed61650122be0c665badc772ea044edfdbd4a48cb
parent60fb1c4ce8aa7b0bfd804e9a7a6631a528aaeb50 (diff)
downloadweston-89b6a4931ef40e4524fec9bfc05627be9a974758.tar.gz
Add a weston_pointer_axis_event
Use an event struct to pass axis events around. This helps dealing with the upcoming axis discrete changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
-rw-r--r--desktop-shell/exposay.c2
-rw-r--r--desktop-shell/shell.c17
-rw-r--r--ivi-shell/hmi-controller.c5
-rw-r--r--src/bindings.c10
-rw-r--r--src/compositor-rdp.c8
-rw-r--r--src/compositor-wayland.c6
-rw-r--r--src/compositor-x11.c37
-rw-r--r--src/compositor.h22
-rw-r--r--src/data-device.c2
-rw-r--r--src/input.c21
-rw-r--r--src/libinput-device.c11
-rw-r--r--src/screen-share.c6
12 files changed, 95 insertions, 52 deletions
diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index 8bd55fbf..f8378590 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 6f1c1672..6e746556 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1598,7 +1598,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)
{
}
@@ -3207,9 +3207,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
@@ -4720,7 +4721,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;
@@ -4736,7 +4738,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;
@@ -4799,9 +4801,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 77426bc8..c21b9e0e 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -1511,9 +1511,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 234c034b..cc68cfe1 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-rdp.c b/src/compositor-rdp.c
index 1bf744cb..d6d2fa17 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -971,6 +971,8 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
}
if (flags & PTR_FLAGS_WHEEL) {
+ struct weston_pointer_axis_event weston_event;
+
/* DEFAULT_AXIS_STEP_DISTANCE is stolen from compositor-x11.c
* The RDP specs says the lower bits of flags contains the "the number of rotation
* units the mouse wheel was rotated".
@@ -981,9 +983,11 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
axis = -axis;
+ weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
+ weston_event.value = axis;
+
notify_axis(&peerContext->item.seat, weston_compositor_get_time(),
- WL_POINTER_AXIS_VERTICAL_SCROLL,
- axis);
+ &weston_event);
}
FREERDP_CB_RETURN(TRUE);
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 4ea0b7d1..48636fe8 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -1431,8 +1431,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 26e387e2..93018dad 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 130b2585..ddcafc62 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -251,6 +251,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);
@@ -259,7 +264,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);
};
@@ -395,7 +401,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,
@@ -1258,8 +1265,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,
@@ -1305,7 +1313,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 54541b33..4a1c1b85 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 f5bb54e1..9382bb19 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 7cc6a357..9860d6e6 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);
}
}
diff --git a/src/screen-share.c b/src/screen-share.c
index 92a91d62..ab649e3b 100644
--- a/src/screen-share.c
+++ b/src/screen-share.c
@@ -160,8 +160,12 @@ ss_seat_handle_axis(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
struct ss_seat *seat = data;
+ struct weston_pointer_axis_event weston_event;
- notify_axis(&seat->base, time, axis, value);
+ weston_event.axis = axis;
+ weston_event.value = value;
+
+ notify_axis(&seat->base, time, &weston_event);
}
static const struct wl_pointer_listener ss_seat_pointer_listener = {