diff --git a/src/terminal/tab.c b/src/terminal/tab.c index 9976f4248..85f60ddb6 100644 --- a/src/terminal/tab.c +++ b/src/terminal/tab.c @@ -61,6 +61,16 @@ found_pos: return win; } +/** If the topmost window is a tab, return 1; else, return 0. */ +NONSTATIC_INLINE int +tabs_are_on_top(struct terminal *term) +{ + if (list_empty(term->windows)) + return 0; + + return ((struct window *) term->windows.next)->type == WINDOW_TAB; +} + /** Number of tabs at the terminal (in term->windows) */ NONSTATIC_INLINE int number_of_tabs(struct terminal *term) diff --git a/src/terminal/tab.h b/src/terminal/tab.h index 2fbc6e72d..1ee1554ba 100644 --- a/src/terminal/tab.h +++ b/src/terminal/tab.h @@ -10,6 +10,7 @@ struct uri; struct window * init_tab(struct terminal *term, void *data, window_handler_T handler); +int tabs_are_on_top(struct terminal *); int number_of_tabs(struct terminal *); int get_tab_number(struct window *); int get_tab_number_by_xpos(struct terminal *term, int xpos); diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 25bb7d1da..33d13c72d 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -1525,8 +1525,11 @@ quit: deselect_mainmenu(win->term, win->data); print_screen_status(ses); } - if (ses->tab != ses->tab->term->windows.next) + if (!tabs_are_on_top(ses->tab->term)) { + /* The event opened a menu; we're done. */ return NULL; + } + /* Otherwise, the event still needs to be handled. */ get_kbd_modifier(ev) |= KBD_MOD_ALT; if (doc_view