| Index: views/widget/native_widget_win.cc
|
| diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
|
| index c356c1269925bf6a40f83e7465660e5b3c47eb1c..14bc4268ff2452c7389657b75e96c7ee5e45a551 100644
|
| --- a/views/widget/native_widget_win.cc
|
| +++ b/views/widget/native_widget_win.cc
|
| @@ -833,6 +833,10 @@ void NativeWidgetWin::Close() {
|
| // Let's hide ourselves right away.
|
| Hide();
|
|
|
| + // Modal dialog windows disable their owner windows; re-enable them now so
|
| + // they can activate as foreground windows upon this window's destruction.
|
| + RestoreEnabledIfNecessary();
|
| +
|
| if (!close_widget_factory_.HasWeakPtrs()) {
|
| // And we delay the close so that if we are called from an ATL callback,
|
| // we don't destroy the window before the callback returned (as the caller
|
| @@ -843,22 +847,6 @@ void NativeWidgetWin::Close() {
|
| base::Bind(&NativeWidgetWin::CloseNow,
|
| close_widget_factory_.GetWeakPtr()));
|
| }
|
| -
|
| - // 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 = ::GetWindow(GetNativeView(), GW_OWNER);
|
| - if (owner && GetNativeView() == GetForegroundWindow() &&
|
| - IsWindowVisible(owner)) {
|
| - SetForegroundWindow(owner);
|
| - }
|
| }
|
|
|
| void NativeWidgetWin::CloseNow() {
|
| @@ -1315,7 +1303,6 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
|
| }
|
|
|
| void NativeWidgetWin::OnDestroy() {
|
| - RestoreEnabledIfNecessary();
|
| delegate_->OnNativeWidgetDestroying();
|
| if (drop_target_.get()) {
|
| RevokeDragDrop(hwnd());
|
| @@ -1605,6 +1592,9 @@ void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
|
| }
|
|
|
| LRESULT NativeWidgetWin::OnNCActivate(BOOL active) {
|
| + if (delegate_->CanActivate())
|
| + delegate_->OnNativeWidgetActivationChanged(!!active);
|
| +
|
| if (!GetWidget()->non_client_view()) {
|
| SetMsgHandled(FALSE);
|
| return 0;
|
| @@ -1613,8 +1603,6 @@ LRESULT NativeWidgetWin::OnNCActivate(BOOL active) {
|
| if (!delegate_->CanActivate())
|
| return TRUE;
|
|
|
| - delegate_->OnNativeWidgetActivationChanged(!!active);
|
| -
|
| // The frame may need to redraw as a result of the activation change.
|
| // We can get WM_NCACTIVATE before we're actually visible. If we're not
|
| // visible, no need to paint.
|
| @@ -2276,6 +2264,11 @@ void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) {
|
| // from the system menu, which is worse. We may need to provide our own
|
| // menu to get the close button to appear properly.
|
| // style &= ~WS_SYSMENU;
|
| +
|
| + // Set the WS_POPUP style for modal dialogs. This ensures that the owner
|
| + // window is activated on destruction. This style should not be set for
|
| + // non-modal non-top-level dialogs like constrained windows.
|
| + style |= delegate_->IsModal() ? WS_POPUP : 0;
|
| }
|
| ex_style |= delegate_->IsDialogBox() ? WS_EX_DLGMODALFRAME : 0;
|
| break;
|
|
|