mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 23:55:39 +00:00
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:
@@ -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))
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user