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:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user