1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:47:34 +00:00

WindowServer: WSButton should be more discerning with MouseUp/MouseMove.

This commit is contained in:
Andreas Kling 2019-04-23 01:17:20 +02:00
parent 2d7cad6a16
commit 62f7e8ac62
2 changed files with 8 additions and 2 deletions

View file

@ -40,7 +40,9 @@ void WSButton::on_mouse_event(const WSMouseEvent& event)
} }
if (event.type() == WSEvent::MouseUp && event.button() == MouseButton::Left) { if (event.type() == WSEvent::MouseUp && event.button() == MouseButton::Left) {
WSWindowManager::the().set_cursor_tracking_button(nullptr); if (wm.cursor_tracking_button() != this)
return;
wm.set_cursor_tracking_button(nullptr);
bool old_pressed = m_pressed; bool old_pressed = m_pressed;
m_pressed = false; m_pressed = false;
if (rect().contains(event.position())) { if (rect().contains(event.position())) {
@ -61,6 +63,8 @@ void WSButton::on_mouse_event(const WSMouseEvent& event)
} }
if (event.type() == WSEvent::MouseMove && event.buttons() & (unsigned)MouseButton::Left) { if (event.type() == WSEvent::MouseMove && event.buttons() & (unsigned)MouseButton::Left) {
if (wm.cursor_tracking_button() != this)
return;
bool old_pressed = m_pressed; bool old_pressed = m_pressed;
m_pressed = m_hovered; m_pressed = m_hovered;
if (old_pressed != m_pressed) if (old_pressed != m_pressed)

View file

@ -101,9 +101,11 @@ public:
const WSCursor& move_cursor() const { return *m_move_cursor; } const WSCursor& move_cursor() const { return *m_move_cursor; }
void set_active_window(WSWindow*); void set_active_window(WSWindow*);
void set_cursor_tracking_button(WSButton*);
void set_hovered_button(WSButton*); void set_hovered_button(WSButton*);
WSButton* cursor_tracking_button() { return m_cursor_tracking_button.ptr(); }
void set_cursor_tracking_button(WSButton*);
void set_resize_candidate(WSWindow&, ResizeDirection); void set_resize_candidate(WSWindow&, ResizeDirection);
void clear_resize_candidate(); void clear_resize_candidate();