window: Use the window widget instead of adding a window sized widget

dev
Kristian Høgsberg 13 years ago
parent 87a57bbd73
commit 19dd1d7eb1
  1. 13
      clients/dnd.c
  2. 28
      clients/window.c

@ -41,7 +41,6 @@ struct dnd {
struct display *display;
uint32_t key;
struct item *items[16];
struct widget *widget;
};
struct dnd_drag {
@ -444,7 +443,10 @@ dnd_motion_handler(struct widget *widget,
struct input *input, uint32_t time,
int32_t x, int32_t y, void *data)
{
return lookup_cursor(data, x, y);
struct window *window = data;
struct dnd *dnd = window_get_user_data(window);
return lookup_cursor(dnd, x, y);
}
static void
@ -509,6 +511,7 @@ dnd_create(struct display *display)
struct dnd *dnd;
int i, x, y;
int32_t width, height;
struct widget *widget;
dnd = malloc(sizeof *dnd);
if (dnd == NULL)
@ -538,9 +541,9 @@ dnd_create(struct display *display)
window_set_data_handler(dnd->window, dnd_data_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);
widget_set_motion_handler(dnd->widget, dnd_motion_handler);
widget = window_get_widget(dnd->window);
widget_set_enter_handler(widget, dnd_enter_handler);
widget_set_motion_handler(widget, dnd_motion_handler);
width = 4 * (item_width + item_padding) + item_padding;
height = 4 * (item_height + item_padding) + item_padding;

@ -183,7 +183,6 @@ struct output {
struct menu {
struct window *window;
struct widget *widget;
const char **entries;
uint32_t time;
int current;
@ -2197,14 +2196,14 @@ window_create_transient(struct display *display, struct window *parent,
}
static int
menu_set_item(struct widget *widget, struct menu *menu, int sy)
menu_set_item(struct menu *menu, int sy)
{
int next;
next = (sy - 8) / 20;
if (menu->current != next) {
menu->current = next;
widget_schedule_redraw(widget);
widget_schedule_redraw(menu->window->widget);
}
return POINTER_LEFT_PTR;
@ -2215,9 +2214,10 @@ menu_motion_handler(struct widget *widget,
struct input *input, uint32_t time,
int32_t x, int32_t y, void *data)
{
struct menu *menu = data;
struct window *window = data;
struct menu *menu = window_get_user_data(window);
return menu_set_item(menu->widget, menu, y);
return menu_set_item(menu, y);
}
static void
@ -2225,13 +2225,19 @@ menu_enter_handler(struct widget *widget,
struct input *input, uint32_t time,
int32_t x, int32_t y, void *data)
{
menu_set_item(widget, data, y);
struct window *window = data;
struct menu *menu = window_get_user_data(window);
menu_set_item(menu, y);
}
static void
menu_leave_handler(struct widget *widget, struct input *input, void *data)
{
menu_set_item(widget, data, -200);
struct window *window = data;
struct menu *menu = window_get_user_data(window);
menu_set_item(menu, -200);
}
static void
@ -2262,7 +2268,6 @@ menu_redraw_handler(struct window *window, void *data)
height = menu->count * 20 + margin * 2;
window_set_child_size(window, width, height);
window_create_surface(window);
widget_set_allocation(menu->widget, 0, 0, width, height);
cr = cairo_create(window->cairo_surface);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
@ -2332,10 +2337,9 @@ window_create_menu(struct display *display,
window_set_redraw_handler(window, menu_redraw_handler);
window_set_user_data(window, menu);
menu->widget = window_add_widget(window, menu);
widget_set_enter_handler(menu->widget, menu_enter_handler);
widget_set_leave_handler(menu->widget, menu_leave_handler);
widget_set_motion_handler(menu->widget, menu_motion_handler);
widget_set_enter_handler(window->widget, menu_enter_handler);
widget_set_leave_handler(window->widget, menu_leave_handler);
widget_set_motion_handler(window->widget, menu_motion_handler);
return window;
}

Loading…
Cancel
Save