toytoolkit: add axis handler

dev
Philipp Brüschweiler 13 years ago committed by Kristian Høgsberg
parent 468262be3e
commit 7e0cc54fca
  1. 19
      clients/window.c
  2. 8
      clients/window.h

@ -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 = {

@ -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);

Loading…
Cancel
Save