Explorar el Código

chore: linting

Almamu hace 2 años
padre
commit
02fd7effbb

+ 2 - 1
src/WallpaperEngine/Application/CApplicationContext.cpp

@@ -307,7 +307,8 @@ void CApplicationContext::printHelp (const char* route) {
     sLog.out ("\t--set-property <name=value>\tOverrides the default value of the given property");
     sLog.out ("\t--no-fullscreen-pause\tPrevents the background pausing when an app is fullscreen");
     sLog.out ("\t--disable-mouse\tDisables mouse interactions");
-    sLog.out ("\t--bg <background_path/background_id>\tAfter --screen-root uses the specified background only on that screen");
+    sLog.out (
+        "\t--bg <background_path/background_id>\tAfter --screen-root uses the specified background only on that screen");
     sLog.out (
         "\t--scaling <mode>\t Scaling mode for wallpaper. Can be stretch, fit, fill, default. Must be used before wallpaper provided.\n\
                     \t\t For default wallpaper last specified value will be used.\n\

+ 4 - 5
src/WallpaperEngine/Core/CProject.cpp

@@ -20,7 +20,7 @@ CProject* CProject::fromFile (const std::string& filename, CContainer* container
     json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container));
 
     std::string dependency = jsonFindDefault<std::string> (content, "dependency", "No dependency");
-    if(dependency=="No dependency"){
+    if (dependency == "No dependency") {
         std::string title = *jsonFindRequired (content, "title", "Project title missing");
         std::string type = *jsonFindRequired (content, "type", "Project type missing");
         std::string file = *jsonFindRequired (content, "file", "Project's main file missing");
@@ -45,7 +45,7 @@ CProject* CProject::fromFile (const std::string& filename, CContainer* container
         if (general != content.end ()) {
             const auto properties = general->find ("properties");
 
-            if (properties != general-> end ()) {
+            if (properties != general->end ()) {
                 for (const auto& cur : properties->items ()) {
                     Projects::CProperty* property = Projects::CProperty::fromJSON (cur.value (), cur.key ());
                     if (property != nullptr)
@@ -54,9 +54,8 @@ CProject* CProject::fromFile (const std::string& filename, CContainer* container
             }
         }
         return project;
-    }
-    else{
-        sLog.exception("Project have dependency. They are not supported, quiting");
+    } else {
+        sLog.exception ("Project have dependency. They are not supported, quiting");
     }
 }
 

+ 21 - 30
src/WallpaperEngine/Core/CWeb.cpp

@@ -1,10 +1,9 @@
 #include "CWeb.h"
 
-#include <utility>
 #include "common.h"
+#include <utility>
 
-static void CEFsetUp(int argc, char** argv)
-{
+static void CEFsetUp (int argc, char** argv) {
     // This function should be called from the application entry point function to
     // execute a secondary process. It can be used to run secondary processes from
     // the browser client executable (default behavior) or from a separate
@@ -15,56 +14,48 @@ static void CEFsetUp(int argc, char** argv)
     // the process exit code. The |application| parameter may be empty. The
     // |windows_sandbox_info| parameter is only used on Windows and may be NULL (see
     // cef_sandbox_win.h for details).
-    CefMainArgs args(argc,argv);
-    int exit_code = CefExecuteProcess(args, nullptr, nullptr);
-    if (exit_code >= 0)
-    {
-        sLog.debug("CEF sub proccess has endend");
+    CefMainArgs args (argc, argv);
+    int exit_code = CefExecuteProcess (args, nullptr, nullptr);
+    if (exit_code >= 0) {
+        sLog.debug ("CEF sub proccess has endend");
         // Sub proccess has endend, so exit
-        exit(exit_code);
-    }
-    else if (exit_code == -1)
-    {
+        exit (exit_code);
+    } else if (exit_code == -1) {
         // If called for the browser process (identified by no "type" command-line value)
         // it will return immediately with a value of -1
     }
 
     // Configurate Chromium
     CefSettings settings;
-    //CefString(&settings.locales_dir_path) = "OffScreenCEF/godot/locales";
-    //CefString(&settings.resources_dir_path) = "OffScreenCEF/godot/";
-    //CefString(&settings.framework_dir_path) = "OffScreenCEF/godot/";
-    //CefString(&settings.cache_path) = "OffScreenCEF/godot/";
+    // CefString(&settings.locales_dir_path) = "OffScreenCEF/godot/locales";
+    // CefString(&settings.resources_dir_path) = "OffScreenCEF/godot/";
+    // CefString(&settings.framework_dir_path) = "OffScreenCEF/godot/";
+    // CefString(&settings.cache_path) = "OffScreenCEF/godot/";
     settings.windowless_rendering_enabled = true;
 #if defined(CEF_NO_SANDBOX)
     settings.no_sandbox = true;
 #endif
 
-    bool result = CefInitialize(args, settings, nullptr, nullptr);
-    if (!result)
-    {
-        sLog.error("CefInitialize: failed");
-        exit(-2);
+    bool result = CefInitialize (args, settings, nullptr, nullptr);
+    if (!result) {
+        sLog.error ("CefInitialize: failed");
+        exit (-2);
     }
 }
 
 using namespace WallpaperEngine::Core;
 
-const std::string& CWeb::getFilename ()
-{
+const std::string& CWeb::getFilename () {
     return this->m_filename;
 }
 
-CWeb::CWeb (std::string filename, CProject& project) :
-    CWallpaper (Type, project),
-    m_filename (std::move(filename))
-{   
-    if(!g_CEFused) {
-        sLog.debug("Setting up CEF");
+CWeb::CWeb (std::string filename, CProject& project) : CWallpaper (Type, project), m_filename (std::move (filename)) {
+    if (!g_CEFused) {
+        sLog.debug ("Setting up CEF");
         // char** argv = new char*("linux-wallpaper\n");
         // CEFsetUp(1, argv);
         // delete argv;
-        g_CEFused=true;
+        g_CEFused = true;
     }
 }
 

+ 4 - 5
src/WallpaperEngine/Render/CWallpaper.cpp

@@ -1,8 +1,8 @@
 #include "CWallpaper.h"
 #include "CScene.h"
 #include "CVideo.h"
-#include "common.h"
 #include "CWeb.h"
+#include "common.h"
 
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
@@ -25,8 +25,7 @@ CWallpaper::CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CRend
     a_TexCoord (GL_NONE),
     m_vaoBuffer (GL_NONE),
     m_audioContext (audioContext),
-    m_state (scalingMode)
-{
+    m_state (scalingMode) {
     // generate the VAO to stop opengl from complaining
     glGenVertexArrays (1, &this->m_vaoBuffer);
     glBindVertexArray (this->m_vaoBuffer);
@@ -287,8 +286,8 @@ CWallpaper* CWallpaper::fromWallpaper (Core::CWallpaper* wallpaper, CRenderConte
         return new WallpaperEngine::Render::CScene (wallpaper->as<Core::CScene> (), context, audioContext, scalingMode);
     if (wallpaper->is<Core::CVideo> ())
         return new WallpaperEngine::Render::CVideo (wallpaper->as<Core::CVideo> (), context, audioContext, scalingMode);
-    else if (wallpaper->is <Core::CWeb> ())
-        return new WallpaperEngine::Render::CWeb (wallpaper->as <Core::CWeb> (), context, audioContext, scalingMode);
+    else if (wallpaper->is<Core::CWeb> ())
+        return new WallpaperEngine::Render::CWeb (wallpaper->as<Core::CWeb> (), context, audioContext, scalingMode);
     else
         sLog.exception ("Unsupported wallpaper type");
 }

+ 57 - 64
src/WallpaperEngine/Render/CWeb.cpp

@@ -5,36 +5,35 @@
 
 using namespace WallpaperEngine::Render;
 
-CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContext, const CWallpaperState::TextureUVsScaling& scalingMode) :
+CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContext,
+            const CWallpaperState::TextureUVsScaling& scalingMode) :
     CWallpaper (web, Type, context, audioContext, scalingMode),
     m_width (context.getOutput ().getFullWidth ()),
     m_height (context.getOutput ().getFullHeight ()),
-    m_browser(),
-    m_client()
-{
+    m_browser (),
+    m_client () {
     // setup framebuffers
-    this->setupFramebuffers();
+    this->setupFramebuffers ();
 
     CefWindowInfo window_info;
-    window_info.SetAsWindowless(0);
+    window_info.SetAsWindowless (0);
 
-    this->m_render_handler = new RenderHandler(this);
+    this->m_render_handler = new RenderHandler (this);
 
     CefBrowserSettings browserSettings;
-    //Documentaion says that 60 fps is maximum value
-    browserSettings.windowless_frame_rate = std::max(60,context.getApp().getContext().settings.render.maximumFPS);
-
-    m_client = new BrowserClient(m_render_handler);
-    std::filesystem::path htmlpath = this->getWeb ()->getProject ().getContainer ()->resolveRealFile (this->getWeb ()->getFilename ());
-    //To open local file in browser URL must be "file:///path/to/file.html"
-    const std::string htmlURL = std::string("file:///") + htmlpath.c_str();
-    m_browser = CefBrowserHost::CreateBrowserSync(window_info, m_client.get(),
-                                                  htmlURL, browserSettings,
-                                                  nullptr, nullptr);
+    // Documentaion says that 60 fps is maximum value
+    browserSettings.windowless_frame_rate = std::max (60, context.getApp ().getContext ().settings.render.maximumFPS);
+
+    m_client = new BrowserClient (m_render_handler);
+    std::filesystem::path htmlpath =
+        this->getWeb ()->getProject ().getContainer ()->resolveRealFile (this->getWeb ()->getFilename ());
+    // To open local file in browser URL must be "file:///path/to/file.html"
+    const std::string htmlURL = std::string ("file:///") + htmlpath.c_str ();
+    m_browser =
+        CefBrowserHost::CreateBrowserSync (window_info, m_client.get (), htmlURL, browserSettings, nullptr, nullptr);
 }
 
-void CWeb::setSize (int64_t width, int64_t height)
-{
+void CWeb::setSize (int64_t width, int64_t height) {
     this->m_width = width > 0 ? width : this->m_width;
     this->m_height = height > 0 ? height : this->m_height;
 
@@ -43,73 +42,67 @@ void CWeb::setSize (int64_t width, int64_t height)
         return;
 
     // reconfigure the texture
-    glBindTexture (GL_TEXTURE_2D, this->getWallpaperTexture());
-    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, this->getWidth(), this->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+    glBindTexture (GL_TEXTURE_2D, this->getWallpaperTexture ());
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, this->getWidth (), this->getHeight (), 0, GL_RGBA, GL_UNSIGNED_BYTE,
+                  nullptr);
 
     // Notify cef that it was resized(maybe it's not even needed)
-    m_browser->GetHost()->WasResized();
+    m_browser->GetHost ()->WasResized ();
 }
 
-void CWeb::renderFrame (glm::ivec4 viewport)
-{
+void CWeb::renderFrame (glm::ivec4 viewport) {
     // ensure the virtual mouse position is up to date
     this->updateMouse (viewport);
     // use the scene's framebuffer by default
-    glBindFramebuffer (GL_FRAMEBUFFER, this->getWallpaperFramebuffer());
+    glBindFramebuffer (GL_FRAMEBUFFER, this->getWallpaperFramebuffer ());
     // ensure we render over the whole framebuffer
     glViewport (0, 0, this->getWidth (), this->getHeight ());
 
-    //Cef processes all messages, including OnPaint, which renders frame
-    //If there is no OnPaint in message loop, we will not update(render) frame
-    // This means some frames will not have OnPaint call in cef messageLoop
-    // Because of that glClear will result in flickering on higher fps
-    // Do not use glClear until some method to control rendering with cef is supported
-    //We might actually try to use cef to execute javascript, and not using off-screen rendering at all
-    //But for now let it be like this
-    // glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-    CefDoMessageLoopWork();
+    // Cef processes all messages, including OnPaint, which renders frame
+    // If there is no OnPaint in message loop, we will not update(render) frame
+    //  This means some frames will not have OnPaint call in cef messageLoop
+    //  Because of that glClear will result in flickering on higher fps
+    //  Do not use glClear until some method to control rendering with cef is supported
+    // We might actually try to use cef to execute javascript, and not using off-screen rendering at all
+    // But for now let it be like this
+    //  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    CefDoMessageLoopWork ();
 }
-void CWeb::updateMouse (glm::ivec4 viewport)
-{
+
+void CWeb::updateMouse (glm::ivec4 viewport) {
     // update virtual mouse position first
-    glm::dvec2 position = this->getContext ().getInputContext ().getMouseInput ().position();
+    glm::dvec2 position = this->getContext ().getInputContext ().getMouseInput ().position ();
 
     CefMouseEvent evt;
     // Set mouse current position. Maybe clamps are not needed
-    evt.x = std::clamp(int(position.x - viewport.x),0,viewport.z);
-    evt.y = std::clamp(int(position.y - viewport.y),0,viewport.w);
+    evt.x = std::clamp (int (position.x - viewport.x), 0, viewport.z);
+    evt.y = std::clamp (int (position.y - viewport.y), 0, viewport.w);
     // Send mouse position to cef
-    m_browser->GetHost()->SendMouseMoveEvent(evt, false);
+    m_browser->GetHost ()->SendMouseMoveEvent (evt, false);
 }
 
-CWeb::~CWeb(){
-    CefDoMessageLoopWork();
-    m_browser->GetHost()->CloseBrowser(true);
+CWeb::~CWeb () {
+    CefDoMessageLoopWork ();
+    m_browser->GetHost ()->CloseBrowser (true);
 }
 
+CWeb::RenderHandler::RenderHandler (CWeb* webdata) : m_webdata (webdata) {}
 
-CWeb::RenderHandler::RenderHandler(CWeb* webdata):
-    m_webdata(webdata)
-{
-}
-CWeb::RenderHandler::~RenderHandler(){
-}
-//Required by CEF
-void CWeb::RenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
-{
-    rect = CefRect(0, 0, this->m_webdata->getWidth(), this->m_webdata->getHeight());
+CWeb::RenderHandler::~RenderHandler () {}
+
+// Required by CEF
+void CWeb::RenderHandler::GetViewRect (CefRefPtr<CefBrowser> browser, CefRect& rect) {
+    rect = CefRect (0, 0, this->m_webdata->getWidth (), this->m_webdata->getHeight ());
 }
-//Will be executed in CEF message loop
-void CWeb::RenderHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type,
-                                         const RectList &dirtyRects, const void *buffer,
-                                         int width, int height)
-{
-    //sLog.debug("BrowserView::RenderHandler::OnPaint");
-    glActiveTexture(GL_TEXTURE0);
-    glBindTexture(GL_TEXTURE_2D, this->texture());
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA_EXT,
-                         GL_UNSIGNED_BYTE, (unsigned char*)buffer);
-    glBindTexture(GL_TEXTURE_2D, 0);
+
+// Will be executed in CEF message loop
+void CWeb::RenderHandler::OnPaint (CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects,
+                                   const void* buffer, int width, int height) {
+    // sLog.debug("BrowserView::RenderHandler::OnPaint");
+    glActiveTexture (GL_TEXTURE0);
+    glBindTexture (GL_TEXTURE_2D, this->texture ());
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (unsigned char*) buffer);
+    glBindTexture (GL_TEXTURE_2D, 0);
 }
 
 const std::string CWeb::Type = "web";

+ 0 - 0
tools/linting.sh