[PATCH 3/4] toytoolkit: add axis handler
Philipp Brüschweiler
blei42 at gmail.com
Tue Aug 14 02:02:41 PDT 2012
---
clients/window.c | 19 +++++++++++++++++++
clients/window.h | 8 ++++++++
2 Dateien geändert, 27 Zeilen hinzugefügt(+)
diff --git a/clients/window.c b/clients/window.c
index dd65328..c274541 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;
@@ -1059,6 +1060,13 @@ widget_set_button_handler(struct widget *widget,
}
void
+widget_set_axis_handler(struct widget *widget,
+ widget_axis_handler_t handler)
+{
+ widget->axis_handler = handler;
+}
+
+void
widget_schedule_redraw(struct widget *widget)
{
window_schedule_redraw(widget->window);
@@ -1920,6 +1928,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 779bc64..41f63da 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);
--
1.7.11.4
More information about the wayland-devel
mailing list