Browse Source

Added some window hints

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez 3 năm trước cách đây
mục cha
commit
93380ae229

+ 3 - 3
src/WallpaperEngine/Application/CApplicationContext.cpp

@@ -135,11 +135,11 @@ CApplicationContext::CApplicationContext (int argc, char* argv[])
 
                 if (pos != nullptr)
                     this->settings.render.window.geometry.x = atoi (pos);
-                if ((pos = strchr (pos, '.')) != nullptr)
+                if ((pos = strchr (pos, 'x')) != nullptr)
                     this->settings.render.window.geometry.y = atoi (pos + 1);
-                if ((pos = strchr (pos + 1, '.')) != nullptr)
+                if ((pos = strchr (pos + 1, 'x')) != nullptr)
                     this->settings.render.window.geometry.z = atoi (pos + 1);
-                if ((pos = strchr (pos + 1, '.')) != nullptr)
+                if ((pos = strchr (pos + 1, 'x')) != nullptr)
                     this->settings.render.window.geometry.w = atoi (pos + 1);
             }
             break;

+ 1 - 1
src/WallpaperEngine/Application/CWallpaperApplication.cpp

@@ -267,7 +267,7 @@ namespace WallpaperEngine::Application
     void CWallpaperApplication::show ()
     {
         // initialize OpenGL driver
-        WallpaperEngine::Render::Drivers::CX11OpenGLDriver videoDriver ("wallpaperengine");
+        WallpaperEngine::Render::Drivers::CX11OpenGLDriver videoDriver ("wallpaperengine", this->m_context);
         // initialize the input subsystem
         WallpaperEngine::Input::CInputContext inputContext (videoDriver);
         // output requested

+ 12 - 1
src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.cpp

@@ -12,7 +12,7 @@ void CustomGLFWErrorHandler (int errorCode, const char* reason)
     sLog.error ("GLFW error ", errorCode, ": ", reason);
 }
 
-CX11OpenGLDriver::CX11OpenGLDriver (const char* windowTitle) :
+CX11OpenGLDriver::CX11OpenGLDriver (const char* windowTitle, CApplicationContext& context) :
     m_frameCounter (0)
 {
     glfwSetErrorCallback (CustomGLFWErrorHandler);
@@ -27,6 +27,17 @@ CX11OpenGLDriver::CX11OpenGLDriver (const char* windowTitle) :
     glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
     glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
     glfwWindowHint (GLFW_VISIBLE, GLFW_FALSE);
+    // set X11-specific hints
+    glfwWindowHintString (GLFW_X11_CLASS_NAME, "linux-wallpaperengine");
+    glfwWindowHintString (GLFW_X11_INSTANCE_NAME, "linux-wallpaperengine");
+
+    // for forced window mode, we can set some hints that'll help position the window
+    if (context.settings.render.mode == Application::CApplicationContext::EXPLICIT_WINDOW)
+    {
+        glfwWindowHint (GLFW_RESIZABLE, GLFW_FALSE);
+        glfwWindowHint (GLFW_DECORATED, GLFW_FALSE);
+        glfwWindowHint (GLFW_FLOATING, GLFW_TRUE);
+    }
 
 #if !NDEBUG
     glfwWindowHint (GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);

+ 1 - 1
src/WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h

@@ -17,7 +17,7 @@ namespace WallpaperEngine::Render::Drivers
     class CX11OpenGLDriver : public CVideoDriver
     {
     public:
-        explicit CX11OpenGLDriver (const char* windowTitle);
+        explicit CX11OpenGLDriver (const char* windowTitle, CApplicationContext& context);
         ~CX11OpenGLDriver();
 
         void* getWindowHandle () const;