Skip to content
Snippets Groups Projects
Commit 57a6423f authored by Sergey Linev's avatar Sergey Linev Committed by Bertrand Bellenot
Browse files

webgui: enable usage of CEF in canvas painter

parent 12d6a73e
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,30 @@
#include "TClass.h"
#include "TBufferJSON.h"
#ifdef WEBGUI_WITH_CEF
#include "../cef/simple_app.h"
#include "TApplication.h"
#include "TTimer.h"
class TCefTimer : public TTimer {
public:
TCefTimer(Long_t milliSec, Bool_t mode) : TTimer(milliSec, mode)
{
// construtor
}
virtual ~TCefTimer()
{
// destructor
}
virtual void Timeout()
{
// just dummy workaround
CefDoMessageLoopWork();
}
};
#endif
namespace {
/** \class TCanvasPainter
......@@ -162,6 +186,76 @@ void TCanvasPainter::PopupBrowser()
addr.Form("%s/web7gui/%s/draw.htm?webcanvas", fAddr.c_str(), GetName());
#ifdef WEBGUI_WITH_CEF
const char* cef = gSystem->Getenv("CEF_PATH");
Info("Show", "CEF %s", cef);
if (cef && !gSystem->AccessPathName(cef)) {
TApplication* root_app = gROOT->GetApplication();
printf("Start cef window with addr %s app %p\n", addr.Data(), root_app);
CefMainArgs main_args(root_app->Argc(), root_app->Argv());
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
/* int exit_code = CefExecuteProcess(main_args, NULL, NULL);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}
*/
// Install xlib error handlers so that the application won't be terminated
// on non-fatal errors.
// XSetErrorHandler(XErrorHandlerImpl);
// XSetIOErrorHandler(XIOErrorHandlerImpl);
// Specify CEF global settings here.
CefSettings settings;
// settings.multi_threaded_message_loop = false; // not supported
// settings.external_message_pump = false;
const char* rootsys = gSystem->Getenv("ROOTSYS");
printf("Get build dir %s\n", rootsys);
TString path, path2, cef_main;
path.Form("%s/Resources/", cef);
path2.Form("%s/Resources/locales/", cef);
cef_main.Form("%s/bin/cef_main", rootsys);
cef_string_ascii_to_utf16(path.Data(), path.Length(), &settings.resources_dir_path);
cef_string_ascii_to_utf16(path2.Data(), path2.Length(), &settings.locales_dir_path);
settings.no_sandbox = true;
// settings.single_process = true;
// SimpleApp implements application-level callbacks for the browser process.
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
CefRefPtr<SimpleApp> *app = new CefRefPtr<SimpleApp>(new SimpleApp(addr.Data(), cef_main.Data()));
// Initialize CEF for the browser process.
CefInitialize(main_args, settings, app->get(), NULL);
// let run CEF message loop, should be improved later
TCefTimer *timer = new TCefTimer(10, kTRUE);
timer->TurnOn();
// Shut down CEF.
//CefShutdown();
return;
}
#endif
if (gSystem->InheritsFrom("TMacOSXSystem"))
exec.Form("open %s", addr.Data());
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment