cairo_surface_destroy(surface);
}
-static int
-motion_handler(struct widget *widget, struct input *input,
- uint32_t time, float x, float y, void *data)
-{
- return CURSOR_HAND1;
-}
-
static void
button_handler(struct widget *widget,
struct input *input, uint32_t time,
widget_set_resize_handler(flower.widget, resize_handler);
widget_set_redraw_handler(flower.widget, redraw_handler);
- widget_set_motion_handler(flower.widget, motion_handler);
widget_set_button_handler(flower.widget, button_handler);
+ widget_set_default_cursor(flower.widget, CURSOR_HAND1);
window_schedule_resize(flower.window, flower.width, flower.height);
window_schedule_redraw(window);
}
-static int
-motion_handler(struct widget *widget, struct input *input,
- uint32_t time, float x, float y, void *data)
-{
- return CURSOR_BLANK;
-}
-
static void
button_handler(struct widget *widget,
struct input *input, uint32_t time,
window_set_title(transformed.window, "Transformed");
widget_set_transparent(transformed.widget, 0);
+ widget_set_default_cursor(transformed.widget, CURSOR_BLANK);
widget_set_redraw_handler(transformed.widget, redraw_handler);
- widget_set_motion_handler(transformed.widget, motion_handler);
widget_set_button_handler(transformed.widget, button_handler);
window_set_fullscreen_handler(transformed.window, fullscreen_handler);
void *user_data;
int opaque;
int tooltip_count;
+ int default_cursor;
};
struct input {
widget->opaque = 0;
widget->tooltip = NULL;
widget->tooltip_count = 0;
+ widget->default_cursor = CURSOR_LEFT_PTR;
return widget;
}
}
void
+widget_set_default_cursor(struct widget *widget, int cursor)
+{
+ widget->default_cursor = cursor;
+}
+
+void
widget_get_allocation(struct widget *widget, struct rectangle *allocation)
{
*allocation = widget->allocation;
float x, float y)
{
struct widget *old, *widget;
- int pointer = CURSOR_LEFT_PTR;
+ int cursor;
if (focus == input->focus_widget)
return;
widget = input->grab;
input->focus_widget = focus;
if (widget->enter_handler)
- pointer = widget->enter_handler(focus, input, x, y,
- widget->user_data);
+ cursor = widget->enter_handler(focus, input, x, y,
+ widget->user_data);
+ else
+ cursor = widget->default_cursor;
- input_set_pointer_image(input, pointer);
+ input_set_pointer_image(input, cursor);
}
}
struct input *input = data;
struct window *window = input->pointer_focus;
struct widget *widget;
- int cursor = CURSOR_LEFT_PTR;
+ int cursor;
float sx = wl_fixed_to_double(sx_w);
float sy = wl_fixed_to_double(sy_w);
cursor = widget->motion_handler(input->focus_widget,
input, time, sx, sy,
widget->user_data);
+ else
+ cursor = input->focus_widget->default_cursor;
input_set_pointer_image(input, cursor);
}
void
widget_destroy(struct widget *widget);
void
+widget_set_default_cursor(struct widget *widget, int cursor);
+void
widget_get_allocation(struct widget *widget, struct rectangle *allocation);
void