mirror of
https://github.com/tmux/tmux.git
synced 2024-12-25 02:48:47 +00:00
A menu must be shown on a client, so always give the client when adding
the items. Also fix mode menus.
This commit is contained in:
parent
7e34645fcb
commit
97900d0442
2
menu.c
2
menu.c
@ -81,8 +81,6 @@ menu_add_item(struct menu *menu, const struct menu_item *item,
|
|||||||
menu->count--;
|
menu->count--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c->tty.sx <= 4)
|
|
||||||
return;
|
|
||||||
max_width = c->tty.sx - 4;
|
max_width = c->tty.sx - 4;
|
||||||
|
|
||||||
slen = strlen(s);
|
slen = strlen(s);
|
||||||
|
12
mode-tree.c
12
mode-tree.c
@ -104,7 +104,6 @@ struct mode_tree_menu {
|
|||||||
struct mode_tree_data *data;
|
struct mode_tree_data *data;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
u_int line;
|
u_int line;
|
||||||
void *itemdata;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void mode_tree_free_items(struct mode_tree_list *);
|
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,
|
mode_tree_menu_callback(__unused struct menu *menu, __unused u_int idx,
|
||||||
key_code key, void *data)
|
key_code key, void *data)
|
||||||
{
|
{
|
||||||
struct mode_tree_menu *mtm = data;
|
struct mode_tree_menu *mtm = data;
|
||||||
struct mode_tree_data *mtd = mtm->data;
|
struct mode_tree_data *mtd = mtm->data;
|
||||||
struct mode_tree_item *mti;
|
|
||||||
|
|
||||||
if (mtd->dead || key == KEYC_NONE)
|
if (mtd->dead || key == KEYC_NONE)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (mtm->line >= mtd->line_size)
|
if (mtm->line >= mtd->line_size)
|
||||||
goto out;
|
goto out;
|
||||||
mti = mtd->line_list[mtm->line].item;
|
|
||||||
if (mti->itemdata != mtm->itemdata)
|
|
||||||
goto out;
|
|
||||||
mtd->current = mtm->line;
|
mtd->current = mtm->line;
|
||||||
mtd->menucb(mtd->modedata, mtm->c, key);
|
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("");
|
title = xstrdup("");
|
||||||
}
|
}
|
||||||
menu = menu_create(title);
|
menu = menu_create(title);
|
||||||
menu_add_items(menu, items, NULL, NULL, NULL);
|
menu_add_items(menu, items, NULL, c, NULL);
|
||||||
free(title);
|
free(title);
|
||||||
|
|
||||||
mtm = xmalloc(sizeof *mtm);
|
mtm = xmalloc(sizeof *mtm);
|
||||||
mtm->data = mtd;
|
mtm->data = mtd;
|
||||||
mtm->c = c;
|
mtm->c = c;
|
||||||
mtm->line = line;
|
mtm->line = line;
|
||||||
mtm->itemdata = mti->itemdata;
|
|
||||||
mtd->references++;
|
mtd->references++;
|
||||||
|
|
||||||
if (x >= (menu->width + 4) / 2)
|
if (x >= (menu->width + 4) / 2)
|
||||||
|
4
popup.c
4
popup.c
@ -566,10 +566,10 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
|
|||||||
menu:
|
menu:
|
||||||
pd->menu = menu_create("");
|
pd->menu = menu_create("");
|
||||||
if (pd->flags & POPUP_INTERNAL) {
|
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);
|
NULL);
|
||||||
} else
|
} 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)
|
if (m->x >= (pd->menu->width + 4) / 2)
|
||||||
x = m->x - (pd->menu->width + 4) / 2;
|
x = m->x - (pd->menu->width + 4) / 2;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user