window: Add a widget motion handler

dev
Kristian Høgsberg 13 years ago
parent ab9e79ffc2
commit 04e98344cf
  1. 12
      clients/window.c
  2. 7
      clients/window.h

@ -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,

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

Loading…
Cancel
Save