Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1448ba8

Browse files
authored
Merge pull request #27670 from greglucas/macos-app-delegate
Implement macos AppDelegate
2 parents 09eab5b + f8df6ba commit 1448ba8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/_macosx.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ static int wait_for_stdin() {
100100
}
101101

102102
/* ---------------------------- Cocoa classes ---------------------------- */
103+
@interface MatplotlibAppDelegate : NSObject <NSApplicationDelegate>
104+
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app;
105+
@end
103106

104107
@interface Window : NSWindow
105108
{ PyObject* manager;
@@ -195,6 +198,7 @@ static void lazy_init(void) {
195198

196199
NSApp = [NSApplication sharedApplication];
197200
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
201+
[NSApp setDelegate: [[[MatplotlibAppDelegate alloc] init] autorelease]];
198202

199203
// Run our own event loop while waiting for stdin on the Python side
200204
// this is needed to keep the application responsive while waiting for input
@@ -779,6 +783,12 @@ int mpl_check_modifier(
779783
},
780784
};
781785

786+
@implementation MatplotlibAppDelegate
787+
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app {
788+
return YES;
789+
}
790+
@end
791+
782792
@interface NavigationToolbar2Handler : NSObject
783793
{ PyObject* toolbar;
784794
NSButton* panbutton;

0 commit comments

Comments
 (0)