summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorLuK1337 <priv.luk@gmail.com>2021-07-10 12:00:32 +0200
committerLinus Groh <mail@linusgroh.de>2021-07-10 14:04:21 +0100
commit5e823d3de0416461fe203143a1dbbb1530d351e8 (patch)
tree6559ea7e35433e61b2a58998098f3b2ec253dc6c /Userland/Services
parenteca74088a0185aac7b7ca56b1b14128daacc6fe0 (diff)
downloadserenity-5e823d3de0416461fe203143a1dbbb1530d351e8.zip
Taskbar: Scale window icon bitmap if it's not 16x16
Fixes: #5806
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/Taskbar/TaskbarWindow.cpp13
-rw-r--r--Userland/Services/Taskbar/TaskbarWindow.h1
2 files changed, 12 insertions, 2 deletions
diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp
index 0d49e07eab..def76601bd 100644
--- a/Userland/Services/Taskbar/TaskbarWindow.cpp
+++ b/Userland/Services/Taskbar/TaskbarWindow.cpp
@@ -297,8 +297,17 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
case GUI::Event::WM_WindowIconBitmapChanged: {
auto& changed_event = static_cast<GUI::WMWindowIconBitmapChangedEvent&>(event);
if (auto* window = WindowList::the().window(identifier)) {
- if (window->button())
- window->button()->set_icon(changed_event.bitmap());
+ if (window->button()) {
+ auto icon = changed_event.bitmap();
+ if (icon->height() != taskbar_icon_size() || icon->width() != taskbar_icon_size()) {
+ auto sw = taskbar_icon_size() / (float)icon->width();
+ auto sh = taskbar_icon_size() / (float)icon->height();
+ auto scaled_bitmap = icon->scaled(sw, sh);
+ window->button()->set_icon(move(scaled_bitmap));
+ } else {
+ window->button()->set_icon(icon);
+ }
+ }
}
break;
}
diff --git a/Userland/Services/Taskbar/TaskbarWindow.h b/Userland/Services/Taskbar/TaskbarWindow.h
index 1f35507048..a7d307bb19 100644
--- a/Userland/Services/Taskbar/TaskbarWindow.h
+++ b/Userland/Services/Taskbar/TaskbarWindow.h
@@ -18,6 +18,7 @@ public:
virtual ~TaskbarWindow() override;
static int taskbar_height() { return 27; }
+ static int taskbar_icon_size() { return 16; }
private:
explicit TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu);