-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace use of progrium/macdriver with cgo to allow Apple Silicon builds
- Loading branch information
1 parent
9c27649
commit a1d221a
Showing
34 changed files
with
937 additions
and
1,264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright ©2022 by Richard A. Wilkes. All rights reserved. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, version 2.0. If a copy of the MPL was not distributed with | ||
// this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
// | ||
// This Source Code Form is "Incompatible With Secondary Licenses", as | ||
// defined by the Mozilla Public License, version 2.0. | ||
|
||
package ns | ||
|
||
/* | ||
#import <Cocoa/Cocoa.h> | ||
typedef CFTypeRef NSMenuRef; | ||
typedef CFTypeRef NSMenuItemRef; | ||
*/ | ||
import "C" | ||
|
||
var ( | ||
menuUpdaters = make(map[Menu]func(Menu)) | ||
menuItemValidators = make(map[MenuItem]func(item MenuItem) bool) | ||
menuItemHandlers = make(map[MenuItem]func(item MenuItem)) | ||
openURLsCallback func([]string) | ||
systemThemeChangedCallback func() | ||
) | ||
|
||
//export updateMenuCallback | ||
func updateMenuCallback(m C.NSMenuRef) { | ||
menu := Menu(m) | ||
if updater, ok := menuUpdaters[menu]; ok && updater != nil { | ||
updater(menu) | ||
} | ||
} | ||
|
||
//export menuItemValidateCallback | ||
func menuItemValidateCallback(mi C.NSMenuItemRef) bool { | ||
item := MenuItem(mi) | ||
if validator, ok := menuItemValidators[item]; ok && validator != nil { | ||
return validator(item) | ||
} | ||
return true | ||
} | ||
|
||
//export menuItemHandleCallback | ||
func menuItemHandleCallback(mi C.NSMenuItemRef) { | ||
item := MenuItem(mi) | ||
if handler, ok := menuItemHandlers[item]; ok && handler != nil { | ||
handler(item) | ||
} | ||
} | ||
|
||
//export appOpenURLsCallback | ||
func appOpenURLsCallback(a C.CFArrayRef) { | ||
if openURLsCallback != nil { | ||
if urls := Array(a).ArrayOfURLToStringSlice(); len(urls) > 0 { | ||
openURLsCallback(urls) | ||
} | ||
} | ||
} | ||
|
||
//export themeChangedCallback | ||
func themeChangedCallback() { | ||
if systemThemeChangedCallback != nil { | ||
systemThemeChangedCallback() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.