make wayland impl optional

This commit is contained in:
vaxerski 2023-04-20 13:52:25 +01:00
parent 43409229a9
commit ffeec7f1dd
5 changed files with 45 additions and 16 deletions

View File

@ -44,6 +44,15 @@ include_directories(
${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}
include) 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( add_executable(
linux-wallpaperengine linux-wallpaperengine
main.cpp main.cpp
@ -130,21 +139,15 @@ add_executable(
src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h
src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp
src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h 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.cpp
src/WallpaperEngine/Render/Drivers/Output/COutput.h src/WallpaperEngine/Render/Drivers/Output/COutput.h
src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp
src/WallpaperEngine/Render/Drivers/Output/CX11Output.h 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.cpp
src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h
src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h
src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp 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.h
src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp
src/WallpaperEngine/Render/CRenderContext.h 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.cpp
src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h
${WAYLAND_SOURCES}
) )
target_link_libraries(linux-wallpaperengine target_link_libraries(linux-wallpaperengine
@ -291,15 +296,18 @@ target_link_libraries(linux-wallpaperengine
${FREEIMAGE_LIBRARIES} ${FREEIMAGE_LIBRARIES}
${MPV_LIBRARY} ${MPV_LIBRARY}
${PULSEAUDIO_LIBRARY} ${PULSEAUDIO_LIBRARY}
${CMAKE_SOURCE_DIR}/wlr-layer-shell-unstable-v1.o glfw)
${CMAKE_SOURCE_DIR}/xdg-shell-protocol.o
glfw if (ENABLE_WAYLAND)
GLESv2 target_link_libraries(linux-wallpaperengine ${CMAKE_SOURCE_DIR}/wlr-layer-shell-unstable-v1.o
pthread ${CMAKE_SOURCE_DIR}/xdg-shell-protocol.o
wayland-cursor GLESv2
/usr/lib/libEGL.so.1 pthread
wayland-client wayland-cursor
wayland-egl) /usr/lib/libEGL.so.1
wayland-client
wayland-egl)
endif()
file(CREATE_LINK linux-wallpaperengine wallengine SYMBOLIC) file(CREATE_LINK linux-wallpaperengine wallengine SYMBOLIC)

View File

@ -263,18 +263,22 @@ namespace WallpaperEngine::Application
void CWallpaperApplication::show () void CWallpaperApplication::show ()
{ {
// initialize OpenGL driver // initialize OpenGL driver
#ifdef ENABLE_WAYLAND
const bool WAYLAND = getenv("WAYLAND_DISPLAY") && this->m_context.settings.render.mode == CApplicationContext::WAYLAND_LAYER_SHELL; const bool WAYLAND = getenv("WAYLAND_DISPLAY") && this->m_context.settings.render.mode == CApplicationContext::WAYLAND_LAYER_SHELL;
if (WAYLAND) { if (WAYLAND) {
videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver>("wallpaperengine", this->m_context, this); videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver>("wallpaperengine", this->m_context, this);
inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get()); inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get());
} else { } else {
#endif
videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CX11OpenGLDriver>("wallpaperengine", this->m_context); videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CX11OpenGLDriver>("wallpaperengine", this->m_context);
inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CX11OpenGLDriver*)videoDriver.get()); inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CX11OpenGLDriver*)videoDriver.get());
#ifdef ENABLE_WAYLAND
} }
if (WAYLAND) if (WAYLAND)
fullscreenDetector = std::make_unique<WallpaperEngine::Render::Drivers::Detectors::CWaylandFullScreenDetector>(this->m_context, *(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get()); fullscreenDetector = std::make_unique<WallpaperEngine::Render::Drivers::Detectors::CWaylandFullScreenDetector>(this->m_context, *(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get());
else else
#endif
fullscreenDetector = std::make_unique<WallpaperEngine::Render::Drivers::Detectors::CX11FullScreenDetector>(this->m_context, *videoDriver); fullscreenDetector = std::make_unique<WallpaperEngine::Render::Drivers::Detectors::CX11FullScreenDetector>(this->m_context, *videoDriver);
// stereo mix recorder for audio processing // stereo mix recorder for audio processing
WallpaperEngine::Audio::Drivers::Recorders::CPulseAudioPlaybackRecorder audioRecorder; WallpaperEngine::Audio::Drivers::Recorders::CPulseAudioPlaybackRecorder audioRecorder;
@ -296,10 +300,11 @@ namespace WallpaperEngine::Application
case CApplicationContext::X11_BACKGROUND: case CApplicationContext::X11_BACKGROUND:
output = new WallpaperEngine::Render::Drivers::Output::CX11Output (this->m_context, *videoDriver, *fullscreenDetector); output = new WallpaperEngine::Render::Drivers::Output::CX11Output (this->m_context, *videoDriver, *fullscreenDetector);
break; break;
#ifdef ENABLE_WAYLAND
case CApplicationContext::WAYLAND_LAYER_SHELL: case CApplicationContext::WAYLAND_LAYER_SHELL:
output = new WallpaperEngine::Render::Drivers::Output::CWaylandOutput (this->m_context, *videoDriver, *fullscreenDetector); output = new WallpaperEngine::Render::Drivers::Output::CWaylandOutput (this->m_context, *videoDriver, *fullscreenDetector);
break; break;
#endif
} }
// initialize render context // initialize render context
@ -318,6 +323,7 @@ namespace WallpaperEngine::Application
this->m_defaultBackground->getWallpaper (), *context, *audioContext this->m_defaultBackground->getWallpaper (), *context, *audioContext
)); ));
#ifdef ENABLE_WAYLAND
if (WAYLAND) { if (WAYLAND) {
renderFrame(); renderFrame();
@ -325,10 +331,13 @@ namespace WallpaperEngine::Application
videoDriver->dispatchEventQueue(); videoDriver->dispatchEventQueue();
} }
} else { } else {
#endif
while (!videoDriver->closeRequested () && this->m_context.state.general.keepRunning) { while (!videoDriver->closeRequested () && this->m_context.state.general.keepRunning) {
renderFrame(); renderFrame();
} }
#ifdef ENABLE_WAYLAND
} }
#endif
// ensure this is updated as sometimes it might not come from a signal // ensure this is updated as sometimes it might not come from a signal
this->m_context.state.general.keepRunning = false; this->m_context.state.general.keepRunning = false;

View File

@ -9,14 +9,20 @@
#include "WallpaperEngine/Render/CWallpaper.h" #include "WallpaperEngine/Render/CWallpaper.h"
#include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/CRenderContext.h"
#include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" #include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h"
#endif
#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h" #include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h" #include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h"
#endif
#include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h" #include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h"
#include "WallpaperEngine/Render/Drivers/Output/CX11Output.h" #include "WallpaperEngine/Render/Drivers/Output/CX11Output.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h" #include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h"
#endif
#include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h" #include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h"

View File

@ -10,11 +10,13 @@ CInputContext::CInputContext (CX11OpenGLDriver& videoDriver) :
{ {
} }
#ifdef ENABLE_WAYLAND
CInputContext::CInputContext (CWaylandOpenGLDriver& videoDriver) : CInputContext::CInputContext (CWaylandOpenGLDriver& videoDriver) :
m_mouse (nullptr) m_mouse (nullptr)
{ {
// todo // todo
} }
#endif
void CInputContext::update () void CInputContext::update ()
{ {

View File

@ -1,7 +1,9 @@
#pragma once #pragma once
#include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" #include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h"
#ifdef ENABLE_WAYLAND
#include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h"
#endif
#include "CMouseInput.h" #include "CMouseInput.h"
namespace WallpaperEngine::Render::Drivers namespace WallpaperEngine::Render::Drivers
@ -15,7 +17,9 @@ namespace WallpaperEngine::Input
{ {
public: public:
explicit CInputContext (Render::Drivers::CX11OpenGLDriver& videoDriver); explicit CInputContext (Render::Drivers::CX11OpenGLDriver& videoDriver);
#ifdef ENABLE_WAYLAND
explicit CInputContext (Render::Drivers::CWaylandOpenGLDriver& videoDriver); explicit CInputContext (Render::Drivers::CWaylandOpenGLDriver& videoDriver);
#endif
void update (); void update ();
[[nodiscard]] const CMouseInput& getMouseInput () const; [[nodiscard]] const CMouseInput& getMouseInput () const;