From bb901fac90064ba58d5d82332eeac3c8e860a2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 9 Jan 2012 11:22:32 -0500 Subject: [PATCH] window: Return pointer type from widget enter handler --- clients/desktop-shell.c | 8 ++++++-- clients/dnd.c | 6 +++++- clients/window.c | 12 +++++++++--- clients/window.h | 9 ++++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c index 043ea500..92b5f202 100644 --- a/clients/desktop-shell.c +++ b/clients/desktop-shell.c @@ -229,11 +229,13 @@ panel_redraw_handler(struct window *window, void *data) window_flush(window); } -static void +static int panel_launcher_enter_handler(struct widget *widget, struct input *input, uint32_t time, int32_t x, int32_t y, void *data) { widget_schedule_redraw(widget); + + return POINTER_LEFT_PTR; } static void @@ -454,12 +456,14 @@ unlock_dialog_keyboard_focus_handler(struct window *window, window_schedule_redraw(window); } -static void +static int unlock_dialog_widget_enter_handler(struct widget *widget, struct input *input, uint32_t time, int32_t x, int32_t y, void *data) { widget_schedule_redraw(widget); + + return POINTER_LEFT_PTR; } static void diff --git a/clients/dnd.c b/clients/dnd.c index f8cd7ef0..febb1ccd 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -432,11 +432,15 @@ lookup_cursor(struct dnd *dnd, int x, int y) return POINTER_LEFT_PTR; } -static void +static int dnd_enter_handler(struct widget *widget, struct input *input, uint32_t time, int32_t x, int32_t y, void *data) { + struct window *window = data; + struct dnd *dnd = window_get_user_data(window); + + return lookup_cursor(dnd, x, y); } static int diff --git a/clients/window.c b/clients/window.c index 70642a45..7ca1e1d0 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1267,6 +1267,7 @@ window_set_focus_widget(struct window *window, struct widget *focus, struct input *input, uint32_t time, int32_t x, int32_t y) { struct widget *old; + int pointer = POINTER_LEFT_PTR; if (focus == window->focus_widget) return; @@ -1280,9 +1281,12 @@ window_set_focus_widget(struct window *window, struct widget *focus, if (focus) { if (focus->enter_handler) - focus->enter_handler(focus, input, time, - x, y, focus->user_data); + pointer = focus->enter_handler(focus, input, time, + x, y, focus->user_data); window->focus_widget = focus; + + pointer = input_get_pointer_image_for_location(input, pointer); + input_set_pointer_image(input, time, pointer); } } @@ -2221,7 +2225,7 @@ menu_motion_handler(struct widget *widget, return menu_set_item(menu, y); } -static void +static int menu_enter_handler(struct widget *widget, struct input *input, uint32_t time, int32_t x, int32_t y, void *data) @@ -2230,6 +2234,8 @@ menu_enter_handler(struct widget *widget, struct menu *menu = window_get_user_data(window); menu_set_item(menu, y); + + return POINTER_LEFT_PTR; } static void diff --git a/clients/window.h b/clients/window.h index 97a1c6a3..c50c0dab 100644 --- a/clients/window.h +++ b/clients/window.h @@ -180,9 +180,9 @@ typedef void (*window_drop_handler_t)(struct window *window, typedef void (*window_close_handler_t)(struct window *window, void *data); -typedef void (*widget_enter_handler_t)(struct widget *widget, - struct input *input, uint32_t time, - int32_t x, int32_t y, void *data); +typedef int (*widget_enter_handler_t)(struct widget *widget, + struct input *input, uint32_t time, + 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, @@ -191,6 +191,9 @@ typedef int (*widget_motion_handler_t)(struct widget *widget, typedef void (*widget_button_handler_t)(struct widget *widget, struct input *input, uint32_t time, int button, int state, void *data); +typedef void (*widget_resize_handler_t)(struct widget *widget, + int32_t width, int32_t height, + void *data); struct window * window_create(struct display *display, int32_t width, int32_t height);