Преглед на файлове

feat: conditionally enable wayland and x11 support

Almamu преди 2 години
родител
ревизия
953ef01749
променени са 26 файла, в които са добавени 191 реда и са изтрити 138 реда
  1. 1 1
      .github/workflows/cmake.yml
  2. 43 23
      CMakeLists.txt
  3. 1 1
      main.cpp
  4. 66 18
      src/WallpaperEngine/Application/CWallpaperApplication.cpp
  5. 11 5
      src/WallpaperEngine/Application/CWallpaperApplication.h
  6. 2 2
      src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp
  7. 3 3
      src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h
  8. 1 1
      src/WallpaperEngine/Render/CWallpaper.h
  9. 23 21
      src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.cpp
  10. 3 7
      src/WallpaperEngine/Render/Drivers/CGLFWOpenGLDriver.h
  11. 0 4
      src/WallpaperEngine/Render/Drivers/CVideoDriver.h
  12. 0 5
      src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp
  13. 0 3
      src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h
  14. 7 1
      src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.cpp
  15. 2 3
      src/WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h
  16. 1 2
      src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.cpp
  17. 1 1
      src/WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h
  18. 2 2
      src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp
  19. 3 3
      src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h
  20. 12 0
      src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp
  21. 2 2
      src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.h
  22. 2 8
      src/WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.cpp
  23. 5 10
      src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp
  24. 0 12
      src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.cpp
  25. 0 0
      src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp
  26. 0 0
      src/WallpaperEngine/WebBrowser/CWebBrowserContext.h

+ 1 - 1
.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.

+ 43 - 23
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})
+    set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES})
 
-# make sure some of the X11 functions we'll use are available
-check_function_exists(XSetIOErrorExitHandler HAVE_XSETIOERROREXITHANDLER)
+    # 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)
+    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})

+ 1 - 1
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;

+ 66 - 18
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
 
-    // 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));
+    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<WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*>(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 <Render::Drivers::CGLFWOpenGLDriver*>(videoDriver)));
+            this->fullScreenDetector = new WallpaperEngine::Render::Drivers::Detectors::CX11FullScreenDetector (this->m_context, *reinterpret_cast <Render::Drivers::CGLFWOpenGLDriver*>(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 <Render::Drivers::CGLFWOpenGLDriver*>(videoDriver));
+        }
+#endif // ENABLE_X11
+        else {
+            this->fullScreenDetector = new WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector (this->m_context);
+        }
 
-        videoDriver = x11Driver;
+        inputContext = new WallpaperEngine::Input::CInputContext (
+            new WallpaperEngine::Input::Drivers::CGLFWMouseInput (reinterpret_cast <Render::Drivers::CGLFWOpenGLDriver*>(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);
 }

+ 11 - 5
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<std::string, Core::CProject*> m_backgrounds;
 
+    WallpaperEngine::Audio::CAudioContext* audioContext;
+    WallpaperEngine::Audio::Drivers::CSDLAudioDriver* audioDriver;
     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::Render::Drivers::CVideoDriver* videoDriver;
+    WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector* fullScreenDetector;
     WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext;
 };
 } // namespace WallpaperEngine::Application

+ 2 - 2
src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.cpp

@@ -1,11 +1,11 @@
 #include "CGLFWMouseInput.h"
 #include <glm/common.hpp>
 
-#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) {}

+ 3 - 3
src/WallpaperEngine/Input/Drivers/CGLFWMouseInput.h

@@ -5,7 +5,7 @@
 #include <glm/vec2.hpp>
 
 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

+ 1 - 1
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"
 

+ 23 - 21
src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp → 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 <FreeImage.h>
@@ -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<float> (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<void*> (glfwGetProcAddress (name));
 }
 
-GLFWwindow* CX11OpenGLDriver::getWindow () {
+GLFWwindow* CGLFWOpenGLDriver::getWindow () {
     return this->m_window;
 }

+ 3 - 7
src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h → 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 <GL/glew.h>
 #include <GLFW/glfw3.h>
 
@@ -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;

+ 0 - 4
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
      */

+ 0 - 5
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;
 }

+ 0 - 3
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<Output::CWaylandOutputViewport*> 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 */

+ 7 - 1
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;
-}
+}
+
+bool CFullScreenDetector::anythingFullscreen () const {
+    return false;
+}
+
+void CFullScreenDetector::reset () {}

+ 2 - 3
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
      */

+ 1 - 2
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 {

+ 1 - 1
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;

+ 2 - 2
src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.cpp

@@ -4,7 +4,7 @@
 #include <X11/Xlib.h>
 #include <X11/extensions/Xrandr.h>
 
-#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

+ 3 - 3
src/WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h

@@ -8,12 +8,12 @@
 #include <X11/Xlib.h>
 
 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<ScreenInfo> m_screens;
-    CX11OpenGLDriver& m_driver;
+    CGLFWOpenGLDriver& m_driver;
 };
 } // namespace Detectors
 } // namespace WallpaperEngine::Render::Drivers

+ 12 - 0
src/WallpaperEngine/Render/Drivers/Output/CGLFWOutputViewport.cpp

@@ -0,0 +1,12 @@
+#include "CGLFWOutputViewport.h"
+
+#include <utility>
+
+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 () {}

+ 2 - 2
src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.h → 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;

+ 2 - 8
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 <GL/glew.h>
 #include <GLFW/glfw3.h>
 
 #include <unistd.h>
 
-#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);
 }

+ 5 - 10
src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp

@@ -1,5 +1,5 @@
 #include "CX11Output.h"
-#include "CX11OutputViewport.h"
+#include "CGLFWOutputViewport.h"
 #include "common.h"
 
 #include <X11/Xatom.h>
@@ -7,8 +7,6 @@
 #include <X11/extensions/Xrandr.h>
 #include <unistd.h>
 
-#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);
 }

+ 0 - 12
src/WallpaperEngine/Render/Drivers/Output/CX11OutputViewport.cpp

@@ -1,12 +0,0 @@
-#include "CX11OutputViewport.h"
-
-#include <utility>
-
-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 () {}

+ 0 - 0
src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.cpp → src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp


+ 0 - 0
src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.h → src/WallpaperEngine/WebBrowser/CWebBrowserContext.h