From ecbecfa40534172bd1d7a43a7f2bc6ecb3e01ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=A2=E5=B2=A9?= Date: Tue, 13 Dec 2022 11:49:32 +0800 Subject: [PATCH] update: window-component,dev --- cef/cef-application.go | 132 ++++++++++++++++++++++++++++++++ cef/cef-events-def.go | 15 ++++ cef/cef-types.go | 8 ++ cef/cef-v8-events.go | 149 ------------------------------------ cef/cef-window-component.go | 134 +++++++++++++++++++++++++------- consts/consts.go | 2 + 6 files changed, 265 insertions(+), 175 deletions(-) delete mode 100644 cef/cef-v8-events.go diff --git a/cef/cef-application.go b/cef/cef-application.go index 60e215a9..d00fce14 100644 --- a/cef/cef-application.go +++ b/cef/cef-application.go @@ -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 + }) +} diff --git a/cef/cef-events-def.go b/cef/cef-events-def.go index cc603cd1..8b0bb8b9 100644 --- a/cef/cef-events-def.go +++ b/cef/cef-events-def.go @@ -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) diff --git a/cef/cef-types.go b/cef/cef-types.go index e89e2931..31b01a3b 100644 --- a/cef/cef-types.go +++ b/cef/cef-types.go @@ -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 } diff --git a/cef/cef-v8-events.go b/cef/cef-v8-events.go deleted file mode 100644 index 8ca3cd8d..00000000 --- a/cef/cef-v8-events.go +++ /dev/null @@ -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 - }) -} diff --git a/cef/cef-window-component.go b/cef/cef-window-component.go index 0b5853e0..0b24229a 100644 --- a/cef/cef-window-component.go +++ b/cef/cef-window-component.go @@ -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 + }) } diff --git a/consts/consts.go b/consts/consts.go index 56c078a2..56dc9f89 100644 --- a/consts/consts.go +++ b/consts/consts.go @@ -603,3 +603,5 @@ const ( CEF_MENU_ANCHOR_TOPRIGHT CEF_MENU_ANCHOR_BOTTOMCENTER ) + +type TCefShowState = int32