1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:38:12 +00:00

LibCore+LibGUI+WindowServer: Make events bubble up through ancestors

With this patch, CEvents no longer stop at the target object, but will
bubble up the ancestor chain as long as CEvent::is_accepted() is false.

To the set accepted flag, call CEvent::accept().
To clear the accepted flag, call CEvent::ignore().

Events start out in the accepted state, so if you want them to bubble
up, you have to call ignore() on them.

Using this mechanism, we now ignore non-tabbing keydown events in
GWidget, causing them to bubble up through the widget's ancestors. :^)
This commit is contained in:
Andreas Kling 2019-09-20 20:37:31 +02:00
parent 74c4e62659
commit fcc3745b02
9 changed files with 54 additions and 17 deletions

View file

@ -664,11 +664,11 @@ void WSWindowManager::process_event_for_doubleclick(WSWindow& window, WSMouseEve
void WSWindowManager::deliver_mouse_event(WSWindow& window, WSMouseEvent& event)
{
window.event(event);
window.dispatch_event(event);
if (event.type() == WSEvent::MouseUp) {
process_event_for_doubleclick(window, event);
if (event.type() == WSEvent::MouseDoubleClick)
window.event(event);
window.dispatch_event(event);
}
}
@ -703,7 +703,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& hovere
// FIXME: Now that the menubar has a dedicated window, is this special-casing really necessary?
if (!active_window_is_modal() && menubar_rect().contains(event.position())) {
m_menu_manager.event(event);
m_menu_manager.dispatch_event(event);
return;
}
@ -915,7 +915,7 @@ void WSWindowManager::event(CEvent& event)
return;
}
if (m_active_window)
return m_active_window->event(event);
return m_active_window->dispatch_event(event);
return;
}