diff --git a/CMakeLists.txt b/CMakeLists.txt
index 096d93391a..25618b855f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,11 +135,16 @@ set_package_properties(epoxy PROPERTIES DESCRIPTION "libepoxy"
PURPOSE "OpenGL dispatch library"
)
-find_package(Wayland 1.2 REQUIRED COMPONENTS Egl Cursor)
+find_package(Wayland 1.2 REQUIRED COMPONENTS Cursor OPTIONAL_COMPONENTS Egl)
set_package_properties(Wayland PROPERTIES
TYPE REQUIRED
PURPOSE "Required for building KWin with Wayland support"
)
+add_feature_info("Wayland::EGL" Wayland_Egl_FOUND "Enable building of Wayland backend and QPA with EGL support.")
+set(HAVE_WAYLAND_EGL FALSE)
+if(Wayland_Egl_FOUND)
+ set(HAVE_WAYLAND_EGL TRUE)
+endif()
find_package(XKB 0.4.1)
set_package_properties(XKB PROPERTIES
diff --git a/backends/wayland/CMakeLists.txt b/backends/wayland/CMakeLists.txt
index 68e78e3e5e..ffc3edf230 100644
--- a/backends/wayland/CMakeLists.txt
+++ b/backends/wayland/CMakeLists.txt
@@ -2,11 +2,18 @@ set(WAYLAND_BACKEND_SOURCES
logging.cpp
scene_qpainter_wayland_backend.cpp
wayland_backend.cpp
- egl_wayland_backend.cpp
)
+if(HAVE_WAYLAND_EGL)
+ set(WAYLAND_BACKEND_SOURCES egl_wayland_backend.cpp ${WAYLAND_BACKEND_SOURCES})
+endif()
+
add_library(KWinWaylandWaylandBackend MODULE ${WAYLAND_BACKEND_SOURCES})
-target_link_libraries(KWinWaylandWaylandBackend kwin KF5::WaylandClient Wayland::Egl)
+target_link_libraries(KWinWaylandWaylandBackend kwin KF5::WaylandClient)
+
+if(HAVE_WAYLAND_EGL)
+ target_link_libraries(KWinWaylandWaylandBackend Wayland::Egl)
+endif()
install(
TARGETS
diff --git a/backends/wayland/wayland_backend.cpp b/backends/wayland/wayland_backend.cpp
index 8e0e5fe8ce..430f630073 100644
--- a/backends/wayland/wayland_backend.cpp
+++ b/backends/wayland/wayland_backend.cpp
@@ -19,6 +19,7 @@ along with this program. If not, see .
*********************************************************************/
// own
#include "wayland_backend.h"
+#include
// KWin
#include "cursor.h"
#include "logging.h"
@@ -27,7 +28,9 @@ along with this program. If not, see .
#include "screens.h"
#include "wayland_server.h"
#include "wayland_cursor_theme.h"
+#if HAVE_WAYLAND_EGL
#include "egl_wayland_backend.h"
+#endif
#include
#include
#include
@@ -449,7 +452,11 @@ Screens *WaylandBackend::createScreens(QObject *parent)
OpenGLBackend *WaylandBackend::createOpenGLBackend()
{
+#if HAVE_WAYLAND_EGL
return new EglWaylandBackend(this);
+#else
+ return nullptr;
+#endif
}
QPainterBackend *WaylandBackend::createQPainterBackend()
diff --git a/config-kwin.h.cmake b/config-kwin.h.cmake
index 34566c2538..2466d7ca7a 100644
--- a/config-kwin.h.cmake
+++ b/config-kwin.h.cmake
@@ -13,6 +13,7 @@
#cmakedefine01 HAVE_DRM
#cmakedefine01 HAVE_GBM
#cmakedefine01 HAVE_LIBHYBRIS
+#cmakedefine01 HAVE_WAYLAND_EGL
/* Define to 1 if you have the header file. */
#cmakedefine HAVE_UNISTD_H 1
diff --git a/plugins/qpa/CMakeLists.txt b/plugins/qpa/CMakeLists.txt
index 296aa470a6..9ebf54fdf3 100644
--- a/plugins/qpa/CMakeLists.txt
+++ b/plugins/qpa/CMakeLists.txt
@@ -18,12 +18,15 @@ add_library(KWinQpaPlugin MODULE ${QPA_SOURCES})
target_link_libraries(KWinQpaPlugin
kwin
KF5::WaylandClient
- Wayland::Egl
Qt5PlatformSupport::Qt5PlatformSupport
${FONTCONFIG_LIBRARIES}
${FREETYPE_LIBRARIES}
)
+if(HAVE_WAYLAND_EGL)
+ target_link_libraries(KWinQpaPlugin Wayland::Egl)
+endif()
+
install(
TARGETS
KWinQpaPlugin
diff --git a/plugins/qpa/window.cpp b/plugins/qpa/window.cpp
index 7efc95cee2..02e77c698c 100644
--- a/plugins/qpa/window.cpp
+++ b/plugins/qpa/window.cpp
@@ -54,9 +54,11 @@ Window::~Window()
if (m_eglSurface != EGL_NO_SURFACE) {
eglDestroySurface(m_integration->eglDisplay(), m_eglSurface);
}
+#if HAVE_WAYLAND_EGL
if (m_eglWaylandWindow) {
wl_egl_window_destroy(m_eglWaylandWindow);
}
+#endif
delete m_shellSurface;
delete m_surface;
}
@@ -95,9 +97,11 @@ void Window::setGeometry(const QRect &rect)
m_resized = true;
}
}
+#if HAVE_WAYLAND_EGL
if (m_eglWaylandWindow) {
wl_egl_window_resize(m_eglWaylandWindow, geometry().width(), geometry().height(), 0, 0);
}
+#endif
}
void Window::unmap()
@@ -116,12 +120,14 @@ void Window::unmap()
void Window::createEglSurface(EGLDisplay dpy, EGLConfig config)
{
+#if HAVE_WAYLAND_EGL
const QSize size = window()->size();
m_eglWaylandWindow = wl_egl_window_create(*m_surface, size.width(), size.height());
if (!m_eglWaylandWindow) {
return;
}
m_eglSurface = eglCreateWindowSurface(dpy, config, m_eglWaylandWindow, nullptr);
+#endif
}
void Window::bindContentFBO()
diff --git a/plugins/qpa/window.h b/plugins/qpa/window.h
index 091b5bd1e1..dc02902880 100644
--- a/plugins/qpa/window.h
+++ b/plugins/qpa/window.h
@@ -24,7 +24,10 @@ along with this program. If not, see .
#include
#include
// wayland
+#include
+#if HAVE_WAYLAND_EGL
#include
+#endif
class QOpenGLFramebufferObject;
diff --git a/workspace.cpp b/workspace.cpp
index 71c5cd874b..078f79f7fd 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -1387,6 +1387,12 @@ QString Workspace::supportInformation() const
support.append(yes);
#else
support.append(no);
+#endif
+ support.append(QStringLiteral("HAVE_WAYLAND_EGL: "));
+#if HAVE_WAYLAND_EGL
+ support.append(yes);
+#else
+ support.append(no);
#endif
support.append(QStringLiteral("\n"));