mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:15:06 +00:00
LibIPC+WindowServer+LibGUI: Detect and highlight unresponsive GUI apps
IPC::ClientConnection now tracks the time since the last time we got a message from the client and calls a virtual function on itself after 3 seconds: may_have_become_unresponsive(). Subclasses of ClientConnection can then react to this if they like. We use this mechanism in WindowServer to send out a friendly Ping message to the client. If he doesn't Pong within 1 second, we mark the client as "unresponsive" and recompose all of his windows with a darkened appearance and amended title until he Pongs us. This is a little on the aggressive side and we should figure out a way to wake up less often. Perhaps this could only be done to windows the user is currently interacting with, for example. Anyways, this is pretty cool! :^)
This commit is contained in:
parent
940fbea3a7
commit
2ce2c4810a
9 changed files with 84 additions and 7 deletions
|
@ -820,4 +820,28 @@ void ClientConnection::handle(const Messages::WindowServer::SetWindowProgress& m
|
|||
it->value->set_progress(message.progress());
|
||||
}
|
||||
|
||||
void ClientConnection::handle(const Messages::WindowServer::Pong&)
|
||||
{
|
||||
m_ping_timer = nullptr;
|
||||
set_unresponsive(false);
|
||||
}
|
||||
|
||||
void ClientConnection::set_unresponsive(bool unresponsive)
|
||||
{
|
||||
if (m_unresponsive == unresponsive)
|
||||
return;
|
||||
m_unresponsive = unresponsive;
|
||||
for (auto& it : m_windows) {
|
||||
it.value->invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientConnection::may_have_become_unresponsive()
|
||||
{
|
||||
post_message(Messages::WindowClient::Ping());
|
||||
m_ping_timer = Core::Timer::create_single_shot(1000, [this] {
|
||||
set_unresponsive(true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue