mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
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:
parent
38e1e205a5
commit
8495abd140
Notes:
sideshowbarker
2024-07-19 14:36:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8495abd140e
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user