1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

WindowServer: Don't start a drag and drop unless holding Primary mouse

Adds a member to record the last processed mouse buttons. If they
do not include MouseButton::Primary, return early before creating
a new drag and drop client. This fixes race conditions in which
MouseUp events canceling or completing a drop could be swallowed
by Overlay creation or postponed by an executing DragOperation,
leaving the operation in limbo.
This commit is contained in:
thankyouverycool 2022-08-12 19:34:04 -04:00 committed by Andreas Kling
parent db058a22ae
commit 9bcd7dc0ce
4 changed files with 6 additions and 2 deletions

View file

@ -817,7 +817,7 @@ void ConnectionFromClient::start_window_resize(i32 window_id)
Messages::WindowServer::StartDragResponse ConnectionFromClient::start_drag(String const& text, HashMap<String, ByteBuffer> const& mime_data, Gfx::ShareableBitmap const& drag_bitmap)
{
auto& wm = WindowManager::the();
if (wm.dnd_client())
if (wm.dnd_client() || !(wm.last_processed_buttons() & MouseButton::Primary))
return false;
wm.start_dnd_drag(*this, text, drag_bitmap.bitmap(), Core::MimeData::construct(mime_data));