Permalink
Browse files

gui, refactor: use the main thread to run the gui.

  • Loading branch information...
xicilion committed Apr 22, 2018
1 parent c33150e commit 87713e2211250e3ae9970322805590dbe07807b5
Showing with 78 additions and 44 deletions.
  1. +66 −40 fibjs/src/base/fibjs.cpp
  2. +5 −1 fibjs/src/gui/other/gui.cpp
  3. +6 −2 fibjs/src/gui/windows/WebView.cpp
  4. +1 −1 vender
View
@@ -24,7 +24,6 @@ void init_start_argv(int32_t argc, char** argv);
void init_prof();
void init_cipher();
void init_acThread();
void init_gui();
void init_logger();
void init_aio();
void init_fs();
@@ -35,6 +34,8 @@ void init_process();
void options(int32_t& pos, char* argv[]);
result_t ifZipFile(exlib::string filename, bool& retVal);
void run_gui();
exlib::string s_root;
void init()
@@ -53,10 +54,8 @@ void init()
// init_prof();
init_date();
init_rt();
init_cipher();
init_acThread();
init_gui();
init_logger();
init_aio();
init_fs();
@@ -112,57 +111,84 @@ static void start_fiber(void* p)
syncCall(isolate, main_fiber, isolate);
}
void main(int32_t argc, char* argv[])
void main(int32_t argc, char** argv)
{
exlib::string exePath;
std::vector<char*> ptrArg;
class MainThread : public exlib::OSThread {
public:
MainThread(int32_t argc, char** argv)
: m_argc(argc)
, m_argv(argv)
{
}
process_base::get_execPath(exePath);
public:
virtual void Run()
{
int32_t argc = m_argc;
char** argv = m_argv;
bool bZip;
ifZipFile(exePath, bZip);
if (bZip) {
exlib::string exePath;
std::vector<char*> ptrArg;
exePath.append(1, '$');
ptrArg.resize(argc + 1);
process_base::get_execPath(exePath);
ptrArg[0] = argv[0];
ptrArg[1] = exePath.c_buffer();
bool bZip;
ifZipFile(exePath, bZip);
if (bZip) {
int32_t i;
for (i = 1; i < argc; i++)
ptrArg[i + 1] = argv[i];
exePath.append(1, '$');
ptrArg.resize(argc + 1);
argv = &ptrArg[0];
argc++;
}
ptrArg[0] = argv[0];
ptrArg[1] = exePath.c_buffer();
init_start_argv(argc, argv);
int32_t i;
for (i = 1; i < argc; i++)
ptrArg[i + 1] = argv[i];
int32_t pos = argc;
options(pos, argv);
argv = &ptrArg[0];
argc++;
}
init();
init_start_argv(argc, argv);
if (pos < argc) {
if (argv[pos][0] == '-')
s_start = argv[pos];
else {
s_start = s_root;
resolvePath(s_start, argv[pos]);
}
int32_t pos = argc;
options(pos, argv);
init();
if (pos < argc) {
if (argv[pos][0] == '-')
s_start = argv[pos];
else {
s_start = s_root;
resolvePath(s_start, argv[pos]);
}
if (pos != 1) {
int32_t p = 1;
for (; pos < argc; pos++)
argv[p++] = argv[pos];
argc = p;
if (pos != 1) {
int32_t p = 1;
for (; pos < argc; pos++)
argv[p++] = argv[pos];
argc = p;
}
}
init_argv(argc, argv);
exlib::Service::Create(start_fiber, NULL, 256 * 1024, "start");
exlib::Service::dispatch();
}
}
init_argv(argc, argv);
exlib::Service::Create(start_fiber, NULL, 256 * 1024, "start");
exlib::Service::dispatch();
private:
int32_t m_argc;
char** m_argv;
};
init_rt();
MainThread* main_thread = new MainThread(argc, argv);
main_thread->start();
run_gui();
}
}
@@ -11,8 +11,12 @@
namespace fibjs {
void init_gui()
void run_gui()
{
exlib::OSThread th;
th.bindCurrent();
th.suspend();
}
void putGuiPool(AsyncEvent* ac)
@@ -366,12 +366,16 @@ class gui_thread : public exlib::OSThread,
}
};
void init_gui()
void run_gui()
{
gui_thread* _thGUI = new gui_thread();
_thGUI->start();
_thGUI->bindCurrent();
s_thread = _thGUI->thread_id;
gui_base::setVersion(99999);
_thGUI->Run();
}
result_t gui_base::setVersion(int32_t ver)
2 vender

0 comments on commit 87713e2

Please sign in to comment.