mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 23:38:11 +00:00
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.
This commit is contained in:
parent
9acb72e804
commit
c17fa67f51
2 changed files with 9 additions and 2 deletions
|
@ -98,8 +98,8 @@ void DragOperation::notify_accepted(Badge<WindowServerConnection>)
|
||||||
|
|
||||||
void DragOperation::notify_cancelled(Badge<WindowServerConnection>)
|
void DragOperation::notify_cancelled(Badge<WindowServerConnection>)
|
||||||
{
|
{
|
||||||
ASSERT(s_current_drag_operation);
|
if (s_current_drag_operation)
|
||||||
s_current_drag_operation->done(Outcome::Cancelled);
|
s_current_drag_operation->done(Outcome::Cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DragOperation::set_text(const String& text)
|
void DragOperation::set_text(const String& text)
|
||||||
|
|
|
@ -1084,8 +1084,15 @@ void WindowManager::event(Core::Event& event)
|
||||||
auto& key_event = static_cast<const KeyEvent&>(event);
|
auto& key_event = static_cast<const KeyEvent&>(event);
|
||||||
m_keyboard_modifiers = key_event.modifiers();
|
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) {
|
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());
|
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();
|
end_dnd_drag();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue