GWindow: Don't send InvalidateRect message with 0 rects to WindowServer.

This could happen if GWindow::hide() was called while a window had pending
repaint rects. The deferred_invoke() lambda in GWindow::update() would
eventually run, but by then, hide() had cleared all pending rects.
This commit is contained in:
Andreas Kling 2019-04-23 20:43:51 +02:00
parent 38e1e205a5
commit 8495abd140
Notes: sideshowbarker 2024-07-19 14:36:54 +09:00

View File

@ -317,17 +317,19 @@ void GWindow::update(const Rect& a_rect)
if (m_pending_paint_event_rects.is_empty()) {
deferred_invoke([this] (auto&) {
auto rects = move(m_pending_paint_event_rects);
if (rects.is_empty())
return;
WSAPI_ClientMessage request;
request.type = WSAPI_ClientMessage::Type::InvalidateRect;
request.window_id = m_window_id;
for (int i = 0; i < min(WSAPI_ClientMessage::max_inline_rect_count, m_pending_paint_event_rects.size()); ++i)
request.rects[i] = m_pending_paint_event_rects[i];
for (int i = 0; i < min(WSAPI_ClientMessage::max_inline_rect_count, rects.size()); ++i)
request.rects[i] = rects[i];
ByteBuffer extra_data;
if (m_pending_paint_event_rects.size() > WSAPI_ClientMessage::max_inline_rect_count)
extra_data = ByteBuffer::wrap(&m_pending_paint_event_rects[WSAPI_ClientMessage::max_inline_rect_count], (m_pending_paint_event_rects.size() - WSAPI_ClientMessage::max_inline_rect_count) * sizeof(WSAPI_Rect));
request.rect_count = m_pending_paint_event_rects.size();
if (rects.size() > WSAPI_ClientMessage::max_inline_rect_count)
extra_data = ByteBuffer::wrap(&rects[WSAPI_ClientMessage::max_inline_rect_count], (rects.size() - WSAPI_ClientMessage::max_inline_rect_count) * sizeof(WSAPI_Rect));
request.rect_count = rects.size();
GEventLoop::current().post_message_to_server(request, extra_data);
m_pending_paint_event_rects.clear_with_capacity();
});
}
m_pending_paint_event_rects.append(a_rect);