mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:57:35 +00:00
WindowServer+LibGUI: Add ability to set per-window icons.
The icons are passed around as filesystem paths for now, since the shared memory bitmaps only support 2 sides.
This commit is contained in:
parent
7a74b76769
commit
c09c114d77
19 changed files with 151 additions and 16 deletions
|
@ -74,13 +74,14 @@ void TaskbarWindow::wm_event(GWMEvent& event)
|
|||
}
|
||||
case GEvent::WM_WindowStateChanged: {
|
||||
auto& changed_event = static_cast<GWMWindowStateChangedEvent&>(event);
|
||||
printf("WM_WindowStateChanged: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u, is_minimized=%u\n",
|
||||
printf("WM_WindowStateChanged: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u, is_minimized=%u, icon_path=%s\n",
|
||||
changed_event.client_id(),
|
||||
changed_event.window_id(),
|
||||
changed_event.title().characters(),
|
||||
changed_event.rect().to_string().characters(),
|
||||
changed_event.is_active(),
|
||||
changed_event.is_minimized()
|
||||
changed_event.is_minimized(),
|
||||
changed_event.icon_path().characters()
|
||||
);
|
||||
if (!should_include_window(changed_event.window_type()))
|
||||
break;
|
||||
|
@ -89,6 +90,7 @@ void TaskbarWindow::wm_event(GWMEvent& event)
|
|||
window.set_rect(changed_event.rect());
|
||||
window.set_active(changed_event.is_active());
|
||||
window.set_minimized(changed_event.is_minimized());
|
||||
window.set_icon_path(changed_event.icon_path());
|
||||
if (window.is_minimized()) {
|
||||
window.button()->set_foreground_color(Color::DarkGray);
|
||||
window.button()->set_caption(String::format("[%s]", changed_event.title().characters()));
|
||||
|
@ -96,6 +98,7 @@ void TaskbarWindow::wm_event(GWMEvent& event)
|
|||
window.button()->set_foreground_color(Color::Black);
|
||||
window.button()->set_caption(changed_event.title());
|
||||
}
|
||||
window.button()->set_icon(window.icon());
|
||||
window.button()->set_checked(changed_event.is_active());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -63,11 +63,27 @@ public:
|
|||
void set_minimized(bool minimized) { m_minimized = minimized; }
|
||||
bool is_minimized() const { return m_minimized; }
|
||||
|
||||
String icon_path() const { return m_icon_path; }
|
||||
void set_icon_path(const String& icon_path)
|
||||
{
|
||||
if (m_icon_path == icon_path)
|
||||
return;
|
||||
auto icon = GraphicsBitmap::load_from_file(icon_path);
|
||||
if (!icon)
|
||||
return;
|
||||
m_icon_path = icon_path;
|
||||
m_icon = move(icon);
|
||||
}
|
||||
|
||||
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
||||
|
||||
private:
|
||||
WindowIdentifier m_identifier;
|
||||
String m_title;
|
||||
Rect m_rect;
|
||||
GButton* m_button { nullptr };
|
||||
String m_icon_path;
|
||||
RetainPtr<GraphicsBitmap> m_icon;
|
||||
bool m_active { false };
|
||||
bool m_minimized { false };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue