@@ -105,6 +105,7 @@ - (void)updateToolbar;
105105- (BOOL )maximizeWindow : (int )options ;
106106- (void )applicationDidChangeScreenParameters : (NSNotification *)notification ;
107107- (void )enterNativeFullScreen ;
108+ - (void )processAfterWindowPresentedQueue ;
108109@end
109110
110111
@@ -236,6 +237,8 @@ - (void)dealloc
236237 [windowAutosaveKey release ]; windowAutosaveKey = nil ;
237238 [vimView release ]; vimView = nil ;
238239 [toolbar release ]; toolbar = nil ;
240+ // in case processAfterWindowPresentedQueue wasn't called
241+ [afterWindowPresentedQueue release ]; afterWindowPresentedQueue = nil ;
239242
240243 [super dealloc ];
241244}
@@ -344,6 +347,9 @@ - (BOOL)presentWindow:(id)unused
344347 // code to depend on the screen state. (Such as constraining views etc.)
345348 windowPresented = YES ;
346349
350+ // Process deferred blocks
351+ [self processAfterWindowPresentedQueue ];
352+
347353 if (fullScreenWindow) {
348354 // Delayed entering of full-screen happens here (a ":set fu" in a
349355 // GUIEnter auto command could cause this).
@@ -1329,6 +1335,19 @@ - (void)windowDidFailToExitFullScreen:(NSWindow *)window
13291335
13301336#endif // (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
13311337
1338+ - (void )runAfterWindowPresentedUsingBlock : (void (^)(void ))block
1339+ {
1340+ if (windowPresented) { // no need to defer block, just run it now
1341+ block ();
1342+ return ;
1343+ }
1344+
1345+ // run block later
1346+ if (afterWindowPresentedQueue == nil )
1347+ afterWindowPresentedQueue = [[NSMutableArray alloc ] init ];
1348+ [afterWindowPresentedQueue addObject: [block copy ]];
1349+ }
1350+
13321351@end // MMWindowController
13331352
13341353
@@ -1665,5 +1684,12 @@ - (void)enterNativeFullScreen
16651684 [decoratedWindow realToggleFullScreen: self ];
16661685}
16671686
1687+ - (void )processAfterWindowPresentedQueue
1688+ {
1689+ for (void (^block)(void ) in afterWindowPresentedQueue)
1690+ block ();
1691+
1692+ [afterWindowPresentedQueue release ]; afterWindowPresentedQueue = nil ;
1693+ }
16681694@end // MMWindowController (Private)
16691695
0 commit comments