diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 20:34:51 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 20:34:51 +0000 |
commit | f66a1879d8103e1c92e18b268b44152190cf5b98 (patch) | |
tree | 80e592e91b17ae6b37e6a659c6c4628fd47069e6 /views/window | |
parent | a983d05927512cf45af404c228b81731ae43c28c (diff) | |
download | chromium_src-f66a1879d8103e1c92e18b268b44152190cf5b98.zip chromium_src-f66a1879d8103e1c92e18b268b44152190cf5b98.tar.gz chromium_src-f66a1879d8103e1c92e18b268b44152190cf5b98.tar.bz2 |
Fix window activation when closing a modal dialog box. It turns out GetForegroundWindow() returns a different value when it's called from WM_DESTROY vs. WM_CLOSE. We need to do activation restoration earlier than WM_DESTROY.
http://crbug.com/75610
TEST=see bug
TBR=sky
Review URL: http://codereview.chromium.org/6670054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window')
-rw-r--r-- | views/window/window_win.cc | 32 | ||||
-rw-r--r-- | views/window/window_win.h | 1 |
2 files changed, 21 insertions, 12 deletions
diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 301b5099..9ba6056 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -404,19 +404,7 @@ void WindowWin::OnCommand(UINT notification_code, int command_id, HWND window) { void WindowWin::OnDestroy() { delegate_->OnNativeWindowDestroying(); - RestoreEnabledIfNecessary(); - - // If the user activates another app after opening us, then comes back and - // closes us, we want our owner to gain activation. But only if the owner - // is visible. If we don't manually force that here, the other app will - // regain activation instead. - HWND owner = GetOwner(GetNativeView()); - if (owner && GetNativeView() == GetForegroundWindow() && - IsWindowVisible(owner)) { - SetForegroundWindow(owner); - } - WidgetWin::OnDestroy(); } @@ -869,6 +857,26 @@ void WindowWin::OnWindowPosChanging(WINDOWPOS* window_pos) { WidgetWin::OnWindowPosChanging(window_pos); } +void WindowWin::Close() { + WidgetWin::Close(); + + // If the user activates another app after opening us, then comes back and + // closes us, we want our owner to gain activation. But only if the owner + // is visible. If we don't manually force that here, the other app will + // regain activation instead. + // It's tempting to think that this could be done from OnDestroy, but by then + // it's too late - GetForegroundWindow() will return the window that Windows + // has decided to re-activate for us instead of this dialog. It's also + // tempting to think about removing the foreground window check entirely, but + // it's necessary to this code path from being triggered when an inactive + // window is closed. + HWND owner = GetOwner(GetNativeView()); + if (owner && GetNativeView() == GetForegroundWindow() && + IsWindowVisible(owner)) { + SetForegroundWindow(owner); + } +} + //////////////////////////////////////////////////////////////////////////////// // WindowWin, NativeWindow implementation: diff --git a/views/window/window_win.h b/views/window/window_win.h index 114ea1e..e2ef0f6 100644 --- a/views/window/window_win.h +++ b/views/window/window_win.h @@ -135,6 +135,7 @@ class WindowWin : public WidgetWin, virtual void OnWindowPosChanging(WINDOWPOS* window_pos) OVERRIDE; virtual Window* GetWindow() OVERRIDE { return this; } virtual const Window* GetWindow() const OVERRIDE { return this; } + virtual void Close() OVERRIDE; // Overridden from NativeWindow: virtual NativeWidget* AsNativeWidget() OVERRIDE; |