diff --git a/clients/window.c b/clients/window.c index 0bd362fc..32621748 100644 --- a/clients/window.c +++ b/clients/window.c @@ -179,6 +179,7 @@ struct widget { widget_leave_handler_t leave_handler; widget_motion_handler_t motion_handler; widget_button_handler_t button_handler; + widget_axis_handler_t axis_handler; void *user_data; int opaque; int tooltip_count; @@ -1058,6 +1059,13 @@ widget_set_button_handler(struct widget *widget, widget->button_handler = handler; } +void +widget_set_axis_handler(struct widget *widget, + widget_axis_handler_t handler) +{ + widget->axis_handler = handler; +} + void widget_schedule_redraw(struct widget *widget) { @@ -1918,6 +1926,17 @@ static void pointer_handle_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { + struct input *input = data; + struct widget *widget; + + widget = input->focus_widget; + if (input->grab) + widget = input->grab; + if (widget && widget->axis_handler) + (*widget->axis_handler)(widget, + input, time, + axis, value, + widget->user_data); } static const struct wl_pointer_listener pointer_listener = { diff --git a/clients/window.h b/clients/window.h index 779bc64e..41f63dab 100644 --- a/clients/window.h +++ b/clients/window.h @@ -196,6 +196,11 @@ typedef void (*widget_button_handler_t)(struct widget *widget, uint32_t button, enum wl_pointer_button_state state, void *data); +typedef void (*widget_axis_handler_t)(struct widget *widget, + struct input *input, uint32_t time, + uint32_t axis, + wl_fixed_t value, + void *data); struct window * window_create(struct display *display); @@ -365,6 +370,9 @@ widget_set_motion_handler(struct widget *widget, void widget_set_button_handler(struct widget *widget, widget_button_handler_t handler); +void +widget_set_axis_handler(struct widget *widget, + widget_axis_handler_t handler); void widget_schedule_redraw(struct widget *widget);