diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f289f..ae3fdfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,15 @@ include_directories( ${CMAKE_SOURCE_DIR} include) +if (ENABLE_WAYLAND) + message(STATUS "Wayland support is enabled!") + add_compile_definitions(ENABLE_WAYLAND) + set(WAYLAND_SOURCES "src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" "src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp" "src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp" + "src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h" "src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.cpp" "src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h") +else() + set(WAYLAND_SOURCES "") +endif() + add_executable( linux-wallpaperengine main.cpp @@ -130,21 +139,15 @@ add_executable( src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h - src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp - src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h src/WallpaperEngine/Render/Drivers/Output/COutput.cpp src/WallpaperEngine/Render/Drivers/Output/COutput.h src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp src/WallpaperEngine/Render/Drivers/Output/CX11Output.h - src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.cpp - src/WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp - src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h - src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp src/WallpaperEngine/Render/Drivers/CVideoDriver.h src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp src/WallpaperEngine/Render/CRenderContext.h @@ -275,6 +278,8 @@ add_executable( src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h + + ${WAYLAND_SOURCES} ) target_link_libraries(linux-wallpaperengine @@ -291,15 +296,18 @@ target_link_libraries(linux-wallpaperengine ${FREEIMAGE_LIBRARIES} ${MPV_LIBRARY} ${PULSEAUDIO_LIBRARY} - ${CMAKE_SOURCE_DIR}/wlr-layer-shell-unstable-v1.o - ${CMAKE_SOURCE_DIR}/xdg-shell-protocol.o - glfw - GLESv2 - pthread - wayland-cursor - /usr/lib/libEGL.so.1 - wayland-client - wayland-egl) + glfw) + +if (ENABLE_WAYLAND) + target_link_libraries(linux-wallpaperengine ${CMAKE_SOURCE_DIR}/wlr-layer-shell-unstable-v1.o + ${CMAKE_SOURCE_DIR}/xdg-shell-protocol.o + GLESv2 + pthread + wayland-cursor + /usr/lib/libEGL.so.1 + wayland-client + wayland-egl) +endif() file(CREATE_LINK linux-wallpaperengine wallengine SYMBOLIC) diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index 84fd23b..88175c4 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -263,18 +263,22 @@ namespace WallpaperEngine::Application void CWallpaperApplication::show () { // initialize OpenGL driver +#ifdef ENABLE_WAYLAND const bool WAYLAND = getenv("WAYLAND_DISPLAY") && this->m_context.settings.render.mode == CApplicationContext::WAYLAND_LAYER_SHELL; if (WAYLAND) { videoDriver = std::make_unique("wallpaperengine", this->m_context, this); inputContext = std::make_unique(*(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get()); } else { +#endif videoDriver = std::make_unique("wallpaperengine", this->m_context); inputContext = std::make_unique(*(WallpaperEngine::Render::Drivers::CX11OpenGLDriver*)videoDriver.get()); +#ifdef ENABLE_WAYLAND } if (WAYLAND) fullscreenDetector = std::make_unique(this->m_context, *(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get()); else +#endif fullscreenDetector = std::make_unique(this->m_context, *videoDriver); // stereo mix recorder for audio processing WallpaperEngine::Audio::Drivers::Recorders::CPulseAudioPlaybackRecorder audioRecorder; @@ -296,10 +300,11 @@ namespace WallpaperEngine::Application case CApplicationContext::X11_BACKGROUND: output = new WallpaperEngine::Render::Drivers::Output::CX11Output (this->m_context, *videoDriver, *fullscreenDetector); break; - +#ifdef ENABLE_WAYLAND case CApplicationContext::WAYLAND_LAYER_SHELL: output = new WallpaperEngine::Render::Drivers::Output::CWaylandOutput (this->m_context, *videoDriver, *fullscreenDetector); break; +#endif } // initialize render context @@ -318,6 +323,7 @@ namespace WallpaperEngine::Application this->m_defaultBackground->getWallpaper (), *context, *audioContext )); +#ifdef ENABLE_WAYLAND if (WAYLAND) { renderFrame(); @@ -325,10 +331,13 @@ namespace WallpaperEngine::Application videoDriver->dispatchEventQueue(); } } else { +#endif while (!videoDriver->closeRequested () && this->m_context.state.general.keepRunning) { renderFrame(); } +#ifdef ENABLE_WAYLAND } +#endif // ensure this is updated as sometimes it might not come from a signal this->m_context.state.general.keepRunning = false; diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.h b/src/WallpaperEngine/Application/CWallpaperApplication.h index 3abd1a9..454cab0 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.h +++ b/src/WallpaperEngine/Application/CWallpaperApplication.h @@ -9,14 +9,20 @@ #include "WallpaperEngine/Render/CWallpaper.h" #include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" +#ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" +#endif #include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h" +#ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h" +#endif #include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h" #include "WallpaperEngine/Render/Drivers/Output/CX11Output.h" +#ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h" +#endif #include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h" diff --git a/src/WallpaperEngine/Input/CInputContext.cpp b/src/WallpaperEngine/Input/CInputContext.cpp index 49a2437..f0b2126 100644 --- a/src/WallpaperEngine/Input/CInputContext.cpp +++ b/src/WallpaperEngine/Input/CInputContext.cpp @@ -10,11 +10,13 @@ CInputContext::CInputContext (CX11OpenGLDriver& videoDriver) : { } +#ifdef ENABLE_WAYLAND CInputContext::CInputContext (CWaylandOpenGLDriver& videoDriver) : m_mouse (nullptr) { // todo } +#endif void CInputContext::update () { diff --git a/src/WallpaperEngine/Input/CInputContext.h b/src/WallpaperEngine/Input/CInputContext.h index 6bf3834..4a74e03 100644 --- a/src/WallpaperEngine/Input/CInputContext.h +++ b/src/WallpaperEngine/Input/CInputContext.h @@ -1,7 +1,9 @@ #pragma once #include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" +#ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" +#endif #include "CMouseInput.h" namespace WallpaperEngine::Render::Drivers @@ -15,7 +17,9 @@ namespace WallpaperEngine::Input { public: explicit CInputContext (Render::Drivers::CX11OpenGLDriver& videoDriver); + #ifdef ENABLE_WAYLAND explicit CInputContext (Render::Drivers::CWaylandOpenGLDriver& videoDriver); + #endif void update (); [[nodiscard]] const CMouseInput& getMouseInput () const;