mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 19:57:48 +08:00
update: window-component,dev
This commit is contained in:
parent
6f1cbc47fc
commit
ecbecfa405
@ -9,10 +9,14 @@
|
||||
package cef
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "github.com/energye/energy/common"
|
||||
. "github.com/energye/energy/consts"
|
||||
"github.com/energye/energy/ipc"
|
||||
"github.com/energye/energy/logger"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
"strings"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@ -149,3 +153,131 @@ func (m *TCEFApplication) SetOnLoadingStateChange(fn GlobalCEFAppEventOnRenderLo
|
||||
func (m *TCEFApplication) SetOnGetDefaultClient(fn GlobalCEFAppEventOnGetDefaultClient) {
|
||||
Proc(internale_CEFGlobalApp_SetOnGetDefaultClient).Call(api.MakeEventDataPtr(fn))
|
||||
}
|
||||
|
||||
func init() {
|
||||
lcl.RegisterExtEventCallback(func(fn interface{}, getVal func(idx int) uintptr) bool {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logger.Error("GlobalCEFApp Error:", err)
|
||||
}
|
||||
}()
|
||||
getPtr := func(i int) unsafe.Pointer {
|
||||
return unsafe.Pointer(getVal(i))
|
||||
}
|
||||
switch fn.(type) {
|
||||
case GlobalCEFAppEventOnBrowserDestroyed:
|
||||
fn.(GlobalCEFAppEventOnBrowserDestroyed)(&ICefBrowser{browseId: int32(getVal(0))})
|
||||
case GlobalCEFAppEventOnRenderLoadStart:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadStart)(browser, frame, TCefTransitionType(getVal(2)))
|
||||
case GlobalCEFAppEventOnRenderLoadEnd:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadEnd)(browser, frame, int32(getVal(2)))
|
||||
case GlobalCEFAppEventOnRenderLoadError:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadError)(browser, frame, TCefErrorCode(getVal(2)), api.GoStr(getVal(3)), api.GoStr(getVal(4)))
|
||||
case GlobalCEFAppEventOnRenderLoadingStateChange:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadingStateChange)(browser, frame, api.GoBool(getVal(2)), api.GoBool(getVal(3)), api.GoBool(getVal(4)))
|
||||
case RenderProcessMessageReceived:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
cefProcMsg := (*ipc.CefProcessMessagePtr)(getPtr(3))
|
||||
args := ipc.NewArgumentList()
|
||||
args.UnPackageBytePtr(cefProcMsg.Data, int32(cefProcMsg.DataLen))
|
||||
processMessage := &ipc.ICefProcessMessage{
|
||||
Name: api.GoStr(cefProcMsg.Name),
|
||||
ArgumentList: args,
|
||||
}
|
||||
var result = (*bool)(getPtr(4))
|
||||
*result = fn.(RenderProcessMessageReceived)(browser, frame, CefProcessId(getVal(2)), processMessage)
|
||||
args.Clear()
|
||||
cefProcMsg.Data = 0
|
||||
cefProcMsg.DataLen = 0
|
||||
cefProcMsg.Name = 0
|
||||
cefProcMsg = nil
|
||||
args = nil
|
||||
case GlobalCEFAppEventOnContextCreated:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
if strings.Index(frame.Url, "devtools://") == 0 {
|
||||
processName = PT_DEVTOOLS
|
||||
return true
|
||||
} else {
|
||||
processName = Args.ProcessType()
|
||||
}
|
||||
v8ctx := (*cefV8Context)(getPtr(2))
|
||||
ctx := &ICefV8Context{
|
||||
Browser: browser,
|
||||
Frame: frame,
|
||||
Global: &ICEFv8Value{instance: v8ctx.Global, ptr: unsafe.Pointer(v8ctx.Global)},
|
||||
}
|
||||
var status = (*bool)(getPtr(3))
|
||||
//用户定义返回 false 创建 render IPC 及 变量绑定
|
||||
var result = fn.(GlobalCEFAppEventOnContextCreated)(browser, frame, ctx)
|
||||
if !result {
|
||||
cefAppContextCreated(browser, frame)
|
||||
*status = true
|
||||
} else {
|
||||
*status = false
|
||||
}
|
||||
case GlobalCEFAppEventOnWebKitInitialized:
|
||||
fn.(GlobalCEFAppEventOnWebKitInitialized)()
|
||||
case GlobalCEFAppEventOnBeforeChildProcessLaunch:
|
||||
commands := (*uintptr)(getPtr(0))
|
||||
commandLine := &TCefCommandLine{commandLines: make(map[string]string)}
|
||||
ipc.IPC.SetPort()
|
||||
commandLine.AppendSwitch(MAINARGS_NETIPCPORT, fmt.Sprintf("%d", ipc.IPC.Port()))
|
||||
fn.(GlobalCEFAppEventOnBeforeChildProcessLaunch)(commandLine)
|
||||
*commands = api.PascalStr(commandLine.toString())
|
||||
case GlobalCEFAppEventOnGetDefaultClient:
|
||||
client := (*uintptr)(getPtr(0))
|
||||
getClient := &ICefClient{instance: unsafe.Pointer(client)}
|
||||
fn.(GlobalCEFAppEventOnGetDefaultClient)(getClient)
|
||||
*client = uintptr(getClient.instance)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
@ -113,3 +113,18 @@ type ChromiumEventOnOpenUrlFromTab func(sender lcl.IObject, browser *ICefBrowser
|
||||
type TCloseEvent func(sender lcl.IObject, action *types.TCloseAction) bool
|
||||
type TNotifyEvent func(sender lcl.IObject) bool
|
||||
type TCloseQueryEvent func(sender lcl.IObject, canClose *bool) bool
|
||||
|
||||
//TCEFWindowComponent
|
||||
type WindowComponentOnWindowCreated func(sender lcl.IObject, window *ICefWindow)
|
||||
type WindowComponentOnWindowDestroyed func(sender lcl.IObject, window *ICefWindow)
|
||||
type WindowComponentOnWindowActivationChanged func(sender lcl.IObject, window *ICefWindow, active bool)
|
||||
type WindowComponentOnGetParentWindow func(sender lcl.IObject, window *ICefWindow, isMenu, canActivateMenu *bool, aResult *ICefWindow)
|
||||
type WindowComponentOnGetInitialBounds func(sender lcl.IObject, window *ICefWindow, aResult *TCefRect)
|
||||
type WindowComponentOnGetInitialShowState func(sender lcl.IObject, window *ICefWindow, aResult *TCefShowState)
|
||||
type WindowComponentOnIsFrameless func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
||||
type WindowComponentOnCanResize func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
||||
type WindowComponentOnCanMaximize func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
||||
type WindowComponentOnCanMinimize func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
||||
type WindowComponentOnCanClose func(sender lcl.IObject, window *ICefWindow, aResult *bool)
|
||||
type WindowComponentOnAccelerator func(sender lcl.IObject, window *ICefWindow, commandId int32, aResult *bool)
|
||||
type WindowComponentOnKeyEvent func(sender lcl.IObject, window *ICefWindow, event *TCefKeyEvent, aResult *bool)
|
||||
|
@ -162,10 +162,18 @@ type ICefDisplay struct {
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
type ICefWindow struct {
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
type ICefClient struct {
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
func (m *ICefWindow) SetWindow(window *ICefWindow) {
|
||||
m.instance = window.instance
|
||||
}
|
||||
|
||||
func (m *ICefClient) SetClient(client *ICefClient) {
|
||||
m.instance = client.instance
|
||||
}
|
||||
|
@ -1,149 +0,0 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package cef
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "github.com/energye/energy/common"
|
||||
. "github.com/energye/energy/consts"
|
||||
"github.com/energye/energy/ipc"
|
||||
"github.com/energye/energy/logger"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
"strings"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func init() {
|
||||
lcl.RegisterExtEventCallback(func(fn interface{}, getVal func(idx int) uintptr) bool {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logger.Error("v8event Error:", err)
|
||||
}
|
||||
}()
|
||||
getPtr := func(i int) unsafe.Pointer {
|
||||
return unsafe.Pointer(getVal(i))
|
||||
}
|
||||
switch fn.(type) {
|
||||
case GlobalCEFAppEventOnBrowserDestroyed:
|
||||
fn.(GlobalCEFAppEventOnBrowserDestroyed)(&ICefBrowser{browseId: int32(getVal(0))})
|
||||
case GlobalCEFAppEventOnRenderLoadStart:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadStart)(browser, frame, TCefTransitionType(getVal(2)))
|
||||
case GlobalCEFAppEventOnRenderLoadEnd:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadEnd)(browser, frame, int32(getVal(2)))
|
||||
case GlobalCEFAppEventOnRenderLoadError:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadError)(browser, frame, TCefErrorCode(getVal(2)), api.GoStr(getVal(3)), api.GoStr(getVal(4)))
|
||||
case GlobalCEFAppEventOnRenderLoadingStateChange:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
fn.(GlobalCEFAppEventOnRenderLoadingStateChange)(browser, frame, api.GoBool(getVal(2)), api.GoBool(getVal(3)), api.GoBool(getVal(4)))
|
||||
case RenderProcessMessageReceived:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
cefProcMsg := (*ipc.CefProcessMessagePtr)(getPtr(3))
|
||||
args := ipc.NewArgumentList()
|
||||
args.UnPackageBytePtr(cefProcMsg.Data, int32(cefProcMsg.DataLen))
|
||||
processMessage := &ipc.ICefProcessMessage{
|
||||
Name: api.GoStr(cefProcMsg.Name),
|
||||
ArgumentList: args,
|
||||
}
|
||||
var result = (*bool)(getPtr(4))
|
||||
*result = fn.(RenderProcessMessageReceived)(browser, frame, CefProcessId(getVal(2)), processMessage)
|
||||
args.Clear()
|
||||
cefProcMsg.Data = 0
|
||||
cefProcMsg.DataLen = 0
|
||||
cefProcMsg.Name = 0
|
||||
cefProcMsg = nil
|
||||
args = nil
|
||||
case GlobalCEFAppEventOnContextCreated:
|
||||
browser := &ICefBrowser{browseId: int32(getVal(0))}
|
||||
tempFrame := (*cefFrame)(getPtr(1))
|
||||
frame := &ICefFrame{
|
||||
Browser: browser,
|
||||
Name: api.GoStr(tempFrame.Name),
|
||||
Url: api.GoStr(tempFrame.Url),
|
||||
Id: StrToInt64(api.GoStr(tempFrame.Identifier)),
|
||||
}
|
||||
if strings.Index(frame.Url, "devtools://") == 0 {
|
||||
processName = PT_DEVTOOLS
|
||||
return true
|
||||
} else {
|
||||
processName = Args.ProcessType()
|
||||
}
|
||||
v8ctx := (*cefV8Context)(getPtr(2))
|
||||
ctx := &ICefV8Context{
|
||||
Browser: browser,
|
||||
Frame: frame,
|
||||
Global: &ICEFv8Value{instance: v8ctx.Global, ptr: unsafe.Pointer(v8ctx.Global)},
|
||||
}
|
||||
var status = (*bool)(getPtr(3))
|
||||
//用户定义返回 false 创建 render IPC 及 变量绑定
|
||||
var result = fn.(GlobalCEFAppEventOnContextCreated)(browser, frame, ctx)
|
||||
if !result {
|
||||
cefAppContextCreated(browser, frame)
|
||||
*status = true
|
||||
} else {
|
||||
*status = false
|
||||
}
|
||||
case GlobalCEFAppEventOnWebKitInitialized:
|
||||
fn.(GlobalCEFAppEventOnWebKitInitialized)()
|
||||
case GlobalCEFAppEventOnBeforeChildProcessLaunch:
|
||||
commands := (*uintptr)(getPtr(0))
|
||||
commandLine := &TCefCommandLine{commandLines: make(map[string]string)}
|
||||
ipc.IPC.SetPort()
|
||||
commandLine.AppendSwitch(MAINARGS_NETIPCPORT, fmt.Sprintf("%d", ipc.IPC.Port()))
|
||||
fn.(GlobalCEFAppEventOnBeforeChildProcessLaunch)(commandLine)
|
||||
*commands = api.PascalStr(commandLine.toString())
|
||||
case GlobalCEFAppEventOnGetDefaultClient:
|
||||
client := (*uintptr)(getPtr(0))
|
||||
getClient := &ICefClient{instance: unsafe.Pointer(client)}
|
||||
fn.(GlobalCEFAppEventOnGetDefaultClient)(getClient)
|
||||
*client = uintptr(getClient.instance)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
. "github.com/energye/energy/common"
|
||||
"github.com/energye/energy/consts"
|
||||
"github.com/energye/energy/logger"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
"unsafe"
|
||||
@ -178,42 +179,123 @@ func (m *TCEFWindowComponent) IsMinimized() bool {
|
||||
return api.GoBool(r1)
|
||||
}
|
||||
|
||||
func (m *TCEFWindowComponent) SetOnWindowCreated() {
|
||||
Proc(internale_CEFWindowComponent_SetOnWindowCreated).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnWindowCreated(fn WindowComponentOnWindowCreated) {
|
||||
Proc(internale_CEFWindowComponent_SetOnWindowCreated).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnWindowDestroyed() {
|
||||
Proc(internale_CEFWindowComponent_SetOnWindowDestroyed).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnWindowDestroyed(fn WindowComponentOnWindowDestroyed) {
|
||||
Proc(internale_CEFWindowComponent_SetOnWindowDestroyed).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnWindowActivationChanged() {
|
||||
Proc(internale_CEFWindowComponent_SetOnWindowActivationChanged).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnWindowActivationChanged(fn WindowComponentOnWindowActivationChanged) {
|
||||
Proc(internale_CEFWindowComponent_SetOnWindowActivationChanged).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnGetParentWindow() {
|
||||
Proc(internale_CEFWindowComponent_SetOnGetParentWindow).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnGetParentWindow(fn WindowComponentOnGetParentWindow) {
|
||||
Proc(internale_CEFWindowComponent_SetOnGetParentWindow).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnGetInitialBounds() {
|
||||
Proc(internale_CEFWindowComponent_SetOnGetInitialBounds).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnGetInitialBounds(fn WindowComponentOnGetInitialBounds) {
|
||||
Proc(internale_CEFWindowComponent_SetOnGetInitialBounds).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnGetInitialShowState() {
|
||||
Proc(internale_CEFWindowComponent_SetOnGetInitialShowState).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnGetInitialShowState(fn WindowComponentOnGetInitialShowState) {
|
||||
Proc(internale_CEFWindowComponent_SetOnGetInitialShowState).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnIsFrameless() {
|
||||
Proc(internale_CEFWindowComponent_SetOnIsFrameless).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnIsFrameless(fn WindowComponentOnIsFrameless) {
|
||||
Proc(internale_CEFWindowComponent_SetOnIsFrameless).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnCanResize() {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanResize).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnCanResize(fn WindowComponentOnCanResize) {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanResize).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnCanMaximize() {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanMaximize).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnCanMaximize(fn WindowComponentOnCanMaximize) {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanMaximize).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnCanMinimize() {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanMinimize).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnCanMinimize(fn WindowComponentOnCanMinimize) {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanMinimize).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnCanClose() {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanClose).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnCanClose(fn WindowComponentOnCanClose) {
|
||||
Proc(internale_CEFWindowComponent_SetOnCanClose).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnAccelerator() {
|
||||
Proc(internale_CEFWindowComponent_SetOnAccelerator).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnAccelerator(fn WindowComponentOnAccelerator) {
|
||||
Proc(internale_CEFWindowComponent_SetOnAccelerator).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
func (m *TCEFWindowComponent) SetOnKeyEvent() {
|
||||
Proc(internale_CEFWindowComponent_SetOnKeyEvent).Call(uintptr(m.instance))
|
||||
func (m *TCEFWindowComponent) SetOnKeyEvent(fn WindowComponentOnKeyEvent) {
|
||||
Proc(internale_CEFWindowComponent_SetOnKeyEvent).Call(uintptr(m.instance), api.MakeEventDataPtr(fn))
|
||||
}
|
||||
|
||||
func init() {
|
||||
lcl.RegisterExtEventCallback(func(fn interface{}, getVal func(idx int) uintptr) bool {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logger.Error("v8event Error:", err)
|
||||
}
|
||||
}()
|
||||
getPtr := func(i int) unsafe.Pointer {
|
||||
return unsafe.Pointer(getVal(i))
|
||||
}
|
||||
switch fn.(type) {
|
||||
case WindowComponentOnWindowCreated:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnWindowCreated)(lcl.AsObject(sender), &ICefWindow{instance: window})
|
||||
case WindowComponentOnWindowDestroyed:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnWindowDestroyed)(lcl.AsObject(sender), &ICefWindow{instance: window})
|
||||
case WindowComponentOnWindowActivationChanged:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnWindowActivationChanged)(lcl.AsObject(sender), &ICefWindow{instance: window}, api.GoBool(getVal(2)))
|
||||
case WindowComponentOnGetParentWindow:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
resultWindowPtr := (*uintptr)(getPtr(4))
|
||||
resultWindow := &ICefWindow{}
|
||||
fn.(WindowComponentOnGetParentWindow)(lcl.AsObject(sender), &ICefWindow{instance: window}, (*bool)(getPtr(2)), (*bool)(getPtr(3)), resultWindow)
|
||||
*resultWindowPtr = uintptr(resultWindow.instance)
|
||||
case WindowComponentOnGetInitialBounds:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
resultRectPtr := (*tCefRect)(getPtr(2))
|
||||
resultRect := &TCefRect{}
|
||||
fn.(WindowComponentOnGetInitialBounds)(lcl.AsObject(sender), &ICefWindow{instance: window}, resultRect)
|
||||
resultRectPtr.X = uintptr(resultRect.X)
|
||||
resultRectPtr.Y = uintptr(resultRect.Y)
|
||||
resultRectPtr.Width = uintptr(resultRect.Width)
|
||||
resultRectPtr.Height = uintptr(resultRect.Height)
|
||||
case WindowComponentOnGetInitialShowState:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
resultShowState := (*consts.TCefShowState)(getPtr(2))
|
||||
fn.(WindowComponentOnGetInitialShowState)(lcl.AsObject(sender), &ICefWindow{instance: window}, resultShowState)
|
||||
case WindowComponentOnIsFrameless:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnIsFrameless)(lcl.AsObject(sender), &ICefWindow{instance: window}, (*bool)(getPtr(2)))
|
||||
case WindowComponentOnCanResize:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnCanResize)(lcl.AsObject(sender), &ICefWindow{instance: window}, (*bool)(getPtr(2)))
|
||||
case WindowComponentOnCanMaximize:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnCanMaximize)(lcl.AsObject(sender), &ICefWindow{instance: window}, (*bool)(getPtr(2)))
|
||||
case WindowComponentOnCanMinimize:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnCanMinimize)(lcl.AsObject(sender), &ICefWindow{instance: window}, (*bool)(getPtr(2)))
|
||||
case WindowComponentOnCanClose:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnCanClose)(lcl.AsObject(sender), &ICefWindow{instance: window}, (*bool)(getPtr(2)))
|
||||
case WindowComponentOnAccelerator:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
fn.(WindowComponentOnAccelerator)(lcl.AsObject(sender), &ICefWindow{instance: window}, int32(getVal(2)), (*bool)(getPtr(3)))
|
||||
case WindowComponentOnKeyEvent:
|
||||
sender := getPtr(0)
|
||||
window := getPtr(1)
|
||||
keyEvent := (*TCefKeyEvent)(getPtr(2))
|
||||
fn.(WindowComponentOnKeyEvent)(lcl.AsObject(sender), &ICefWindow{instance: window}, keyEvent, (*bool)(getPtr(3)))
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
@ -603,3 +603,5 @@ const (
|
||||
CEF_MENU_ANCHOR_TOPRIGHT
|
||||
CEF_MENU_ANCHOR_BOTTOMCENTER
|
||||
)
|
||||
|
||||
type TCefShowState = int32
|
||||
|
Loading…
Reference in New Issue
Block a user