From ae555005e5139a12e71fe10fe99e4b51a06a679e Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Thu, 10 Sep 2020 18:56:53 +0300 Subject: [PATCH] * Source/NSWindow.m (makeKeyAndOrderFront:): unhide/activate application after ordering and making it key. This prevents focus flickering between current key window and this window on application activation. Do not try to set key and main if window can't be set as key. --- Source/NSWindow.m | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 31335febd..54be517e3 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1667,19 +1667,22 @@ titleWithRepresentedFilename(NSString *representedFilename) - (void) makeKeyAndOrderFront: (id)sender { [self deminiaturize: self]; - /* - * If a window is ordered in, make sure that the application isn't hidden, - * and is active. - */ - if ([self canBecomeKeyWindow]) - [NSApp unhide: self]; [self orderFrontRegardless]; - [self makeKeyWindow]; - /* - * OPENSTEP makes a window the main window when it makes it the key window. - * So we do the same (though the documentation doesn't mention it). - */ - [self makeMainWindow]; + + if ([self canBecomeKeyWindow] != NO) + { + [self makeKeyWindow]; + /* + * OPENSTEP makes a window the main window when it makes it the key window. + * So we do the same (though the documentation doesn't mention it). + */ + [self makeMainWindow]; + /* + * If a window is ordered in, make sure that the application isn't hidden, + * and is active. + */ + [NSApp unhide: self]; + } } - (void) makeKeyWindow