1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

WindowServer: Generate a separate WM event for window icon changes.

This commit is contained in:
Andreas Kling 2019-04-18 00:39:11 +02:00
parent c4c7f224d5
commit c931eaa22c
12 changed files with 95 additions and 23 deletions

View file

@ -97,6 +97,7 @@ struct WSAPI_ServerMessage {
ScreenRectChanged,
WM_WindowRemoved,
WM_WindowStateChanged,
WM_WindowIconChanged,
};
Type type { Invalid };
int window_id { -1 };
@ -116,8 +117,6 @@ struct WSAPI_ServerMessage {
bool is_active;
bool is_minimized;
WSAPI_WindowType window_type;
int icon_path_length;
char icon_path[256];
} wm;
struct {
WSAPI_Rect rect;

View file

@ -370,7 +370,7 @@ void WSClientConnection::handle_request(const WSAPISetWindowIconRequest& request
}
window.frame().invalidate_title_bar();
WSWindowManager::the().tell_wm_listeners_window_state_changed(window);
WSWindowManager::the().tell_wm_listeners_window_icon_changed(window);
}
void WSClientConnection::handle_request(const WSAPISetWindowRectRequest& request)

View file

@ -29,6 +29,7 @@ public:
WM_WindowRemoved,
WM_WindowStateChanged,
WM_WindowIconChanged,
__Begin_API_Client_Requests,
APICreateMenubarRequest,
@ -712,10 +713,9 @@ public:
class WSWMWindowStateChangedEvent : public WSWMEvent {
public:
WSWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type, bool is_minimized, const String& icon_path)
WSWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type, bool is_minimized)
: WSWMEvent(WSEvent::WM_WindowStateChanged, client_id, window_id)
, m_title(title)
, m_icon_path(icon_path)
, m_rect(rect)
, m_active(is_active)
, m_window_type(window_type)
@ -724,7 +724,6 @@ public:
}
String title() const { return m_title; }
String icon_path() const { return m_icon_path; }
Rect rect() const { return m_rect; }
bool is_active() const { return m_active; }
WSWindowType window_type() const { return m_window_type; }
@ -732,9 +731,22 @@ public:
private:
String m_title;
String m_icon_path;
Rect m_rect;
bool m_active;
WSWindowType m_window_type;
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;
};

View file

@ -196,9 +196,17 @@ void WSWindow::event(CEvent& event)
memcpy(server_message.text, changed_event.title().characters(), changed_event.title().length());
server_message.text_length = changed_event.title().length();
server_message.wm.rect = changed_event.rect();
ASSERT(changed_event.icon_path().length() < sizeof(server_message.wm.icon_path));
memcpy(server_message.wm.icon_path, changed_event.icon_path().characters(), changed_event.icon_path().length());
server_message.wm.icon_path_length = changed_event.icon_path().length();
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() < 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;
}

View file

@ -318,7 +318,7 @@ void WSWindowManager::remove_window(WSWindow& window)
void WSWindowManager::tell_wm_listener_about_window(WSWindow& listener, WSWindow& window)
{
if (window.client())
WSEventLoop::the().post_event(listener, make<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type(), window.is_minimized(), window.icon_path()));
WSEventLoop::the().post_event(listener, make<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type(), window.is_minimized()));
}
void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window)
@ -329,6 +329,15 @@ void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window)
});
}
void WSWindowManager::tell_wm_listeners_window_icon_changed(WSWindow& window)
{
for_each_window_listening_to_wm_events([&] (WSWindow& listener) {
if (window.client())
WSEventLoop::the().post_event(listener, make<WSWMWindowIconChangedEvent>(window.client()->client_id(), window.window_id(), window.icon_path()));
return IterationDecision::Continue;
});
}
void WSWindowManager::notify_title_changed(WSWindow& window)
{
dbgprintf("[WM] WSWindow{%p} title set to '%s'\n", &window, window.title().characters());

View file

@ -111,6 +111,7 @@ public:
bool any_opaque_window_above_this_one_contains_rect(const WSWindow&, const Rect&);
void tell_wm_listeners_window_state_changed(WSWindow&);
void tell_wm_listeners_window_icon_changed(WSWindow&);
private:
void process_mouse_event(const WSMouseEvent&, WSWindow*& event_window);