From 74f673e23ce3a771fb616f558add2471fc75b577 Mon Sep 17 00:00:00 2001 From: Loki Date: Tue, 31 Aug 2021 21:19:02 +0200 Subject: [PATCH] Fix build for SUNSHINE_ENABLE_WAYLAND=OFF --- CMakeLists.txt | 12 +++++++--- sunshine/platform/linux/wayland.h | 39 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 275be431..17a57fa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,12 +108,18 @@ else() if(${SUNSHINE_ENABLE_X11}) find_package(X11) + else() + set(X11_FOUND OFF) endif() if(${SUNSHINE_ENABLE_DRM}) find_package(LIBDRM) + else() + set(LIBDRM_FOUND OFF) endif() if(${SUNSHINE_ENABLE_WAYLAND}) find_package(Wayland) + else() + set(WAYLAND_FOUND OFF) endif() find_package(FFMPEG REQUIRED) @@ -165,11 +171,10 @@ else() list(APPEND PLATFORM_LIBRARIES ${WAYLAND_LIBRARIES}) list(APPEND PLATFORM_TARGET_FILES sunshine/platform/linux/wlgrab.cpp - sunshine/platform/linux/wayland.cpp - sunshine/platform/linux/wayland.h) + sunshine/platform/linux/wayland.cpp) endif() if(NOT ${X11_FOUND} AND NOT ${LIBDRM_FOUND} AND NOT ${WAYLAND_FOUND}) - message(FATAL_ERROR "Couldn't find either x11 or libdrm") + message(FATAL_ERROR "Couldn't find either x11, wayland or libdrm") endif() list(APPEND PLATFORM_TARGET_FILES @@ -183,6 +188,7 @@ else() sunshine/platform/linux/audio.cpp sunshine/platform/linux/input.cpp sunshine/platform/linux/x11grab.h + sunshine/platform/linux/wayland.h third-party/glad/src/egl.c third-party/glad/src/gl.c third-party/glad/include/EGL/eglplatform.h diff --git a/sunshine/platform/linux/wayland.h b/sunshine/platform/linux/wayland.h index 67bfa884..3b961349 100644 --- a/sunshine/platform/linux/wayland.h +++ b/sunshine/platform/linux/wayland.h @@ -3,11 +3,19 @@ #include +#ifdef SUNSHINE_BUILD_WAYLAND #include #include +#endif #include "graphics.h" +/** + * The classes defined in this macro block should only be used by + * cpp files whose compilation depends on SUNSHINE_BUILD_WAYLAND + */ +#ifdef SUNSHINE_BUILD_WAYLAND + namespace wl { using display_internal_t = util::safe_ptr; @@ -179,5 +187,36 @@ std::vector> monitors(const char *display_name = null int init(); } // namespace wl +#else + +struct wl_output; +struct zxdg_output_manager_v1; + +namespace wl { +class monitor_t { +public: + monitor_t(monitor_t &&) = delete; + monitor_t(const monitor_t &) = delete; + + monitor_t &operator=(const monitor_t &) = delete; + monitor_t &operator=(monitor_t &&) = delete; + + monitor_t(wl_output *output); + + void listen(zxdg_output_manager_v1 *output_manager); + + wl_output *output; + + std::string name; + std::string description; + + platf::touch_port_t viewport; +}; + +inline std::vector> monitors(const char *display_name = nullptr) { return {}; } + +inline int init() { return -1; } +} // namespace wl +#endif #endif \ No newline at end of file