1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:08:10 +00:00

WindowServer: Add window icons. Every window has the same icon for now.

The icons show up both in the title bars and in the window switcher.
Eventually I'd like to be able to minimize to icon, and maybe even have
myself a taskbar.
This commit is contained in:
Andreas Kling 2019-03-06 23:03:36 +01:00
parent 3729f7cc6a
commit 67ee579113
5 changed files with 34 additions and 5 deletions

View file

@ -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));