mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Refactor message processing functions
This commit is contained in:
parent
dad7798da9
commit
f84c4aca72
9 changed files with 198 additions and 122 deletions
|
|
@ -2,4 +2,9 @@ module github.com/wailsapp/wails/exp
|
|||
|
||||
go 1.19
|
||||
|
||||
require github.com/leaanthony/clir v1.3.0
|
||||
require (
|
||||
github.com/leaanthony/clir v1.3.0
|
||||
github.com/samber/lo v1.36.0
|
||||
)
|
||||
|
||||
require golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
|
||||
|
|
|
|||
|
|
@ -1,2 +1,11 @@
|
|||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/leaanthony/clir v1.3.0 h1:L9nPDWrmc/qU9UWZZvRaFajWYuO0np9V5p+5gxyYno0=
|
||||
github.com/leaanthony/clir v1.3.0/go.mod h1:k/RBkdkFl18xkkACMCLt09bhiZnrGORoxmomeMvDpE0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/samber/lo v1.36.0 h1:4LaOxH1mHnbDGhTVE0i1z8v/lWaQW8AIfOD3HU4mSaw=
|
||||
github.com/samber/lo v1.36.0/go.mod h1:HLeWcJRRyLKp3+/XBJvOrerCQn9mhdKMHyd7IRlgeQ8=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
[NSApp activateIgnoringOtherApps:YES];
|
||||
|
||||
//callOnApplicationDidFinishLaunchingHandler();
|
||||
applicationEventHandler(EventApplicationDidFinishLaunching);
|
||||
processApplicationEvent(EventApplicationDidFinishLaunching);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -28,79 +28,79 @@
|
|||
|
||||
// GENERATED EVENTS START
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidBecomeActive);
|
||||
processApplicationEvent(EventApplicationDidBecomeActive);
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeBackingProperties:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidChangeBackingProperties);
|
||||
processApplicationEvent(EventApplicationDidChangeBackingProperties);
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeEffectiveAppearance:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidChangeEffectiveAppearance);
|
||||
processApplicationEvent(EventApplicationDidChangeEffectiveAppearance);
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeIcon:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidChangeIcon);
|
||||
processApplicationEvent(EventApplicationDidChangeIcon);
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeOcclusionState:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidChangeOcclusionState);
|
||||
processApplicationEvent(EventApplicationDidChangeOcclusionState);
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeScreenParameters:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidChangeScreenParameters);
|
||||
processApplicationEvent(EventApplicationDidChangeScreenParameters);
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeStatusBarFrame:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidChangeStatusBarFrame);
|
||||
processApplicationEvent(EventApplicationDidChangeStatusBarFrame);
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidChangeStatusBarOrientation);
|
||||
processApplicationEvent(EventApplicationDidChangeStatusBarOrientation);
|
||||
}
|
||||
|
||||
- (void)applicationDidHide:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidHide);
|
||||
processApplicationEvent(EventApplicationDidHide);
|
||||
}
|
||||
|
||||
- (void)applicationDidResignActive:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidResignActive);
|
||||
processApplicationEvent(EventApplicationDidResignActive);
|
||||
}
|
||||
|
||||
- (void)applicationDidUnhide:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidUnhide);
|
||||
processApplicationEvent(EventApplicationDidUnhide);
|
||||
}
|
||||
|
||||
- (void)applicationDidUpdate:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationDidUpdate);
|
||||
processApplicationEvent(EventApplicationDidUpdate);
|
||||
}
|
||||
|
||||
- (void)applicationWillBecomeActive:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationWillBecomeActive);
|
||||
processApplicationEvent(EventApplicationWillBecomeActive);
|
||||
}
|
||||
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationWillFinishLaunching);
|
||||
processApplicationEvent(EventApplicationWillFinishLaunching);
|
||||
}
|
||||
|
||||
- (void)applicationWillHide:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationWillHide);
|
||||
processApplicationEvent(EventApplicationWillHide);
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationWillResignActive);
|
||||
processApplicationEvent(EventApplicationWillResignActive);
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationWillTerminate);
|
||||
processApplicationEvent(EventApplicationWillTerminate);
|
||||
}
|
||||
|
||||
- (void)applicationWillUnhide:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationWillUnhide);
|
||||
processApplicationEvent(EventApplicationWillUnhide);
|
||||
}
|
||||
|
||||
- (void)applicationWillUpdate:(NSNotification *)notification {
|
||||
applicationEventHandler(EventApplicationWillUpdate);
|
||||
processApplicationEvent(EventApplicationWillUpdate);
|
||||
}
|
||||
|
||||
// GENERATED EVENTS END
|
||||
|
|
|
|||
|
|
@ -12,17 +12,18 @@ func init() {
|
|||
runtime.LockOSThread()
|
||||
}
|
||||
|
||||
type platformApp interface {
|
||||
run() error
|
||||
destroy()
|
||||
}
|
||||
|
||||
// Messages sent from javascript get routed here
|
||||
type windowMessage struct {
|
||||
windowId uint
|
||||
message string
|
||||
}
|
||||
|
||||
var messageBuffer = make(chan *windowMessage)
|
||||
|
||||
type Application interface {
|
||||
Run() error
|
||||
}
|
||||
var windowMessageBuffer = make(chan *windowMessage)
|
||||
|
||||
type App struct {
|
||||
options *options.Application
|
||||
|
|
@ -46,6 +47,9 @@ type App struct {
|
|||
|
||||
// Running
|
||||
running bool
|
||||
|
||||
// platform app
|
||||
app platformApp
|
||||
}
|
||||
|
||||
func (a *App) getSystemTrayID() uint {
|
||||
|
|
@ -122,8 +126,8 @@ func (a *App) Run() error {
|
|||
}()
|
||||
go func() {
|
||||
for {
|
||||
event := <-messageBuffer
|
||||
a.handleMessage(event)
|
||||
event := <-windowMessageBuffer
|
||||
a.handleWindowMessage(event)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
@ -147,7 +151,17 @@ func (a *App) Run() error {
|
|||
return a.run()
|
||||
}
|
||||
|
||||
func (a *App) handleMessage(event *windowMessage) {
|
||||
func (a *App) handleApplicationEvent(event uint) {
|
||||
listeners, ok := a.applicationEventListeners[event]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for _, listener := range listeners {
|
||||
go listener()
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) handleWindowMessage(event *windowMessage) {
|
||||
// Get window from window map
|
||||
a.windowsLock.Lock()
|
||||
window, ok := a.windows[event.windowId]
|
||||
|
|
@ -180,3 +194,26 @@ func (a *App) handleMenuItemClicked(menuItemID uint) {
|
|||
}
|
||||
menuItem.handleClick()
|
||||
}
|
||||
|
||||
func (a *App) Quit() {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
a.windowsLock.Lock()
|
||||
for _, window := range a.windows {
|
||||
window.Destroy()
|
||||
}
|
||||
a.windowsLock.Unlock()
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
a.systemTraysLock.Lock()
|
||||
for _, systray := range a.systemTrays {
|
||||
systray.Destroy()
|
||||
}
|
||||
a.systemTraysLock.Unlock()
|
||||
wg.Done()
|
||||
}()
|
||||
wg.Wait()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,19 @@ import (
|
|||
"github.com/wailsapp/wails/exp/pkg/options"
|
||||
)
|
||||
|
||||
func New(options *options.Application) *App {
|
||||
func New() *App {
|
||||
C.Init()
|
||||
return newApp()
|
||||
}
|
||||
|
||||
func newApp() *App {
|
||||
return &App{
|
||||
applicationEventListeners: make(map[uint][]func()),
|
||||
systemTrays: make(map[uint]*SystemTray),
|
||||
}
|
||||
}
|
||||
|
||||
func NewWithOptions(options *options.Application) *App {
|
||||
C.Init()
|
||||
if options.Mac != nil {
|
||||
C.SetActivationPolicy(C.int(options.Mac.ActivationPolicy))
|
||||
|
|
@ -31,23 +43,13 @@ func (a *App) run() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *App) handleApplicationEvent(event uint) {
|
||||
listeners, ok := a.applicationEventListeners[event]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for _, listener := range listeners {
|
||||
go listener()
|
||||
}
|
||||
}
|
||||
|
||||
//export applicationEventHandler
|
||||
func applicationEventHandler(eventID C.uint) {
|
||||
//export processApplicationEvent
|
||||
func processApplicationEvent(eventID C.uint) {
|
||||
applicationEvents <- uint(eventID)
|
||||
}
|
||||
|
||||
//export windowEventHandler
|
||||
func windowEventHandler(windowID C.uint, eventID C.uint) {
|
||||
//export processWindowEvent
|
||||
func processWindowEvent(windowID C.uint, eventID C.uint) {
|
||||
windowEvents <- &WindowEvent{
|
||||
WindowID: uint(windowID),
|
||||
EventID: uint(eventID),
|
||||
|
|
@ -56,7 +58,7 @@ func windowEventHandler(windowID C.uint, eventID C.uint) {
|
|||
|
||||
//export processMessage
|
||||
func processMessage(windowID C.uint, message *C.char) {
|
||||
messageBuffer <- &windowMessage{
|
||||
windowMessageBuffer <- &windowMessage{
|
||||
windowId: uint(windowID),
|
||||
message: C.GoString(message),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ type windowImpl interface {
|
|||
width() int
|
||||
height() int
|
||||
position() (int, int)
|
||||
destroy()
|
||||
}
|
||||
|
||||
type Window struct {
|
||||
|
|
@ -281,3 +282,10 @@ func (w *Window) Position() (int, int) {
|
|||
}
|
||||
return w.impl.position()
|
||||
}
|
||||
|
||||
func (w *Window) Destroy() {
|
||||
if w.impl == nil {
|
||||
return
|
||||
}
|
||||
w.impl.destroy()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,6 +451,17 @@ void windowGetPosition(void* nsWindow, int* x, int* y) {
|
|||
*y = frame.origin.y;
|
||||
}
|
||||
|
||||
// Destroy window
|
||||
void windowDestroy(void* nsWindow) {
|
||||
// Destroy window on main thread
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// get main window
|
||||
NSWindow* window = (NSWindow*)nsWindow;
|
||||
// close window
|
||||
[window close];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
|
@ -675,3 +686,7 @@ func (w *macosWindow) position() (int, int) {
|
|||
wg.Wait()
|
||||
return int(x), int(y)
|
||||
}
|
||||
|
||||
func (w *macosWindow) destroy() {
|
||||
C.windowDestroy(w.nsWindow)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,295 +44,295 @@
|
|||
|
||||
// GENERATED EVENTS START
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidBecomeKey);
|
||||
processWindowEvent(self.windowId, EventWindowDidBecomeKey);
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeMain:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidBecomeMain);
|
||||
processWindowEvent(self.windowId, EventWindowDidBecomeMain);
|
||||
}
|
||||
|
||||
- (void)windowDidBeginSheet:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidBeginSheet);
|
||||
processWindowEvent(self.windowId, EventWindowDidBeginSheet);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeAlpha:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeAlpha);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeAlpha);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeBackingLocation:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeBackingLocation);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeBackingLocation);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeBackingProperties:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeBackingProperties);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeBackingProperties);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeCollectionBehavior:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeCollectionBehavior);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeCollectionBehavior);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeEffectiveAppearance:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeEffectiveAppearance);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeEffectiveAppearance);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeOcclusionState:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeOcclusionState);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeOcclusionState);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeOrderingMode:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeOrderingMode);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeOrderingMode);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeScreen);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeScreen);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeScreenParameters:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeScreenParameters);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeScreenParameters);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeScreenProfile:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeScreenProfile);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeScreenProfile);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeScreenSpace:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeScreenSpace);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeScreenSpace);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeScreenSpaceProperties:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeScreenSpaceProperties);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeScreenSpaceProperties);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeSharingType:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeSharingType);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeSharingType);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeSpace:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeSpace);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeSpace);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeSpaceOrderingMode:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeSpaceOrderingMode);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeSpaceOrderingMode);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeTitle:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeTitle);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeTitle);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeToolbar:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeToolbar);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeToolbar);
|
||||
}
|
||||
|
||||
- (void)windowDidChangeVisibility:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidChangeVisibility);
|
||||
processWindowEvent(self.windowId, EventWindowDidChangeVisibility);
|
||||
}
|
||||
|
||||
- (void)windowDidClose:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidClose);
|
||||
processWindowEvent(self.windowId, EventWindowDidClose);
|
||||
}
|
||||
|
||||
- (void)windowDidDeminiaturize:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidDeminiaturize);
|
||||
processWindowEvent(self.windowId, EventWindowDidDeminiaturize);
|
||||
}
|
||||
|
||||
- (void)windowDidEndSheet:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidEndSheet);
|
||||
processWindowEvent(self.windowId, EventWindowDidEndSheet);
|
||||
}
|
||||
|
||||
- (void)windowDidEnterFullScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidEnterFullScreen);
|
||||
processWindowEvent(self.windowId, EventWindowDidEnterFullScreen);
|
||||
}
|
||||
|
||||
- (void)windowDidEnterVersionBrowser:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidEnterVersionBrowser);
|
||||
processWindowEvent(self.windowId, EventWindowDidEnterVersionBrowser);
|
||||
}
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidExitFullScreen);
|
||||
processWindowEvent(self.windowId, EventWindowDidExitFullScreen);
|
||||
}
|
||||
|
||||
- (void)windowDidExitVersionBrowser:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidExitVersionBrowser);
|
||||
processWindowEvent(self.windowId, EventWindowDidExitVersionBrowser);
|
||||
}
|
||||
|
||||
- (void)windowDidExpose:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidExpose);
|
||||
processWindowEvent(self.windowId, EventWindowDidExpose);
|
||||
}
|
||||
|
||||
- (void)windowDidFocus:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidFocus);
|
||||
processWindowEvent(self.windowId, EventWindowDidFocus);
|
||||
}
|
||||
|
||||
- (void)windowDidMiniaturize:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidMiniaturize);
|
||||
processWindowEvent(self.windowId, EventWindowDidMiniaturize);
|
||||
}
|
||||
|
||||
- (void)windowDidMove:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidMove);
|
||||
processWindowEvent(self.windowId, EventWindowDidMove);
|
||||
}
|
||||
|
||||
- (void)windowDidOrderOffScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidOrderOffScreen);
|
||||
processWindowEvent(self.windowId, EventWindowDidOrderOffScreen);
|
||||
}
|
||||
|
||||
- (void)windowDidOrderOnScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidOrderOnScreen);
|
||||
processWindowEvent(self.windowId, EventWindowDidOrderOnScreen);
|
||||
}
|
||||
|
||||
- (void)windowDidResignKey:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidResignKey);
|
||||
processWindowEvent(self.windowId, EventWindowDidResignKey);
|
||||
}
|
||||
|
||||
- (void)windowDidResignMain:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidResignMain);
|
||||
processWindowEvent(self.windowId, EventWindowDidResignMain);
|
||||
}
|
||||
|
||||
- (void)windowDidResize:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidResize);
|
||||
processWindowEvent(self.windowId, EventWindowDidResize);
|
||||
}
|
||||
|
||||
- (void)windowDidUnfocus:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUnfocus);
|
||||
processWindowEvent(self.windowId, EventWindowDidUnfocus);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdate:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdate);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdate);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdateAlpha:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdateAlpha);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdateAlpha);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdateCollectionBehavior:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdateCollectionBehavior);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdateCollectionBehavior);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdateCollectionProperties:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdateCollectionProperties);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdateCollectionProperties);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdateShadow:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdateShadow);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdateShadow);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdateTitle:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdateTitle);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdateTitle);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdateToolbar:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdateToolbar);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdateToolbar);
|
||||
}
|
||||
|
||||
- (void)windowDidUpdateVisibility:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowDidUpdateVisibility);
|
||||
processWindowEvent(self.windowId, EventWindowDidUpdateVisibility);
|
||||
}
|
||||
|
||||
- (void)windowWillBecomeKey:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillBecomeKey);
|
||||
processWindowEvent(self.windowId, EventWindowWillBecomeKey);
|
||||
}
|
||||
|
||||
- (void)windowWillBecomeMain:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillBecomeMain);
|
||||
processWindowEvent(self.windowId, EventWindowWillBecomeMain);
|
||||
}
|
||||
|
||||
- (void)windowWillBeginSheet:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillBeginSheet);
|
||||
processWindowEvent(self.windowId, EventWindowWillBeginSheet);
|
||||
}
|
||||
|
||||
- (void)windowWillChangeOrderingMode:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillChangeOrderingMode);
|
||||
processWindowEvent(self.windowId, EventWindowWillChangeOrderingMode);
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillClose);
|
||||
processWindowEvent(self.windowId, EventWindowWillClose);
|
||||
}
|
||||
|
||||
- (void)windowWillDeminiaturize:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillDeminiaturize);
|
||||
processWindowEvent(self.windowId, EventWindowWillDeminiaturize);
|
||||
}
|
||||
|
||||
- (void)windowWillEnterFullScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillEnterFullScreen);
|
||||
processWindowEvent(self.windowId, EventWindowWillEnterFullScreen);
|
||||
}
|
||||
|
||||
- (void)windowWillEnterVersionBrowser:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillEnterVersionBrowser);
|
||||
processWindowEvent(self.windowId, EventWindowWillEnterVersionBrowser);
|
||||
}
|
||||
|
||||
- (void)windowWillExitFullScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillExitFullScreen);
|
||||
processWindowEvent(self.windowId, EventWindowWillExitFullScreen);
|
||||
}
|
||||
|
||||
- (void)windowWillExitVersionBrowser:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillExitVersionBrowser);
|
||||
processWindowEvent(self.windowId, EventWindowWillExitVersionBrowser);
|
||||
}
|
||||
|
||||
- (void)windowWillFocus:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillFocus);
|
||||
processWindowEvent(self.windowId, EventWindowWillFocus);
|
||||
}
|
||||
|
||||
- (void)windowWillMiniaturize:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillMiniaturize);
|
||||
processWindowEvent(self.windowId, EventWindowWillMiniaturize);
|
||||
}
|
||||
|
||||
- (void)windowWillMove:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillMove);
|
||||
processWindowEvent(self.windowId, EventWindowWillMove);
|
||||
}
|
||||
|
||||
- (void)windowWillOrderOffScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillOrderOffScreen);
|
||||
processWindowEvent(self.windowId, EventWindowWillOrderOffScreen);
|
||||
}
|
||||
|
||||
- (void)windowWillOrderOnScreen:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillOrderOnScreen);
|
||||
processWindowEvent(self.windowId, EventWindowWillOrderOnScreen);
|
||||
}
|
||||
|
||||
- (void)windowWillResignMain:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillResignMain);
|
||||
processWindowEvent(self.windowId, EventWindowWillResignMain);
|
||||
}
|
||||
|
||||
- (void)windowWillResize:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillResize);
|
||||
processWindowEvent(self.windowId, EventWindowWillResize);
|
||||
}
|
||||
|
||||
- (void)windowWillUnfocus:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUnfocus);
|
||||
processWindowEvent(self.windowId, EventWindowWillUnfocus);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdate:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdate);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdate);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdateAlpha:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdateAlpha);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdateAlpha);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdateCollectionBehavior:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdateCollectionBehavior);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdateCollectionBehavior);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdateCollectionProperties:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdateCollectionProperties);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdateCollectionProperties);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdateShadow:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdateShadow);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdateShadow);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdateTitle:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdateTitle);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdateTitle);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdateToolbar:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdateToolbar);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdateToolbar);
|
||||
}
|
||||
|
||||
- (void)windowWillUpdateVisibility:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUpdateVisibility);
|
||||
processWindowEvent(self.windowId, EventWindowWillUpdateVisibility);
|
||||
}
|
||||
|
||||
- (void)windowWillUseStandardFrame:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, EventWindowWillUseStandardFrame);
|
||||
processWindowEvent(self.windowId, EventWindowWillUseStandardFrame);
|
||||
}
|
||||
|
||||
// GENERATED EVENTS END
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ var eventsH = `//go:build darwin
|
|||
#ifndef _events_h
|
||||
#define _events_h
|
||||
|
||||
extern void applicationEventHandler(unsigned int);
|
||||
extern void windowEventHandler(unsigned int, unsigned int);
|
||||
extern void processApplicationEvent(unsigned int);
|
||||
extern void processWindowEvent(unsigned int, unsigned int);
|
||||
|
||||
$$CHEADEREVENTS
|
||||
|
||||
|
|
@ -80,14 +80,14 @@ func main() {
|
|||
// Check if this is a window event
|
||||
if strings.HasPrefix(event, "Window") {
|
||||
windowDelegateEvents.WriteString(`- (void)` + delegateEventFunction + `:(NSNotification *)notification {
|
||||
windowEventHandler(self.windowId, Event` + eventTitle + `);
|
||||
processWindowEvent(self.windowId, Event` + eventTitle + `);
|
||||
}
|
||||
|
||||
`)
|
||||
}
|
||||
if strings.HasPrefix(event, "Application") {
|
||||
applicationDelegateEvents.WriteString(`- (void)` + delegateEventFunction + `:(NSNotification *)notification {
|
||||
applicationEventHandler(Event` + eventTitle + `);
|
||||
processApplicationEvent(Event` + eventTitle + `);
|
||||
}
|
||||
|
||||
`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue