mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
LibGUI+WindowServer: Mark minimized window backing stores as volatile
WindowServer will now send out a WindowStateChanged message to clients when one of their windows is minimized. This is then forwarded to the GWindow, which will try to mark its underlying window backing store as volatile. This allows the kernel to steal the memory used by minimized windows in case it starts running low. Very cool! :^)
This commit is contained in:
@@ -693,3 +693,18 @@ void GWindow::update_all_windows(Badge<GWindowServerConnection>)
|
||||
window->update();
|
||||
}
|
||||
}
|
||||
|
||||
void GWindow::notify_state_changed(Badge<GWindowServerConnection>, bool minimized)
|
||||
{
|
||||
// When double buffering is enabled, minimization means we can mark the front bitmap volatile (in addition to the back bitmap.)
|
||||
// When double buffering is disabled, there is only the back bitmap (which we can now mark volatile!)
|
||||
RefPtr<GraphicsBitmap>& bitmap = m_double_buffering_enabled ? m_front_bitmap : m_back_bitmap;
|
||||
if (!bitmap)
|
||||
return;
|
||||
if (minimized) {
|
||||
bitmap->shared_buffer()->set_volatile();
|
||||
} else {
|
||||
if (!bitmap->shared_buffer()->set_nonvolatile())
|
||||
bitmap = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user