| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "golang.org/x/sys/windows" |
| 7 | "syscall" |
| 8 | "unsafe" |
| 9 | ) |
| 10 | |
| 11 | type ICoreWebView2Controller4Vtbl struct { |
| 12 | _IUnknownVtbl |
| 13 | GetIsVisible ComProc |
| 14 | PutIsVisible ComProc |
| 15 | GetBounds ComProc |
| 16 | PutBounds ComProc |
| 17 | GetZoomFactor ComProc |
| 18 | PutZoomFactor ComProc |
| 19 | AddZoomFactorChanged ComProc |
| 20 | RemoveZoomFactorChanged ComProc |
| 21 | SetBoundsAndZoomFactor ComProc |
| 22 | MoveFocus ComProc |
| 23 | AddMoveFocusRequested ComProc |
| 24 | RemoveMoveFocusRequested ComProc |
| 25 | AddGotFocus ComProc |
| 26 | RemoveGotFocus ComProc |
| 27 | AddLostFocus ComProc |
| 28 | RemoveLostFocus ComProc |
| 29 | AddAcceleratorKeyPressed ComProc |
| 30 | RemoveAcceleratorKeyPressed ComProc |
| 31 | GetParentWindow ComProc |
| 32 | PutParentWindow ComProc |
| 33 | NotifyParentWindowPositionChanged ComProc |
| 34 | Close ComProc |
| 35 | GetCoreWebView2 ComProc |
| 36 | GetDefaultBackgroundColor ComProc |
| 37 | PutDefaultBackgroundColor ComProc |
| 38 | GetRasterizationScale ComProc |
| 39 | PutRasterizationScale ComProc |
| 40 | GetShouldDetectMonitorScaleChanges ComProc |
| 41 | PutShouldDetectMonitorScaleChanges ComProc |
| 42 | AddRasterizationScaleChanged ComProc |
| 43 | RemoveRasterizationScaleChanged ComProc |
| 44 | GetBoundsMode ComProc |
| 45 | PutBoundsMode ComProc |
| 46 | GetAllowExternalDrop ComProc |
| 47 | PutAllowExternalDrop ComProc |
| 48 | } |
| 49 | |
| 50 | type ICoreWebView2Controller4 struct { |
| 51 | Vtbl *ICoreWebView2Controller4Vtbl |
| 52 | } |
| 53 | |
| 54 | func (i *ICoreWebView2Controller4) AddRef() uintptr { |
| 55 | refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i))) |
| 56 | return refCounter |
| 57 | } |
| 58 | |
| 59 | func (i *ICoreWebView2Controller) GetICoreWebView2Controller4() *ICoreWebView2Controller4 { |
| 60 | var result *ICoreWebView2Controller4 |
| 61 | |
| 62 | iidICoreWebView2Controller4 := NewGUID("{97d418d5-a426-4e49-a151-e1a10f327d9e}") |
| 63 | _, _, _ = i.vtbl.QueryInterface.Call( |
| 64 | uintptr(unsafe.Pointer(i)), |
| 65 | uintptr(unsafe.Pointer(iidICoreWebView2Controller4)), |
| 66 | uintptr(unsafe.Pointer(&result))) |
| 67 | |
| 68 | return result |
| 69 | } |
| 70 | |
| 71 | func (i *ICoreWebView2Controller4) GetAllowExternalDrop() (bool, error) { |
| 72 | // Create int32 to hold bool result |
| 73 | var _value int32 |
| 74 | |
| 75 | hr, _, _ := i.Vtbl.GetAllowExternalDrop.Call( |
| 76 | uintptr(unsafe.Pointer(i)), |
| 77 | uintptr(unsafe.Pointer(&_value)), |
| 78 | ) |
| 79 | if windows.Handle(hr) != windows.S_OK { |
| 80 | return false, syscall.Errno(hr) |
| 81 | } |
| 82 | // Get result and cleanup |
| 83 | value := _value != 0 |
| 84 | return value, nil |
| 85 | } |
| 86 | |
| 87 | func (i *ICoreWebView2Controller4) PutAllowExternalDrop(value bool) error { |
| 88 | |
| 89 | hr, _, _ := i.Vtbl.PutAllowExternalDrop.Call( |
| 90 | uintptr(unsafe.Pointer(i)), |
| 91 | uintptr(boolToInt(value)), |
| 92 | ) |
| 93 | if windows.Handle(hr) != windows.S_OK { |
| 94 | return syscall.Errno(hr) |
| 95 | } |
| 96 | return nil |
| 97 | } |
| 98 |