summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-23 20:43:51 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-23 20:43:51 +0200
commit8495abd140ec3d9f6d1d256ca00c4578e0045708 (patch)
tree82249497651e61add6e8b58c0c818e1b48c2d281
parent38e1e205a5795a0de807a5ac5e9c7148ed6cf8b0 (diff)
downloadserenity-8495abd140ec3d9f6d1d256ca00c4578e0045708.zip
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.
-rw-r--r--LibGUI/GWindow.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp
index cf1d1214fa..13319204e0 100644
--- a/LibGUI/GWindow.cpp
+++ b/LibGUI/GWindow.cpp
@@ -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);