1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

WindowServer: Add wallpaper backing bitmap

Fixes inconsistencies in redrawing the wallpaper when in stretch mode by
first drawing to a backing bitmap. To reduce unnecessary allocations,
the backing bitmap is only used for stretch mode.
This commit is contained in:
Chun Ngai Au 2022-08-06 01:21:06 +01:00 committed by Linus Groh
parent d0008409a8
commit 5bccb16e61
3 changed files with 59 additions and 12 deletions

View file

@ -550,10 +550,14 @@ ErrorOr<int> run_in_desktop_mode()
} wallpaper_listener;
auto selected_wallpaper = Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv);
RefPtr<Gfx::Bitmap> wallpaper_bitmap {};
if (!selected_wallpaper.is_empty()) {
auto wallpaper_bitmap = TRY(Gfx::Bitmap::try_load_from_file(selected_wallpaper));
GUI::Desktop::the().set_wallpaper(wallpaper_bitmap, {});
wallpaper_bitmap = TRY(Gfx::Bitmap::try_load_from_file(selected_wallpaper));
}
// This sets the wallpaper at startup, even if there is no wallpaper, the
// desktop should still show the background color. It's fine to pass a
// nullptr to Desktop::set_wallpaper.
GUI::Desktop::the().set_wallpaper(wallpaper_bitmap, {});
window->show();
return GUI::Application::the()->exec();