From 3e05c835913529b807b479e006d1f90a73c28d99 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Mon, 20 Jan 2020 21:56:43 +1300 Subject: [PATCH] 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. --- Servers/WindowServer/WSMenu.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Servers/WindowServer/WSMenu.cpp b/Servers/WindowServer/WSMenu.cpp index ac9b9ec7744..fac6d8abe48 100644 --- a/Servers/WindowServer/WSMenu.cpp +++ b/Servers/WindowServer/WSMenu.cpp @@ -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()))