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

We want the ability to create a detached menu.
dev
Jasper St. Pierre 11 years ago committed by Kristian Høgsberg
parent be803ad67c
commit dda9313bd9
  1. 2
      clients/desktop-shell.c
  2. 3
      clients/resizor.c
  3. 2
      clients/stacking.c
  4. 5
      clients/terminal.c
  5. 11
      clients/window.c
  6. 3
      clients/window.h

@ -146,7 +146,7 @@ sigchild_handler(int s)
} }
static void 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); printf("Selected index %d from a panel menu.\n", index);
} }

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

@ -82,7 +82,7 @@ new_window(struct stacking *stacking, struct window *parent_window)
} }
static void 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. */ /* Ignore the selected menu item. */
} }

@ -2680,9 +2680,10 @@ recompute_selection(struct terminal *terminal)
} }
static void 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); fprintf(stderr, "picked entry %d\n", index);

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

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

Loading…
Cancel
Save