From 64c9dc446ec7010a862772a24458c9bdbf7f10f0 Mon Sep 17 00:00:00 2001 From: Joel Winarske Date: Mon, 17 Apr 2023 16:53:37 -0700 Subject: [PATCH] Wayland Support (#1018) Signed-off-by: Joel Winarske --- .github/workflows/node-ci.yml | 2 ++ platform/glfw/glfw_view.cpp | 6 +++--- platform/linux/linux.cmake | 14 +++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 375a5eb56..030b8fab0 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -8,6 +8,7 @@ on: tags: - 'node-*' paths: + - "platform/linux/**" - "platform/default/**" - 'platform/node/**' - 'platform/windows/**' @@ -32,6 +33,7 @@ on: branches: - main paths: + - "platform/linux/**" - "platform/default/**" - 'platform/node/**' - 'platform/windows/**' diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index fbbee2831..46048ce84 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -559,9 +559,9 @@ void GLFWView::updateFreeCameraDemo() { } mbgl::Color GLFWView::makeRandomColor() const { - const auto r = static_cast(std::rand()) / RAND_MAX; - const auto g = static_cast(std::rand()) / RAND_MAX; - const auto b = static_cast(std::rand()) / RAND_MAX; + const auto r = static_cast(std::rand()) / static_cast(RAND_MAX); + const auto g = static_cast(std::rand()) / static_cast(RAND_MAX); + const auto b = static_cast(std::rand()) / static_cast(RAND_MAX); return { r, g, b, 1.0f }; } diff --git a/platform/linux/linux.cmake b/platform/linux/linux.cmake index 18d9653ec..88a867806 100644 --- a/platform/linux/linux.cmake +++ b/platform/linux/linux.cmake @@ -1,10 +1,15 @@ +option(MBGL_WITH_X11 "Build with X11 Support" ON) +option(MBGL_WITH_WAYLAND "Build with Wayland Support" OFF) + find_package(CURL REQUIRED) find_package(ICU OPTIONAL_COMPONENTS i18n) find_package(ICU OPTIONAL_COMPONENTS uc) find_package(JPEG REQUIRED) find_package(PNG REQUIRED) find_package(PkgConfig REQUIRED) -find_package(X11 REQUIRED) +if (MBGL_WITH_X11) + find_package(X11 REQUIRED) +endif () find_package(Threads REQUIRED) pkg_search_module(LIBUV libuv REQUIRED) @@ -64,6 +69,13 @@ if(MBGL_WITH_EGL) PRIVATE OpenGL::EGL ) + if (MBGL_WITH_WAYLAND) + target_compile_definitions(mbgl-core PUBLIC + EGL_NO_X11 + MESA_EGL_NO_X11_HEADERS + WL_EGL_PLATFORM + ) + endif() else() find_package(OpenGL REQUIRED GLX) target_sources(