clients: Remove the window / user parameters from the menu function

We want the ability to create a detached menu.
This commit is contained in:
Jasper St. Pierre 2014-03-13 12:06:00 -04:00 committed by Kristian Høgsberg
parent be803ad67c
commit dda9313bd9
6 changed files with 12 additions and 14 deletions

View File

@ -146,7 +146,7 @@ sigchild_handler(int s)
}
static void
menu_func(struct window *window, struct input *input, int index, void *data)
menu_func(void *data, struct input *input, int index)
{
printf("Selected index %d from a panel menu.\n", index);
}

View File

@ -200,8 +200,7 @@ key_handler(struct window *window, struct input *input, uint32_t time,
}
static void
menu_func(struct window *window,
struct input *input, int index, void *user_data)
menu_func(void *data, struct input *input, int index)
{
fprintf(stderr, "picked entry %d\n", index);
}

View File

@ -82,7 +82,7 @@ new_window(struct stacking *stacking, struct window *parent_window)
}
static void
show_popup_cb(struct window *window, struct input *input, int index, void *data)
show_popup_cb(void *data, struct input *input, int index)
{
/* Ignore the selected menu item. */
}

View File

@ -2680,9 +2680,10 @@ recompute_selection(struct terminal *terminal)
}
static void
menu_func(struct window *window, struct input *input, int index, void *data)
menu_func(void *data, struct input *input, int index)
{
struct terminal *terminal = data;
struct window *window = data;
struct terminal *terminal = window_get_user_data(window);
fprintf(stderr, "picked entry %d\n", index);

View File

@ -363,8 +363,8 @@ struct window_frame {
};
struct menu {
void *user_data;
struct window *window;
struct window *parent;
struct widget *widget;
struct input *input;
struct frame *frame;
@ -2229,9 +2229,9 @@ frame_get_pointer_image_for_location(struct window_frame *frame,
}
static void
frame_menu_func(struct window *window,
struct input *input, int index, void *data)
frame_menu_func(void *data, struct input *input, int index)
{
struct window *window = data;
struct display *display;
switch (index) {
@ -4507,8 +4507,7 @@ menu_button_handler(struct widget *widget,
(menu->release_count > 0 || time - menu->time > 500)) {
/* Either relase after press-drag-release or
* click-motion-click. */
menu->func(menu->parent, input,
menu->current, menu->parent->user_data);
menu->func(menu->user_data, input, menu->current);
input_ungrab(input);
menu_destroy(menu);
} else if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
@ -4605,7 +4604,7 @@ window_show_menu(struct display *display,
}
menu->window = window;
menu->parent = parent;
menu->user_data = parent;
menu->widget = window_add_widget(menu->window, menu);
window_set_buffer_scale (menu->window, window_get_buffer_scale (parent));
window_set_buffer_transform (menu->window, window_get_buffer_transform (parent));

View File

@ -284,8 +284,7 @@ window_get_parent(struct window *window);
int
window_has_focus(struct window *window);
typedef void (*menu_func_t)(struct window *window,
struct input *input, int index, void *data);
typedef void (*menu_func_t)(void *data, struct input *input, int index);
void
window_show_menu(struct display *display,