提交 924f4e0c 编写于 作者: yanghye's avatar yanghye

U: remove const.IsMessageLoop, add application.IsMessageLoop()

上级 afc2073e
......@@ -45,7 +45,7 @@ func appWebKitInitialized() {
return
energyExtensionHandler := V8HandlerRef.New()
energyExtensionHandler.Execute(func(name string, object *ICefV8Value, arguments *TCefV8ValueArray, retVal *ResultV8Value, exception *ResultString) bool {
fmt.Println("Execute", name, consts.IsMessageLoop, application.SingleProcess())
fmt.Println("Execute", name, application.IsMessageLoop(), application.SingleProcess())
if name == "mouseMove" {
message := &ipcArgument.List{
Id: -1,
......
......@@ -160,6 +160,15 @@ func (m *TCEFApplication) MultiThreadedMessageLoop() bool {
return api.GoBool(r1)
}
// IsMessageLoop
// 消息轮询方式使用不同的窗口组件
// return true: 使用VF(views framework)窗口组件, false: 使用LCL窗口组件
func (m *TCEFApplication) IsMessageLoop() bool {
emp := m.ExternalMessagePump()
mtml := m.MultiThreadedMessageLoop()
return !emp && !mtml
}
func (m *TCEFApplication) SetMultiThreadedMessageLoop(value bool) {
imports.Proc(def.CEFAppConfig_SetMultiThreadedMessageLoop).Call(api.PascalBool(value))
}
......
......@@ -16,7 +16,6 @@ import (
"github.com/energye/energy/v2/cef/lclwidget"
"github.com/energye/energy/v2/cef/process"
"github.com/energye/energy/v2/common"
"github.com/energye/energy/v2/consts"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/api"
)
......@@ -61,35 +60,32 @@ func Run(app *TCEFApplication) {
app.Free()
} else {
//externalMessagePump 和 multiThreadedMessageLoop 为 false 时, 启用 VF (ViewsFrameworkBrowserWindow) 窗口组件
emp := app.ExternalMessagePump()
mtml := app.MultiThreadedMessageLoop()
consts.IsMessageLoop = !emp && !mtml
if consts.IsMessageLoop {
if app.IsMessageLoop() {
// 启用VF窗口组件
BrowserWindow.appContextInitialized(app)
}
// 启动主进程
success := app.StartMainProcess()
if success {
if !consts.IsMessageLoop {
//LCL -> Linux 必须在主进程启动之后初始化组件
lclwidget.CustomWidgetSetInitialization()
}
//if !consts.IsMessageLoop {
//LCL -> Linux 必须在主进程启动之后初始化组件
lclwidget.CustomWidgetSetInitialization()
//}
// 主进程启动成功之后回调
if browserProcessStartAfterCallback != nil {
browserProcessStartAfterCallback(success)
}
appMainRunCallback()
if consts.IsMessageLoop {
if app.IsMessageLoop() {
lcl.Application.Initialize()
// VF窗口消息轮询
// VF窗口
app.RunMessageLoop()
} else {
// 创建LCL窗口组件
if BrowserWindow.mainBrowserWindow == nil {
BrowserWindow.mainBrowserWindow = new(lclBrowserWindow)
}
// 运行主窗口
// LCL窗口
lcl.RunApp(&BrowserWindow.mainBrowserWindow)
lclwidget.CustomWidgetSetFinalization()
}
......
......@@ -62,7 +62,7 @@ func chromiumOnBeforeBrowser(browser *ICefBrowser, frame *ICefFrame) {
}
BrowserWindow.putWindowInfo(browser.BrowserId(), bw)
}
if !consts.IsMessageLoop {
if !application.IsMessageLoop() {
QueueAsyncCall(func(id int) {
// lcl
BrowserWindow.createNextLCLPopupWindow()
......
......@@ -14,7 +14,6 @@ package cef
import (
"github.com/energye/energy/v2/common"
"github.com/energye/energy/v2/consts"
"github.com/energye/energy/v2/pkgs/notice"
"github.com/energye/energy/v2/pkgs/systray"
"github.com/energye/golcl/energy/emfs"
......@@ -109,7 +108,7 @@ func (m *SysTray) Show() {
}
if common.IsDarwin() {
// view framework
if consts.IsMessageLoop {
if application.IsMessageLoop() {
runLoop()
} else {
//LCL
......
......@@ -21,10 +21,9 @@ import (
)
var (
ExePath string //执行文件目录
HomeDir, _ = homedir.Dir() //系统用户目录
Separator = string(filepath.Separator) //系统目录分隔符
IsMessageLoop = false //CEF应用的窗口, true: 使用VF(views framework)窗口组件, false: 使用LCL窗口组件, 其实是窗口消息轮询使用方式.
ExePath string //执行文件目录
HomeDir, _ = homedir.Dir() //系统用户目录
Separator = string(filepath.Separator) //系统目录分隔符
)
const (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册