diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-08 23:47:53 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-09 12:02:07 +0100 |
commit | c17fa67f511e981ce6c62bae33a00933e588e295 (patch) | |
tree | c7ec46e56664f85190301d464487cd67ab5fe85e /Services | |
parent | 9acb72e804a71d2003761507b980b9ddb73905d4 (diff) | |
download | serenity-c17fa67f511e981ce6c62bae33a00933e588e295.zip |
WindowServer+LibGUI: Notify hovered window when drag&drop is cancelled
The hovered window may want to react to a drag being cancelled, even
if the drag originated in some other window.
Diffstat (limited to 'Services')
-rw-r--r-- | Services/WindowServer/WindowManager.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Services/WindowServer/WindowManager.cpp b/Services/WindowServer/WindowManager.cpp index 86c9ed9c77..2002512eea 100644 --- a/Services/WindowServer/WindowManager.cpp +++ b/Services/WindowServer/WindowManager.cpp @@ -1084,8 +1084,15 @@ void WindowManager::event(Core::Event& event) auto& key_event = static_cast<const KeyEvent&>(event); m_keyboard_modifiers = key_event.modifiers(); + // Escape key cancels an ongoing drag. if (key_event.type() == Event::KeyDown && key_event.key() == Key_Escape && m_dnd_client) { + // Notify the drag-n-drop client that the drag was cancelled. m_dnd_client->post_message(Messages::WindowClient::DragCancelled()); + + // Also notify the currently hovered window (if any) that the ongoing drag was cancelled. + if (m_hovered_window && m_hovered_window->client() && m_hovered_window->client() != m_dnd_client) + m_hovered_window->client()->post_message(Messages::WindowClient::DragCancelled()); + end_dnd_drag(); return; } |