summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorOliver Kraitschy <oliver@okraits.de>2020-01-30 23:06:01 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-01 08:51:53 +0100
commit5aa37f6f5c9026346e8dbc7db26cf73516a7a876 (patch)
treea3f1839a0a581e12354015b75aa94d01b52c9132 /Servers
parent4a36a5161833f28f045f30fe30c64f3100cce2e1 (diff)
downloadserenity-5aa37f6f5c9026346e8dbc7db26cf73516a7a876.zip
WindowServer: make menus wrap vertically
This commit adds vertical wrap to menus. The first item is focused if Key_Down is pressed on the last item and the last item is focused if Key_up is pressed on the first item.
Diffstat (limited to 'Servers')
-rw-r--r--Servers/WindowServer/WSMenu.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Servers/WindowServer/WSMenu.cpp b/Servers/WindowServer/WSMenu.cpp
index fa622f8c89..f59d30bcee 100644
--- a/Servers/WindowServer/WSMenu.cpp
+++ b/Servers/WindowServer/WSMenu.cpp
@@ -393,9 +393,12 @@ void WSMenu::event(CEvent& event)
return;
do {
- if (m_hovered_item_index <= 0)
+ if (m_hovered_item_index == 0)
+ m_hovered_item_index = m_items.size() - 1;
+ else if (m_hovered_item_index < 0)
return;
- --m_hovered_item_index;
+ else
+ --m_hovered_item_index;
} while (hovered_item()->type() == WSMenuItem::Separator);
if (is_scrollable() && m_hovered_item_index < m_scroll_offset)
@@ -412,9 +415,12 @@ void WSMenu::event(CEvent& event)
return;
do {
- if (m_hovered_item_index >= m_items.size() - 1)
+ if (m_hovered_item_index == m_items.size() - 1)
+ m_hovered_item_index = 0;
+ else if (m_hovered_item_index > m_items.size() - 1)
return;
- ++m_hovered_item_index;
+ else
+ ++m_hovered_item_index;
} while (hovered_item()->type() == WSMenuItem::Separator);
if (is_scrollable() && m_hovered_item_index >= (m_scroll_offset + visible_item_count()))