CWeb.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "CWeb.h"
  2. #include "common.h"
  3. #include <utility>
  4. static void CEFsetUp (int argc, char** argv) {
  5. // This function should be called from the application entry point function to
  6. // execute a secondary process. It can be used to run secondary processes from
  7. // the browser client executable (default behavior) or from a separate
  8. // executable specified by the CefSettings.browser_subprocess_path value. If
  9. // called for the browser process (identified by no "type" command-line value)
  10. // it will return immediately with a value of -1. If called for a recognized
  11. // secondary process it will block until the process should exit and then return
  12. // the process exit code. The |application| parameter may be empty. The
  13. // |windows_sandbox_info| parameter is only used on Windows and may be NULL (see
  14. // cef_sandbox_win.h for details).
  15. CefMainArgs args (argc, argv);
  16. int exit_code = CefExecuteProcess (args, nullptr, nullptr);
  17. if (exit_code >= 0) {
  18. sLog.debug ("CEF sub proccess has endend");
  19. // Sub proccess has endend, so exit
  20. exit (exit_code);
  21. } else if (exit_code == -1) {
  22. // If called for the browser process (identified by no "type" command-line value)
  23. // it will return immediately with a value of -1
  24. }
  25. // Configurate Chromium
  26. CefSettings settings;
  27. // CefString(&settings.locales_dir_path) = "OffScreenCEF/godot/locales";
  28. // CefString(&settings.resources_dir_path) = "OffScreenCEF/godot/";
  29. // CefString(&settings.framework_dir_path) = "OffScreenCEF/godot/";
  30. // CefString(&settings.cache_path) = "OffScreenCEF/godot/";
  31. settings.windowless_rendering_enabled = true;
  32. #if defined(CEF_NO_SANDBOX)
  33. settings.no_sandbox = true;
  34. #endif
  35. bool result = CefInitialize (args, settings, nullptr, nullptr);
  36. if (!result) {
  37. sLog.error ("CefInitialize: failed");
  38. exit (-2);
  39. }
  40. }
  41. using namespace WallpaperEngine::Core;
  42. const std::string& CWeb::getFilename () {
  43. return this->m_filename;
  44. }
  45. CWeb::CWeb (std::string filename, CProject& project) : CWallpaper (Type, project), m_filename (std::move (filename)) {
  46. if (!g_CEFused) {
  47. sLog.debug ("Setting up CEF");
  48. // char** argv = new char*("linux-wallpaper\n");
  49. // CEFsetUp(1, argv);
  50. // delete argv;
  51. g_CEFused = true;
  52. }
  53. }
  54. const std::string CWeb::Type = "web";