mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 17:55:07 +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:
parent
329cc60a92
commit
99b98dc653
9 changed files with 14 additions and 97 deletions
|
@ -54,26 +54,6 @@ void TaskbarWindow::wm_event(GWMEvent& event)
|
||||||
{
|
{
|
||||||
WindowIdentifier identifier { event.client_id(), event.window_id() };
|
WindowIdentifier identifier { event.client_id(), event.window_id() };
|
||||||
switch (event.type()) {
|
switch (event.type()) {
|
||||||
case GEvent::WM_WindowAdded: {
|
|
||||||
auto& added_event = static_cast<GWMWindowAddedEvent&>(event);
|
|
||||||
printf("WM_WindowAdded: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u\n",
|
|
||||||
added_event.client_id(),
|
|
||||||
added_event.window_id(),
|
|
||||||
added_event.title().characters(),
|
|
||||||
added_event.rect().to_string().characters(),
|
|
||||||
added_event.is_active()
|
|
||||||
);
|
|
||||||
if (!should_include_window(added_event.window_type()))
|
|
||||||
break;
|
|
||||||
auto& window = m_window_list.ensure_window(identifier);
|
|
||||||
window.set_title(added_event.title());
|
|
||||||
window.set_rect(added_event.rect());
|
|
||||||
window.set_active(added_event.is_active());
|
|
||||||
window.button()->set_caption(window.title());
|
|
||||||
window.button()->set_checked(window.is_active());
|
|
||||||
update();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GEvent::WM_WindowRemoved: {
|
case GEvent::WM_WindowRemoved: {
|
||||||
auto& removed_event = static_cast<GWMWindowRemovedEvent&>(event);
|
auto& removed_event = static_cast<GWMWindowRemovedEvent&>(event);
|
||||||
printf("WM_WindowRemoved: client_id=%d, window_id=%d\n",
|
printf("WM_WindowRemoved: client_id=%d, window_id=%d\n",
|
||||||
|
|
|
@ -37,7 +37,6 @@ public:
|
||||||
WindowCloseRequest,
|
WindowCloseRequest,
|
||||||
ChildAdded,
|
ChildAdded,
|
||||||
ChildRemoved,
|
ChildRemoved,
|
||||||
WM_WindowAdded,
|
|
||||||
WM_WindowRemoved,
|
WM_WindowRemoved,
|
||||||
WM_WindowStateChanged,
|
WM_WindowStateChanged,
|
||||||
};
|
};
|
||||||
|
@ -73,29 +72,6 @@ private:
|
||||||
int m_window_id { -1 };
|
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 {
|
class GWMWindowRemovedEvent : public GWMEvent {
|
||||||
public:
|
public:
|
||||||
GWMWindowRemovedEvent(int client_id, int window_id)
|
GWMWindowRemovedEvent(int client_id, int window_id)
|
||||||
|
|
|
@ -273,8 +273,6 @@ void GEventLoop::handle_wm_event(const WSAPI_ServerMessage& event, GWindow& wind
|
||||||
#ifdef GEVENTLOOP_DEBUG
|
#ifdef GEVENTLOOP_DEBUG
|
||||||
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
|
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
|
||||||
#endif
|
#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)
|
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));
|
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)
|
if (event.type == WSAPI_ServerMessage::WM_WindowRemoved)
|
||||||
|
@ -411,7 +409,6 @@ void GEventLoop::process_unprocessed_messages()
|
||||||
case WSAPI_ServerMessage::Type::WindowResized:
|
case WSAPI_ServerMessage::Type::WindowResized:
|
||||||
handle_resize_event(event, *window);
|
handle_resize_event(event, *window);
|
||||||
break;
|
break;
|
||||||
case WSAPI_ServerMessage::Type::WM_WindowAdded:
|
|
||||||
case WSAPI_ServerMessage::Type::WM_WindowRemoved:
|
case WSAPI_ServerMessage::Type::WM_WindowRemoved:
|
||||||
case WSAPI_ServerMessage::Type::WM_WindowStateChanged:
|
case WSAPI_ServerMessage::Type::WM_WindowStateChanged:
|
||||||
handle_wm_event(event, *window);
|
handle_wm_event(event, *window);
|
||||||
|
|
|
@ -258,7 +258,7 @@ void GWindow::event(GEvent& event)
|
||||||
return;
|
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));
|
return wm_event(static_cast<GWMEvent&>(event));
|
||||||
|
|
||||||
GObject::event(event);
|
GObject::event(event);
|
||||||
|
|
|
@ -93,7 +93,6 @@ struct WSAPI_ServerMessage {
|
||||||
DidSetWallpaper,
|
DidSetWallpaper,
|
||||||
DidGetWallpaper,
|
DidGetWallpaper,
|
||||||
ScreenRectChanged,
|
ScreenRectChanged,
|
||||||
WM_WindowAdded,
|
|
||||||
WM_WindowRemoved,
|
WM_WindowRemoved,
|
||||||
WM_WindowStateChanged,
|
WM_WindowStateChanged,
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,6 @@ public:
|
||||||
WindowCloseRequest,
|
WindowCloseRequest,
|
||||||
WindowResized,
|
WindowResized,
|
||||||
|
|
||||||
WM_WindowAdded,
|
|
||||||
WM_WindowRemoved,
|
WM_WindowRemoved,
|
||||||
WM_WindowStateChanged,
|
WM_WindowStateChanged,
|
||||||
|
|
||||||
|
@ -621,29 +620,6 @@ private:
|
||||||
int m_window_id;
|
int m_window_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSWMWindowAddedEvent : public WSWMEvent {
|
|
||||||
public:
|
|
||||||
WSWMWindowAddedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type)
|
|
||||||
: WSWMEvent(WSMessage::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; }
|
|
||||||
WSWindowType window_type() const { return m_window_type; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
String m_title;
|
|
||||||
Rect m_rect;
|
|
||||||
bool m_active;
|
|
||||||
WSWindowType m_window_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WSWMWindowRemovedEvent : public WSWMEvent {
|
class WSWMWindowRemovedEvent : public WSWMEvent {
|
||||||
public:
|
public:
|
||||||
WSWMWindowRemovedEvent(int client_id, int window_id)
|
WSWMWindowRemovedEvent(int client_id, int window_id)
|
||||||
|
|
|
@ -157,19 +157,6 @@ void WSWindow::on_message(const WSMessage& message)
|
||||||
server_message.window.old_rect = static_cast<const WSResizeEvent&>(message).old_rect();
|
server_message.window.old_rect = static_cast<const WSResizeEvent&>(message).old_rect();
|
||||||
server_message.window.rect = static_cast<const WSResizeEvent&>(message).rect();
|
server_message.window.rect = static_cast<const WSResizeEvent&>(message).rect();
|
||||||
break;
|
break;
|
||||||
case WSMessage::WM_WindowAdded: {
|
|
||||||
auto& added_event = static_cast<const WSWMWindowAddedEvent&>(message);
|
|
||||||
server_message.type = WSAPI_ServerMessage::Type::WM_WindowAdded;
|
|
||||||
server_message.wm.client_id = added_event.client_id();
|
|
||||||
server_message.wm.window_id = added_event.window_id();
|
|
||||||
server_message.wm.is_active = added_event.is_active();
|
|
||||||
server_message.wm.window_type = to_api(added_event.window_type());
|
|
||||||
ASSERT(added_event.title().length() < sizeof(server_message.text));
|
|
||||||
memcpy(server_message.text, added_event.title().characters(), added_event.title().length());
|
|
||||||
server_message.text_length = added_event.title().length();
|
|
||||||
server_message.wm.rect = added_event.rect();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WSMessage::WM_WindowRemoved: {
|
case WSMessage::WM_WindowRemoved: {
|
||||||
auto& removed_event = static_cast<const WSWMWindowRemovedEvent&>(message);
|
auto& removed_event = static_cast<const WSWMWindowRemovedEvent&>(message);
|
||||||
server_message.type = WSAPI_ServerMessage::Type::WM_WindowRemoved;
|
server_message.type = WSAPI_ServerMessage::Type::WM_WindowRemoved;
|
||||||
|
|
|
@ -494,18 +494,14 @@ void WSWindowManager::add_window(WSWindow& window)
|
||||||
m_switcher.refresh();
|
m_switcher.refresh();
|
||||||
|
|
||||||
if (window.listens_to_wm_events()) {
|
if (window.listens_to_wm_events()) {
|
||||||
for_each_window([&window] (WSWindow& other_window) {
|
for_each_window([&] (WSWindow& other_window) {
|
||||||
if (&window != &other_window && other_window.client())
|
if (&window != &other_window)
|
||||||
WSMessageLoop::the().post_message(window, make<WSWMWindowAddedEvent>(other_window.client()->client_id(), other_window.window_id(), other_window.title(), other_window.rect(), other_window.is_active(), other_window.type()));
|
tell_wm_listener_about_window(window, other_window);
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_window_listening_to_wm_events([&window] (WSWindow& listener) {
|
tell_wm_listeners_window_state_changed(window);
|
||||||
if (window.client())
|
|
||||||
WSMessageLoop::the().post_message(listener, make<WSWMWindowAddedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type()));
|
|
||||||
return IterationDecision::Continue;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSWindowManager::move_to_front_and_make_active(WSWindow& window)
|
void WSWindowManager::move_to_front_and_make_active(WSWindow& window)
|
||||||
|
@ -541,11 +537,16 @@ void WSWindowManager::remove_window(WSWindow& window)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window)
|
void WSWindowManager::tell_wm_listener_about_window(WSWindow& listener, WSWindow& window)
|
||||||
{
|
{
|
||||||
for_each_window_listening_to_wm_events([&window] (WSWindow& listener) {
|
|
||||||
if (window.client())
|
if (window.client())
|
||||||
WSMessageLoop::the().post_message(listener, make<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type()));
|
WSMessageLoop::the().post_message(listener, make<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window)
|
||||||
|
{
|
||||||
|
for_each_window_listening_to_wm_events([&] (WSWindow& listener) {
|
||||||
|
tell_wm_listener_about_window(listener, window);
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,7 @@ private:
|
||||||
void flip_buffers();
|
void flip_buffers();
|
||||||
void tick_clock();
|
void tick_clock();
|
||||||
void tell_wm_listeners_window_state_changed(WSWindow&);
|
void tell_wm_listeners_window_state_changed(WSWindow&);
|
||||||
|
void tell_wm_listener_about_window(WSWindow& listener, WSWindow&);
|
||||||
|
|
||||||
WSScreen& m_screen;
|
WSScreen& m_screen;
|
||||||
Rect m_screen_rect;
|
Rect m_screen_rect;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue