Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
5f7c0fc9
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f7c0fc9
编写于
1月 05, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
v2.1 Fixed Chinese input and gtk3 issues for linux packaging
上级
d512e42d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
61 deletion
+51
-61
.gitignore
.gitignore
+1
-1
cef/cef-browser-window.go
cef/cef-browser-window.go
+5
-6
cef/cef-lcl-browser-window.go
cef/cef-lcl-browser-window.go
+16
-22
cef/cef-views-framework-browser-window.go
cef/cef-views-framework-browser-window.go
+27
-31
example/mini-browser/src/min-browser.go
example/mini-browser/src/min-browser.go
+2
-1
未找到文件。
.gitignore
浏览文件 @
5f7c0fc9
...
...
@@ -115,4 +115,4 @@ test
1048576000
/exe/app.ico
/resources/manifest.xml
/app_windows_amd64.syso
/app_windows_amd64.syso
\ No newline at end of file
cef/cef-browser-window.go
浏览文件 @
5f7c0fc9
...
...
@@ -57,7 +57,7 @@ type browser struct {
windowSerial
int32
//窗口序号
}
// 浏览器全局事件监听
// 浏览器全局事件监听
-扩展
//
// 在主浏览器进程调用
type
BrowserEvent
struct
{
...
...
@@ -70,11 +70,10 @@ type BrowserEvent struct {
onFrameCreated
ChromiumEventOnFrameCreated
//default
onFrameDetached
ChromiumEventOnFrameDetached
//default
onMainFrameChanged
ChromiumEventOnMainFrameChanged
//default
onBeforeDownload
ChromiumEventOnBeforeDownload
//default
onKeyEvent
ChromiumEventOnKeyEvent
//default
onBeforeDownload
ChromiumEventOnBeforeDownload
//default
can cover
onKeyEvent
ChromiumEventOnKeyEvent
//default
can cover
onProcessMessageReceived
BrowseProcessMessageReceived
//default
onTitleChange
ChromiumEventOnTitleChange
//default
onLoadingStateChange
ChromiumEventOnLoadingStateChange
//default
onContextMenuCommand
ChromiumEventOnContextMenuCommand
//default
onBeforeContextMenu
ChromiumEventOnBeforeContextMenu
//default
onBeforeResourceLoad
ChromiumEventOnBeforeResourceLoad
//default
...
...
@@ -104,7 +103,7 @@ func Run(cefApp *TCEFApplication) {
//externalMessagePump 和 multiThreadedMessageLoop 为 false 时启用CEF views framework (ViewsFrameworkBrowserWindow) 窗口
IsMessageLoop
=
!
api
.
GoBool
(
cefApp
.
cfg
.
externalMessagePump
)
&&
!
api
.
GoBool
(
cefApp
.
cfg
.
multiThreadedMessageLoop
)
if
IsMessageLoop
{
BrowserWindow
.
mainBrowserWindow
.
appContextInitialized
(
cefApp
)
BrowserWindow
.
appContextInitialized
(
cefApp
)
}
success
:=
cefApp
.
StartMainProcess
()
if
browserProcessStartAfterCallback
!=
nil
{
...
...
@@ -382,7 +381,7 @@ func (m *BrowserEvent) SetOnLoadStart(event ChromiumEventOnLoadStart) {
// BrowserEvent.SetOnLoadingStateChange
func
(
m
*
BrowserEvent
)
SetOnLoadingStateChange
(
event
ChromiumEventOnLoadingStateChange
)
{
if
Args
.
IsMain
()
{
m
.
onLoadingStateChange
=
event
m
.
chromium
.
SetOnLoadingStateChange
(
event
)
}
}
...
...
cef/cef-lcl-browser-window.go
浏览文件 @
5f7c0fc9
...
...
@@ -525,30 +525,29 @@ func (m *LCLBrowserWindow) activate(sender lcl.IObject) {
func
(
m
*
LCLBrowserWindow
)
registerPopupEvent
()
{
var
bwEvent
=
BrowserWindow
.
browserEvent
m
.
chromium
.
SetOnBeforePopup
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
frame
*
ICefFrame
,
beforePopupInfo
*
BeforePopupInfo
,
client
*
ICefClient
,
noJavascriptAccess
*
bool
)
bool
{
if
!
api
.
GoBool
(
BrowserWindow
.
Config
.
chromiumConfig
.
enableWindowPopup
)
{
if
!
api
.
GoBool
(
BrowserWindow
.
Config
.
ChromiumConfig
()
.
enableWindowPopup
)
{
return
true
}
BrowserWindow
.
popupWindow
.
SetWindowType
(
consts
.
WT_POPUP_SUB_BROWSER
)
BrowserWindow
.
popupWindow
.
ChromiumCreate
(
BrowserWindow
.
Config
.
chromiumConfig
,
beforePopupInfo
.
TargetUrl
)
BrowserWindow
.
popupWindow
.
ChromiumCreate
(
BrowserWindow
.
Config
.
ChromiumConfig
()
,
beforePopupInfo
.
TargetUrl
)
BrowserWindow
.
popupWindow
.
putChromiumWindowInfo
()
BrowserWindow
.
popupWindow
.
defaultChromiumEvent
()
var
result
=
false
defer
func
()
{
if
result
{
QueueAsyncCall
(
func
(
id
int
)
{
winProperty
:=
BrowserWindow
.
popupWindow
.
windowProperty
if
winProperty
!=
nil
{
if
winProperty
.
IsShowModel
{
BrowserWindow
.
popupWindow
.
ShowModal
()
return
}
}
BrowserWindow
.
popupWindow
.
Show
()
})
}
}()
if
bwEvent
.
onBeforePopup
!=
nil
{
result
=
!
bwEvent
.
onBeforePopup
(
sender
,
browser
,
frame
,
beforePopupInfo
,
BrowserWindow
.
popupWindow
,
noJavascriptAccess
)
result
=
bwEvent
.
onBeforePopup
(
sender
,
browser
,
frame
,
beforePopupInfo
,
BrowserWindow
.
popupWindow
,
noJavascriptAccess
)
}
if
!
result
{
QueueAsyncCall
(
func
(
id
int
)
{
winProperty
:=
BrowserWindow
.
popupWindow
.
windowProperty
if
winProperty
!=
nil
{
if
winProperty
.
IsShowModel
{
BrowserWindow
.
popupWindow
.
ShowModal
()
return
}
}
BrowserWindow
.
popupWindow
.
Show
()
})
result
=
true
}
return
result
})
...
...
@@ -593,11 +592,6 @@ func (m *LCLBrowserWindow) registerDefaultEvent() {
bwEvent
.
onContextMenuCommand
(
sender
,
browser
,
frame
,
params
,
commandId
,
eventFlags
,
result
)
}
})
m
.
chromium
.
SetOnLoadingStateChange
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
isLoading
,
canGoBack
,
canGoForward
bool
)
{
if
bwEvent
.
onLoadingStateChange
!=
nil
{
bwEvent
.
onLoadingStateChange
(
sender
,
browser
,
isLoading
,
canGoBack
,
canGoForward
)
}
})
m
.
chromium
.
SetOnFrameCreated
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
frame
*
ICefFrame
)
{
QueueAsyncCall
(
func
(
id
int
)
{
BrowserWindow
.
putBrowserFrame
(
browser
,
frame
)
...
...
cef/cef-views-framework-browser-window.go
浏览文件 @
5f7c0fc9
...
...
@@ -99,22 +99,22 @@ func (m *ViewsFrameworkBrowserWindow) BrowserViewComponent() *TCEFBrowserViewCom
}
//ViewsFrameworkBrowserWindow 主窗口初始化
func
(
m
*
browser
Window
)
appContextInitialized
(
app
*
TCEFApplication
)
{
func
(
m
*
browser
)
appContextInitialized
(
app
*
TCEFApplication
)
{
if
!
common
.
Args
.
IsMain
()
{
return
}
app
.
SetOnContextInitialized
(
func
()
{
vFrameBrowserWindow
:=
NewViewsFrameworkBrowserWindow
(
BrowserWindow
.
Config
.
ChromiumConfig
(),
&
BrowserWindow
.
Config
.
WindowProperty
)
m
.
chromium
=
vFrameBrowserWindow
.
chromium
m
.
putChromiumWindowInfo
()
vFrameBrowserWindow
:=
NewViewsFrameworkBrowserWindow
(
m
.
Config
.
ChromiumConfig
(),
&
m
.
Config
.
WindowProperty
)
//BrowserWindow.mainBrowserWindow.windowId = BrowserWindow.GetNextWindowNum()
//BrowserWindow.mainBrowserWindow
.putChromiumWindowInfo()
vFrameBrowserWindow
.
registerPopupEvent
()
vFrameBrowserWindow
.
registerDefaultEvent
()
vFrameBrowserWindow
.
windowComponent
.
SetOnCanClose
(
func
(
sender
lcl
.
IObject
,
window
*
ICefWindow
,
aResult
*
bool
)
{
*
aResult
=
true
app
.
QuitMessageLoop
()
})
if
BrowserWindow
.
Config
.
viewsFrameBrowserWindowOnEventCallback
!=
nil
{
BrowserWindow
.
Config
.
viewsFrameBrowserWindowOnEventCallback
(
BrowserWindow
.
browserEvent
,
vFrameBrowserWindow
)
if
m
.
Config
.
viewsFrameBrowserWindowOnEventCallback
!=
nil
{
m
.
Config
.
viewsFrameBrowserWindowOnEventCallback
(
m
.
browserEvent
,
vFrameBrowserWindow
)
}
vFrameBrowserWindow
.
windowComponent
.
CreateTopLevelWindow
()
})
...
...
@@ -129,10 +129,9 @@ func (m *ViewsFrameworkBrowserWindow) registerPopupEvent() {
fmt
.
Println
(
"BrowserWindow-TargetUrl:"
,
beforePopupInfo
.
TargetUrl
,
"IsMessageLoop:"
,
consts
.
IsMessageLoop
)
var
result
=
false
if
bwEvent
.
onBeforePopup
!=
nil
{
result
=
!
bwEvent
.
onBeforePopup
(
sender
,
browser
,
frame
,
beforePopupInfo
,
BrowserWindow
.
popupWindow
,
noJavascriptAccess
)
result
=
bwEvent
.
onBeforePopup
(
sender
,
browser
,
frame
,
beforePopupInfo
,
BrowserWindow
.
popupWindow
,
noJavascriptAccess
)
}
if
!
result
{
result
=
true
wp
:=
&
WindowProperty
{
Title
:
BrowserWindow
.
Config
.
WindowProperty
.
Title
,
Url
:
beforePopupInfo
.
TargetUrl
,
...
...
@@ -151,10 +150,12 @@ func (m *ViewsFrameworkBrowserWindow) registerPopupEvent() {
Height
:
BrowserWindow
.
Config
.
WindowProperty
.
Height
,
}
vFrameBrowserWindow
:=
NewViewsFrameworkBrowserWindow
(
BrowserWindow
.
Config
.
ChromiumConfig
(),
wp
)
//BrowserWindow.mainBrowserWindow.windowId = BrowserWindow.GetNextWindowNum()
//BrowserWindow.mainBrowserWindow.putChromiumWindowInfo()
vFrameBrowserWindow
.
registerPopupEvent
()
vFrameBrowserWindow
.
registerDefaultEvent
()
vFrameBrowserWindow
.
windowComponent
.
CreateTopLevelWindow
()
result
=
true
}
return
result
})
...
...
@@ -178,7 +179,7 @@ func (m *ViewsFrameworkBrowserWindow) registerDefaultEvent() {
bwEvent
.
onBeforeResourceLoad
(
sender
,
browser
,
frame
,
request
,
callback
,
result
)
}
})
//事件可以
被
覆盖
//事件可以覆盖
m
.
chromium
.
SetOnBeforeDownload
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
beforeDownloadItem
*
DownloadItem
,
suggestedName
string
,
callback
*
ICefBeforeDownloadCallback
)
{
if
bwEvent
.
onBeforeDownload
!=
nil
{
bwEvent
.
onBeforeDownload
(
sender
,
browser
,
beforeDownloadItem
,
suggestedName
,
callback
)
...
...
@@ -198,11 +199,6 @@ func (m *ViewsFrameworkBrowserWindow) registerDefaultEvent() {
bwEvent
.
onContextMenuCommand
(
sender
,
browser
,
frame
,
params
,
commandId
,
eventFlags
,
result
)
}
})
m
.
chromium
.
SetOnLoadingStateChange
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
isLoading
,
canGoBack
,
canGoForward
bool
)
{
if
bwEvent
.
onLoadingStateChange
!=
nil
{
bwEvent
.
onLoadingStateChange
(
sender
,
browser
,
isLoading
,
canGoBack
,
canGoForward
)
}
})
m
.
chromium
.
SetOnFrameCreated
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
frame
*
ICefFrame
)
{
QueueAsyncCall
(
func
(
id
int
)
{
BrowserWindow
.
putBrowserFrame
(
browser
,
frame
)
...
...
@@ -217,7 +213,6 @@ func (m *ViewsFrameworkBrowserWindow) registerDefaultEvent() {
bwEvent
.
onFrameDetached
(
sender
,
browser
,
frame
)
}
})
m
.
chromium
.
SetOnAfterCreated
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
)
{
if
chromiumOnAfterCreate
(
browser
)
{
return
...
...
@@ -228,25 +223,26 @@ func (m *ViewsFrameworkBrowserWindow) registerDefaultEvent() {
})
//事件可以被覆盖
m
.
chromium
.
SetOnKeyEvent
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
event
*
TCefKeyEvent
,
result
*
bool
)
{
if
api
.
GoBool
(
BrowserWindow
.
Config
.
chromiumConfig
.
enableDevTools
)
{
if
winInfo
:=
BrowserWindow
.
GetWindowInfo
(
browser
.
Identifier
());
winInfo
!=
nil
{
if
winInfo
.
WindowType
()
==
consts
.
WT_DEV_TOOLS
||
winInfo
.
WindowType
()
==
consts
.
WT_VIEW_SOURCE
{
return
if
bwEvent
.
onKeyEvent
!=
nil
{
bwEvent
.
onKeyEvent
(
sender
,
browser
,
event
,
result
)
}
else
{
if
api
.
GoBool
(
BrowserWindow
.
Config
.
chromiumConfig
.
enableDevTools
)
{
if
winInfo
:=
BrowserWindow
.
GetWindowInfo
(
browser
.
Identifier
());
winInfo
!=
nil
{
if
winInfo
.
WindowType
()
==
consts
.
WT_DEV_TOOLS
||
winInfo
.
WindowType
()
==
consts
.
WT_VIEW_SOURCE
{
return
}
}
if
event
.
WindowsKeyCode
==
VkF12
&&
event
.
Kind
==
consts
.
KEYEVENT_RAW_KEYDOWN
{
browser
.
ShowDevTools
()
*
result
=
true
}
else
if
event
.
WindowsKeyCode
==
VkF12
&&
event
.
Kind
==
consts
.
KEYEVENT_KEYUP
{
*
result
=
true
}
}
if
event
.
WindowsKeyCode
==
VkF12
&&
event
.
Kind
==
consts
.
KEYEVENT_RAW_KEYDOWN
{
browser
.
ShowDevTools
()
*
result
=
true
}
else
if
event
.
WindowsKeyCode
==
VkF12
&&
event
.
Kind
==
consts
.
KEYEVENT_KEYUP
{
*
result
=
true
if
KeyAccelerator
.
accelerator
(
browser
,
event
,
result
)
{
return
}
}
if
KeyAccelerator
.
accelerator
(
browser
,
event
,
result
)
{
return
}
if
bwEvent
.
onKeyEvent
!=
nil
{
bwEvent
.
onKeyEvent
(
sender
,
browser
,
event
,
result
)
}
})
m
.
chromium
.
SetOnBeforeBrowser
(
func
(
sender
lcl
.
IObject
,
browser
*
ICefBrowser
,
frame
*
ICefFrame
)
bool
{
chromiumOnBeforeBrowser
(
browser
,
frame
)
...
...
example/mini-browser/src/min-browser.go
浏览文件 @
5f7c0fc9
...
...
@@ -187,6 +187,7 @@ func AppBrowserInit() {
fmt
.
Println
(
"主窗口初始化回调函数"
)
lcl
.
Application
.
Icon
()
.
LoadFromFSFile
(
"resources/icon.ico"
)
//设置应用图标
browserWindow
.
SetCaption
(
"这里设置应用标题"
)
//browserWindow.EnableTransparent(100) //窗口透明
//设置窗口样式,无标题 ,最大化按钮等
//browserWindow.SetBorderStyle(types.BsSingle)
//browserWindow.SetFormStyle(types.FsNormal)
...
...
@@ -194,7 +195,7 @@ func AppBrowserInit() {
//设置窗口大小
//browserWindow.SetWidth(1600)
//browserWindow.SetHeight(900)
//限制窗口大小
linux 下不是很友好
//限制窗口大小
//browserWindow.Window.Constraints().SetMinHeight(300)
//browserWindow.Window.Constraints().SetMinWidth(300)
//browserWindow.Window.Constraints().SetMaxWidth(1600)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录