From dda9313bd99005cfc182af77fbc52b448a3803fa Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 13 Mar 2014 12:06:00 -0400 Subject: [PATCH] clients: Remove the window / user parameters from the menu function We want the ability to create a detached menu. --- clients/desktop-shell.c | 2 +- clients/resizor.c | 3 +-- clients/stacking.c | 2 +- clients/terminal.c | 5 +++-- clients/window.c | 11 +++++------ clients/window.h | 3 +-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c index e121cc73..73b21346 100644 --- a/clients/desktop-shell.c +++ b/clients/desktop-shell.c @@ -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); } diff --git a/clients/resizor.c b/clients/resizor.c index 029042fd..19c6eeb3 100644 --- a/clients/resizor.c +++ b/clients/resizor.c @@ -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); } diff --git a/clients/stacking.c b/clients/stacking.c index f51a476c..abeded88 100644 --- a/clients/stacking.c +++ b/clients/stacking.c @@ -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. */ } diff --git a/clients/terminal.c b/clients/terminal.c index cc603e98..eb133cd9 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -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); diff --git a/clients/window.c b/clients/window.c index 7b77f93a..7cb4b270 100644 --- a/clients/window.c +++ b/clients/window.c @@ -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)); diff --git a/clients/window.h b/clients/window.h index b7b3f6ae..1d0c4af7 100644 --- a/clients/window.h +++ b/clients/window.h @@ -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,