You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Wayland: suspend window after frame timeout or suspend state
This is a pretty popular approach that took a while for me to wrap my head around and which only recently got "official" support through an update (xdg_shell version 6), so I think that this is all-in-all a better option than the overkill 2000Hz ticking we have now :P Basically, we wait for a frame event and, if either too much time passes or we get the new `suspended` state, we consider the window as "hidden" and stop drawing, ticking by the low usage rate. This should work great for KDE and Mutter, which support the new state, but not yet for sway, which is still stuck at a very old xdg_shell version and thus falls back to the timeout approach. Be aware that if we rely on timing out the engine will have to stall for the whole timeout, which _could_ be problematic but doensn't seem like it. Further testing is needed. Special thanks go to the guys over at #wayland on OFTC, who very patiently explained me this approach way too many times.
This commit is contained in:
@@ -177,6 +177,7 @@ public:
|
||||
|
||||
Rect2i rect;
|
||||
DisplayServer::WindowMode mode = DisplayServer::WINDOW_MODE_WINDOWED;
|
||||
bool suspended = false;
|
||||
|
||||
// These are true by default as it isn't guaranteed that we'll find an
|
||||
// xdg-shell implementation with wm_capabilities available. If and once we
|
||||
@@ -939,6 +940,9 @@ public:
|
||||
|
||||
void set_frame();
|
||||
bool get_reset_frame();
|
||||
bool wait_frame_suspend_ms(int p_timeout);
|
||||
|
||||
bool is_suspended() const;
|
||||
|
||||
Error init();
|
||||
void destroy();
|
||||
|
||||
Reference in New Issue
Block a user