WindowServer: Stop infinite menu movement cycle

While I really enjoyed having an infinite cycle when I implemented menu
keys (and seeing it wizz around and around :D), menu key movement should
be consistent between menus - and an inifinite cycle does not make much
sense for a scrollable menu.
This commit is contained in:
Shannon Booth 2020-01-20 21:56:43 +13:00 committed by Andreas Kling
parent de74458f13
commit 3e05c83591
Notes: sideshowbarker 2024-07-19 09:56:59 +09:00

View File

@ -392,9 +392,9 @@ void WSMenu::event(CEvent& event)
return;
do {
m_hovered_item_index--;
if (m_hovered_item_index < 0)
m_hovered_item_index = m_items.size() - 1;
if (m_hovered_item_index <= 0)
return;
--m_hovered_item_index;
} while (hovered_item()->type() == WSMenuItem::Separator);
if (is_scrollable() && m_hovered_item_index < m_scroll_offset)
@ -411,9 +411,9 @@ void WSMenu::event(CEvent& event)
return;
do {
m_hovered_item_index++;
if (m_hovered_item_index >= m_items.size())
m_hovered_item_index = 0;
if (m_hovered_item_index >= m_items.size() - 1)
return;
++m_hovered_item_index;
} while (hovered_item()->type() == WSMenuItem::Separator);
if (is_scrollable() && m_hovered_item_index >= (m_scroll_offset + visible_item_count()))