mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibGUI: Have widgets signal willingness to accept drops
If a widget accept()'s a "drag enter" event, that widget now becomes the application-wide "pending drop" widget. That state is cleared if the drag moves over another widget (or leaves the window entirely.)
This commit is contained in:
@@ -444,10 +444,18 @@ void Window::handle_drag_move_event(DragEvent& event)
|
||||
if (!m_main_widget)
|
||||
return;
|
||||
auto result = m_main_widget->hit_test(event.position());
|
||||
auto local_event = make<DragEvent>(static_cast<Event::Type>(event.type()), result.local_position, event.data_type());
|
||||
ASSERT(result.widget);
|
||||
|
||||
Application::the()->set_drag_hovered_widget({}, result.widget, result.local_position, event.data_type());
|
||||
return result.widget->dispatch_event(*local_event, this);
|
||||
|
||||
// NOTE: Setting the drag hovered widget may have executed arbitrary code, so re-check that the widget is still there.
|
||||
if (!result.widget)
|
||||
return;
|
||||
|
||||
if (result.widget->has_pending_drop()) {
|
||||
DragEvent drag_move_event(static_cast<Event::Type>(event.type()), result.local_position, event.data_type());
|
||||
result.widget->dispatch_event(drag_move_event, this);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::handle_left_event()
|
||||
|
||||
Reference in New Issue
Block a user