You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Wayland: Handle fifo_v1 and clean up suspension logic
Before, the WSI was unfortunately quite broken and we had work around it by manually pacing frames. Needless to say it was not an ideal solution. Now, the WSI can make use of the new fifo_v1 protocol to work properly. If it's available, we'll trust the WSI by disabling manual frame pacing. While we're at it, let's clean up the suspension code a bit by removing some duplicated stuff and handling the suspension state through a switch case.
This commit is contained in:
@@ -60,6 +60,10 @@
|
||||
#define DEBUG_LOG_WAYLAND_THREAD(...)
|
||||
#endif
|
||||
|
||||
// Since we're never going to use this interface directly, it's not worth
|
||||
// generating the whole deal.
|
||||
#define FIFO_INTERFACE_NAME "wp_fifo_manager_v1"
|
||||
|
||||
// Read the content pointed by fd into a Vector<uint8_t>.
|
||||
Vector<uint8_t> WaylandThread::_read_fd(int fd) {
|
||||
// This is pretty much an arbitrary size.
|
||||
@@ -640,6 +644,10 @@ void WaylandThread::_wl_registry_on_global(void *data, struct wl_registry *wl_re
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(interface, FIFO_INTERFACE_NAME) == 0) {
|
||||
registry->wp_fifo_manager_name = name;
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandThread::_wl_registry_on_global_remove(void *data, struct wl_registry *wl_registry, uint32_t name) {
|
||||
@@ -1028,6 +1036,10 @@ void WaylandThread::_wl_registry_on_global_remove(void *data, struct wl_registry
|
||||
it = it->next();
|
||||
}
|
||||
}
|
||||
|
||||
if (name == registry->wp_fifo_manager_name) {
|
||||
registry->wp_fifo_manager_name = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandThread::_wl_surface_on_enter(void *data, struct wl_surface *wl_surface, struct wl_output *wl_output) {
|
||||
@@ -4275,6 +4287,10 @@ Error WaylandThread::init() {
|
||||
}
|
||||
#endif // DBUS_ENABLED
|
||||
|
||||
if (!registry.wp_fifo_manager_name) {
|
||||
WARN_PRINT("FIFO protocol not found! Frame pacing will be degraded.");
|
||||
}
|
||||
|
||||
// Wait for seat capabilities.
|
||||
wl_display_roundtrip(wl_display);
|
||||
|
||||
@@ -4777,6 +4793,10 @@ bool WaylandThread::window_is_suspended(DisplayServer::WindowID p_window_id) con
|
||||
return windows[p_window_id].suspended;
|
||||
}
|
||||
|
||||
bool WaylandThread::is_fifo_available() const {
|
||||
return registry.wp_fifo_manager_name != 0;
|
||||
}
|
||||
|
||||
bool WaylandThread::is_suspended() const {
|
||||
for (const KeyValue<DisplayServer::WindowID, WindowState> &E : windows) {
|
||||
if (!E.value.suspended) {
|
||||
|
||||
Reference in New Issue
Block a user