Chromium Code Reviews| Index: ui/views/widget/native_widget_aura.cc |
| diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc |
| index 9de1e78968b415a06c6e9a71023fc9fb87d37e28..ae26fe09d1c3e47e39e1f88d75c54692fdd2b655 100644 |
| --- a/ui/views/widget/native_widget_aura.cc |
| +++ b/ui/views/widget/native_widget_aura.cc |
| @@ -9,13 +9,9 @@ |
| #include "third_party/skia/include/core/SkRegion.h" |
| #include "ui/aura/client/activation_client.h" |
| #include "ui/aura/client/aura_constants.h" |
| -#include "ui/aura/client/dispatcher_client.h" |
| #include "ui/aura/client/drag_drop_client.h" |
| #include "ui/aura/client/window_move_client.h" |
| #include "ui/aura/client/window_types.h" |
| -#include "ui/aura/desktop/desktop_activation_client.h" |
| -#include "ui/aura/desktop/desktop_dispatcher_client.h" |
| -#include "ui/aura/desktop/desktop_root_window_event_filter.h" |
| #include "ui/aura/env.h" |
| #include "ui/aura/event.h" |
| #include "ui/aura/root_window.h" |
| @@ -31,6 +27,7 @@ |
| #include "ui/views/ime/input_method_bridge.h" |
| #include "ui/views/widget/drop_helper.h" |
| #include "ui/views/widget/native_widget_delegate.h" |
| +#include "ui/views/widget/desktop_native_widget_helper_aura.h" |
| #include "ui/views/widget/root_view.h" |
| #include "ui/views/widget/tooltip_manager_aura.h" |
| #include "ui/views/widget/widget_delegate.h" |
| @@ -48,8 +45,6 @@ |
| namespace views { |
| -bool NativeWidgetAura::g_aura_desktop_hax = false; |
| - |
| namespace { |
| aura::client::WindowType GetAuraWindowTypeForWidgetType( |
| @@ -139,7 +134,12 @@ class NativeWidgetAura::ActiveWindowObserver : public aura::WindowObserver { |
| NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
| : delegate_(delegate), |
| - root_window_(NULL), |
| +#if defined(USE_ASH) |
|
Ben Goodger (Google)
2012/04/17 15:42:55
views is not allowed to know about ash.
instead, t
|
| + desktop_helper_(NULL), |
| +#else |
| + ALLOW_THIS_IN_INITIALIZER_LIST(desktop_helper_( |
| + new views::DesktopNatitveWidgetHelperAura(this))), |
| +#endif |
| ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
| @@ -173,25 +173,9 @@ gfx::Font NativeWidgetAura::GetWindowTitleFont() { |
| void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| ownership_ = params.ownership; |
| - // TODO(erg): What kind of windows do we want to have their own root windows? |
| - if (g_aura_desktop_hax) { |
| - gfx::Rect bounds = params.bounds; |
| - if (bounds.IsEmpty()) { |
| - // We must pass some non-zero value when we initialize a RootWindow. This |
| - // will probably be SetBounds()ed soon. |
| - bounds.set_size(gfx::Size(100, 100)); |
| - } |
| - root_window_.reset(new aura::RootWindow(bounds)); |
| - root_window_->SetEventFilter( |
| - new aura::DesktopRootWindowEventFilter(root_window_.get())); |
| - root_window_->AddRootWindowObserver(this); |
| - |
| - aura::client::SetActivationClient( |
| - root_window_.get(), |
| - new aura::DesktopActivationClient(root_window_.get())); |
| - aura::client::SetDispatcherClient(root_window_.get(), |
| - new aura::DesktopDispatcherClient); |
| - } |
| + |
| + if (desktop_helper_.get()) |
| + desktop_helper_->PreInitialize(params); |
| window_->set_user_data(this); |
| window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
| @@ -204,8 +188,8 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| window_->Show(); |
| delegate_->OnNativeWidgetCreated(); |
| - if (root_window_.get()) { |
| - window_->SetParent(root_window_.get()); |
| + if (desktop_helper_.get() && desktop_helper_->root_window()) { |
| + window_->SetParent(desktop_helper_->root_window()); |
| } else if (params.child) { |
| window_->SetParent(params.GetParent()); |
| } else { |
| @@ -220,7 +204,7 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| // client per root window instead. For now, we hax our way around this by |
| // forcing the parent to be the root window instead of passing NULL as |
| // the parent which will dispatch to the stacking client. |
| - if (g_aura_desktop_hax) |
| + if (desktop_helper_.get()) |
| parent = parent->GetRootWindow(); |
| else |
| parent = NULL; |
| @@ -253,8 +237,9 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| aura::client::SetActivationDelegate(window_, this); |
| - if (root_window_.get()) |
| - root_window_->ShowRootWindow(); |
| + // TODO(erg): Move this somewhere else? |
| + if (desktop_helper_.get()) |
| + desktop_helper_->ShowRootWindow(); |
| } |
| NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { |
| @@ -471,11 +456,8 @@ gfx::Rect NativeWidgetAura::GetRestoredBounds() const { |
| void NativeWidgetAura::SetBounds(const gfx::Rect& in_bounds) { |
| gfx::Rect bounds = in_bounds; |
| - if (root_window_.get() && !bounds.IsEmpty()) { |
| - root_window_->SetHostBounds(bounds); |
| - bounds.set_x(0); |
| - bounds.set_y(0); |
| - } |
| + if (desktop_helper_.get()) |
| + bounds = desktop_helper_->ModifyAndSetBounds(bounds); |
| #if defined(ENABLE_DIP) |
| bounds = ConvertRectToMonitor(bounds); |
| #endif |
| @@ -873,23 +855,6 @@ void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// NativeWidgetAura, aura::RootWindowObserver implementation: |
| - |
| -void NativeWidgetAura::OnRootWindowResized(const aura::RootWindow* root, |
| - const gfx::Size& old_size) { |
| - // This case can only happen if we have our own aura::RootWindow*. When that |
| - // happens, our main window should be at the origin and sized to the |
| - // RootWindow. |
| - DCHECK_EQ(root, root_window_.get()); |
| - SetBounds(gfx::Rect(root->GetHostSize())); |
| -} |
| - |
| -void NativeWidgetAura::OnRootWindowHostClosed(const aura::RootWindow* root) { |
| - DCHECK_EQ(root, root_window_.get()); |
| - GetWidget()->Close(); |
| -} |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| // NativeWidgetAura, aura::ActivationDelegate implementation: |
| bool NativeWidgetAura::ShouldActivate(const aura::Event* event) { |