From 04e98344cf918b1ae4d9ee3947bafa13d82f1418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 9 Jan 2012 09:36:16 -0500 Subject: [PATCH] window: Add a widget motion handler --- clients/window.c | 12 ++++++++++++ clients/window.h | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clients/window.c b/clients/window.c index e838a37b..4f437cfd 100644 --- a/clients/window.c +++ b/clients/window.c @@ -152,6 +152,7 @@ struct widget { struct rectangle allocation; widget_enter_handler_t enter_handler; widget_leave_handler_t leave_handler; + widget_motion_handler_t motion_handler; void *user_data; }; @@ -1113,6 +1114,13 @@ widget_set_leave_handler(struct widget *widget, widget_leave_handler_t handler) widget->leave_handler = handler; } +void +widget_set_motion_handler(struct widget *widget, + widget_motion_handler_t handler) +{ + widget->motion_handler = handler; +} + void widget_schedule_redraw(struct widget *widget) { @@ -1286,6 +1294,10 @@ input_handle_motion(void *data, struct wl_input_device *input_device, window_set_focus_widget(window, widget, input, time, sx, sy); } + widget = window->focus_widget; + if (widget && widget->motion_handler) + pointer = widget->motion_handler(widget, input, time, sx, sy, + widget->user_data); if (window->motion_handler) pointer = (*window->motion_handler)(window, input, time, x, y, sx, sy, diff --git a/clients/window.h b/clients/window.h index 45ea9bd9..cfabf587 100644 --- a/clients/window.h +++ b/clients/window.h @@ -194,6 +194,9 @@ typedef void (*widget_enter_handler_t)(struct widget *widget, int32_t x, int32_t y, void *data); typedef void (*widget_leave_handler_t)(struct widget *widget, struct input *input, void *data); +typedef int (*widget_motion_handler_t)(struct widget *widget, + struct input *input, uint32_t time, + int32_t x, int32_t y, void *data); struct window * window_create(struct display *display, int32_t width, int32_t height); @@ -357,7 +360,9 @@ widget_set_enter_handler(struct widget *widget, void widget_set_leave_handler(struct widget *widget, widget_leave_handler_t handler); - +void +widget_set_motion_handler(struct widget *widget, + widget_motion_handler_t handler); void widget_schedule_redraw(struct widget *widget);