forked from RepoMirrors/bemenu
Fix: select last entry if pointer/touch above last index (#332)
* Fix: select last entry if pointer/touch above last index * Select first line if pointer/touch above title bar
This commit is contained in:
parent
f53310a961
commit
0c0107e8cb
11
lib/menu.c
11
lib/menu.c
@ -677,7 +677,7 @@ bm_menu_set_highlighted_index(struct bm_menu *menu, uint32_t index)
|
||||
bm_menu_get_filtered_items(menu, &count);
|
||||
|
||||
if (count <= index)
|
||||
return 0;
|
||||
index = (count > 0 ? count - 1 : 0);
|
||||
|
||||
if (menu->index != index)
|
||||
menu->dirty = true;
|
||||
@ -902,13 +902,14 @@ menu_point_select(struct bm_menu *menu, uint32_t posx, uint32_t posy, uint32_t d
|
||||
}
|
||||
uint32_t selected_line = posy / line_height;
|
||||
|
||||
if (0 == selected_line) { // Mouse over title bar
|
||||
return;
|
||||
}
|
||||
|
||||
assert(menu->lines != 0);
|
||||
uint16_t current_page_index = menu->index / menu->lines;
|
||||
|
||||
if (0 == selected_line) { // Mouse over title bar
|
||||
bm_menu_set_highlighted_index(menu, current_page_index * menu->lines);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected_line >= displayed) { // This might be useless
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user