فهرست منبع

~ Fix background setup not working properly after the implementation of mouse support

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez 4 سال پیش
والد
کامیت
18ab051d47
3فایلهای تغییر یافته به همراه15 افزوده شده و 8 حذف شده
  1. 6 4
      main.cpp
  2. 7 3
      src/WallpaperEngine/Render/CContext.cpp
  3. 2 1
      src/WallpaperEngine/Render/CContext.h

+ 6 - 4
main.cpp

@@ -179,6 +179,8 @@ int main (int argc, char* argv[])
     // parse the project.json file
     auto project = WallpaperEngine::Core::CProject::fromFile ("project.json", containers);
     WallpaperEngine::Render::CWallpaper* wallpaper;
+    // initialize custom context class
+    WallpaperEngine::Render::CContext* context = new WallpaperEngine::Render::CContext (screens);
 
     // auto projection = project->getWallpaper ()->as <WallpaperEngine::Core::CScene> ()->getOrthogonalProjection ();
     // create the window!
@@ -193,12 +195,12 @@ int main (int argc, char* argv[])
         return 2;
     }
 
-    glfwMakeContextCurrent (window);
-
     // initialize inputs
     CMouseInput* mouseInput = new CMouseInput (window);
-    // initialize custom context class
-    WallpaperEngine::Render::CContext* context = new WallpaperEngine::Render::CContext (screens, mouseInput);
+
+    context->setMouse (mouseInput);
+
+    glfwMakeContextCurrent (window);
 
     // TODO: FIGURE THESE OUT BASED ON THE SCREEN
     int windowWidth = 1920;

+ 7 - 3
src/WallpaperEngine/Render/CContext.cpp

@@ -10,12 +10,11 @@
 
 using namespace WallpaperEngine::Render;
 
-CContext::CContext (std::vector <std::string> screens, CMouseInput* mouse) :
+CContext::CContext (std::vector <std::string> screens) :
     m_wallpaper (nullptr),
     m_screens (std::move (screens)),
     m_isRootWindow (m_screens.empty () == false),
-    m_defaultViewport ({0, 0, 1920, 1080}),
-    m_mouse (mouse)
+    m_defaultViewport ({0, 0, 1920, 1080})
 {
     this->initializeViewports ();
 }
@@ -117,4 +116,9 @@ void CContext::setDefaultViewport (glm::vec4 defaultViewport)
 CMouseInput* CContext::getMouse () const
 {
     return this->m_mouse;
+}
+
+void CContext::setMouse (CMouseInput* mouse)
+{
+    this->m_mouse = mouse;
 }

+ 2 - 1
src/WallpaperEngine/Render/CContext.h

@@ -15,13 +15,14 @@ namespace WallpaperEngine::Render
     class CContext
     {
     public:
-        CContext (std::vector <std::string> screens, CMouseInput* mouse);
+        CContext (std::vector <std::string> screens);
 
         void initializeViewports ();
         void render ();
         void setWallpaper (CWallpaper* wallpaper);
         void setDefaultViewport (glm::vec4 defaultViewport);
         CMouseInput* getMouse () const;
+        void setMouse (CMouseInput* mouse);
     private:
         std::vector <std::string> m_screens;
         std::vector <glm::vec4> m_viewports;