Wayland: Unsuspend only for the same reason as suspension

Before, we would check both methods together, leading to loops.

Now we track the actual reason we suspended and only unsuspend when
that same reason triggers. For example, if we suspend because of the
suspended flag we'll unsuspend only because it got unset. Conversely, if
we suspend because of a timeout we'll unsuspend only if we get a new
frame event.

We do this because, while some compositors properly report a "suspended"
state (hinting us to stop repainting), most don't and we need a "safety
net" anyways as we do not want to constantly stay at 1fps (the max time
we'll wait before giving up) either.
This commit is contained in:
Riteo
2024-09-26 10:07:53 +02:00
committed by Riteo Siuga
parent d2ada64a03
commit e5ac45e822
2 changed files with 39 additions and 14 deletions

View File

@ -105,6 +105,12 @@ class DisplayServerWayland : public DisplayServer {
Point2i hotspot;
};
enum class SuspendState {
NONE, // Unsuspended.
TIMEOUT, // Legacy fallback.
CAPABILITY, // New "suspended" wm_capability flag.
};
CursorShape cursor_shape = CURSOR_ARROW;
DisplayServer::MouseMode mouse_mode = DisplayServer::MOUSE_MODE_VISIBLE;
@ -118,7 +124,7 @@ class DisplayServerWayland : public DisplayServer {
String ime_text;
Vector2i ime_selection;
bool suspended = false;
SuspendState suspend_state = SuspendState::NONE;
bool emulate_vsync = false;
String rendering_driver;