From af5e54d95fc3bdce2b80568c45386e695e440838 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Wed, 19 Jan 2011 03:33:00 +0000 Subject: [PATCH] send_kbd_event: Fix accesskeys when priority = 0 With document.browse.accesskey.priority = 0, accesskeys were ignored if the current tab was not the last (rightmost) tab. This commit fixes the problem. Add a function tabs_are_on_top(struct terminal *) which returns a Boolean value indicating whether the topmost window is a tab (as opposed to, e.g., a menu). This commit fixes commit 1bd498cde9c972527a4c8b8b7a7050727f60b61d. --- src/terminal/tab.c | 10 ++++++++++ src/terminal/tab.h | 1 + src/viewer/text/view.c | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) 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