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>
dev
Peter Hutterer 9 years ago committed by Jonas Ådahl
parent 60fb1c4ce8
commit 89b6a4931e
  1. 2
      desktop-shell/exposay.c
  2. 17
      desktop-shell/shell.c
  3. 5
      ivi-shell/hmi-controller.c
  4. 10
      src/bindings.c
  5. 8
      src/compositor-rdp.c
  6. 6
      src/compositor-wayland.c
  7. 37
      src/compositor-x11.c
  8. 22
      src/compositor.h
  9. 2
      src/data-device.c
  10. 21
      src/input.c
  11. 11
      src/libinput-device.c
  12. 6
      src/screen-share.c

@ -387,7 +387,7 @@ exposay_button(struct weston_pointer_grab *grab, uint32_t time, uint32_t button,
static void static void
exposay_axis(struct weston_pointer_grab *grab, 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)
{ {
} }

@ -1598,7 +1598,7 @@ noop_grab_focus(struct weston_pointer_grab *grab)
static void static void
noop_grab_axis(struct weston_pointer_grab *grab, 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 static void
popup_grab_axis(struct weston_pointer_grab *grab, 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 static void
@ -4720,7 +4721,8 @@ resize_binding(struct weston_pointer *pointer, uint32_t time,
static void static void
surface_opacity_binding(struct weston_pointer *pointer, uint32_t time, 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; float step = 0.005;
struct shell_surface *shsurf; struct shell_surface *shsurf;
@ -4736,7 +4738,7 @@ surface_opacity_binding(struct weston_pointer *pointer, uint32_t time,
if (!shsurf) if (!shsurf)
return; 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) if (shsurf->view->alpha > 1.0)
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 static void
zoom_axis_binding(struct weston_pointer *pointer, uint32_t time, 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 static void

@ -1511,9 +1511,10 @@ pointer_noop_grab_focus(struct weston_pointer_grab *grab)
static void static void
pointer_default_grab_axis(struct weston_pointer_grab *grab, 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 static void

@ -390,20 +390,20 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor,
int int
weston_compositor_run_axis_binding(struct weston_compositor *compositor, weston_compositor_run_axis_binding(struct weston_compositor *compositor,
struct weston_pointer *pointer, struct weston_pointer *pointer,
uint32_t time, uint32_t axis, uint32_t time,
wl_fixed_t value) struct weston_pointer_axis_event *event)
{ {
struct weston_binding *b, *tmp; struct weston_binding *b, *tmp;
/* Invalidate all active modifier bindings. */ /* Invalidate all active modifier bindings. */
wl_list_for_each(b, &compositor->modifier_binding_list, link) 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) { 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) { b->modifier == pointer->seat->modifier_state) {
weston_axis_binding_handler_t handler = b->handler; weston_axis_binding_handler_t handler = b->handler;
handler(pointer, time, axis, value, b->data); handler(pointer, time, event, b->data);
return 1; return 1;
} }
} }

@ -971,6 +971,8 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
} }
if (flags & PTR_FLAGS_WHEEL) { if (flags & PTR_FLAGS_WHEEL) {
struct weston_pointer_axis_event weston_event;
/* DEFAULT_AXIS_STEP_DISTANCE is stolen from compositor-x11.c /* 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 * The RDP specs says the lower bits of flags contains the "the number of rotation
* units the mouse wheel was rotated". * 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) if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
axis = -axis; axis = -axis;
weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
weston_event.value = axis;
notify_axis(&peerContext->item.seat, weston_compositor_get_time(), notify_axis(&peerContext->item.seat, weston_compositor_get_time(),
WL_POINTER_AXIS_VERTICAL_SCROLL, &weston_event);
axis);
} }
FREERDP_CB_RETURN(TRUE); FREERDP_CB_RETURN(TRUE);

@ -1431,8 +1431,12 @@ input_handle_axis(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t axis, wl_fixed_t value) uint32_t time, uint32_t axis, wl_fixed_t value)
{ {
struct wayland_input *input = data; 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 = { static const struct wl_pointer_listener pointer_listener = {

@ -1047,6 +1047,7 @@ x11_backend_deliver_button_event(struct x11_backend *b,
(xcb_button_press_event_t *) event; (xcb_button_press_event_t *) event;
uint32_t button; uint32_t button;
struct x11_output *output; struct x11_output *output;
struct weston_pointer_axis_event weston_event;
output = x11_backend_find_output(b, button_event->event); output = x11_backend_find_output(b, button_event->event);
if (!output) if (!output)
@ -1082,32 +1083,44 @@ x11_backend_deliver_button_event(struct x11_backend *b,
case 4: case 4:
/* Axis are measured in pixels, but the xcb events are discrete /* Axis are measured in pixels, but the xcb events are discrete
* steps. Therefore move the axis by some pixels every step. */ * 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, notify_axis(&b->core_seat,
weston_compositor_get_time(), weston_compositor_get_time(),
WL_POINTER_AXIS_VERTICAL_SCROLL, &weston_event);
-DEFAULT_AXIS_STEP_DISTANCE); }
return; return;
case 5: 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, notify_axis(&b->core_seat,
weston_compositor_get_time(), weston_compositor_get_time(),
WL_POINTER_AXIS_VERTICAL_SCROLL, &weston_event);
DEFAULT_AXIS_STEP_DISTANCE); }
return; return;
case 6: 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, notify_axis(&b->core_seat,
weston_compositor_get_time(), weston_compositor_get_time(),
WL_POINTER_AXIS_HORIZONTAL_SCROLL, &weston_event);
-DEFAULT_AXIS_STEP_DISTANCE); }
return; return;
case 7: 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, notify_axis(&b->core_seat,
weston_compositor_get_time(), weston_compositor_get_time(),
WL_POINTER_AXIS_HORIZONTAL_SCROLL, &weston_event);
DEFAULT_AXIS_STEP_DISTANCE); }
return; return;
default: default:
button = button_event->detail + BTN_SIDE - 8; button = button_event->detail + BTN_SIDE - 8;

@ -251,6 +251,11 @@ struct weston_pointer_motion_event {
double dy; double dy;
}; };
struct weston_pointer_axis_event {
uint32_t axis;
wl_fixed_t value;
};
struct weston_pointer_grab; struct weston_pointer_grab;
struct weston_pointer_grab_interface { struct weston_pointer_grab_interface {
void (*focus)(struct weston_pointer_grab *grab); void (*focus)(struct weston_pointer_grab *grab);
@ -259,7 +264,8 @@ struct weston_pointer_grab_interface {
void (*button)(struct weston_pointer_grab *grab, void (*button)(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state); uint32_t time, uint32_t button, uint32_t state);
void (*axis)(struct weston_pointer_grab *grab, 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); void (*cancel)(struct weston_pointer_grab *grab);
}; };
@ -395,7 +401,8 @@ void
weston_pointer_destroy(struct weston_pointer *pointer); weston_pointer_destroy(struct weston_pointer *pointer);
void void
weston_pointer_send_axis(struct weston_pointer *pointer, 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 void
weston_pointer_set_focus(struct weston_pointer *pointer, weston_pointer_set_focus(struct weston_pointer *pointer,
struct weston_view *view, struct weston_view *view,
@ -1133,8 +1140,8 @@ void
notify_button(struct weston_seat *seat, uint32_t time, int32_t button, notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
enum wl_pointer_button_state state); enum wl_pointer_button_state state);
void void
notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, notify_axis(struct weston_seat *seat, uint32_t time,
wl_fixed_t value); struct weston_pointer_axis_event *event);
void void
notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
enum wl_keyboard_key_state state, enum wl_keyboard_key_state state,
@ -1258,8 +1265,9 @@ weston_compositor_add_touch_binding(struct weston_compositor *compositor,
void *data); void *data);
typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer, typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
uint32_t time, uint32_t axis, uint32_t time,
wl_fixed_t value, void *data); struct weston_pointer_axis_event *event,
void *data);
struct weston_binding * struct weston_binding *
weston_compositor_add_axis_binding(struct weston_compositor *compositor, weston_compositor_add_axis_binding(struct weston_compositor *compositor,
uint32_t axis, uint32_t axis,
@ -1305,7 +1313,7 @@ weston_compositor_run_touch_binding(struct weston_compositor *compositor,
int int
weston_compositor_run_axis_binding(struct weston_compositor *compositor, weston_compositor_run_axis_binding(struct weston_compositor *compositor,
struct weston_pointer *pointer, uint32_t time, struct weston_pointer *pointer, uint32_t time,
uint32_t axis, int32_t value); struct weston_pointer_axis_event *event);
int int
weston_compositor_run_debug_binding(struct weston_compositor *compositor, weston_compositor_run_debug_binding(struct weston_compositor *compositor,
struct weston_keyboard *keyboard, uint32_t time, struct weston_keyboard *keyboard, uint32_t time,

@ -412,7 +412,7 @@ drag_grab_button(struct weston_pointer_grab *grab,
static void static void
drag_grab_axis(struct weston_pointer_grab *grab, 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)
{ {
} }

@ -333,7 +333,8 @@ default_grab_pointer_button(struct weston_pointer_grab *grab,
*/ */
WL_EXPORT void WL_EXPORT void
weston_pointer_send_axis(struct weston_pointer *pointer, 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_resource *resource;
struct wl_list *resource_list; struct wl_list *resource_list;
@ -343,14 +344,16 @@ weston_pointer_send_axis(struct weston_pointer *pointer,
resource_list = &pointer->focus_client->pointer_resources; resource_list = &pointer->focus_client->pointer_resources;
wl_resource_for_each(resource, resource_list) 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 static void
default_grab_pointer_axis(struct weston_pointer_grab *grab, 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 static void
@ -1266,22 +1269,22 @@ notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
} }
WL_EXPORT void WL_EXPORT void
notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, notify_axis(struct weston_seat *seat, uint32_t time,
wl_fixed_t value) struct weston_pointer_axis_event *event)
{ {
struct weston_compositor *compositor = seat->compositor; struct weston_compositor *compositor = seat->compositor;
struct weston_pointer *pointer = weston_seat_get_pointer(seat); struct weston_pointer *pointer = weston_seat_get_pointer(seat);
weston_compositor_wake(compositor); weston_compositor_wake(compositor);
if (!value) if (!event->value)
return; return;
if (weston_compositor_run_axis_binding(compositor, pointer, if (weston_compositor_run_axis_binding(compositor, pointer,
time, axis, value)) time, event))
return; return;
pointer->grab->interface->axis(pointer->grab, time, axis, value); pointer->grab->interface->axis(pointer->grab, time, event);
} }
WL_EXPORT int WL_EXPORT int

@ -199,23 +199,26 @@ handle_pointer_axis(struct libinput_device *libinput_device,
libinput_device_get_user_data(libinput_device); libinput_device_get_user_data(libinput_device);
double value; double value;
enum libinput_pointer_axis axis; enum libinput_pointer_axis axis;
struct weston_pointer_axis_event weston_event;
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
if (libinput_event_pointer_has_axis(pointer_event, axis)) { if (libinput_event_pointer_has_axis(pointer_event, axis)) {
value = normalize_scroll(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, notify_axis(device->seat,
libinput_event_pointer_get_time(pointer_event), libinput_event_pointer_get_time(pointer_event),
WL_POINTER_AXIS_VERTICAL_SCROLL, &weston_event);
wl_fixed_from_double(value));
} }
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
if (libinput_event_pointer_has_axis(pointer_event, axis)) { if (libinput_event_pointer_has_axis(pointer_event, axis)) {
value = normalize_scroll(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, notify_axis(device->seat,
libinput_event_pointer_get_time(pointer_event), libinput_event_pointer_get_time(pointer_event),
WL_POINTER_AXIS_HORIZONTAL_SCROLL, &weston_event);
wl_fixed_from_double(value));
} }
} }

@ -160,8 +160,12 @@ ss_seat_handle_axis(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t axis, wl_fixed_t value) uint32_t time, uint32_t axis, wl_fixed_t value)
{ {
struct ss_seat *seat = data; 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 = { static const struct wl_pointer_listener ss_seat_pointer_listener = {

Loading…
Cancel
Save