forked from cztomczak/cef2go
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcef_darwin.go
59 lines (49 loc) · 1.56 KB
/
cef_darwin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2014 The cef2go authors. All rights reserved.
// License: BSD 3-clause.
// Website: https://github.com/CzarekTomczak/cef2go
package cef2go
/*
#cgo CFLAGS: -I. -x objective-c
#cgo LDFLAGS: -framework Cocoa
#include <stdlib.h>
#include <string.h>
#include "include/capi/cef_app_capi.h"
#include <Cocoa/Cocoa.h>
NSRect GetWindowBounds(void* view) {
[NSAutoreleasePool new];
NSView* nsView = (__bridge NSView*)view;
return [nsView bounds];
}
*/
import "C"
import "unsafe"
import (
"os"
)
var _Argv []*C.char = make([]*C.char, len(os.Args))
func FillMainArgs(mainArgs *C.struct__cef_main_args_t,
appHandle unsafe.Pointer) {
// On Mac appHandle is nil.
Logger.Infof("FillMainArgs, argc=%s", len(os.Args))
for i, arg := range os.Args {
_Argv[C.int(i)] = C.CString(arg)
}
mainArgs.argc = C.int(len(os.Args))
mainArgs.argv = &_Argv[0]
}
func FillWindowInfo(windowInfo *C.cef_window_info_t, hwnd unsafe.Pointer) {
Logger.Infof("FillWindowInfo")
// Setting title isn't required for the CEF inner window.
// --
// var windowName *C.char = C.CString("TODO Darwin example")
// defer C.free(unsafe.Pointer(windowName))
// C.cef_string_from_utf8(windowName, C.strlen(windowName),
// &windowInfo.window_name)
var bounds C.NSRect = C.GetWindowBounds(hwnd)
windowInfo.x = C.int(bounds.origin.x)
windowInfo.y = C.int(bounds.origin.y)
windowInfo.width = C.int(bounds.size.width)
windowInfo.height = C.int(bounds.size.height)
// parent
windowInfo.parent_view = hwnd
}