diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 15:27:45 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 15:27:45 +0000 |
commit | c39e715f96f482ebf4b2a00405bb3ccb5b8e8826 (patch) | |
tree | 7075abb007b554979d25fb7218283f048e1b792e /chrome/browser/views/constrained_window_win.cc | |
parent | 211386d58b7fb341e2a895e5776e8380184d58c4 (diff) | |
download | chromium_src-c39e715f96f482ebf4b2a00405bb3ccb5b8e8826.zip chromium_src-c39e715f96f482ebf4b2a00405bb3ccb5b8e8826.tar.gz chromium_src-c39e715f96f482ebf4b2a00405bb3ccb5b8e8826.tar.bz2 |
Revert :
Changed by: jcampan@chromium.org
Changed at: Fri 19 Jun 2009 21:22:47
Branch: src
Revision: 18889
Comments:
Relanding focus manager refactoring with build fix, see:http://codereview.chromium.org/125148BUG=NoneTEST=NoneTBR=ben
Review URL: http://codereview.chromium.org/141013
Because it creates hundreds of new reliability crashes.
TBR:jcampan
Review URL: http://codereview.chromium.org/140064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/constrained_window_win.cc')
-rw-r--r-- | chrome/browser/views/constrained_window_win.cc | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/chrome/browser/views/constrained_window_win.cc b/chrome/browser/views/constrained_window_win.cc index 03759a3..f641f6f 100644 --- a/chrome/browser/views/constrained_window_win.cc +++ b/chrome/browser/views/constrained_window_win.cc @@ -638,13 +638,48 @@ ConstrainedWindowWin::ConstrainedWindowWin( void ConstrainedWindowWin::ActivateConstrainedWindow() { // Other pop-ups are simply moved to the front of the z-order. SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + + // Store the focus of our parent focus manager so we can restore it when we + // close. + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(GetNativeView()); + DCHECK(focus_manager); + focus_manager = focus_manager->GetParentFocusManager(); + if (focus_manager) { + // We could not have a parent focus manager if the ConstrainedWindow is + // displayed in a tab that is not currently selected. + // TODO(jcampan): we should store the ConstrainedWindow active events in + // that case and replay them when the TabContents becomes selected. + focus_manager->StoreFocusedView(); + + // Give our window the focus so we get keyboard messages. + ::SetFocus(GetNativeView()); + } } //////////////////////////////////////////////////////////////////////////////// // ConstrainedWindowWin, views::WidgetWin overrides: void ConstrainedWindowWin::OnDestroy() { - // TODO(jcampan): figure out focus restoration + // We do this here, rather than |Close|, since the window may be destroyed in + // a way other than by some other component calling Close, e.g. by the native + // window hierarchy closing. We are guaranteed to receive a WM_DESTROY + // message regardless of how the window is closed. + // Note that when we get this message, the focus manager of the + // ConstrainedWindow has already been destroyed (by the processing of + // WM_DESTROY in FocusManager). So the FocusManager we retrieve here is the + // parent one (the one from the top window). + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(GetNativeView()); + if (focus_manager) { + // We may not have a focus manager if: + // - we are hidden when closed (the TabContent would be detached). + // - the tab has been closed and we are closed as a result. + // TODO(jcampan): when hidden, we should modify the stored focus of the tab + // so when it becomes visible again we retrieve the focus appropriately. + if (!focus_restoration_disabled_) + focus_manager->RestoreFocusedView(); + } // Make sure we call super so that it can do its cleanup. WindowWin::OnDestroy(); |