Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: chrome/browser/ui/cocoa/browser_window_utils.mm

Issue 9310075: Ensure the previously active browser window gets the focus after a browser window is closed on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: separate return to its own line Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_utils.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_utils.mm b/chrome/browser/ui/cocoa/browser_window_utils.mm
index 442463d7c5de09cacaee7ae1289912a34fbb0cac..8193b48c18c8571efdba69e4c389740c19333bcb 100644
--- a/chrome/browser/ui/cocoa/browser_window_utils.mm
+++ b/chrome/browser/ui/cocoa/browser_window_utils.mm
@@ -10,6 +10,8 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/global_keyboard_shortcuts_mac.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
#import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
@@ -186,4 +188,22 @@ const CGFloat kPatternVerticalOffsetNoTabStrip = 3;
SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
}
++ (void)selectPreviousActiveBrowserWindow:(Browser*)closedBrowser {
+ if (![NSApp isActive] || closedBrowser != BrowserList::GetLastActive())
+ return;
Scott Hess - ex-Googler 2012/02/09 22:51:54 Are you sure about the -isActive test? You would
jennb 2012/02/09 23:25:24 My thinking is that if Chrome is not active, then
+
+ // Select previous active window if this is the current active window.
+ // Otherwise, OSX will always give focus to a Panel window after this one
+ // is closed because Panels have a higher priority NSWindowLevel.
+ BrowserList::const_reverse_iterator iter = BrowserList::begin_last_active();
+ BrowserList::const_reverse_iterator end = BrowserList::end_last_active();
+ for (; iter != end; ++iter) {
+ Browser* browser = *iter;
+ if (browser != closedBrowser &&
+ [browser->window()->GetNativeHandle() canBecomeKeyWindow]) {
+ browser->window()->Activate();
+ return;
+ }
+ }
+}
Scott Hess - ex-Googler 2012/02/09 22:51:54 This will subvert the ordering logic if there are
jennb 2012/02/09 23:25:24 Thanks for pointing out the non-browser window cas
@end
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_utils.h ('k') | chrome/browser/ui/cocoa/tabs/tab_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698