Skip to content

Commit

Permalink
Backport PR matplotlib#27670: Implement macos AppDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
tacaswell authored and meeseeksmachine committed Jan 22, 2024
1 parent 6755d50 commit a9ff1e7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ static int wait_for_stdin() {
}

/* ---------------------------- Cocoa classes ---------------------------- */
@interface MatplotlibAppDelegate : NSObject <NSApplicationDelegate>
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app;
@end

@interface Window : NSWindow
{ PyObject* manager;
Expand Down Expand Up @@ -195,6 +198,7 @@ static void lazy_init(void) {

NSApp = [NSApplication sharedApplication];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp setDelegate: [[[MatplotlibAppDelegate alloc] init] autorelease]];

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

@implementation MatplotlibAppDelegate
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app {
return YES;
}
@end

@interface NavigationToolbar2Handler : NSObject
{ PyObject* toolbar;
NSButton* panbutton;
Expand Down

0 comments on commit a9ff1e7

Please sign in to comment.