mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
Let userland retain the window backing store while drawing into it.
To start painting, call: gui$get_window_backing_store() Then finish up with: gui$release_window_backing_store() Process will retain the underlying GraphicsBitmap behind the scenes. This fixes racing between the WindowServer and GUI clients. This patch also adds a WSWindowLocker that is exactly what it sounds like.
This commit is contained in:
@@ -19,21 +19,28 @@ WSWindow::~WSWindow()
|
||||
|
||||
void WSWindow::set_title(String&& title)
|
||||
{
|
||||
if (m_title == title)
|
||||
return;
|
||||
{
|
||||
WSWindowLocker locker(*this);
|
||||
if (m_title == title)
|
||||
return;
|
||||
m_title = move(title);
|
||||
}
|
||||
|
||||
m_title = move(title);
|
||||
WSWindowManager::the().notify_title_changed(*this);
|
||||
}
|
||||
|
||||
void WSWindow::set_rect(const Rect& rect)
|
||||
{
|
||||
if (m_rect == rect)
|
||||
return;
|
||||
auto old_rect = m_rect;
|
||||
m_rect = rect;
|
||||
m_backing = GraphicsBitmap::create(m_process, m_rect.size());
|
||||
WSWindowManager::the().notify_rect_changed(*this, old_rect, m_rect);
|
||||
Rect old_rect;
|
||||
{
|
||||
WSWindowLocker locker(*this);
|
||||
if (m_rect == rect)
|
||||
return;
|
||||
old_rect = m_rect;
|
||||
m_rect = rect;
|
||||
m_backing = GraphicsBitmap::create(m_process, m_rect.size());
|
||||
}
|
||||
WSWindowManager::the().notify_rect_changed(*this, old_rect, rect);
|
||||
}
|
||||
|
||||
// FIXME: Just use the same types.
|
||||
@@ -86,6 +93,12 @@ void WSWindow::event(WSEvent& event)
|
||||
case WSEvent::WM_Invalidate:
|
||||
WSWindowManager::the().invalidate(*this, static_cast<WSWindowInvalidationEvent&>(event).rect());
|
||||
return;
|
||||
case WSEvent::WM_SetWindowRect:
|
||||
set_rect(static_cast<WSSetWindowRect&>(event).rect());
|
||||
return;
|
||||
case WSEvent::WM_SetWindowTitle:
|
||||
set_title(static_cast<WSSetWindowTitle&>(event).title());
|
||||
return;
|
||||
case WSEvent::WindowActivated:
|
||||
gui_event.type = GUI_Event::Type::WindowActivated;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user