mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
WindowServer+Userland: Pass wallpapers as Gfx::Bitmap
instead of path
The WindowServer _really_ does not need to know the filesystem path to it's wallpaper, and allows setting arbitrary wallpapers (those outside of `/res/wallpapers`). The GUI::Desktop will keep track of the path to the wallpaper (if any), and save it to config if desired (to be persisted). This avoids the need to `unveil` paths to the wallpaper, fixing #11158
This commit is contained in:
parent
f538545987
commit
a0e7a4b9a8
13 changed files with 61 additions and 58 deletions
|
@ -805,26 +805,14 @@ bool Compositor::set_wallpaper_mode(const String& mode)
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
bool Compositor::set_wallpaper(const String& path, Function<void(bool)>&& callback)
|
||||
bool Compositor::set_wallpaper(RefPtr<Gfx::Bitmap> bitmap)
|
||||
{
|
||||
(void)Threading::BackgroundAction<ErrorOr<NonnullRefPtr<Gfx::Bitmap>>>::construct(
|
||||
[path](auto&) {
|
||||
return Gfx::Bitmap::try_load_from_file(path);
|
||||
},
|
||||
if (!bitmap)
|
||||
m_wallpaper = nullptr;
|
||||
else
|
||||
m_wallpaper = bitmap;
|
||||
invalidate_screen();
|
||||
|
||||
[this, path, callback = move(callback)](ErrorOr<NonnullRefPtr<Gfx::Bitmap>> bitmap) {
|
||||
if (bitmap.is_error() && !path.is_empty()) {
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
m_wallpaper_path = path;
|
||||
if (bitmap.is_error())
|
||||
m_wallpaper = nullptr;
|
||||
else
|
||||
m_wallpaper = bitmap.release_value();
|
||||
invalidate_screen();
|
||||
callback(true);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue