diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-22 20:33:50 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-22 20:33:50 +0000 |
commit | 5d3df47dd554b7569a955d22d8d5cf0a37a421d2 (patch) | |
tree | 2ed6b24dcf76c0362c822482b2f0ebc3322b8f60 /chrome/browser/cocoa | |
parent | f76a3e198cbeb3f6c2d4c7f1c45b22427c995546 (diff) | |
download | chromium_src-5d3df47dd554b7569a955d22d8d5cf0a37a421d2.zip chromium_src-5d3df47dd554b7569a955d22d8d5cf0a37a421d2.tar.gz chromium_src-5d3df47dd554b7569a955d22d8d5cf0a37a421d2.tar.bz2 |
Mac: Delay setting window titles while the window menu is being tracked. Works around OS wackiness.
BUG=56745
TEST=repro as in bug 60165 (has better instructions)
Review URL: http://codereview.chromium.org/4005005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 9747178..9a46f7d 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_ #pragma once +#include "base/scoped_nsobject.h" #include "base/task.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -134,6 +135,7 @@ class BrowserWindowCocoa : public BrowserWindow, Browser* browser_; // weak, owned by controller BrowserWindowController* controller_; // weak, owns us ScopedRunnableMethodFactory<Browser> confirm_close_factory_; + scoped_nsobject<NSString> pending_window_title_; }; #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_ diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 2203240..03fc6c0 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -151,7 +151,24 @@ void BrowserWindowCocoa::UpdateTitleBar() { NSString* newTitle = base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab()); - [window() setTitle:newTitle]; + // Work around Cocoa bug: if a window changes title during the tracking of the + // Window menu it doesn't display well and the constant re-sorting of the list + // makes it difficult for the user to pick the desired window. Delay window + // title updates until the default run-loop mode. + + if (pending_window_title_.get()) + [[NSRunLoop currentRunLoop] + cancelPerformSelector:@selector(setTitle:) + target:window() + argument:pending_window_title_.get()]; + + pending_window_title_.reset([newTitle copy]); + [[NSRunLoop currentRunLoop] + performSelector:@selector(setTitle:) + target:window() + argument:newTitle + order:0 + modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]]; } void BrowserWindowCocoa::ShelfVisibilityChanged() { |