Skip to content
This repository has been archived by the owner on Sep 13, 2021. It is now read-only.

Commit

Permalink
Update to CEF 74.1.19+gb62bacf+chromium-74.0.3729.157
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwilkes committed May 28, 2019
1 parent 2628a7c commit cc62893
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 77 deletions.
83 changes: 83 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
run:
deadline: 5m
tests: true
modules-download-mode: readonly
output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
- log
- github.com/satori/go.uuid
errcheck:
check-type-assertions: true
check-blank: true
goconst:
min-len: 3
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- performance
- style
- opinionated
- experimental
disabled-checks:
- sloppyReassign
gofmt:
simplify: true
golint:
min-confidence: 0.8
govet:
check-shadowing: true
maligned:
suggest-new: true
misspell:
locale: US
prealloc:
simple: true
range-loops: true
for-loops: false
unused:
check-exported: false
linters:
disable-all: true
enable:
- deadcode
- depguard
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- maligned
- misspell
- prealloc
- scopelint
- staticcheck
- structcheck
- unconvert
- unused
- varcheck
issues:
max-per-linter: 20
max-same-issues: 3
new: false
exclude-use-default: false
exclude:
- should call os.Exit to set exit code
- "G301: Expect directory permissions to be 0750 or less"
- "G302: Expect file permissions to be 0600 or less"
- "G304: Potential file inclusion via variable"
- "G104: Errors unhandled"
- "G204: Subprocess launched with variable"
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/richardwilkes/webapp

require (
github.com/richardwilkes/cef v0.3.0
github.com/richardwilkes/toolbox v1.5.0
github.com/richardwilkes/win32 v0.0.0-20190406213358-71a843438309
github.com/richardwilkes/cef v0.4.0
github.com/richardwilkes/toolbox v1.6.1
github.com/richardwilkes/win32 v0.0.0-20190428175257-646fcc5380f6
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/richardwilkes/cef v0.3.0 h1:IlFSDGxHd01ZtNGUw1JZ6qvrbWX+cdTfiZvcaRNlX20=
github.com/richardwilkes/cef v0.3.0/go.mod h1:A20cGsTahRTVSl638WMo0xkWkJ7gwG+e/fU0V5nRmmE=
github.com/richardwilkes/toolbox v1.5.0 h1:8HkK68pUD20ZYiSFUWing23bSPkJHuMTkR8TdUzoobA=
github.com/richardwilkes/toolbox v1.5.0/go.mod h1:BhrbXd529SOF8vK4ve7ABji9fvItLH7+5sVpnqVQCvs=
github.com/richardwilkes/win32 v0.0.0-20190406213358-71a843438309 h1:TupC6/xiwVWMV2QW+qlvYQC5hdwjAR9cy+q1LXyiXEQ=
github.com/richardwilkes/win32 v0.0.0-20190406213358-71a843438309/go.mod h1:aftnMEcGujnd5RnximWCiV+XzhCjwJuEY+vZv7/Qabw=
github.com/richardwilkes/cef v0.4.0 h1:b/unhHrLnY+HcqjSjZKC4q+KZ8PVtrCQDt3H/S0dOTs=
github.com/richardwilkes/cef v0.4.0/go.mod h1:swJnlVsiMJGSGeaob9GcDUjDmp8PuzntCRF7Y6St5Z0=
github.com/richardwilkes/toolbox v1.6.1 h1:mC97qYjledp68mpg9yiM25SXYJIjKuvt0s3s0pitmrY=
github.com/richardwilkes/toolbox v1.6.1/go.mod h1:/3ynfaWs6sEF5hZEN3ANCDLOvFwaWmHi1AnlmHmaAqM=
github.com/richardwilkes/win32 v0.0.0-20190428175257-646fcc5380f6 h1:5WQK/z0xgYffAAnjAdLmrx6Xr2jyBQzHxyF8f5xtDj0=
github.com/richardwilkes/win32 v0.0.0-20190428175257-646fcc5380f6/go.mod h1:aftnMEcGujnd5RnximWCiV+XzhCjwJuEY+vZv7/Qabw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc h1:4gbWbmmPFp4ySWICouJl6emP0MyS31yy9SrTlAGFT+g=
golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190520201301-c432e742b0af h1:NXfmMfXz6JqGfG3ikSxcz2N93j6DgScr19Oo2uwFu88=
golang.org/x/sys v0.0.0-20190520201301-c432e742b0af/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
Expand Down
110 changes: 64 additions & 46 deletions internal/macos/menu_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ func (d *driver) MenuInit(menu *webapp.Menu) {
}

func (d *driver) MenuItemAtIndex(menu *webapp.Menu, index int) *webapp.MenuItem {
if item := C.menuItemAtIndex(menu.PlatformData.(C.CMenuPtr), C.int(index)); item != nil {
return d.toMenuItem(item)
if p, ok := menu.PlatformData.(C.CMenuPtr); ok {
if item := C.menuItemAtIndex(p, C.int(index)); item != nil {
return d.toMenuItem(item)
}
}
return nil
}

func (d *driver) MenuItemAtIndexSetTitle(menu *webapp.Menu, index int, title string) {
if item := C.menuItemAtIndex(menu.PlatformData.(C.CMenuPtr), C.int(index)); item != nil {
cTitle := C.CString(title)
C.setMenuItemTitle(item, cTitle)
C.free(unsafe.Pointer(cTitle))
if p, ok := menu.PlatformData.(C.CMenuPtr); ok {
if item := C.menuItemAtIndex(p, C.int(index)); item != nil {
cTitle := C.CString(title)
C.setMenuItemTitle(item, cTitle)
C.free(unsafe.Pointer(cTitle))
}
}
}

Expand All @@ -47,59 +51,73 @@ func (d *driver) toMenuItem(item C.CMenuItemPtr) *webapp.MenuItem {
}

func (d *driver) MenuInsertSeparator(menu *webapp.Menu, beforeIndex int) {
C.insertMenuItem(menu.PlatformData.(C.CMenuPtr), C.newMenuSeparator(), C.int(beforeIndex))
if p, ok := menu.PlatformData.(C.CMenuPtr); ok {
C.insertMenuItem(p, C.newMenuSeparator(), C.int(beforeIndex))
}
}

func (d *driver) MenuInsertItem(menu *webapp.Menu, beforeIndex, id int, title string, key *keys.Key, keyModifiers keys.Modifiers, validator func() bool, handler func()) {
cTitle := C.CString(title)
var keyCodeStr string
if key != nil {
keyCodeStr = key.MacEquiv
}
cKey := C.CString(keyCodeStr)
var needDelegate bool
var selector string
switch id {
case webapp.MenuIDCutItem:
selector = "cut:"
case webapp.MenuIDCopyItem:
selector = "copy:"
case webapp.MenuIDPasteItem:
selector = "paste:"
case webapp.MenuIDDeleteItem:
selector = "delete:"
case webapp.MenuIDSelectAllItem:
selector = "selectAll:"
default:
selector = "handleMenuItem:"
needDelegate = true
if p, ok := menu.PlatformData.(C.CMenuPtr); ok {
cTitle := C.CString(title)
var keyCodeStr string
if key != nil {
keyCodeStr = key.MacEquiv
}
cKey := C.CString(keyCodeStr)
var needDelegate bool
var selector string
switch id {
case webapp.MenuIDCutItem:
selector = "cut:"
case webapp.MenuIDCopyItem:
selector = "copy:"
case webapp.MenuIDPasteItem:
selector = "paste:"
case webapp.MenuIDDeleteItem:
selector = "delete:"
case webapp.MenuIDSelectAllItem:
selector = "selectAll:"
default:
selector = "handleMenuItem:"
needDelegate = true
}
cSelector := C.CString(selector)
mi := C.newMenuItem(C.int(id), cTitle, cSelector, cKey, C.int(keyModifiers), C.bool(needDelegate))
C.free(unsafe.Pointer(cSelector))
C.free(unsafe.Pointer(cKey))
C.free(unsafe.Pointer(cTitle))
C.insertMenuItem(p, mi, C.int(beforeIndex))
d.menuItemValidators[id] = validator
d.menuItemHandlers[id] = handler
}
cSelector := C.CString(selector)
mi := C.newMenuItem(C.int(id), cTitle, cSelector, cKey, C.int(keyModifiers), C.bool(needDelegate))
C.free(unsafe.Pointer(cSelector))
C.free(unsafe.Pointer(cKey))
C.free(unsafe.Pointer(cTitle))
C.insertMenuItem(menu.PlatformData.(C.CMenuPtr), mi, C.int(beforeIndex))
d.menuItemValidators[id] = validator
d.menuItemHandlers[id] = handler
}

func (d *driver) MenuInsertMenu(menu *webapp.Menu, beforeIndex, id int, title string) *webapp.Menu {
cTitle := C.CString(title)
mi := C.newMenuItem(C.int(id), cTitle, handleMenuItemCStr, emptyCStr, 0, true)
C.free(unsafe.Pointer(cTitle))
subMenu := webapp.NewMenu(id, title)
C.setSubMenu(mi, subMenu.PlatformData.(C.CMenuPtr))
C.insertMenuItem(menu.PlatformData.(C.CMenuPtr), mi, C.int(beforeIndex))
return subMenu
if p, ok := menu.PlatformData.(C.CMenuPtr); ok {
cTitle := C.CString(title)
mi := C.newMenuItem(C.int(id), cTitle, handleMenuItemCStr, emptyCStr, 0, true)
C.free(unsafe.Pointer(cTitle))
subMenu := webapp.NewMenu(id, title)
if sp, ok := subMenu.PlatformData.(C.CMenuPtr); ok {
C.setSubMenu(mi, sp)
C.insertMenuItem(p, mi, C.int(beforeIndex))
return subMenu
}
}
return nil
}

func (d *driver) MenuRemove(menu *webapp.Menu, index int) {
C.removeMenuItem(menu.PlatformData.(C.CMenuPtr), C.int(index))
if p, ok := menu.PlatformData.(C.CMenuPtr); ok {
C.removeMenuItem(p, C.int(index))
}
}

func (d *driver) MenuCount(menu *webapp.Menu) int {
return int(C.menuItemCount(menu.PlatformData.(C.CMenuPtr)))
if p, ok := menu.PlatformData.(C.CMenuPtr); ok {
return int(C.menuItemCount(p))
}
return 0
}

func (d *driver) MenuDispose(menu *webapp.Menu) {
Expand Down
51 changes: 31 additions & 20 deletions internal/macos/menubar_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,53 @@ func (d *driver) MenuBarForWindow(_ *webapp.Window) (*webapp.MenuBar, bool, bool
}

func (d *driver) MenuBarMenuAtIndex(bar *webapp.MenuBar, index int) *webapp.Menu {
if item := C.menuItemAtIndex(bar.PlatformData.(C.CMenuPtr), C.int(index)); item != nil {
if menu := C.subMenu(item); menu != nil {
if m, ok := d.menus[menu]; ok {
return m
if p, ok := bar.PlatformData.(C.CMenuPtr); ok {
if item := C.menuItemAtIndex(p, C.int(index)); item != nil {
if menu := C.subMenu(item); menu != nil {
if m, ok := d.menus[menu]; ok {
return m
}
}
}
}
return nil
}

func (d *driver) MenuBarInsert(bar *webapp.MenuBar, beforeIndex int, menu *webapp.Menu) {
if m, ok := menu.PlatformData.(C.CMenuPtr); ok {
cTitle := C.CString(menu.Title)
mi := C.newMenuItem(C.int(menu.ID), cTitle, handleMenuItemCStr, emptyCStr, 0, true)
C.free(unsafe.Pointer(cTitle))
C.setSubMenu(mi, m)
C.insertMenuItem(bar.PlatformData.(C.CMenuPtr), mi, C.int(beforeIndex))
switch menu.ID {
case webapp.MenuIDAppMenu:
if servicesMenu := bar.Menu(webapp.MenuIDServicesMenu); servicesMenu != nil {
C.setServicesMenu(servicesMenu.PlatformData.(C.CMenuPtr))
if p, ok := bar.PlatformData.(C.CMenuPtr); ok {
if m, ok := menu.PlatformData.(C.CMenuPtr); ok {
cTitle := C.CString(menu.Title)
mi := C.newMenuItem(C.int(menu.ID), cTitle, handleMenuItemCStr, emptyCStr, 0, true)
C.free(unsafe.Pointer(cTitle))
C.setSubMenu(mi, m)
C.insertMenuItem(p, mi, C.int(beforeIndex))
switch menu.ID {
case webapp.MenuIDAppMenu:
if servicesMenu := bar.Menu(webapp.MenuIDServicesMenu); servicesMenu != nil {
if sm, ok := servicesMenu.PlatformData.(C.CMenuPtr); ok {
C.setServicesMenu(sm)
}
}
case webapp.MenuIDWindowMenu:
C.setWindowMenu(m)
case webapp.MenuIDHelpMenu:
C.setHelpMenu(m)
}
case webapp.MenuIDWindowMenu:
C.setWindowMenu(m)
case webapp.MenuIDHelpMenu:
C.setHelpMenu(m)
}
}
}

func (d *driver) MenuBarRemove(bar *webapp.MenuBar, index int) {
C.removeMenuItem(bar.PlatformData.(C.CMenuPtr), C.int(index))
if p, ok := bar.PlatformData.(C.CMenuPtr); ok {
C.removeMenuItem(p, C.int(index))
}
}

func (d *driver) MenuBarCount(bar *webapp.MenuBar) int {
return int(C.menuItemCount(bar.PlatformData.(C.CMenuPtr)))
if p, ok := bar.PlatformData.(C.CMenuPtr); ok {
return int(C.menuItemCount(p))
}
return 0
}

func (d *driver) MenuBarHeightInWindow() float64 {
Expand Down

0 comments on commit cc62893

Please sign in to comment.