dnd: Use a widget for enter/leave handling

dev
Kristian Høgsberg 13 years ago
parent 391649b0dc
commit ac7619f3f4
  1. 10
      clients/dnd.c

@ -41,6 +41,7 @@ struct dnd {
struct display *display; struct display *display;
uint32_t key; uint32_t key;
struct item *items[16]; struct item *items[16];
struct widget *widget;
}; };
struct dnd_drag { struct dnd_drag {
@ -431,12 +432,11 @@ lookup_cursor(struct dnd *dnd, int x, int y)
return POINTER_LEFT_PTR; return POINTER_LEFT_PTR;
} }
static int static void
dnd_enter_handler(struct window *window, dnd_enter_handler(struct widget *widget,
struct input *input, uint32_t time, struct input *input, uint32_t time,
int32_t x, int32_t y, void *data) int32_t x, int32_t y, void *data)
{ {
return lookup_cursor(data, x, y);
} }
static int static int
@ -536,11 +536,13 @@ dnd_create(struct display *display)
window_set_keyboard_focus_handler(dnd->window, window_set_keyboard_focus_handler(dnd->window,
keyboard_focus_handler); keyboard_focus_handler);
window_set_button_handler(dnd->window, dnd_button_handler); window_set_button_handler(dnd->window, dnd_button_handler);
window_set_enter_handler(dnd->window, dnd_enter_handler);
window_set_motion_handler(dnd->window, dnd_motion_handler); window_set_motion_handler(dnd->window, dnd_motion_handler);
window_set_data_handler(dnd->window, dnd_data_handler); window_set_data_handler(dnd->window, dnd_data_handler);
window_set_drop_handler(dnd->window, dnd_drop_handler); window_set_drop_handler(dnd->window, dnd_drop_handler);
dnd->widget = window_add_widget(dnd->window, dnd);
widget_set_enter_handler(dnd->widget, dnd_enter_handler);
width = 4 * (item_width + item_padding) + item_padding; width = 4 * (item_width + item_padding) + item_padding;
height = 4 * (item_height + item_padding) + item_padding; height = 4 * (item_height + item_padding) + item_padding;
window_set_child_size(dnd->window, width, height); window_set_child_size(dnd->window, width, height);

Loading…
Cancel
Save