From 8b26b522f44aff00660b62e602ec46cd53372ffd Mon Sep 17 00:00:00 2001 From: Richard Wilkes Date: Thu, 6 Dec 2018 12:32:11 -0800 Subject: [PATCH] Enable Linux support --- cef/MainArgs.go | 2 ++ cef/WindowInfo_linux.go | 37 ++++++++++++------------------------- internal/cmd/dist.go | 6 +++--- internal/cmd/platform.go | 2 ++ 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/cef/MainArgs.go b/cef/MainArgs.go index 337d504..8cc88b5 100644 --- a/cef/MainArgs.go +++ b/cef/MainArgs.go @@ -3,6 +3,8 @@ package cef import ( // #cgo darwin CFLAGS: -I/usr/local/cef // #cgo darwin LDFLAGS: -framework Cocoa -F/usr/local/cef/Release -framework "Chromium Embedded Framework" + // #cgo linux CFLAGS: -I/usr/local/cef + // #cgo linux LDFLAGS: -L/usr/local/cef/Release -lcef // #cgo windows pkg-config: cef // #cgo windows LDFLAGS: -Wl,--subsystem,windows // #include diff --git a/cef/WindowInfo_linux.go b/cef/WindowInfo_linux.go index 6e94fe4..0179d14 100644 --- a/cef/WindowInfo_linux.go +++ b/cef/WindowInfo_linux.go @@ -19,8 +19,6 @@ type WindowInfo struct { Height int32 // ParentWindow (parent_window) ParentWindow unsafe.Pointer - // Menu (menu) - Menu unsafe.Pointer // WindowlessRenderingEnabled (windowless_rendering_enabled) // Set to true (1) to create the browser using windowless (off-screen) // rendering. No window will be created for the browser and all rendering will @@ -33,31 +31,23 @@ type WindowInfo struct { // Transparent painting is enabled by default but can be disabled by setting // CefBrowserSettings.background_color to an opaque value. WindowlessRenderingEnabled int32 - // SharedTextEnabled (shared_texture_enabled) - // Set to true (1) to enable shared textures for windowless rendering. Only - // valid if windowless_rendering_enabled above is also set to true. Currently - // only supported on Windows (D3D11). - SharedTextureEnabled int32 - // ExternalBeginFrameEnabled (external_begin_frame_enabled) - // Set to true (1) to enable the ability to issue BeginFrame requests from the - // client application by calling CefBrowserHost::SendExternalBeginFrame. - ExternalBeginFrameEnabled int32 // Window (window) // Handle for the new browser window. Only used with windowed rendering. Window unsafe.Pointer } +func (d *WindowInfo) platformInit(parent unsafe.Pointer) { + d.ParentWindow = parent +} + func (d *WindowInfo) toNative(native *C.cef_window_info_t) *C.cef_window_info_t { - native.x = C.int(d.X) - native.y = C.int(d.Y) - native.width = C.int(d.Width) - native.height = C.int(d.Height) - native.parent_window = d.ParentWindow - native.menu = d.Menu + native.x = C.uint(d.X) + native.y = C.uint(d.Y) + native.width = C.uint(d.Width) + native.height = C.uint(d.Height) + native.parent_window = C.ulong(uintptr(d.ParentWindow)) native.windowless_rendering_enabled = C.int(d.WindowlessRenderingEnabled) - native.shared_texture_enabled = C.int(d.SharedTextureEnabled) - native.external_begin_frame_enabled = C.int(d.ExternalBeginFrameEnabled) - native.window = d.Window + native.window = C.ulong(uintptr(d.Window)) return native } @@ -72,10 +62,7 @@ func (n *C.cef_window_info_t) intoGo(d *WindowInfo) { d.Y = int32(n.y) d.Width = int32(n.width) d.Height = int32(n.height) - d.ParentWindow = unsafe.Pointer(n.parent_window) - d.Menu = unsafe.Pointer(n.menu) + d.ParentWindow = unsafe.Pointer(uintptr(n.parent_window)) d.WindowlessRenderingEnabled = int32(n.windowless_rendering_enabled) - d.SharedTextureEnabled = int32(n.shared_texture_enabled) - d.ExternalBeginFrameEnabled = int32(n.external_begin_frame_enabled) - d.Window = unsafe.Pointer(n.window) + d.Window = unsafe.Pointer(uintptr(n.window)) } diff --git a/internal/cmd/dist.go b/internal/cmd/dist.go index da9fa1a..3990abe 100644 --- a/internal/cmd/dist.go +++ b/internal/cmd/dist.go @@ -78,8 +78,8 @@ func (d *dist) Run(cl *cmdline.CmdLine, args []string) error { switch runtime.GOOS { case "darwin": d.distMacOS() - case "windows": - d.distWindows() + case "linux", "windows": + d.distNotMacOS() default: return fmt.Errorf("Unhandled OS: %s", runtime.GOOS) } @@ -190,7 +190,7 @@ func (d *dist) distMacOS() { checkFileError(f.Close(), "write", plist) } -func (d *dist) distWindows() { +func (d *dist) distNotMacOS() { copyDirContents(path.Join(installPrefix, "Release"), d.root) copyDirContents(path.Join(installPrefix, "Resources"), d.root) } diff --git a/internal/cmd/platform.go b/internal/cmd/platform.go index d7fb120..f967090 100644 --- a/internal/cmd/platform.go +++ b/internal/cmd/platform.go @@ -18,6 +18,8 @@ func checkPlatform() { switch runtime.GOOS { case "darwin": cefPlatform = "macosx64" + case "linux": + cefPlatform = "linux64" case "windows": if os.Getenv("MSYSTEM") != "MINGW64" { fmt.Println("Windows is only supported through the use of MINGW64") -- GitLab