chore: linting

This commit is contained in:
Almamu 2024-05-07 04:24:46 +02:00
parent f20b2a0c37
commit 8dbb4aa7e8
5 changed files with 35 additions and 37 deletions

View File

@ -19,7 +19,8 @@ float g_TimeLast;
float g_Daytime; float g_Daytime;
namespace WallpaperEngine::Application { namespace WallpaperEngine::Application {
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context, WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) : CWallpaperApplication::CWallpaperApplication (CApplicationContext& context,
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) :
m_context (context), m_context (context),
m_defaultBackground (nullptr), m_defaultBackground (nullptr),
browserContext (browserContext) { browserContext (browserContext) {
@ -158,7 +159,7 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const
void CWallpaperApplication::loadBackgrounds () { void CWallpaperApplication::loadBackgrounds () {
// load default background if specified // load default background if specified
if (!this->m_context.settings.general.defaultBackground.empty()) { if (!this->m_context.settings.general.defaultBackground.empty ()) {
this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground); this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground);
} }
@ -303,8 +304,8 @@ void CWallpaperApplication::show () {
} }
// wallpapers are setup, free browsesr context if possible // wallpapers are setup, free browsesr context if possible
if (!this->browserContext.isUsed()) { if (!this->browserContext.isUsed ()) {
this->browserContext.stop(); this->browserContext.stop ();
} }
static time_t seconds; static time_t seconds;

View File

@ -9,7 +9,6 @@ const std::string& CWeb::getFilename () {
return this->m_filename; return this->m_filename;
} }
CWeb::CWeb (std::string filename, CProject& project) : CWallpaper (Type, project), m_filename (std::move (filename)) { CWeb::CWeb (std::string filename, CProject& project) : CWallpaper (Type, project), m_filename (std::move (filename)) {}
}
const std::string CWeb::Type = "web"; const std::string CWeb::Type = "web";

View File

@ -287,7 +287,8 @@ CWallpaper* CWallpaper::fromWallpaper (Core::CWallpaper* wallpaper, CRenderConte
if (wallpaper->is<Core::CVideo> ()) if (wallpaper->is<Core::CVideo> ())
return new WallpaperEngine::Render::CVideo (wallpaper->as<Core::CVideo> (), context, audioContext, scalingMode); return new WallpaperEngine::Render::CVideo (wallpaper->as<Core::CVideo> (), context, audioContext, scalingMode);
else if (wallpaper->is<Core::CWeb> ()) else if (wallpaper->is<Core::CWeb> ())
return new WallpaperEngine::Render::CWeb (wallpaper->as<Core::CWeb> (), context, audioContext, browserContext, scalingMode); return new WallpaperEngine::Render::CWeb (wallpaper->as<Core::CWeb> (), context, audioContext, browserContext,
scalingMode);
else else
sLog.exception ("Unsupported wallpaper type"); sLog.exception ("Unsupported wallpaper type");
} }

View File

@ -6,8 +6,7 @@
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
using namespace WallpaperEngine::WebBrowser; using namespace WallpaperEngine::WebBrowser;
CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContext, CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContext, CWebBrowserContext& browserContext,
CWebBrowserContext& browserContext,
const CWallpaperState::TextureUVsScaling& scalingMode) : const CWallpaperState::TextureUVsScaling& scalingMode) :
CWallpaper (web, Type, context, audioContext, scalingMode), CWallpaper (web, Type, context, audioContext, scalingMode),
m_width (16), m_width (16),
@ -15,7 +14,7 @@ CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContex
m_browserContext (browserContext), m_browserContext (browserContext),
m_browser (), m_browser (),
m_client () { m_client () {
this->m_browserContext.markAsUsed(); this->m_browserContext.markAsUsed ();
// setup framebuffers // setup framebuffers
this->setupFramebuffers (); this->setupFramebuffers ();
@ -56,8 +55,8 @@ void CWeb::setSize (int64_t width, int64_t height) {
void CWeb::renderFrame (glm::ivec4 viewport) { void CWeb::renderFrame (glm::ivec4 viewport) {
// ensure the viewport matches the window size, and resize if needed // ensure the viewport matches the window size, and resize if needed
if (viewport.z != this->getWidth() || viewport.w != this->getHeight()) { if (viewport.z != this->getWidth () || viewport.w != this->getHeight ()) {
this->setSize(viewport.z, viewport.w); this->setSize (viewport.z, viewport.w);
} }
// ensure the virtual mouse position is up to date // ensure the virtual mouse position is up to date

View File

@ -6,52 +6,50 @@
using namespace WallpaperEngine::WebBrowser; using namespace WallpaperEngine::WebBrowser;
CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped(false) { CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (false) {
// clone original argc/argv as they'll be modified by cef // clone original argc/argv as they'll be modified by cef
char** argv2 = new char*[argc]; char** argv2 = new char*[argc];
for(int i = 0; i < argc; i ++) { for (int i = 0; i < argc; i++) {
argv2[i] = new char[strlen(argv[i]) + 1]; argv2 [i] = new char [strlen (argv [i]) + 1];
strcpy(argv2[i], argv[i]); strcpy (argv2 [i], argv [i]);
} }
CefMainArgs args(argc, argv2); CefMainArgs args (argc, argv2);
int exit_code = CefExecuteProcess(args, nullptr, nullptr);//Spawned processes will terminate here(see CefIninitilize below). Maybe implementing settings.browser_subprocess_path will allow it to work not in main function. int exit_code = CefExecuteProcess (
if (exit_code >= 0) args, nullptr, nullptr); // Spawned processes will terminate here(see CefIninitilize below). Maybe implementing
{ // settings.browser_subprocess_path will allow it to work not in main function.
if (exit_code >= 0) {
// Sub proccess has endend, so exit // Sub proccess has endend, so exit
exit(exit_code); exit (exit_code);
} } else if (exit_code == -1) {
else if (exit_code == -1)
{
// If called for the browser process (identified by no "type" command-line value) // If called for the browser process (identified by no "type" command-line value)
// it will return immediately with a value of -1 // it will return immediately with a value of -1
} }
// Configurate Chromium // Configurate Chromium
CefSettings settings; CefSettings settings;
//CefString(&settings.locales_dir_path) = "OffScreenCEF/godot/locales"; // CefString(&settings.locales_dir_path) = "OffScreenCEF/godot/locales";
//CefString(&settings.resources_dir_path) = "OffScreenCEF/godot/"; // CefString(&settings.resources_dir_path) = "OffScreenCEF/godot/";
//CefString(&settings.framework_dir_path) = "OffScreenCEF/godot/"; // CefString(&settings.framework_dir_path) = "OffScreenCEF/godot/";
//CefString(&settings.cache_path) = "OffScreenCEF/godot/"; // CefString(&settings.cache_path) = "OffScreenCEF/godot/";
// CefString(&settings.browser_subprocess_path) = "path/to/client" // CefString(&settings.browser_subprocess_path) = "path/to/client"
settings.windowless_rendering_enabled = true; settings.windowless_rendering_enabled = true;
#if defined(CEF_NO_SANDBOX) #if defined(CEF_NO_SANDBOX)
settings.no_sandbox = true; settings.no_sandbox = true;
#endif #endif
// spawns two new processess // spawns two new processess
bool result = CefInitialize(args, settings, nullptr, nullptr); bool result = CefInitialize (args, settings, nullptr, nullptr);
if (!result) if (!result) {
{
sLog.exception ("CefInitialize: failed"); sLog.exception ("CefInitialize: failed");
} }
} }
CWebBrowserContext::~CWebBrowserContext() { CWebBrowserContext::~CWebBrowserContext () {
this->stop(); this->stop ();
} }
void CWebBrowserContext::markAsUsed () { void CWebBrowserContext::markAsUsed () {
@ -62,14 +60,14 @@ bool CWebBrowserContext::isUsed () {
return this->m_inUse; return this->m_inUse;
} }
void CWebBrowserContext::stop() { void CWebBrowserContext::stop () {
if (this->m_stopped) { if (this->m_stopped) {
return; return;
} }
sLog.out("Shutting down CEF"); sLog.out ("Shutting down CEF");
this->m_stopped = true; this->m_stopped = true;
CefShutdown(); CefShutdown ();
} }