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

WindowServer: Merge WM_WindowAdded and WM_WindowStateChanged.

These events are identical, so it's silly to send both. Just broadcast
window state changes everywhere instead, it doesn't matter when it was
added as clients are learning about this asynchronously anyway.
This commit is contained in:
Andreas Kling 2019-04-05 15:01:28 +02:00
parent 329cc60a92
commit 99b98dc653
9 changed files with 14 additions and 97 deletions

View file

@ -37,7 +37,6 @@ public:
WindowCloseRequest,
ChildAdded,
ChildRemoved,
WM_WindowAdded,
WM_WindowRemoved,
WM_WindowStateChanged,
};
@ -73,29 +72,6 @@ private:
int m_window_id { -1 };
};
class GWMWindowAddedEvent : public GWMEvent {
public:
GWMWindowAddedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, GWindowType window_type)
: GWMEvent(GEvent::Type::WM_WindowAdded, client_id, window_id)
, m_title(title)
, m_rect(rect)
, m_active(is_active)
, m_window_type(window_type)
{
}
String title() const { return m_title; }
Rect rect() const { return m_rect; }
bool is_active() const { return m_active; }
GWindowType window_type() const { return m_window_type; }
private:
String m_title;
Rect m_rect;
bool m_active;
GWindowType m_window_type;
};
class GWMWindowRemovedEvent : public GWMEvent {
public:
GWMWindowRemovedEvent(int client_id, int window_id)

View file

@ -273,8 +273,6 @@ void GEventLoop::handle_wm_event(const WSAPI_ServerMessage& event, GWindow& wind
#ifdef GEVENTLOOP_DEBUG
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
if (event.type == WSAPI_ServerMessage::WM_WindowAdded)
return post_event(window, make<GWMWindowAddedEvent>(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));
if (event.type == WSAPI_ServerMessage::WM_WindowStateChanged)
return 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));
if (event.type == WSAPI_ServerMessage::WM_WindowRemoved)
@ -411,7 +409,6 @@ void GEventLoop::process_unprocessed_messages()
case WSAPI_ServerMessage::Type::WindowResized:
handle_resize_event(event, *window);
break;
case WSAPI_ServerMessage::Type::WM_WindowAdded:
case WSAPI_ServerMessage::Type::WM_WindowRemoved:
case WSAPI_ServerMessage::Type::WM_WindowStateChanged:
handle_wm_event(event, *window);

View file

@ -258,7 +258,7 @@ void GWindow::event(GEvent& event)
return;
}
if (event.type() == GEvent::WM_WindowAdded || event.type() == GEvent::WM_WindowRemoved || event.type() == GEvent::WM_WindowStateChanged)
if (event.type() == GEvent::WM_WindowRemoved || event.type() == GEvent::WM_WindowStateChanged)
return wm_event(static_cast<GWMEvent&>(event));
GObject::event(event);