mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
WindowServer: Add methods for set background color and wallpaper mode
This commit is contained in:
parent
7194b4823e
commit
adf524015a
5 changed files with 55 additions and 1 deletions
|
@ -139,12 +139,18 @@ void Compositor::compose()
|
|||
return false;
|
||||
};
|
||||
|
||||
Color background_color = wm.palette().desktop_background();
|
||||
String background_color_entry = wm.wm_config()->read_entry("Background", "Color", "");
|
||||
if (!background_color_entry.is_empty()) {
|
||||
background_color = Color::from_string(background_color_entry).value_or(background_color);
|
||||
}
|
||||
|
||||
// Paint the wallpaper.
|
||||
for (auto& dirty_rect : dirty_rects.rects()) {
|
||||
if (wm.any_opaque_window_contains_rect(dirty_rect))
|
||||
continue;
|
||||
// FIXME: If the wallpaper is opaque, no need to fill with color!
|
||||
m_back_painter->fill_rect(dirty_rect, wm.palette().desktop_background());
|
||||
m_back_painter->fill_rect(dirty_rect, background_color);
|
||||
if (m_wallpaper) {
|
||||
if (m_wallpaper_mode == WallpaperMode::Simple) {
|
||||
m_back_painter->blit(dirty_rect.location(), *m_wallpaper, dirty_rect);
|
||||
|
@ -325,6 +331,32 @@ void Compositor::invalidate(const Gfx::Rect& a_rect)
|
|||
}
|
||||
}
|
||||
|
||||
bool Compositor::set_backgound_color(const String& background_color)
|
||||
{
|
||||
auto& wm = WindowManager::the();
|
||||
wm.wm_config()->write_entry("Background", "Color", background_color);
|
||||
bool ret_val = wm.wm_config()->sync();
|
||||
|
||||
if (ret_val)
|
||||
Compositor::invalidate();
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
bool Compositor::set_wallpaper_mode(const String& mode)
|
||||
{
|
||||
auto& wm = WindowManager::the();
|
||||
wm.wm_config()->write_entry("Background", "Mode", mode);
|
||||
bool ret_val = wm.wm_config()->sync();
|
||||
|
||||
if (ret_val) {
|
||||
m_wallpaper_mode = mode_to_enum(mode);
|
||||
Compositor::invalidate();
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
bool Compositor::set_wallpaper(const String& path, Function<void(bool)>&& callback)
|
||||
{
|
||||
LibThread::BackgroundAction<RefPtr<Gfx::Bitmap>>::create(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue