A menu must be shown on a client, so always give the client when adding

the items. Also fix mode menus.
pull/3079/head
nicm 2022-02-01 18:12:20 +00:00
parent 7e34645fcb
commit 97900d0442
3 changed files with 5 additions and 13 deletions

2
menu.c
View File

@ -81,8 +81,6 @@ menu_add_item(struct menu *menu, const struct menu_item *item,
menu->count--;
return;
}
if (c->tty.sx <= 4)
return;
max_width = c->tty.sx - 4;
slen = strlen(s);

View File

@ -104,7 +104,6 @@ struct mode_tree_menu {
struct mode_tree_data *data;
struct client *c;
u_int line;
void *itemdata;
};
static void mode_tree_free_items(struct mode_tree_list *);
@ -909,18 +908,14 @@ static void
mode_tree_menu_callback(__unused struct menu *menu, __unused u_int idx,
key_code key, void *data)
{
struct mode_tree_menu *mtm = data;
struct mode_tree_data *mtd = mtm->data;
struct mode_tree_item *mti;
struct mode_tree_menu *mtm = data;
struct mode_tree_data *mtd = mtm->data;
if (mtd->dead || key == KEYC_NONE)
goto out;
if (mtm->line >= mtd->line_size)
goto out;
mti = mtd->line_list[mtm->line].item;
if (mti->itemdata != mtm->itemdata)
goto out;
mtd->current = mtm->line;
mtd->menucb(mtd->modedata, mtm->c, key);
@ -954,14 +949,13 @@ mode_tree_display_menu(struct mode_tree_data *mtd, struct client *c, u_int x,
title = xstrdup("");
}
menu = menu_create(title);
menu_add_items(menu, items, NULL, NULL, NULL);
menu_add_items(menu, items, NULL, c, NULL);
free(title);
mtm = xmalloc(sizeof *mtm);
mtm->data = mtd;
mtm->c = c;
mtm->line = line;
mtm->itemdata = mti->itemdata;
mtd->references++;
if (x >= (menu->width + 4) / 2)

View File

@ -566,10 +566,10 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
menu:
pd->menu = menu_create("");
if (pd->flags & POPUP_INTERNAL) {
menu_add_items(pd->menu, popup_internal_menu_items, NULL, NULL,
menu_add_items(pd->menu, popup_internal_menu_items, NULL, c,
NULL);
} else
menu_add_items(pd->menu, popup_menu_items, NULL, NULL, NULL);
menu_add_items(pd->menu, popup_menu_items, NULL, c, NULL);
if (m->x >= (pd->menu->width + 4) / 2)
x = m->x - (pd->menu->width + 4) / 2;
else