summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/Desktop.cpp31
-rw-r--r--Userland/Libraries/LibGUI/Desktop.h6
2 files changed, 24 insertions, 13 deletions
diff --git a/Userland/Libraries/LibGUI/Desktop.cpp b/Userland/Libraries/LibGUI/Desktop.cpp
index 9c5f500db5..7c42ea8a12 100644
--- a/Userland/Libraries/LibGUI/Desktop.cpp
+++ b/Userland/Libraries/LibGUI/Desktop.cpp
@@ -5,6 +5,7 @@
*/
#include <AK/Badge.h>
+#include <AK/TemporaryChange.h>
#include <LibGUI/Desktop.h>
#include <LibGUI/WindowServerConnection.h>
#include <string.h>
@@ -53,22 +54,30 @@ void Desktop::set_wallpaper_mode(StringView mode)
WindowServerConnection::the().async_set_wallpaper_mode(mode);
}
-bool Desktop::set_wallpaper(StringView path, bool save_config)
+String Desktop::wallpaper_path() const
{
- WindowServerConnection::the().async_set_wallpaper(path);
+ return Config::read_string("WindowManager", "Background", "Wallpaper");
+}
+
+RefPtr<Gfx::Bitmap> Desktop::wallpaper_bitmap() const
+{
+ return WindowServerConnection::the().get_wallpaper().bitmap();
+}
+
+bool Desktop::set_wallpaper(RefPtr<Gfx::Bitmap> wallpaper_bitmap, Optional<String> path)
+{
+ if (m_is_setting_desktop_wallpaper)
+ return false;
+
+ TemporaryChange is_setting_desktop_wallpaper_change(m_is_setting_desktop_wallpaper, true);
+ WindowServerConnection::the().async_set_wallpaper(wallpaper_bitmap ? wallpaper_bitmap->to_shareable_bitmap() : Gfx::ShareableBitmap {});
auto ret_val = WindowServerConnection::the().wait_for_specific_message<Messages::WindowClient::SetWallpaperFinished>()->success();
- if (ret_val && save_config) {
- dbgln("Saving wallpaper path '{}' to ConfigServer", path);
- Config::write_string("WindowManager", "Background", "Wallpaper", path);
+ if (ret_val && path.has_value()) {
+ dbgln("Saving wallpaper path '{}' to ConfigServer", *path);
+ Config::write_string("WindowManager", "Background", "Wallpaper", *path);
}
return ret_val;
}
-
-String Desktop::wallpaper() const
-{
- return WindowServerConnection::the().get_wallpaper();
-}
-
}
diff --git a/Userland/Libraries/LibGUI/Desktop.h b/Userland/Libraries/LibGUI/Desktop.h
index c29ec616b1..a80f10f4b3 100644
--- a/Userland/Libraries/LibGUI/Desktop.h
+++ b/Userland/Libraries/LibGUI/Desktop.h
@@ -29,8 +29,9 @@ public:
void set_wallpaper_mode(StringView mode);
- String wallpaper() const;
- bool set_wallpaper(StringView path, bool save_config = true);
+ String wallpaper_path() const;
+ RefPtr<Gfx::Bitmap> wallpaper_bitmap() const;
+ bool set_wallpaper(RefPtr<Gfx::Bitmap> wallpaper_bitmap, Optional<String> path);
Gfx::IntRect rect() const { return m_bounding_rect; }
const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; }
@@ -56,6 +57,7 @@ private:
unsigned m_workspace_rows { 1 };
unsigned m_workspace_columns { 1 };
Vector<Function<void(Desktop&)>> m_receive_rects_callbacks;
+ bool m_is_setting_desktop_wallpaper { false };
};
}