mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:07:34 +00:00
WSWindowManager: Improve opening and closing the system menu
The system menu can now be opened by pressing the window key even while in a focused window. The current menu can also now be closed by pressing escape. We still cannot navigate a menu using arrow keys while there is an active window, but this is another step towards that.
This commit is contained in:
parent
2f0eb3e28e
commit
529a65c283
1 changed files with 14 additions and 7 deletions
|
@ -940,6 +940,18 @@ void WSWindowManager::event(CEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (key_event.type() == WSEvent::KeyUp && key_event.key() == Key_Logo && !m_switcher.is_visible()) {
|
||||
WSMenuManager::the().open_menu(WSMenuManager::the().system_menu());
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_event.type() == WSEvent::KeyUp && key_event.key() == Key_Escape) {
|
||||
auto current_menu = WSMenuManager::the().current_menu();
|
||||
if (current_menu)
|
||||
WSMenuManager::the().close_everyone();
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_event.type() == WSEvent::KeyDown && ((key_event.modifiers() == Mod_Logo && key_event.key() == Key_Tab) || (key_event.modifiers() == (Mod_Logo | Mod_Shift) && key_event.key() == Key_Tab)))
|
||||
m_switcher.show();
|
||||
if (m_switcher.is_visible()) {
|
||||
|
@ -989,13 +1001,8 @@ void WSWindowManager::event(CEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
// FIXME: I would prefer to be WSEvent::KeyUp, and be at the top of this function
|
||||
// However, the modifier is Invalid of Mod_Logo for a keyup event. Move after a fix is made.
|
||||
if (key_event.type() == WSEvent::KeyDown && key_event.modifiers() == Mod_Logo) {
|
||||
WSMenuManager::the().open_menu(WSMenuManager::the().system_menu());
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: We should send events to the MenuManager if a window is open
|
||||
// This should take priority over sending to a window.
|
||||
WSMenuManager::the().dispatch_event(event);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue