mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +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:
parent
db058a22ae
commit
9bcd7dc0ce
4 changed files with 6 additions and 2 deletions
|
@ -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)
|
Messages::WindowServer::StartDragResponse ConnectionFromClient::start_drag(String const& text, HashMap<String, ByteBuffer> const& mime_data, Gfx::ShareableBitmap const& drag_bitmap)
|
||||||
{
|
{
|
||||||
auto& wm = WindowManager::the();
|
auto& wm = WindowManager::the();
|
||||||
if (wm.dnd_client())
|
if (wm.dnd_client() || !(wm.last_processed_buttons() & MouseButton::Primary))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wm.start_dnd_drag(*this, text, drag_bitmap.bitmap(), Core::MimeData::construct(mime_data));
|
wm.start_dnd_drag(*this, text, drag_bitmap.bitmap(), Core::MimeData::construct(mime_data));
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
bool is_key_event() const { return type() == KeyUp || type() == KeyDown; }
|
bool is_key_event() const { return type() == KeyUp || type() == KeyDown; }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class MouseButton : u8 {
|
enum MouseButton : u8 {
|
||||||
None = 0,
|
None = 0,
|
||||||
Primary = 1,
|
Primary = 1,
|
||||||
Secondary = 2,
|
Secondary = 2,
|
||||||
|
|
|
@ -1459,6 +1459,7 @@ void WindowManager::event(Core::Event& event)
|
||||||
m_previous_event_was_super_keydown = false;
|
m_previous_event_was_super_keydown = false;
|
||||||
|
|
||||||
process_mouse_event(mouse_event);
|
process_mouse_event(mouse_event);
|
||||||
|
m_last_processed_buttons = mouse_event.buttons();
|
||||||
// TODO: handle transitioning between two stacks
|
// TODO: handle transitioning between two stacks
|
||||||
set_hovered_window(current_window_stack().window_at(mouse_event.position(), WindowStack::IncludeWindowFrame::No));
|
set_hovered_window(current_window_stack().window_at(mouse_event.position(), WindowStack::IncludeWindowFrame::No));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -347,6 +347,8 @@ public:
|
||||||
Window const* automatic_cursor_tracking_window() const { return m_automatic_cursor_tracking_window; }
|
Window const* automatic_cursor_tracking_window() const { return m_automatic_cursor_tracking_window; }
|
||||||
void set_automatic_cursor_tracking_window(Window* window) { m_automatic_cursor_tracking_window = window; }
|
void set_automatic_cursor_tracking_window(Window* window) { m_automatic_cursor_tracking_window = window; }
|
||||||
|
|
||||||
|
u8 last_processed_buttons() { return m_last_processed_buttons; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit WindowManager(Gfx::PaletteImpl const&);
|
explicit WindowManager(Gfx::PaletteImpl const&);
|
||||||
|
|
||||||
|
@ -469,6 +471,7 @@ private:
|
||||||
ResizeDirection m_resize_direction { ResizeDirection::None };
|
ResizeDirection m_resize_direction { ResizeDirection::None };
|
||||||
|
|
||||||
u8 m_keyboard_modifiers { 0 };
|
u8 m_keyboard_modifiers { 0 };
|
||||||
|
u8 m_last_processed_buttons { MouseButton::None };
|
||||||
|
|
||||||
NonnullRefPtr<WindowSwitcher> m_switcher;
|
NonnullRefPtr<WindowSwitcher> m_switcher;
|
||||||
NonnullRefPtr<KeymapSwitcher> m_keymap_switcher;
|
NonnullRefPtr<KeymapSwitcher> m_keymap_switcher;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue