WindowServer: Don't spam clients with resize events.

Wait for them to finish a paint, then send them a new resize event.
The exception is when releasing the mouse button to end the resize.
Then we send a new resize event right away.
This commit is contained in:
Andreas Kling 2019-02-20 15:50:05 +01:00
parent 59b8183c4b
commit d054fbee91
Notes: sideshowbarker 2024-07-19 15:39:40 +09:00
3 changed files with 10 additions and 2 deletions

View file

@ -358,6 +358,7 @@ void WSClientConnection::handle_request(WSAPIDidFinishPaintingNotification& requ
return;
}
auto& window = *(*it).value;
window.set_has_painted_since_last_resize(true);
WSWindowManager::the().invalidate(window, request.rect());
}

View file

@ -63,6 +63,9 @@ public:
bool has_alpha_channel() const { return m_has_alpha_channel; }
void set_has_alpha_channel(bool value) { m_has_alpha_channel = value; }
void set_has_painted_since_last_resize(bool b) { m_has_painted_since_last_resize = b; }
bool has_painted_since_last_resize() const { return m_has_painted_since_last_resize; }
// For InlineLinkedList.
// FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that.
WSWindow* m_next { nullptr };
@ -76,6 +79,7 @@ private:
bool m_global_cursor_tracking_enabled { false };
bool m_visible { true };
bool m_has_alpha_channel { false };
bool m_has_painted_since_last_resize { false };
WSMenu* m_menu { nullptr };
RetainPtr<GraphicsBitmap> m_backing;
int m_window_id { -1 };

View file

@ -531,7 +531,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
#ifdef RESIZE_DEBUG
printf("[WM] Finish resizing WSWindow{%p}\n", m_resize_window.ptr());
#endif
invalidate(*m_resize_window);
WSMessageLoop::the().post_message(m_resize_window.ptr(), make<WSResizeEvent>(m_resize_window->rect(), m_resize_window->rect()));
m_resize_window = nullptr;
return;
}
@ -553,7 +553,10 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
if (new_rect.height() < 50)
new_rect.set_height(50);
m_resize_window->set_rect(new_rect);
WSMessageLoop::the().post_message(m_resize_window.ptr(), make<WSResizeEvent>(old_rect, new_rect));
if (m_resize_window->has_painted_since_last_resize()) {
m_resize_window->set_has_painted_since_last_resize(false);
WSMessageLoop::the().post_message(m_resize_window.ptr(), make<WSResizeEvent>(old_rect, new_rect));
}
return;
}
}