Chromium Code Reviews| Index: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
| =================================================================== |
| --- ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (revision 226057) |
| +++ ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (working copy) |
| @@ -185,7 +185,8 @@ |
| native_widget_delegate_(delegate), |
| last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
| restore_focus_on_activate_(false), |
| - cursor_(gfx::kNullCursor) { |
| + cursor_(gfx::kNullCursor), |
| + widget_type_(Widget::InitParams::TYPE_WINDOW) { |
| window_->SetProperty(kDesktopNativeWidgetAuraKey, this); |
| aura::client::SetFocusChangeObserver(window_, this); |
| aura::client::SetActivationChangeObserver(window_, this); |
| @@ -208,6 +209,9 @@ |
| // Don't invoke Widget::OnNativeWidgetDestroying(), its done by |
| // DesktopRootWindowHost. |
| + if (window_modality_controller_) |
|
sky
2013/10/02 15:54:12
Document why this is explicit.
ananta
2013/10/02 17:46:55
Done.
|
| + window_modality_controller_.reset(); |
| + |
| // Make sure we don't still have capture. Otherwise CaptureController and |
| // RootWindow are left referencing a deleted Window. |
| { |
| @@ -222,10 +226,6 @@ |
| shadow_controller_.reset(); |
| tooltip_manager_.reset(); |
| scoped_tooltip_client_.reset(); |
| - if (window_modality_controller_) { |
| - root_window_->RemovePreTargetHandler(window_modality_controller_.get()); |
| - window_modality_controller_.reset(); |
| - } |
| root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); |
| @@ -296,12 +296,23 @@ |
| } |
| } |
| +void DesktopNativeWidgetAura::InstallWindowModalityController( |
| + aura::RootWindow* root) { |
| + // The WindowsModalityController event filter should be at the head of the |
| + // pre target handlers list. This ensures that it handles input events first |
| + // when modal windows are at the top of the Zorder. |
| + if (widget_type_ == Widget::InitParams::TYPE_WINDOW) |
| + window_modality_controller_.reset( |
| + new views::corewm::WindowModalityController(root)); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: |
| void DesktopNativeWidgetAura::InitNativeWidget( |
| const Widget::InitParams& params) { |
| ownership_ = params.ownership; |
| + widget_type_ = params.type; |
| NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); |
| // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate |
| @@ -354,12 +365,6 @@ |
| GetNativeView()->GetRootWindow()); |
| } |
| - if (params.type == Widget::InitParams::TYPE_WINDOW) { |
| - window_modality_controller_.reset( |
| - new views::corewm::WindowModalityController); |
| - root_window_->AddPreTargetHandler(window_modality_controller_.get()); |
| - } |
| - |
| window_->Show(); |
| desktop_root_window_host_->InitFocus(window_); |