WindowServer+LibGUI: Remove old "icon path" way of doing things.

Now that we can set icons directly "by bitmap", there's no need for passing
around the icon paths anymore, so get rid of all the IPC and API related
to that. :^)
This commit is contained in:
Andreas Kling 2019-07-28 10:24:58 +02:00
parent 841b2e5d13
commit d4892b3fdc
Notes: sideshowbarker 2024-07-19 13:01:05 +09:00
13 changed files with 3 additions and 158 deletions

View file

@ -86,25 +86,11 @@ void TaskbarWindow::wm_event(GWMEvent& event)
#endif
break;
}
case GEvent::WM_WindowIconChanged: {
auto& changed_event = static_cast<GWMWindowIconChangedEvent&>(event);
#ifdef EVENT_DEBUG
dbgprintf("WM_WindowIconChanged: client_id=%d, window_id=%d, icon_path=%s\n",
changed_event.client_id(),
changed_event.window_id(),
changed_event.icon_path().characters());
#endif
if (auto* window = WindowList::the().window(identifier)) {
window->set_icon_path(changed_event.icon_path());
window->button()->set_icon(window->icon());
}
break;
}
case GEvent::WM_WindowIconBitmapChanged: {
auto& changed_event = static_cast<GWMWindowIconBitmapChangedEvent&>(event);
#ifdef EVENT_DEBUG
dbgprintf("WM_WindowIconChanged: client_id=%d, window_id=%d, icon_buffer_id=%d\n",
dbgprintf("WM_WindowIconBitmapChanged: client_id=%d, window_id=%d, icon_buffer_id=%d\n",
changed_event.client_id(),
changed_event.window_id(),
changed_event.icon_buffer_id());

View file

@ -35,18 +35,6 @@ 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:
@ -54,7 +42,6 @@ private:
String m_title;
Rect m_rect;
GButton* m_button { nullptr };
String m_icon_path;
RefPtr<GraphicsBitmap> m_icon;
bool m_active { false };
bool m_minimized { false };

View file

@ -39,7 +39,6 @@ public:
WM_WindowRemoved,
WM_WindowStateChanged,
WM_WindowRectChanged,
WM_WindowIconChanged,
WM_WindowIconBitmapChanged,
__End_WM_Events,
};
@ -120,20 +119,6 @@ private:
Rect m_rect;
};
class GWMWindowIconChangedEvent : public GWMEvent {
public:
GWMWindowIconChangedEvent(int client_id, int window_id, const StringView& icon_path)
: GWMEvent(GEvent::Type::WM_WindowIconChanged, client_id, window_id)
, m_icon_path(icon_path)
{
}
String icon_path() const { return m_icon_path; }
private:
String m_icon_path;
};
class GWMWindowIconBitmapChangedEvent : public GWMEvent {
public:
GWMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Size& icon_size)

View file

@ -192,8 +192,6 @@ void GWindowServerConnection::handle_wm_event(const WSAPI_ServerMessage& event,
CEventLoop::current().post_event(window, make<GWMWindowStateChangedEvent>(event.wm.client_id, event.wm.window_id, String(event.text, event.text_length), event.wm.rect, event.wm.is_active, (GWindowType)event.wm.window_type, event.wm.is_minimized));
else if (event.type == WSAPI_ServerMessage::WM_WindowRectChanged)
CEventLoop::current().post_event(window, make<GWMWindowRectChangedEvent>(event.wm.client_id, event.wm.window_id, event.wm.rect));
else if (event.type == WSAPI_ServerMessage::WM_WindowIconChanged)
CEventLoop::current().post_event(window, make<GWMWindowIconChangedEvent>(event.wm.client_id, event.wm.window_id, String(event.text, event.text_length)));
else if (event.type == WSAPI_ServerMessage::WM_WindowIconBitmapChanged)
CEventLoop::current().post_event(window, make<GWMWindowIconBitmapChangedEvent>(event.wm.client_id, event.wm.window_id, event.wm.icon_buffer_id, event.wm.icon_size));
else if (event.type == WSAPI_ServerMessage::WM_WindowRemoved)

View file

@ -643,22 +643,6 @@ void GWindow::set_icon(const GraphicsBitmap* icon)
GWindowServerConnection::the().post_message_to_server(message);
}
void GWindow::set_icon_path(const StringView& path)
{
if (m_icon_path == path)
return;
m_icon_path = path;
if (!m_window_id)
return;
WSAPI_ClientMessage message;
message.type = WSAPI_ClientMessage::Type::SetWindowIcon;
message.window_id = m_window_id;
ASSERT(path.length() < (int)sizeof(message.text));
strcpy(message.text, String(path).characters());
message.text_length = path.length();
GWindowServerConnection::the().post_message_to_server(message);
}
void GWindow::start_wm_resize()
{
WSAPI_ClientMessage message;

View file

@ -119,9 +119,6 @@ public:
void set_override_cursor(GStandardCursor);
String icon_path() const { return m_icon_path; }
void set_icon_path(const StringView&);
void set_icon(const GraphicsBitmap*);
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
@ -154,7 +151,6 @@ private:
WeakPtr<GWidget> m_hovered_widget;
Rect m_rect_when_windowless;
String m_title_when_windowless;
String m_icon_path;
Vector<Rect, 32> m_pending_paint_event_rects;
Size m_size_increment;
Size m_base_size;

View file

@ -116,7 +116,6 @@ struct WSAPI_ServerMessage {
WM_WindowRemoved,
WM_WindowStateChanged,
WM_WindowRectChanged,
WM_WindowIconChanged,
WM_WindowIconBitmapChanged,
__End_WM_Events__,
};
@ -232,7 +231,6 @@ struct WSAPI_ClientMessage {
WM_PopupWindowMenu,
PopupMenu,
DismissMenu,
SetWindowIcon,
SetWindowHasAlphaChannel,
MoveWindowToFront,
SetWindowIconBitmap,

View file

@ -139,13 +139,6 @@ bool WSClientConnection::handle_message(const WSAPI_ClientMessage& message, cons
case WSAPI_ClientMessage::Type::DismissMenu:
CEventLoop::current().post_event(*this, make<WSAPIDismissMenuRequest>(client_id(), message.menu.menu_id));
break;
case WSAPI_ClientMessage::Type::SetWindowIcon:
if (message.text_length > (int)sizeof(message.text)) {
did_misbehave();
return false;
}
CEventLoop::current().post_event(*this, make<WSAPISetWindowIconRequest>(client_id(), message.window_id, String(message.text, message.text_length)));
break;
case WSAPI_ClientMessage::Type::SetWindowIconBitmap:
CEventLoop::current().post_event(*this, make<WSAPISetWindowIconBitmapRequest>(client_id(), message.window_id, message.window.icon_buffer_id, message.window.icon_size));
break;
@ -577,28 +570,6 @@ void WSClientConnection::handle_request(const WSAPIGetWindowTitleRequest& reques
post_message(response);
}
void WSClientConnection::handle_request(const WSAPISetWindowIconRequest& request)
{
int window_id = request.window_id();
auto it = m_windows.find(window_id);
if (it == m_windows.end()) {
post_error("WSAPISetWindowIconRequest: Bad window ID");
return;
}
auto& window = *(*it).value;
if (request.icon_path().is_empty()) {
window.set_default_icon();
} else {
auto icon = GraphicsBitmap::load_from_file(request.icon_path());
if (!icon)
return;
window.set_icon(request.icon_path(), *icon);
}
window.frame().invalidate_title_bar();
WSWindowManager::the().tell_wm_listeners_window_icon_changed(window);
}
void WSClientConnection::handle_request(const WSAPISetWindowIconBitmapRequest& request)
{
int window_id = request.window_id();
@ -970,8 +941,6 @@ void WSClientConnection::on_request(const WSAPIClientRequest& request)
return handle_request(static_cast<const WSAPISetWindowRectRequest&>(request));
case WSEvent::APIGetWindowRectRequest:
return handle_request(static_cast<const WSAPIGetWindowRectRequest&>(request));
case WSEvent::APISetWindowIconRequest:
return handle_request(static_cast<const WSAPISetWindowIconRequest&>(request));
case WSEvent::APISetWindowIconBitmapRequest:
return handle_request(static_cast<const WSAPISetWindowIconBitmapRequest&>(request));
case WSEvent::APISetClipboardContentsRequest:

View file

@ -54,7 +54,6 @@ private:
void handle_request(const WSAPIGetWindowTitleRequest&);
void handle_request(const WSAPISetWindowRectRequest&);
void handle_request(const WSAPIGetWindowRectRequest&);
void handle_request(const WSAPISetWindowIconRequest&);
void handle_request(const WSAPISetWindowIconBitmapRequest&);
void handle_request(const WSAPISetClipboardContentsRequest&);
void handle_request(const WSAPIGetClipboardContentsRequest&);

View file

@ -31,7 +31,6 @@ public:
WM_WindowRemoved,
WM_WindowStateChanged,
WM_WindowRectChanged,
WM_WindowIconChanged,
WM_WindowIconBitmapChanged,
__Begin_API_Client_Requests,
@ -50,7 +49,6 @@ public:
APIGetWindowTitleRequest,
APISetWindowRectRequest,
APIGetWindowRectRequest,
APISetWindowIconRequest,
APISetWindowIconBitmapRequest,
APIInvalidateRectRequest,
APIDidFinishPaintingNotification,
@ -573,23 +571,6 @@ private:
Rect m_rect;
};
class WSAPISetWindowIconRequest final : public WSAPIClientRequest {
public:
explicit WSAPISetWindowIconRequest(int client_id, int window_id, const String& icon_path)
: WSAPIClientRequest(WSEvent::APISetWindowIconRequest, client_id)
, m_window_id(window_id)
, m_icon_path(icon_path)
{
}
int window_id() const { return m_window_id; }
String icon_path() const { return m_icon_path; }
private:
int m_window_id { 0 };
String m_icon_path;
};
class WSAPISetWindowIconBitmapRequest final : public WSAPIClientRequest {
public:
explicit WSAPISetWindowIconBitmapRequest(int client_id, int window_id, int icon_buffer_id, const Size& icon_size)
@ -864,20 +845,6 @@ private:
bool m_minimized;
};
class WSWMWindowIconChangedEvent : public WSWMEvent {
public:
WSWMWindowIconChangedEvent(int client_id, int window_id, const String& icon_path)
: WSWMEvent(WSEvent::WM_WindowIconChanged, client_id, window_id)
, m_icon_path(icon_path)
{
}
String icon_path() const { return m_icon_path; }
private:
String m_icon_path;
};
class WSWMWindowIconBitmapChangedEvent : public WSWMEvent {
public:
WSWMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Size& icon_size)

View file

@ -22,7 +22,6 @@ WSWindow::WSWindow(CObject& internal_owner, WSWindowType type)
: m_internal_owner(&internal_owner)
, m_type(type)
, m_icon(default_window_icon())
, m_icon_path(default_window_icon_path())
, m_frame(*this)
{
WSWindowManager::the().add_window(*this);
@ -36,7 +35,6 @@ WSWindow::WSWindow(WSClientConnection& client, WSWindowType window_type, int win
, m_fullscreen(fullscreen)
, m_window_id(window_id)
, m_icon(default_window_icon())
, m_icon_path(default_window_icon_path())
, m_frame(*this)
{
// FIXME: This should not be hard-coded here.
@ -243,17 +241,6 @@ void WSWindow::event(CEvent& event)
break;
}
case WSEvent::WM_WindowIconChanged: {
auto& changed_event = static_cast<const WSWMWindowIconChangedEvent&>(event);
server_message.type = WSAPI_ServerMessage::Type::WM_WindowIconChanged;
server_message.wm.client_id = changed_event.client_id();
server_message.wm.window_id = changed_event.window_id();
ASSERT(changed_event.icon_path().length() < (int)sizeof(server_message.text));
memcpy(server_message.text, changed_event.icon_path().characters(), changed_event.icon_path().length());
server_message.text_length = changed_event.icon_path().length();
break;
}
case WSEvent::WM_WindowIconBitmapChanged: {
auto& changed_event = static_cast<const WSWMWindowIconBitmapChangedEvent&>(event);
server_message.type = WSAPI_ServerMessage::Type::WM_WindowIconBitmapChanged;
@ -321,7 +308,6 @@ bool WSWindow::is_blocked_by_modal_window() const
void WSWindow::set_default_icon()
{
m_icon = default_window_icon();
m_icon_path = default_window_icon_path();
}
void WSWindow::request_update(const Rect& rect)

View file

@ -131,12 +131,6 @@ public:
const GraphicsBitmap& icon() const { return *m_icon; }
void set_icon(NonnullRefPtr<GraphicsBitmap>&& icon) { m_icon = move(icon); }
String icon_path() const { return m_icon_path; }
void set_icon(const String& path, NonnullRefPtr<GraphicsBitmap>&& icon)
{
m_icon_path = path;
m_icon = move(icon);
}
void set_default_icon();
const WSCursor* override_cursor() const { return m_override_cursor.ptr(); }
@ -176,7 +170,6 @@ private:
Size m_size_increment;
Size m_base_size;
NonnullRefPtr<GraphicsBitmap> m_icon;
String m_icon_path;
RefPtr<WSCursor> m_override_cursor;
WSWindowFrame m_frame;
Color m_background_color { Color::WarmGray };

View file

@ -319,11 +319,8 @@ void WSWindowManager::tell_wm_listener_about_window_icon(WSWindow& listener, WSW
{
if (!(listener.wm_event_mask() & WSAPI_WMEventMask::WindowIconChanges))
return;
if (window.client()) {
CEventLoop::current().post_event(listener, make<WSWMWindowIconChangedEvent>(window.client()->client_id(), window.window_id(), window.icon_path()));
if (window.icon().shared_buffer_id() != -1)
CEventLoop::current().post_event(listener, make<WSWMWindowIconBitmapChangedEvent>(window.client()->client_id(), window.window_id(), window.icon().shared_buffer_id(), window.icon().size()));
}
if (window.client() && window.icon().shared_buffer_id() != -1)
CEventLoop::current().post_event(listener, make<WSWMWindowIconBitmapChangedEvent>(window.client()->client_id(), window.window_id(), window.icon().shared_buffer_id(), window.icon().size()));
}
void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window)