app/internal/window: [macOS] remove window reference from app delegate

Updates #19

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-03 21:11:43 +02:00
parent 7c22a888b1
commit 9efdc3409c
2 changed files with 16 additions and 5 deletions
+14
View File
@@ -259,6 +259,20 @@ func gio_onShow(view C.CFTypeRef) {
w.setStage(system.StageRunning)
}
//export gio_onAppHide
func gio_onAppHide() {
for _, w := range viewMap {
w.setStage(system.StagePaused)
}
}
//export gio_onAppShow
func gio_onAppShow() {
for _, w := range viewMap {
w.setStage(system.StageRunning)
}
}
//export gio_onCreate
func gio_onCreate(view C.CFTypeRef) {
scale := float32(C.gio_getViewBackingScale(view))
+2 -5
View File
@@ -7,7 +7,6 @@
#include "_cgo_export.h"
@interface GioAppDelegate : NSObject<NSApplicationDelegate>
@property (strong,nonatomic) NSWindow *window;
@end
@interface GioWindowDelegate : NSObject<NSWindowDelegate>
@@ -18,10 +17,10 @@
[[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
}
- (void)applicationDidHide:(NSNotification *)aNotification {
gio_onHide((__bridge CFTypeRef)self.window.contentView);
gio_onAppHide();
}
- (void)applicationWillUnhide:(NSNotification *)notification {
gio_onShow((__bridge CFTypeRef)self.window.contentView);
gio_onAppShow();
}
@end
@@ -178,8 +177,6 @@ void gio_main(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat heigh
globalWindowDel = [[GioWindowDelegate alloc] init];
NSWindow *window = (__bridge NSWindow *)gio_createWindow(viewRef, title, width, height);
del.window = window;
[NSApp setDelegate:del];
[NSApp run];