From 2c1841d1d418ad79892a706a8b448653e5fdcff6 Mon Sep 17 00:00:00 2001 From: Itai Ferber Date: Sat, 12 Nov 2016 15:33:23 -0800 Subject: [PATCH] Report focus change on window key (not main) MacVim should report FocusGained and FocusLost events not just when its windows become main, but when they become key -- if a panel is opened, or a background application (i.e. an LSUIElement app) becomes active, MacVim should reflect the focus state. --- src/MacVim/MMWindowController.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index c54409e699..912917aec6 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -969,7 +969,6 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item - (void)windowDidBecomeMain:(NSNotification *)notification { [[MMAppController sharedInstance] setMainMenu:[vimController mainMenu]]; - [vimController sendMessage:GotFocusMsgID data:nil]; if ([vimView textView]) { NSFontManager *fm = [NSFontManager sharedFontManager]; @@ -977,7 +976,12 @@ - (void)windowDidBecomeMain:(NSNotification *)notification } } -- (void)windowDidResignMain:(NSNotification *)notification +- (void)windowDidBecomeKey:(NSNotificationCenter *)notification +{ + [vimController sendMessage:GotFocusMsgID data:nil]; +} + +- (void)windowDidResignKey:(NSNotification *)notification { [vimController sendMessage:LostFocusMsgID data:nil]; }