summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Services/WindowServer/MultiScaleBitmaps.cpp2
-rw-r--r--Userland/Services/WindowServer/MultiScaleBitmaps.h2
-rw-r--r--Userland/Services/WindowServer/WindowFrame.cpp51
3 files changed, 20 insertions, 35 deletions
diff --git a/Userland/Services/WindowServer/MultiScaleBitmaps.cpp b/Userland/Services/WindowServer/MultiScaleBitmaps.cpp
index 0d3fa827ea..8ad1a2184e 100644
--- a/Userland/Services/WindowServer/MultiScaleBitmaps.cpp
+++ b/Userland/Services/WindowServer/MultiScaleBitmaps.cpp
@@ -38,6 +38,8 @@ bool MultiScaleBitmaps::load(StringView const& filename, StringView const& defau
Optional<Gfx::BitmapFormat> bitmap_format;
bool did_load_any = false;
+ m_bitmaps.clear(); // If we're reloading the bitmaps get rid of the old ones
+
auto add_bitmap = [&](StringView const& path, int scale_factor) {
auto bitmap = Gfx::Bitmap::load_from_file(path, scale_factor);
if (bitmap) {
diff --git a/Userland/Services/WindowServer/MultiScaleBitmaps.h b/Userland/Services/WindowServer/MultiScaleBitmaps.h
index 90e4c95cdf..830ef97c58 100644
--- a/Userland/Services/WindowServer/MultiScaleBitmaps.h
+++ b/Userland/Services/WindowServer/MultiScaleBitmaps.h
@@ -20,10 +20,10 @@ public:
Gfx::Bitmap const& default_bitmap() const { return bitmap(1); }
Gfx::Bitmap const& bitmap(int scale_factor) const;
Gfx::BitmapFormat format() const { return m_format; }
+ bool load(StringView const& filename, StringView const& default_filename = {});
private:
MultiScaleBitmaps() = default;
- bool load(StringView const& filename, StringView const& default_filename);
HashMap<int, NonnullRefPtr<Gfx::Bitmap>> m_bitmaps;
Gfx::BitmapFormat m_format { Gfx::BitmapFormat::Invalid };
diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp
index ab394dc803..e237d5c8f5 100644
--- a/Userland/Services/WindowServer/WindowFrame.cpp
+++ b/Userland/Services/WindowServer/WindowFrame.cpp
@@ -41,8 +41,6 @@ static RefPtr<MultiScaleBitmaps> s_restore_icon;
static RefPtr<MultiScaleBitmaps> s_close_icon;
static RefPtr<MultiScaleBitmaps> s_close_modified_icon;
-static String s_last_title_button_icons_path;
-
static RefPtr<MultiScaleBitmaps> s_active_window_shadow;
static RefPtr<MultiScaleBitmaps> s_inactive_window_shadow;
static RefPtr<MultiScaleBitmaps> s_menu_shadow;
@@ -126,46 +124,31 @@ void WindowFrame::reload_config()
{
String icons_path = WindowManager::the().palette().title_button_icons_path();
- StringBuilder full_path;
- if (!s_minimize_icon || s_last_title_button_icons_path != icons_path) {
- full_path.append(icons_path);
- full_path.append("window-minimize.png");
- s_minimize_icon = MultiScaleBitmaps::create(full_path.to_string(), "/res/icons/16x16/downward-triangle.png");
- full_path.clear();
- }
- if (!s_maximize_icon || s_last_title_button_icons_path != icons_path) {
- full_path.append(icons_path);
- full_path.append("window-maximize.png");
- s_maximize_icon = MultiScaleBitmaps::create(full_path.to_string(), "/res/icons/16x16/upward-triangle.png");
- full_path.clear();
- }
- if (!s_restore_icon || s_last_title_button_icons_path != icons_path) {
- full_path.append(icons_path);
- full_path.append("window-restore.png");
- s_restore_icon = MultiScaleBitmaps::create(full_path.to_string(), "/res/icons/16x16/window-restore.png");
- full_path.clear();
- }
- if (!s_close_icon || s_last_title_button_icons_path != icons_path) {
+ auto reload_icon = [&](RefPtr<MultiScaleBitmaps>& icon, StringView const& path, StringView const& default_path) {
+ StringBuilder full_path;
full_path.append(icons_path);
- full_path.append("window-close.png");
- s_close_icon = MultiScaleBitmaps::create(full_path.to_string(), "/res/icons/16x16/window-close.png");
- full_path.clear();
- }
- if (!s_close_modified_icon || s_last_title_button_icons_path != icons_path) {
- full_path.append(icons_path);
- full_path.append("window-close-modified.png");
- s_close_modified_icon = MultiScaleBitmaps::create(full_path.to_string(), "/res/icons/16x16/window-close-modified.png");
- full_path.clear();
- }
+ full_path.append(path);
+ if (icon)
+ icon->load(full_path.to_string(), default_path);
+ else
+ icon = MultiScaleBitmaps::create(full_path.to_string(), default_path);
+ };
- s_last_title_button_icons_path = icons_path;
+ reload_icon(s_minimize_icon, "window-minimize.png", "/res/icons/16x16/downward-triangle.png");
+ reload_icon(s_maximize_icon, "window-maximize.png", "/res/icons/16x16/upward-triangle.png");
+ reload_icon(s_restore_icon, "window-restore.png", "/res/icons/16x16/window-restore.png");
+ reload_icon(s_close_icon, "window-close.png", "/res/icons/16x16/window-close.png");
+ reload_icon(s_close_modified_icon, "window-close-modified.png", "/res/icons/16x16/window-close-modified.png");
auto load_shadow = [](const String& path, String& last_path, RefPtr<MultiScaleBitmaps>& shadow_bitmap) {
if (path.is_empty()) {
last_path = String::empty();
shadow_bitmap = nullptr;
} else if (!shadow_bitmap || last_path != path) {
- shadow_bitmap = MultiScaleBitmaps::create(path);
+ if (shadow_bitmap)
+ shadow_bitmap->load(path);
+ else
+ shadow_bitmap = MultiScaleBitmaps::create(path);
if (shadow_bitmap)
last_path = path;
else