mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
WSWindowManager: Use early return to limit nesting
Let's be a little nicer on the eyes :^)
This commit is contained in:
parent
4683424e7a
commit
7fb7b399a3
1 changed files with 31 additions and 28 deletions
|
@ -713,8 +713,15 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
|
|||
ASSERT(topmost_menu);
|
||||
auto* window = topmost_menu->menu_window();
|
||||
ASSERT(window);
|
||||
|
||||
bool event_is_inside_current_menu = window->rect().contains(event.position());
|
||||
if (!event_is_inside_current_menu) {
|
||||
if (event_is_inside_current_menu) {
|
||||
hovered_window = window;
|
||||
auto translated_event = event.translated(-window->position());
|
||||
deliver_mouse_event(*window, translated_event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (topmost_menu->hovered_item())
|
||||
topmost_menu->clear_hovered_item();
|
||||
if (event.type() == WSEvent::MouseDown || event.type() == WSEvent::MouseUp) {
|
||||
|
@ -729,6 +736,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
|
|||
m_menu_manager.close_bar();
|
||||
topmost_menu->set_window_menu_open(false);
|
||||
}
|
||||
|
||||
if (event.type() == WSEvent::MouseMove) {
|
||||
for (auto& menu : m_menu_manager.open_menu_stack()) {
|
||||
if (!menu)
|
||||
|
@ -741,11 +749,6 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hovered_window = window;
|
||||
auto translated_event = event.translated(-window->position());
|
||||
deliver_mouse_event(*window, translated_event);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue