mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibGUI: Allow setting window icon before show().
This commit is contained in:
parent
33b0c4cfaf
commit
c02868f000
2 changed files with 15 additions and 3 deletions
|
@ -87,6 +87,8 @@ void GWindow::show()
|
|||
auto response = GWindowServerConnection::the().sync_request(request, WSAPI_ServerMessage::Type::DidCreateWindow);
|
||||
m_window_id = response.window_id;
|
||||
|
||||
apply_icon();
|
||||
|
||||
reified_windows.set(m_window_id, this);
|
||||
update();
|
||||
}
|
||||
|
@ -626,8 +628,6 @@ void GWindow::set_icon(const GraphicsBitmap* icon)
|
|||
{
|
||||
if (m_icon == icon)
|
||||
return;
|
||||
if (!m_window_id)
|
||||
return;
|
||||
|
||||
m_icon = create_shared_bitmap(GraphicsBitmap::Format::RGBA32, icon->size());
|
||||
{
|
||||
|
@ -635,6 +635,17 @@ void GWindow::set_icon(const GraphicsBitmap* icon)
|
|||
painter.blit({ 0, 0 }, *icon, icon->rect());
|
||||
}
|
||||
|
||||
apply_icon();
|
||||
}
|
||||
|
||||
void GWindow::apply_icon()
|
||||
{
|
||||
if (!m_icon)
|
||||
return;
|
||||
|
||||
if (!m_window_id)
|
||||
return;
|
||||
|
||||
int rc = seal_shared_buffer(m_icon->shared_buffer_id());
|
||||
ASSERT(rc == 0);
|
||||
|
||||
|
@ -649,7 +660,7 @@ void GWindow::set_icon(const GraphicsBitmap* icon)
|
|||
message.type = WSAPI_ClientMessage::Type::SetWindowIconBitmap;
|
||||
message.window_id = m_window_id;
|
||||
message.window.icon_buffer_id = m_icon->shared_buffer_id();
|
||||
message.window.icon_size = icon->size();
|
||||
message.window.icon_size = m_icon->size();
|
||||
GWindowServerConnection::the().post_message_to_server(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ public:
|
|||
void set_override_cursor(GStandardCursor);
|
||||
|
||||
void set_icon(const GraphicsBitmap*);
|
||||
void apply_icon();
|
||||
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
||||
|
||||
Vector<GWidget*> focusable_widgets() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue