mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
app/internal/window: [macOS] only terminate app when last window closes
Updates #19 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -39,6 +39,7 @@ __attribute__ ((visibility ("hidden"))) CFTypeRef gio_readClipboard(void);
|
|||||||
__attribute__ ((visibility ("hidden"))) void gio_writeClipboard(unichar *chars, NSUInteger length);
|
__attribute__ ((visibility ("hidden"))) void gio_writeClipboard(unichar *chars, NSUInteger length);
|
||||||
__attribute__ ((visibility ("hidden"))) void gio_setNeedsDisplay(CFTypeRef viewRef);
|
__attribute__ ((visibility ("hidden"))) void gio_setNeedsDisplay(CFTypeRef viewRef);
|
||||||
__attribute__ ((visibility ("hidden"))) void gio_makeKeyAndOrderFront(CFTypeRef viewRef);
|
__attribute__ ((visibility ("hidden"))) void gio_makeKeyAndOrderFront(CFTypeRef viewRef);
|
||||||
|
__attribute__ ((visibility ("hidden"))) void gio_appTerminate(void);
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
@@ -239,12 +240,15 @@ func configFor(scale float32) config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export gio_onTerminate
|
//export gio_onClose
|
||||||
func gio_onTerminate(view C.CFTypeRef) {
|
func gio_onClose(view C.CFTypeRef) {
|
||||||
w := mustView(view)
|
w := mustView(view)
|
||||||
w.displayLink.Close()
|
w.displayLink.Close()
|
||||||
deleteView(view)
|
deleteView(view)
|
||||||
w.w.Event(system.DestroyEvent{})
|
w.w.Event(system.DestroyEvent{})
|
||||||
|
if len(viewMap) == 0 {
|
||||||
|
C.gio_appTerminate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export gio_onHide
|
//export gio_onHide
|
||||||
|
|||||||
@@ -50,8 +50,7 @@
|
|||||||
- (void)windowWillClose:(NSNotification *)notification {
|
- (void)windowWillClose:(NSNotification *)notification {
|
||||||
NSWindow *window = (NSWindow *)[notification object];
|
NSWindow *window = (NSWindow *)[notification object];
|
||||||
window.delegate = nil;
|
window.delegate = nil;
|
||||||
gio_onTerminate((__bridge CFTypeRef)window.contentView);
|
gio_onClose((__bridge CFTypeRef)window.contentView);
|
||||||
[NSApp terminate:nil];
|
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -151,6 +150,12 @@ void gio_makeKeyAndOrderFront(CFTypeRef viewRef) {
|
|||||||
[view.window makeKeyAndOrderFront:nil];
|
[view.window makeKeyAndOrderFront:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gio_appTerminate(void) {
|
||||||
|
@autoreleasepool {
|
||||||
|
[NSApp terminate:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void gio_main(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat height) {
|
void gio_main(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat height) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
|
|||||||
Reference in New Issue
Block a user