diff options
Diffstat (limited to 'WindowServer')
-rw-r--r-- | WindowServer/WSWindow.cpp | 10 | ||||
-rw-r--r-- | WindowServer/WSWindow.h | 4 | ||||
-rw-r--r-- | WindowServer/WSWindowManager.cpp | 19 | ||||
-rw-r--r-- | WindowServer/WSWindowSwitcher.cpp | 6 |
4 files changed, 34 insertions, 5 deletions
diff --git a/WindowServer/WSWindow.cpp b/WindowServer/WSWindow.cpp index 7cfbc4b6e2..bcebe450cb 100644 --- a/WindowServer/WSWindow.cpp +++ b/WindowServer/WSWindow.cpp @@ -5,9 +5,18 @@ #include <WindowServer/WSAPITypes.h> #include <WindowServer/WSClientConnection.h> +static GraphicsBitmap& default_window_icon() +{ + static GraphicsBitmap* s_icon; + if (!s_icon) + s_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/window16.rgb", { 16, 16 }).leak_ref(); + return *s_icon; +} + WSWindow::WSWindow(WSMessageReceiver& internal_owner, WSWindowType type) : m_internal_owner(&internal_owner) , m_type(type) + , m_icon(default_window_icon()) { WSWindowManager::the().add_window(*this); } @@ -16,6 +25,7 @@ WSWindow::WSWindow(WSClientConnection& client, int window_id) : m_client(&client) , m_type(WSWindowType::Normal) , m_window_id(window_id) + , m_icon(default_window_icon()) { WSWindowManager::the().add_window(*this); } diff --git a/WindowServer/WSWindow.h b/WindowServer/WSWindow.h index 26c4a41bef..7d0273a742 100644 --- a/WindowServer/WSWindow.h +++ b/WindowServer/WSWindow.h @@ -78,6 +78,9 @@ public: Size base_size() const { return m_base_size; } void set_base_size(const Size& size) { m_base_size = size; } + const GraphicsBitmap& icon() const { return *m_icon; } + void set_icon(Retained<GraphicsBitmap>&& icon) { m_icon = move(icon); } + // For InlineLinkedList. // FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that. WSWindow* m_next { nullptr }; @@ -99,4 +102,5 @@ private: Rect m_last_lazy_resize_rect; Size m_size_increment; Size m_base_size; + Retained<GraphicsBitmap> m_icon; }; diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index f1e0c1123d..db28c3017c 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -41,13 +41,25 @@ static inline Rect title_bar_rect(const Rect& window) }; } -static inline Rect title_bar_text_rect(const Rect& window) +static inline Rect title_bar_icon_rect(const Rect& window) { auto titlebar_rect = title_bar_rect(window); return { titlebar_rect.x() + 2, titlebar_rect.y(), - titlebar_rect.width() - 4, + 16, + titlebar_rect.height(), + }; +} + +static inline Rect title_bar_text_rect(const Rect& window) +{ + auto titlebar_rect = title_bar_rect(window); + auto titlebar_icon_rect = title_bar_icon_rect(window); + return { + titlebar_rect.x() + 2 + titlebar_icon_rect.width() + 2, + titlebar_rect.y(), + titlebar_rect.width() - 4 - titlebar_icon_rect.width() - 2, titlebar_rect.height() }; } @@ -400,6 +412,7 @@ void WSWindowManager::paint_window_frame(WSWindow& window) return; auto titlebar_rect = title_bar_rect(window.rect()); + auto titlebar_icon_rect = title_bar_icon_rect(window.rect()); auto titlebar_inner_rect = title_bar_text_rect(window.rect()); auto outer_rect = outer_window_rect(window); auto border_rect = border_window_rect(window.rect()); @@ -459,6 +472,8 @@ void WSWindowManager::paint_window_frame(WSWindow& window) m_back_painter->fill_rect_with_gradient(close_button_rect.shrunken(2, 2), Color::LightGray, Color::White); + m_back_painter->blit(titlebar_icon_rect.location(), window.icon(), window.icon().rect()); + m_back_painter->draw_rect(close_button_rect, Color::DarkGray); auto x_location = close_button_rect.center(); x_location.move_by(-(s_close_button_bitmap_width / 2), -(s_close_button_bitmap_height / 2)); diff --git a/WindowServer/WSWindowSwitcher.cpp b/WindowServer/WSWindowSwitcher.cpp index f751de7188..5c1bae7993 100644 --- a/WindowServer/WSWindowSwitcher.cpp +++ b/WindowServer/WSWindowSwitcher.cpp @@ -80,8 +80,9 @@ void WSWindowSwitcher::draw() text_color = Color::Black; rect_text_color = Color::DarkGray; } + painter.blit(item_rect.location().translated(0, (item_rect.height() - window.icon().height()) / 2), window.icon(), window.icon().rect()); painter.set_font(Font::default_bold_font()); - painter.draw_text(item_rect, window.title(), TextAlignment::CenterLeft, text_color); + painter.draw_text(item_rect.translated(window.icon().width() + 4, 0), window.title(), TextAlignment::CenterLeft, text_color); painter.set_font(WSWindowManager::the().font()); painter.draw_text(item_rect, window.rect().to_string(), TextAlignment::CenterRight, rect_text_color); } @@ -118,7 +119,6 @@ void WSWindowSwitcher::refresh() draw(); } -void WSWindowSwitcher::on_message(WSMessage& message) +void WSWindowSwitcher::on_message(WSMessage&) { - } |