Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Almamu committed May 7, 2024
1 parent f20b2a0 commit 8dbb4aa
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
9 changes: 5 additions & 4 deletions src/WallpaperEngine/Application/CWallpaperApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ float g_TimeLast;
float g_Daytime;

namespace WallpaperEngine::Application {
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context, WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) :
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context,
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) :
m_context (context),
m_defaultBackground (nullptr),
browserContext (browserContext) {
Expand Down Expand Up @@ -158,7 +159,7 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const

void CWallpaperApplication::loadBackgrounds () {
// 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);
}

Expand Down Expand Up @@ -303,8 +304,8 @@ void CWallpaperApplication::show () {
}

// wallpapers are setup, free browsesr context if possible
if (!this->browserContext.isUsed()) {
this->browserContext.stop();
if (!this->browserContext.isUsed ()) {
this->browserContext.stop ();
}

static time_t seconds;
Expand Down
3 changes: 1 addition & 2 deletions src/WallpaperEngine/Core/Wallpapers/CWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const std::string& CWeb::getFilename () {
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";
3 changes: 2 additions & 1 deletion src/WallpaperEngine/Render/CWallpaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ CWallpaper* CWallpaper::fromWallpaper (Core::CWallpaper* wallpaper, CRenderConte
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, browserContext, scalingMode);
return new WallpaperEngine::Render::CWeb (wallpaper->as<Core::CWeb> (), context, audioContext, browserContext,
scalingMode);
else
sLog.exception ("Unsupported wallpaper type");
}
9 changes: 4 additions & 5 deletions src/WallpaperEngine/Render/Wallpapers/CWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
using namespace WallpaperEngine::Render;
using namespace WallpaperEngine::WebBrowser;

CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContext,
CWebBrowserContext& browserContext,
CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContext, CWebBrowserContext& browserContext,
const CWallpaperState::TextureUVsScaling& scalingMode) :
CWallpaper (web, Type, context, audioContext, scalingMode),
m_width (16),
m_height (16),
m_browserContext (browserContext),
m_browser (),
m_client () {
this->m_browserContext.markAsUsed();
this->m_browserContext.markAsUsed ();
// setup framebuffers
this->setupFramebuffers ();

Expand Down Expand Up @@ -56,8 +55,8 @@ void CWeb::setSize (int64_t width, int64_t height) {

void CWeb::renderFrame (glm::ivec4 viewport) {
// ensure the viewport matches the window size, and resize if needed
if (viewport.z != this->getWidth() || viewport.w != this->getHeight()) {
this->setSize(viewport.z, viewport.w);
if (viewport.z != this->getWidth () || viewport.w != this->getHeight ()) {
this->setSize (viewport.z, viewport.w);
}

// ensure the virtual mouse position is up to date
Expand Down
48 changes: 23 additions & 25 deletions src/WallpaperEngine/WebBrowsesr/CWebBrowserContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,50 @@

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
char** argv2 = new char*[argc];

for(int i = 0; i < argc; i ++) {
argv2[i] = new char[strlen(argv[i]) + 1];
strcpy(argv2[i], argv[i]);
for (int i = 0; i < argc; i++) {
argv2 [i] = new char [strlen (argv [i]) + 1];
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.
if (exit_code >= 0)
{
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.
if (exit_code >= 0) {
// 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.browser_subprocess_path) = "path/to/client"
// 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.browser_subprocess_path) = "path/to/client"
settings.windowless_rendering_enabled = true;
#if defined(CEF_NO_SANDBOX)
settings.no_sandbox = true;
#endif

// 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");
}
}

CWebBrowserContext::~CWebBrowserContext() {
this->stop();
CWebBrowserContext::~CWebBrowserContext () {
this->stop ();
}

void CWebBrowserContext::markAsUsed () {
Expand All @@ -62,14 +60,14 @@ bool CWebBrowserContext::isUsed () {
return this->m_inUse;
}

void CWebBrowserContext::stop() {
void CWebBrowserContext::stop () {
if (this->m_stopped) {
return;
}

sLog.out("Shutting down CEF");
sLog.out ("Shutting down CEF");

this->m_stopped = true;

CefShutdown();
CefShutdown ();
}

0 comments on commit 8dbb4aa

Please sign in to comment.