返回 DeepSeek-Reasonix
ICoreWebView2Controller.go
根目录 / desktop / third_party / go-webview2 / pkg / edge / ICoreWebView2Controller.go
1 //go:build windows
2
3 package edge
4
5 import (
6 "math"
7 "unsafe"
8
9 "github.com/wailsapp/go-webview2/internal/w32"
10 "golang.org/x/sys/windows"
11 )
12
13 type _ICoreWebView2ControllerVtbl struct {
14 _IUnknownVtbl
15 GetIsVisible ComProc
16 PutIsVisible ComProc
17 GetBounds ComProc
18 PutBounds ComProc
19 GetZoomFactor ComProc
20 PutZoomFactor ComProc
21 AddZoomFactorChanged ComProc
22 RemoveZoomFactorChanged ComProc
23 SetBoundsAndZoomFactor ComProc
24 MoveFocus ComProc
25 AddMoveFocusRequested ComProc
26 RemoveMoveFocusRequested ComProc
27 AddGotFocus ComProc
28 RemoveGotFocus ComProc
29 AddLostFocus ComProc
30 RemoveLostFocus ComProc
31 AddAcceleratorKeyPressed ComProc
32 RemoveAcceleratorKeyPressed ComProc
33 GetParentWindow ComProc
34 PutParentWindow ComProc
35 NotifyParentWindowPositionChanged ComProc
36 Close ComProc
37 GetCoreWebView2 ComProc
38 }
39
40 type ICoreWebView2Controller struct {
41 vtbl *_ICoreWebView2ControllerVtbl
42 }
43
44 func (i *ICoreWebView2Controller) AddRef() uintptr {
45 ret, _, _ := i.vtbl.AddRef.Call(uintptr(unsafe.Pointer(i)))
46
47 return ret
48 }
49
50 func (i *ICoreWebView2Controller) Release() uintptr {
51 ret, _, _ := i.vtbl.Release.Call(uintptr(unsafe.Pointer(i)))
52
53 return ret
54 }
55
56 func (i *ICoreWebView2Controller) GetCoreWebView2() (*ICoreWebView2, error) {
57 var wv2Ptr *ICoreWebView2
58 hr, _, _ := i.vtbl.GetCoreWebView2.Call(
59 uintptr(unsafe.Pointer(i)),
60 uintptr(unsafe.Pointer(&wv2Ptr)),
61 )
62 if windows.Handle(hr) != windows.S_OK {
63 return nil, windows.Errno(hr)
64 }
65
66 return wv2Ptr, nil
67 }
68
69 func (i *ICoreWebView2Controller) GetBounds() (*w32.Rect, error) {
70 var bounds w32.Rect
71 hr, _, _ := i.vtbl.GetBounds.Call(
72 uintptr(unsafe.Pointer(i)),
73 uintptr(unsafe.Pointer(&bounds)),
74 )
75 if windows.Handle(hr) != windows.S_OK {
76 return nil, windows.Errno(hr)
77 }
78 return &bounds, nil
79 }
80
81 func (i *ICoreWebView2Controller) PutBounds(bounds w32.Rect) error {
82 hr, _, _ := i.vtbl.PutBounds.Call(
83 uintptr(unsafe.Pointer(i)),
84 uintptr(unsafe.Pointer(&bounds)),
85 )
86 if windows.Handle(hr) != windows.S_OK {
87 return windows.Errno(hr)
88 }
89 return nil
90 }
91
92 func (i *ICoreWebView2Controller) MoveFocus(reason COREWEBVIEW2_MOVE_FOCUS_REASON) error {
93
94 hr, _, _ := i.vtbl.MoveFocus.Call(
95 uintptr(unsafe.Pointer(i)),
96 uintptr(reason),
97 )
98 if windows.Handle(hr) != windows.S_OK {
99 return windows.Errno(hr)
100 }
101 return nil
102 }
103
104 func (i *ICoreWebView2Controller) AddAcceleratorKeyPressed(eventHandler *ICoreWebView2AcceleratorKeyPressedEventHandler, token *_EventRegistrationToken) error {
105
106 hr, _, _ := i.vtbl.AddAcceleratorKeyPressed.Call(
107 uintptr(unsafe.Pointer(i)),
108 uintptr(unsafe.Pointer(eventHandler)),
109 uintptr(unsafe.Pointer(&token)),
110 )
111 if windows.Handle(hr) != windows.S_OK {
112 return windows.Errno(hr)
113 }
114 return nil
115 }
116
117 func (i *ICoreWebView2Controller) PutIsVisible(isVisible bool) error {
118
119 hr, _, _ := i.vtbl.PutIsVisible.Call(
120 uintptr(unsafe.Pointer(i)),
121 uintptr(boolToInt(isVisible)),
122 )
123 if windows.Handle(hr) != windows.S_OK {
124 return windows.Errno(hr)
125 }
126 return nil
127 }
128
129 func (i *ICoreWebView2Controller) GetICoreWebView2Controller2() *ICoreWebView2Controller2 {
130
131 var result *ICoreWebView2Controller2
132
133 iidICoreWebView2Controller2 := NewGUID("{c979903e-d4ca-4228-92eb-47ee3fa96eab}")
134 i.vtbl.QueryInterface.Call(
135 uintptr(unsafe.Pointer(i)),
136 uintptr(unsafe.Pointer(iidICoreWebView2Controller2)),
137 uintptr(unsafe.Pointer(&result)))
138
139 return result
140 }
141
142 func (i *ICoreWebView2Controller) NotifyParentWindowPositionChanged() error {
143
144 hr, _, _ := i.vtbl.NotifyParentWindowPositionChanged.Call(
145 uintptr(unsafe.Pointer(i)),
146 )
147 if windows.Handle(hr) != windows.S_OK {
148 return windows.Errno(hr)
149 }
150 return nil
151 }
152
153 func (i *ICoreWebView2Controller) PutZoomFactor(zoomFactor float64) error {
154
155 hr, _, _ := i.vtbl.PutZoomFactor.Call(
156 uintptr(unsafe.Pointer(i)),
157 uintptr(math.Float64bits(zoomFactor)),
158 )
159 if windows.Handle(hr) != windows.S_OK {
160 return windows.Errno(hr)
161 }
162 return nil
163 }
164
165 func (i *ICoreWebView2Controller) GetZoomFactor() (float64, error) {
166
167 var zoomFactorUint64 uint64
168 hr, _, _ := i.vtbl.GetZoomFactor.Call(
169 uintptr(unsafe.Pointer(i)),
170 uintptr(unsafe.Pointer(&zoomFactorUint64)),
171 )
172 if windows.Handle(hr) != windows.S_OK {
173 return 0.0, windows.Errno(hr)
174 }
175 return math.Float64frombits(zoomFactorUint64), nil
176 }
177
177 lines GO