1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-09-17 05:16:17 +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:
Andreas Kling 2020-06-11 22:46:49 +02:00
parent 940fbea3a7
commit 2ce2c4810a
9 changed files with 84 additions and 7 deletions

View file

@ -217,15 +217,22 @@ void Compositor::compose()
}
Gfx::IntRect dirty_rect_in_backing_coordinates = dirty_rect
.intersected(window.rect())
.intersected(backing_rect)
.translated(-backing_rect.location());
.intersected(window.rect())
.intersected(backing_rect)
.translated(-backing_rect.location());
if (dirty_rect_in_backing_coordinates.is_empty())
continue;
auto dst = backing_rect.location().translated(dirty_rect_in_backing_coordinates.location());
m_back_painter->blit(dst, *backing_store, dirty_rect_in_backing_coordinates, window.opacity());
if (window.client() && window.client()->is_unresponsive()) {
m_back_painter->blit_filtered(dst, *backing_store, dirty_rect_in_backing_coordinates, [](Color src) {
return src.to_grayscale().darkened(0.75f);
});
} else {
m_back_painter->blit(dst, *backing_store, dirty_rect_in_backing_coordinates, window.opacity());
}
for (auto background_rect : window.rect().shatter(backing_rect))
m_back_painter->fill_rect(background_rect, wm.palette().window());
}