diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f6c7857..b2aaba0 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v3 - name: Install dependencies - run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libfreeimage-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0 wayland-scanner++ wayland-protocols libwayland-dev libwayland-egl-backend-dev + run: sudo apt-get update && sudo apt-get -y install libfreeimage-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv1 libpulse-dev libpulse0 wayland-scanner++ wayland-protocols libwayland-dev libwayland-egl-backend-dev - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. diff --git a/CMakeLists.txt b/CMakeLists.txt index 0503e97..45b0032 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing") add_compile_definitions(ERRORONLY=${ERRORONLY}) add_compile_definitions(DATADIR="${DATADIR}") -find_package(X11 REQUIRED) -find_package(Xrandr REQUIRED) +find_package(X11) find_package(OpenGL REQUIRED) find_package(GLEW REQUIRED) find_package(GLUT REQUIRED) @@ -90,7 +89,6 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper) include_directories( ${MPV_INCLUDE_DIR} - ${X11_INCLUDE_DIR} ${XRANDR_INCLUDE_DIR} ${GLEW_INCLUDE_DIR} ${LZ4_INCLUDE_DIR} @@ -155,6 +153,28 @@ if(WAYLAND_SUPPORT_FOUND) "wlr-layer-shell-unstable-v1-protocol.c") endif() +if(X11_FOUND) + if(NOT X11_Xrandr_FOUND) + message(WARNING "X11 support disabled. Xrandr package is missing") + endif() + if(NOT X11_xf86vmode_FOUND) + message(WARNING "X11 support disabled. Xxf86vm package is missing") + endif() + + set(X11_SUPPORT_FOUND TRUE) +endif() + +if(X11_SUPPORT_FOUND) + include_directories(${X11_INCLUDE_DIR}) + add_compile_definitions(ENABLE_X11) + + set(X11_SOURCES + "src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp" + "src/WallpaperEngine/Render/Drivers/Output/CX11Output.h" + "src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp" + "src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h") +endif() + add_executable( linux-wallpaperengine main.cpp @@ -241,21 +261,17 @@ add_executable( src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp 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/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/CGLFWWindowOutput.cpp src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h + src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp + src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h src/WallpaperEngine/Render/Drivers/Output/COutputViewport.cpp src/WallpaperEngine/Render/Drivers/Output/COutputViewport.h - src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.cpp - src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.h - src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h - src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp + src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h + src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp src/WallpaperEngine/Render/Drivers/CVideoDriver.h src/WallpaperEngine/Render/Drivers/CVideoDriver.cpp src/WallpaperEngine/Render/CRenderContext.h @@ -295,8 +311,8 @@ add_executable( src/WallpaperEngine/Render/Objects/Effects/CMaterial.h src/WallpaperEngine/Render/Objects/Effects/CMaterial.cpp - src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.cpp - src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.h + src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp + src/WallpaperEngine/WebBrowser/CWebBrowserContext.h src/WallpaperEngine/FileSystem/FileSystem.cpp src/WallpaperEngine/FileSystem/FileSystem.h @@ -397,6 +413,7 @@ add_executable( src/WallpaperEngine/Core/Objects/Images/Materials/CPass.h ${WAYLAND_SOURCES} + ${X11_SOURCES} ) COPY_FILES(linux-wallpaperengine "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${TARGET_OUTPUT_DIRECTORY}") @@ -408,10 +425,7 @@ add_dependencies(linux-wallpaperengine libcef_dll_wrapper) # Need to remove libvulkan, otherwise will get error on linking: # /usr/bin/ld: /usr/lib/libmpv.so: undefined reference to `vkCreateXlibSurfaceKHR' file(REMOVE "${CEF_BINARY_DIR_DEBUG}/libvulkan.so.1" "${CEF_BINARY_DIR_RELEASE}/libvulkan.so.1") -target_link_libraries (linux-wallpaperengine PUBLIC - ${X11_LIBRARIES} - ${Xrandr_LIBRARIES} - ${X11_Xxf86vm_LIB} +target_link_libraries (linux-wallpaperengine PUBLIC ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} @@ -435,17 +449,23 @@ if (WAYLAND_SUPPORT_FOUND) ${OPENGL_egl_LIBRARY}) endif() -file(CREATE_LINK linux-wallpaperengine wallengine SYMBOLIC) +if(X11_SUPPORT_FOUND) + target_link_libraries (linux-wallpaperengine PUBLIC + ${X11_LIBRARIES} ${X11_Xrandr_LIB}) -set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES}) -# make sure some of the X11 functions we'll use are available -check_function_exists(XSetIOErrorExitHandler HAVE_XSETIOERROREXITHANDLER) + set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES}) -if(HAVE_XSETIOERROREXITHANDLER) - add_compile_definitions(HAVE_XSETIOERROREXITHANDLER=1) + # make sure some of the X11 functions we'll use are available + check_function_exists(XSetIOErrorExitHandler HAVE_XSETIOERROREXITHANDLER) + + if(HAVE_XSETIOERROREXITHANDLER) + add_compile_definitions(HAVE_XSETIOERROREXITHANDLER=1) + endif() endif() +file(CREATE_LINK linux-wallpaperengine wallengine SYMBOLIC) + # set some install parameters if not in debug mode install(TARGETS linux-wallpaperengine) install(DIRECTORY share/ DESTINATION share/${PROJECT_NAME}) diff --git a/main.cpp b/main.cpp index 7f79682..de7710f 100644 --- a/main.cpp +++ b/main.cpp @@ -4,7 +4,7 @@ #include "WallpaperEngine/Application/CApplicationContext.h" #include "WallpaperEngine/Application/CWallpaperApplication.h" #include "WallpaperEngine/Core/Wallpapers/CWeb.h" -#include "WallpaperEngine/WebBrowsesr/CWebBrowserContext.h" +#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" #include "common.h" WallpaperEngine::Application::CWallpaperApplication* appPointer; diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index b01d4dd..2488be3 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -13,6 +13,9 @@ #include "WallpaperEngine/Input/Drivers/CWaylandMouseInput.h" #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" +#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h" + +#define FULLSCREEN_CHECK_WAIT_TIME 250 float g_Time; float g_TimeLast; @@ -255,26 +258,67 @@ void CWallpaperApplication::takeScreenshot (const Render::CRenderContext& contex } void CWallpaperApplication::show () { + const char* XDG_SESSION_TYPE = getenv ("XDG_SESSION_TYPE"); + + if (!XDG_SESSION_TYPE) { + sLog.exception("Cannot read environment variable XDG_SESSION_TYPE, window server detection failed. Please ensure proper values are set"); + } + + #ifdef ENABLE_WAYLAND - const bool WAYLAND_DISPLAY = getenv ("WAYLAND_DISPLAY"); + bool isWayland = strncmp("wayland", XDG_SESSION_TYPE, strlen("wayland")) == 0; +#endif // ENABLE_WAYLAND +#ifdef ENABLE_X11 + bool isX11 = strncmp("x11", XDG_SESSION_TYPE, strlen("x11")) == 0; +#endif // ENABLE_X11 + + if (this->m_context.settings.render.mode == CApplicationContext::DESKTOP_BACKGROUND) { +#ifdef ENABLE_WAYLAND + if (isWayland) { + videoDriver = new WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver (this->m_context, *this); + inputContext = new WallpaperEngine::Input::CInputContext ( + new WallpaperEngine::Input::Drivers::CWaylandMouseInput (reinterpret_cast(videoDriver))); + this->fullScreenDetector = new WallpaperEngine::Render::Drivers::Detectors::CWaylandFullScreenDetector(this->m_context); + } +#endif // ENABLE_WAYLAND +#ifdef ENABLE_X11 +#ifdef ENABLE_WAYLAND + else +#endif // ENABLE_WAYLAND + if (isX11) + { + videoDriver = new WallpaperEngine::Render::Drivers::CGLFWOpenGLDriver ("wallpaperengine", this->m_context, *this); + inputContext = new WallpaperEngine::Input::CInputContext ( + new WallpaperEngine::Input::Drivers::CGLFWMouseInput (reinterpret_cast (videoDriver))); + this->fullScreenDetector = new WallpaperEngine::Render::Drivers::Detectors::CX11FullScreenDetector (this->m_context, *reinterpret_cast (videoDriver)); + } +#endif // ENABLE_X11 + else { + sLog.exception("Cannot run in background mode, window server could not be detected. XDG_SESSION_TYPE must be wayland or x11"); + } + } else { + videoDriver = new WallpaperEngine::Render::Drivers::CGLFWOpenGLDriver ("wallpaperengine", this->m_context, *this); + +#ifdef ENABLE_WAYLAND + if (isWayland) { + this->fullScreenDetector = new WallpaperEngine::Render::Drivers::Detectors::CWaylandFullScreenDetector(this->m_context); + } +#endif // ENABLE_WAYLAND +#ifdef ENABLE_X11 +#ifdef ENABLE_WAYLAND + else +#endif // ENABLE_WAYLAND + if(isX11) + { + this->fullScreenDetector = new WallpaperEngine::Render::Drivers::Detectors::CX11FullScreenDetector (this->m_context, *reinterpret_cast (videoDriver)); + } +#endif // ENABLE_X11 + else { + this->fullScreenDetector = new WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector (this->m_context); + } - // setup the right video driver based on the environment and the startup mode requested - if (WAYLAND_DISPLAY && this->m_context.settings.render.mode == CApplicationContext::DESKTOP_BACKGROUND) { - const auto waylandDriver = new WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver (this->m_context, *this); inputContext = new WallpaperEngine::Input::CInputContext ( - new WallpaperEngine::Input::Drivers::CWaylandMouseInput (waylandDriver)); - - videoDriver = waylandDriver; - } else -#endif - { - const auto x11Driver = - new WallpaperEngine::Render::Drivers::CX11OpenGLDriver ("wallpaperengine", this->m_context, *this); - // no wayland detected, try the old X11 method - inputContext = new WallpaperEngine::Input::CInputContext ( - new WallpaperEngine::Input::Drivers::CGLFWMouseInput (x11Driver)); - - videoDriver = x11Driver; + new WallpaperEngine::Input::Drivers::CGLFWMouseInput (reinterpret_cast (videoDriver))); } if (this->m_context.settings.audio.audioprocessing) { @@ -285,7 +329,7 @@ void CWallpaperApplication::show () { // audio playing detector WallpaperEngine::Audio::Drivers::Detectors::CPulseAudioPlayingDetector audioDetector ( - this->m_context, videoDriver->getFullscreenDetector ()); + this->m_context, *this->fullScreenDetector); // initialize sdl audio driver audioDriver = new WallpaperEngine::Audio::Drivers::CSDLAudioDriver (this->m_context, audioDetector, *this->audioRecorder); @@ -345,6 +389,10 @@ void CWallpaperApplication::show () { } void CWallpaperApplication::update (Render::Drivers::Output::COutputViewport* viewport) { + // check for fullscreen windows and wait until there's none fullscreen + while (this->fullScreenDetector->anythingFullscreen () && this->m_context.state.general.keepRunning) + usleep (FULLSCREEN_CHECK_WAIT_TIME); + // render the scene context->render (viewport); } diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.h b/src/WallpaperEngine/Application/CWallpaperApplication.h index 43a2b26..c0ba28f 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.h +++ b/src/WallpaperEngine/Application/CWallpaperApplication.h @@ -8,18 +8,23 @@ #include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/CWallpaper.h" -#include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" +#include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h" +#include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h" #ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" #endif +#ifdef ENABLE_X11 #include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h" +#endif #ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h" #endif #include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h" +#ifdef ENABLE_X11 #include "WallpaperEngine/Render/Drivers/Output/CX11Output.h" +#endif #ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h" #endif @@ -27,7 +32,7 @@ #include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h" #include "WallpaperEngine/Input/CInputContext.h" -#include "WallpaperEngine/WebBrowsesr/CWebBrowserContext.h" +#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" namespace WallpaperEngine::Application { /** @@ -117,12 +122,13 @@ class CWallpaperApplication { /** Maps screens to backgrounds */ std::map m_backgrounds; - WallpaperEngine::Audio::Drivers::Recorders::CPlaybackRecorder* audioRecorder; - WallpaperEngine::Render::Drivers::CVideoDriver* videoDriver; - WallpaperEngine::Input::CInputContext* inputContext; - WallpaperEngine::Audio::Drivers::CSDLAudioDriver* audioDriver; - WallpaperEngine::Render::CRenderContext* context; WallpaperEngine::Audio::CAudioContext* audioContext; + WallpaperEngine::Audio::Drivers::CSDLAudioDriver* audioDriver; + WallpaperEngine::Audio::Drivers::Recorders::CPlaybackRecorder* audioRecorder; + WallpaperEngine::Input::CInputContext* inputContext; + WallpaperEngine::Render::CRenderContext* context; + WallpaperEngine::Render::Drivers::CVideoDriver* videoDriver; + WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector* fullScreenDetector; WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext; }; } // namespace WallpaperEngine::Application diff --git a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp b/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp index 7ba1619..edc5856 100644 --- a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp +++ b/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp @@ -1,11 +1,11 @@ #include "CGLFWMouseInput.h" #include -#include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" +#include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h" using namespace WallpaperEngine::Input::Drivers; -CGLFWMouseInput::CGLFWMouseInput (Render::Drivers::CX11OpenGLDriver* driver) : +CGLFWMouseInput::CGLFWMouseInput (Render::Drivers::CGLFWOpenGLDriver* driver) : m_reportedPosition (), m_mousePosition (), m_driver (driver) {} diff --git a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h b/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h index 4e56525..e33b762 100644 --- a/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h +++ b/src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h @@ -5,7 +5,7 @@ #include namespace WallpaperEngine::Render::Drivers { -class CX11OpenGLDriver; +class CGLFWOpenGLDriver; } namespace WallpaperEngine::Input::Drivers { @@ -14,7 +14,7 @@ namespace WallpaperEngine::Input::Drivers { */ class CGLFWMouseInput final : public CMouseInput { public: - explicit CGLFWMouseInput (Render::Drivers::CX11OpenGLDriver* driver); + explicit CGLFWMouseInput (Render::Drivers::CGLFWOpenGLDriver* driver); /** * Takes current mouse position and updates it @@ -27,7 +27,7 @@ class CGLFWMouseInput final : public CMouseInput { [[nodiscard]] glm::dvec2 position () const override; private: - Render::Drivers::CX11OpenGLDriver* m_driver; + Render::Drivers::CGLFWOpenGLDriver* m_driver; /** * The current mouse position diff --git a/src/WallpaperEngine/Render/CWallpaper.h b/src/WallpaperEngine/Render/CWallpaper.h index bf52342..71aa484 100644 --- a/src/WallpaperEngine/Render/CWallpaper.h +++ b/src/WallpaperEngine/Render/CWallpaper.h @@ -14,7 +14,7 @@ #include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/Helpers/CContextAware.h" -#include "WallpaperEngine/WebBrowsesr/CWebBrowserContext.h" +#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h" #include "CWallpaperState.h" diff --git a/src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp similarity index 82% rename from src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp rename to src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp index adf3b5d..2732b98 100644 --- a/src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp @@ -1,4 +1,4 @@ -#include "CX11OpenGLDriver.h" +#include "CGLFWOpenGLDriver.h" #include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h" #include "common.h" #include @@ -14,9 +14,8 @@ void CustomGLFWErrorHandler (int errorCode, const char* reason) { sLog.error ("GLFW error ", errorCode, ": ", reason); } -CX11OpenGLDriver::CX11OpenGLDriver (const char* windowTitle, CApplicationContext& context, CWallpaperApplication& app) : +CGLFWOpenGLDriver::CGLFWOpenGLDriver (const char* windowTitle, CApplicationContext& context, CWallpaperApplication& app) : m_frameCounter (0), - m_fullscreenDetector (context, *this), m_context (context), CVideoDriver (app) { glfwSetErrorCallback (CustomGLFWErrorHandler); @@ -68,50 +67,53 @@ CX11OpenGLDriver::CX11OpenGLDriver (const char* windowTitle, CApplicationContext if (context.settings.render.mode == CApplicationContext::EXPLICIT_WINDOW || context.settings.render.mode == CApplicationContext::NORMAL_WINDOW) { m_output = new WallpaperEngine::Render::Drivers::Output::CGLFWWindowOutput (context, *this); - } else { + } +#ifdef ENABLE_X11 + else { m_output = new WallpaperEngine::Render::Drivers::Output::CX11Output (context, *this); } +#else + else { + sLog.exception("Trying to start GLFW in background mode without X11 support installed. Bailing out"); + } +#endif } -CX11OpenGLDriver::~CX11OpenGLDriver () { +CGLFWOpenGLDriver::~CGLFWOpenGLDriver () { glfwTerminate (); FreeImage_DeInitialise (); } -Detectors::CFullScreenDetector& CX11OpenGLDriver::getFullscreenDetector () { - return this->m_fullscreenDetector; -} - -Output::COutput& CX11OpenGLDriver::getOutput () { +Output::COutput& CGLFWOpenGLDriver::getOutput () { return *this->m_output; } -float CX11OpenGLDriver::getRenderTime () const { +float CGLFWOpenGLDriver::getRenderTime () const { return static_cast (glfwGetTime ()); } -bool CX11OpenGLDriver::closeRequested () { +bool CGLFWOpenGLDriver::closeRequested () { return glfwWindowShouldClose (this->m_window); } -void CX11OpenGLDriver::resizeWindow (glm::ivec2 size) { +void CGLFWOpenGLDriver::resizeWindow (glm::ivec2 size) { glfwSetWindowSize (this->m_window, size.x, size.y); } -void CX11OpenGLDriver::resizeWindow (glm::ivec4 sizeandpos) { +void CGLFWOpenGLDriver::resizeWindow (glm::ivec4 sizeandpos) { glfwSetWindowPos (this->m_window, sizeandpos.x, sizeandpos.y); glfwSetWindowSize (this->m_window, sizeandpos.z, sizeandpos.w); } -void CX11OpenGLDriver::showWindow () { +void CGLFWOpenGLDriver::showWindow () { glfwShowWindow (this->m_window); } -void CX11OpenGLDriver::hideWindow () { +void CGLFWOpenGLDriver::hideWindow () { glfwHideWindow (this->m_window); } -glm::ivec2 CX11OpenGLDriver::getFramebufferSize () const { +glm::ivec2 CGLFWOpenGLDriver::getFramebufferSize () const { glm::ivec2 size; glfwGetFramebufferSize (this->m_window, &size.x, &size.y); @@ -119,11 +121,11 @@ glm::ivec2 CX11OpenGLDriver::getFramebufferSize () const { return size; } -uint32_t CX11OpenGLDriver::getFrameCounter () const { +uint32_t CGLFWOpenGLDriver::getFrameCounter () const { return this->m_frameCounter; } -void CX11OpenGLDriver::dispatchEventQueue () { +void CGLFWOpenGLDriver::dispatchEventQueue () { static float startTime, endTime, minimumTime = 1.0f / this->m_context.settings.render.maximumFPS; // get the start time of the frame startTime = this->getRenderTime (); @@ -156,10 +158,10 @@ void CX11OpenGLDriver::dispatchEventQueue () { usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC); } -void* CX11OpenGLDriver::getProcAddress (const char* name) const { +void* CGLFWOpenGLDriver::getProcAddress (const char* name) const { return reinterpret_cast (glfwGetProcAddress (name)); } -GLFWwindow* CX11OpenGLDriver::getWindow () { +GLFWwindow* CGLFWOpenGLDriver::getWindow () { return this->m_window; } diff --git a/src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h b/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h similarity index 73% rename from src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h rename to src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h index 8c3784e..94e47e1 100644 --- a/src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h +++ b/src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h @@ -4,8 +4,6 @@ #include "WallpaperEngine/Application/CWallpaperApplication.h" #include "WallpaperEngine/Render/Drivers/CVideoDriver.h" #include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h" -#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h" -#include "WallpaperEngine/Render/Drivers/Output/CX11Output.h" #include #include @@ -17,12 +15,11 @@ class CWallpaperApplication; namespace WallpaperEngine::Render::Drivers { using namespace WallpaperEngine::Application; -class CX11OpenGLDriver final : public CVideoDriver { +class CGLFWOpenGLDriver final : public CVideoDriver { public: - explicit CX11OpenGLDriver (const char* windowTitle, CApplicationContext& context, CWallpaperApplication& app); - ~CX11OpenGLDriver () override; + explicit CGLFWOpenGLDriver (const char* windowTitle, CApplicationContext& context, CWallpaperApplication& app); + ~CGLFWOpenGLDriver () override; - [[nodiscard]] Detectors::CFullScreenDetector& getFullscreenDetector () override; [[nodiscard]] Output::COutput& getOutput () override; [[nodiscard]] float getRenderTime () const override; bool closeRequested () override; @@ -38,7 +35,6 @@ class CX11OpenGLDriver final : public CVideoDriver { GLFWwindow* getWindow (); private: - Detectors::CX11FullScreenDetector m_fullscreenDetector; CApplicationContext& m_context; Output::COutput* m_output; GLFWwindow* m_window; diff --git a/src/WallpaperEngine/Render/Drivers/CVideoDriver.h b/src/WallpaperEngine/Render/Drivers/CVideoDriver.h index 8ff388d..d945331 100644 --- a/src/WallpaperEngine/Render/Drivers/CVideoDriver.h +++ b/src/WallpaperEngine/Render/Drivers/CVideoDriver.h @@ -19,10 +19,6 @@ class CVideoDriver { explicit CVideoDriver (CWallpaperApplication& app); virtual ~CVideoDriver (); - /** - * @return The fullscreen detector this video driver uses - */ - [[nodiscard]] virtual Detectors::CFullScreenDetector& getFullscreenDetector () = 0; /** * @return The current output in use */ diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp index 9e800d0..b5715e9 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp @@ -214,7 +214,6 @@ void CWaylandOpenGLDriver::onLayerClose (Output::CWaylandOutputViewport* viewpor CWaylandOpenGLDriver::CWaylandOpenGLDriver (CApplicationContext& context, CWallpaperApplication& app) : m_frameCounter (0), - m_fullscreenDetector (context, *this), m_output (context, *this), m_requestedExit (false), m_context (context), @@ -305,10 +304,6 @@ void CWaylandOpenGLDriver::dispatchEventQueue () { usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC); } -Detectors::CFullScreenDetector& CWaylandOpenGLDriver::getFullscreenDetector () { - return this->m_fullscreenDetector; -} - Output::COutput& CWaylandOpenGLDriver::getOutput () { return this->m_output; } diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h index 1228d3b..06683f8 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h +++ b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h @@ -62,7 +62,6 @@ class CWaylandOpenGLDriver final : public CVideoDriver { explicit CWaylandOpenGLDriver (CApplicationContext& context, CWallpaperApplication& app); ~CWaylandOpenGLDriver (); - [[nodiscard]] Detectors::CFullScreenDetector& getFullscreenDetector () override; [[nodiscard]] Output::COutput& getOutput () override; float getRenderTime () const override; bool closeRequested () override; @@ -87,8 +86,6 @@ class CWaylandOpenGLDriver final : public CVideoDriver { std::vector m_screens; private: - /** Fullscreen detection used by this driver */ - Detectors::CWaylandFullScreenDetector m_fullscreenDetector; /** The output used by the driver */ Output::CWaylandOutput m_output; /** The EGL context in use */ diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp index ef5e5d8..3ac070f 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp +++ b/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp @@ -8,4 +8,10 @@ CFullScreenDetector::CFullScreenDetector (Application::CApplicationContext& appC Application::CApplicationContext& CFullScreenDetector::getApplicationContext () const { return this->m_applicationContext; -} \ No newline at end of file +} + +bool CFullScreenDetector::anythingFullscreen () const { + return false; +} + +void CFullScreenDetector::reset () {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h b/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h index ee0d6d7..0a89088 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h +++ b/src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h @@ -11,12 +11,11 @@ class CFullScreenDetector { /** * @return If anything is fullscreen */ - [[nodiscard]] virtual bool anythingFullscreen () const = 0; - + [[nodiscard]] virtual bool anythingFullscreen () const; /** * Restarts the fullscreen detector, specially useful if there's any resources tied to the output driver */ - virtual void reset () = 0; + virtual void reset (); /** * @return The application context using this detector */ diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp index 6390ba3..21b49ff 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp +++ b/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp @@ -2,8 +2,7 @@ using namespace WallpaperEngine::Render::Drivers::Detectors; -CWaylandFullScreenDetector::CWaylandFullScreenDetector (Application::CApplicationContext& appContext, - CWaylandOpenGLDriver& driver) : +CWaylandFullScreenDetector::CWaylandFullScreenDetector (Application::CApplicationContext& appContext) : CFullScreenDetector (appContext) {} bool CWaylandFullScreenDetector::anythingFullscreen () const { diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h b/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h index 2be1286..23e94ff 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h +++ b/src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h @@ -15,7 +15,7 @@ class CWaylandOpenGLDriver; namespace Detectors { class CWaylandFullScreenDetector final : public CFullScreenDetector { public: - CWaylandFullScreenDetector (Application::CApplicationContext& appContext, CWaylandOpenGLDriver& driver); + CWaylandFullScreenDetector (Application::CApplicationContext& appContext); ~CWaylandFullScreenDetector () override = default; [[nodiscard]] bool anythingFullscreen () const override; diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp b/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp index deadafa..9302d79 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp +++ b/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp @@ -4,7 +4,7 @@ #include #include -#include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" +#include "WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h" namespace WallpaperEngine::Render::Drivers::Detectors { void CustomXIOErrorExitHandler (Display* dsp, void* userdata) { @@ -29,7 +29,7 @@ int CustomXIOErrorHandler (Display* dsp) { } CX11FullScreenDetector::CX11FullScreenDetector (Application::CApplicationContext& appContext, - CX11OpenGLDriver& driver) : + CGLFWOpenGLDriver& driver) : CFullScreenDetector (appContext), m_driver (driver) { // do not use previous handler, it might stop the app under weird circumstances diff --git a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h b/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h index 34f1a8e..bd13965 100644 --- a/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h +++ b/src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h @@ -8,12 +8,12 @@ #include namespace WallpaperEngine::Render::Drivers { -class CX11OpenGLDriver; +class CGLFWOpenGLDriver; namespace Detectors { class CX11FullScreenDetector final : public CFullScreenDetector { public: - CX11FullScreenDetector (Application::CApplicationContext& appContext, CX11OpenGLDriver& driver); + CX11FullScreenDetector (Application::CApplicationContext& appContext, CGLFWOpenGLDriver& driver); ~CX11FullScreenDetector () override; [[nodiscard]] bool anythingFullscreen () const override; @@ -31,7 +31,7 @@ class CX11FullScreenDetector final : public CFullScreenDetector { Display* m_display; Window m_root; std::vector m_screens; - CX11OpenGLDriver& m_driver; + CGLFWOpenGLDriver& m_driver; }; } // namespace Detectors } // namespace WallpaperEngine::Render::Drivers \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp b/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp new file mode 100644 index 0000000..4d0ae3b --- /dev/null +++ b/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp @@ -0,0 +1,12 @@ +#include "CGLFWOutputViewport.h" + +#include + +using namespace WallpaperEngine::Render::Drivers::Output; + +CGLFWOutputViewport::CGLFWOutputViewport (glm::ivec4 viewport, std::string name) : + COutputViewport (viewport, std::move (name)) {} + +void CGLFWOutputViewport::makeCurrent () {} + +void CGLFWOutputViewport::swapOutput () {} \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.h b/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h similarity index 65% rename from src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.h rename to src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h index 2738d07..0eb60ac 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.h +++ b/src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h @@ -3,9 +3,9 @@ #include "COutputViewport.h" namespace WallpaperEngine::Render::Drivers::Output { -class CX11OutputViewport final : public COutputViewport { +class CGLFWOutputViewport final : public COutputViewport { public: - CX11OutputViewport (glm::ivec4 viewport, std::string name); + CGLFWOutputViewport (glm::ivec4 viewport, std::string name); void makeCurrent () override; void swapOutput () override; diff --git a/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp b/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp index fbf8e2f..e566564 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp +++ b/src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp @@ -1,13 +1,11 @@ #include "CGLFWWindowOutput.h" -#include "CX11OutputViewport.h" +#include "CGLFWOutputViewport.h" #include "WallpaperEngine/Logging/CLog.h" #include #include #include -#define FULLSCREEN_CHECK_WAIT_TIME 250 - using namespace WallpaperEngine::Render::Drivers::Output; CGLFWWindowOutput::CGLFWWindowOutput (CApplicationContext& context, CVideoDriver& driver) : COutput (context, driver) { @@ -29,7 +27,7 @@ CGLFWWindowOutput::CGLFWWindowOutput (CApplicationContext& context, CVideoDriver } // register the default viewport - this->m_viewports ["default"] = new CX11OutputViewport {{0, 0, this->m_fullWidth, this->m_fullHeight}, "default"}; + this->m_viewports ["default"] = new CGLFWOutputViewport {{0, 0, this->m_fullWidth, this->m_fullHeight}, "default"}; } void CGLFWWindowOutput::repositionWindow () { @@ -68,8 +66,4 @@ void CGLFWWindowOutput::updateRender () const { // update the default viewport this->m_viewports ["default"]->viewport = {0, 0, this->m_fullWidth, this->m_fullHeight}; - - // check for fullscreen windows and wait until there's none fullscreen - while (this->m_driver.getFullscreenDetector ().anythingFullscreen () && this->m_context.state.general.keepRunning) - usleep (FULLSCREEN_CHECK_WAIT_TIME); } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp b/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp index 784087e..74d7778 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp +++ b/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp @@ -1,5 +1,5 @@ #include "CX11Output.h" -#include "CX11OutputViewport.h" +#include "CGLFWOutputViewport.h" #include "common.h" #include @@ -7,8 +7,6 @@ #include #include -#define FULLSCREEN_CHECK_WAIT_TIME 250 - using namespace WallpaperEngine::Render::Drivers::Output; void CustomXIOErrorExitHandler (Display* dsp, void* userdata) { @@ -50,7 +48,8 @@ void CX11Output::reset () { // re-load screen info this->loadScreenInfo (); // do the same for the detector - this->m_driver.getFullscreenDetector ().reset (); + // TODO: BRING BACK THIS FUNCTIONALITY + // this->m_driver.getFullscreenDetector ().reset (); } void CX11Output::free () { @@ -125,7 +124,7 @@ void CX11Output::loadScreenInfo () { continue; // add the screen to the list of screens - this->m_screens.push_back (new CX11OutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}); + this->m_screens.push_back (new CGLFWOutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}); // only keep info of registered screens if (this->m_context.settings.general.screenBackgrounds.find (info->name) != @@ -134,7 +133,7 @@ void CX11Output::loadScreenInfo () { crtc->height); this->m_viewports [info->name] = - new CX11OutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}; + new CGLFWOutputViewport {{crtc->x, crtc->y, crtc->width, crtc->height}, info->name}; } XRRFreeCrtcInfo (crtc); @@ -189,8 +188,4 @@ void CX11Output::updateRender () const { XClearWindow (this->m_display, this->m_root); XFlush (this->m_display); - - // check for fullscreen windows and wait until there's none fullscreen - while (this->m_driver.getFullscreenDetector ().anythingFullscreen () && this->m_context.state.general.keepRunning) - usleep (FULLSCREEN_CHECK_WAIT_TIME); } diff --git a/src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.cpp b/src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.cpp deleted file mode 100644 index d9cfb4f..0000000 --- a/src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "CX11OutputViewport.h" - -#include - -using namespace WallpaperEngine::Render::Drivers::Output; - -CX11OutputViewport::CX11OutputViewport (glm::ivec4 viewport, std::string name) : - COutputViewport (viewport, std::move (name)) {} - -void CX11OutputViewport::makeCurrent () {} - -void CX11OutputViewport::swapOutput () {} \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.cpp b/src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp similarity index 100% rename from src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.cpp rename to src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp diff --git a/src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.h b/src/WallpaperEngine/WebBrowser/CWebBrowserContext.h similarity index 100% rename from src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.h rename to src/WallpaperEngine/WebBrowser/CWebBrowserContext.h