diff --git a/CMakeLists.txt b/CMakeLists.txt index 51d2f65..7aa2c66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,14 +148,23 @@ if(BUILD_WSI_WAYLAND) COMMAND ${WAYLAND_SCANNER_EXEC} public-code ${WAYLAND_PROTOCOLS_DIR}/unstable/linux-explicit-synchronization/linux-explicit-synchronization-unstable-v1.xml ${CMAKE_CURRENT_BINARY_DIR}/linux-explicit-synchronization-unstable-v1-protocol.c + COMMAND ${WAYLAND_SCANNER_EXEC} client-header + ${WAYLAND_PROTOCOLS_DIR}/stable/presentation-time/presentation-time.xml + ${CMAKE_CURRENT_BINARY_DIR}/presentation-time-client-protocol.h + COMMAND ${WAYLAND_SCANNER_EXEC} public-code + ${WAYLAND_PROTOCOLS_DIR}/stable/presentation-time/presentation-time.xml + ${CMAKE_CURRENT_BINARY_DIR}/presentation-time-client-protocol.c BYPRODUCTS linux-dmabuf-unstable-v1-protocol.c linux-dmabuf-unstable-v1-client-protocol.h - linux-explicit-synchronization-unstable-v1-protocol.c linux-explicit-synchronization-unstable-v1-protocol.h) + linux-explicit-synchronization-unstable-v1-protocol.c linux-explicit-synchronization-unstable-v1-protocol.h + presentation-time-client-protocol.c presentation-time-client-protocol.h) target_sources(wayland_wsi PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/linux-dmabuf-unstable-v1-protocol.c ${CMAKE_CURRENT_BINARY_DIR}/linux-dmabuf-unstable-v1-client-protocol.h ${CMAKE_CURRENT_BINARY_DIR}/linux-explicit-synchronization-unstable-v1-protocol.c - ${CMAKE_CURRENT_BINARY_DIR}/linux-explicit-synchronization-unstable-v1-protocol.h) + ${CMAKE_CURRENT_BINARY_DIR}/linux-explicit-synchronization-unstable-v1-protocol.h + ${CMAKE_CURRENT_BINARY_DIR}/presentation-time-client-protocol.c + ${CMAKE_CURRENT_BINARY_DIR}/presentation-time-client-protocol.h) add_dependencies(wayland_wsi wayland_generated_files) target_include_directories(wayland_wsi PRIVATE diff --git a/wsi/wayland/surface.cpp b/wsi/wayland/surface.cpp index 07ef607..61ed4b5 100644 --- a/wsi/wayland/surface.cpp +++ b/wsi/wayland/surface.cpp @@ -170,6 +170,19 @@ surface_registry_handler(void *data, struct wl_registry *wl_registry, uint32_t n wsi_surface->explicit_sync_interface.reset(explicit_sync_interface_obj); } + else if (!strcmp(interface, wp_presentation_interface.name)) + { + wp_presentation *wp_presentation_obj = + reinterpret_cast(wl_registry_bind(wl_registry, name, &wp_presentation_interface, 1)); + + if (wp_presentation_obj == nullptr) + { + WSI_LOG_ERROR("Failed to get wp_presentation interface."); + return; + } + + wsi_surface->presentation_time_interface.reset(wp_presentation_obj); + } } bool surface::init() @@ -222,6 +235,12 @@ bool surface::init() return false; } + if (presentation_time_interface.get() == nullptr) + { + WSI_LOG_ERROR("Failed to obtain wp_presentation interface."); + return false; + } + auto surface_sync_obj = zwp_linux_explicit_synchronization_v1_get_synchronization(explicit_sync_interface.get(), wayland_surface); if (surface_sync_obj == nullptr) diff --git a/wsi/wayland/surface.hpp b/wsi/wayland/surface.hpp index fd005d4..877ca99 100644 --- a/wsi/wayland/surface.hpp +++ b/wsi/wayland/surface.hpp @@ -171,6 +171,9 @@ private: /** Container for the surface specific zwp_linux_surface_synchronization_v1 interface. */ wayland_owner surface_sync_interface; + /** Container for the wp_presentation interface binding */ + wayland_owner presentation_time_interface; + /** * Container for a callback object for the latest frame done event. * diff --git a/wsi/wayland/wl_object_owner.hpp b/wsi/wayland/wl_object_owner.hpp index 7199e66..0ed09ef 100644 --- a/wsi/wayland/wl_object_owner.hpp +++ b/wsi/wayland/wl_object_owner.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,11 @@ static inline void wayland_object_destroy(zwp_linux_surface_synchronization_v1 * zwp_linux_surface_synchronization_v1_destroy(obj); } +static inline void wayland_object_destroy(wp_presentation *obj) +{ + wp_presentation_destroy(obj); +} + static inline void wayland_object_destroy(wl_callback *obj) { wl_callback_destroy(obj);