1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:18:11 +00:00

WindowServer+LibGUI: Add a "drag move" event

This allows windows/widgets to learn when something is being dragged
over them. They can then repaint themselves somehow to indicate that
they are willing to accept a drop.

Currently this is piggybacking somewhat on the mouse event mechanism
in WindowServer. I'm not sure that's the best design but it seemed
easier to do it this way right now.
This commit is contained in:
Andreas Kling 2020-02-13 21:43:32 +01:00
parent 7590270e13
commit 3ce80bec97
9 changed files with 71 additions and 8 deletions

View file

@ -594,6 +594,21 @@ bool WindowManager::process_ongoing_drag(MouseEvent& event, Window*& hovered_win
{
if (!m_dnd_client)
return false;
if (event.type() == Event::MouseMove) {
// We didn't let go of the drag yet, see if we should send some drag move events..
for_each_visible_window_from_front_to_back([&](Window& window) {
if (!window.rect().contains(event.position()))
return IterationDecision::Continue;
hovered_window = &window;
auto translated_event = event.translated(-window.position());
translated_event.set_drag(true);
translated_event.set_drag_data_type(m_dnd_data_type);
deliver_mouse_event(window, translated_event);
return IterationDecision::Break;
});
}
if (!(event.type() == Event::MouseUp && event.button() == MouseButton::Left))
return true;