mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 16:58:01 +02:00
toytoolkit: add axis handler
This commit is contained in:
parent
468262be3e
commit
7e0cc54fca
2 changed files with 27 additions and 0 deletions
|
|
@ -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…
Add table
Reference in a new issue