| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "views/widget/native_widget_aura.h" | 5 #include "views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
| 10 #include "ui/aura/desktop_observer.h" | 10 #include "ui/aura/desktop_observer.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 //////////////////////////////////////////////////////////////////////////////// | 86 //////////////////////////////////////////////////////////////////////////////// |
| 87 // NativeWidgetAura, public: | 87 // NativeWidgetAura, public: |
| 88 | 88 |
| 89 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) | 89 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
| 90 : delegate_(delegate), | 90 : delegate_(delegate), |
| 91 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 91 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| 92 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 92 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 93 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 93 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
| 94 can_activate_(true), | 94 can_activate_(true), |
| 95 accept_events_(true), |
| 95 cursor_(gfx::kNullCursor) { | 96 cursor_(gfx::kNullCursor) { |
| 96 } | 97 } |
| 97 | 98 |
| 98 NativeWidgetAura::~NativeWidgetAura() { | 99 NativeWidgetAura::~NativeWidgetAura() { |
| 99 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 100 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 100 delete delegate_; | 101 delete delegate_; |
| 101 else | 102 else |
| 102 CloseNow(); | 103 CloseNow(); |
| 103 } | 104 } |
| 104 | 105 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } else { | 141 } else { |
| 141 // Set up the transient child before the window is added. This way the | 142 // Set up the transient child before the window is added. This way the |
| 142 // LayoutManager knows the window has a transient parent. | 143 // LayoutManager knows the window has a transient parent. |
| 143 gfx::NativeView parent = params.GetParent(); | 144 gfx::NativeView parent = params.GetParent(); |
| 144 if (parent) | 145 if (parent) |
| 145 parent->AddTransientChild(window_); | 146 parent->AddTransientChild(window_); |
| 146 // SetAlwaysOnTop before SetParent so that always-on-top container is used. | 147 // SetAlwaysOnTop before SetParent so that always-on-top container is used. |
| 147 SetAlwaysOnTop(params.keep_on_top); | 148 SetAlwaysOnTop(params.keep_on_top); |
| 148 window_->SetParent(NULL); | 149 window_->SetParent(NULL); |
| 149 } | 150 } |
| 151 accept_events_ = params.accept_events; |
| 150 // TODO(beng): do this some other way. | 152 // TODO(beng): do this some other way. |
| 151 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); | 153 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); |
| 152 can_activate_ = params.can_activate; | 154 can_activate_ = params.can_activate; |
| 153 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { | 155 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { |
| 154 DCHECK(GetWidget()->GetRootView()); | 156 DCHECK(GetWidget()->GetRootView()); |
| 155 views::TooltipManagerViews* manager = new views::TooltipManagerViews( | 157 views::TooltipManagerViews* manager = new views::TooltipManagerViews( |
| 156 GetWidget()->GetRootView()); | 158 GetWidget()->GetRootView()); |
| 157 tooltip_manager_.reset(manager); | 159 tooltip_manager_.reset(manager); |
| 158 } | 160 } |
| 159 } | 161 } |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 ui::TouchStatus NativeWidgetAura::OnTouchEvent(aura::TouchEvent* event) { | 592 ui::TouchStatus NativeWidgetAura::OnTouchEvent(aura::TouchEvent* event) { |
| 591 DCHECK(window_->IsVisible()); | 593 DCHECK(window_->IsVisible()); |
| 592 TouchEvent touch_event(event); | 594 TouchEvent touch_event(event); |
| 593 return delegate_->OnTouchEvent(touch_event); | 595 return delegate_->OnTouchEvent(touch_event); |
| 594 } | 596 } |
| 595 | 597 |
| 596 bool NativeWidgetAura::ShouldActivate(aura::Event* event) { | 598 bool NativeWidgetAura::ShouldActivate(aura::Event* event) { |
| 597 return can_activate_; | 599 return can_activate_; |
| 598 } | 600 } |
| 599 | 601 |
| 602 bool NativeWidgetAura::ShouldAcceptEvents() { |
| 603 return accept_events_; |
| 604 } |
| 605 |
| 600 void NativeWidgetAura::OnActivated() { | 606 void NativeWidgetAura::OnActivated() { |
| 601 delegate_->OnNativeWidgetActivationChanged(true); | 607 delegate_->OnNativeWidgetActivationChanged(true); |
| 602 if (IsVisible() && GetWidget()->non_client_view()) | 608 if (IsVisible() && GetWidget()->non_client_view()) |
| 603 GetWidget()->non_client_view()->SchedulePaint(); | 609 GetWidget()->non_client_view()->SchedulePaint(); |
| 604 } | 610 } |
| 605 | 611 |
| 606 void NativeWidgetAura::OnLostActive() { | 612 void NativeWidgetAura::OnLostActive() { |
| 607 delegate_->OnNativeWidgetActivationChanged(false); | 613 delegate_->OnNativeWidgetActivationChanged(false); |
| 608 if (IsVisible() && GetWidget()->non_client_view()) | 614 if (IsVisible() && GetWidget()->non_client_view()) |
| 609 GetWidget()->non_client_view()->SchedulePaint(); | 615 GetWidget()->non_client_view()->SchedulePaint(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 NOTIMPLEMENTED(); | 728 NOTIMPLEMENTED(); |
| 723 } | 729 } |
| 724 | 730 |
| 725 // static | 731 // static |
| 726 bool NativeWidgetPrivate::IsMouseButtonDown() { | 732 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 727 return aura::Desktop::GetInstance()->IsMouseButtonDown(); | 733 return aura::Desktop::GetInstance()->IsMouseButtonDown(); |
| 728 } | 734 } |
| 729 | 735 |
| 730 } // namespace internal | 736 } // namespace internal |
| 731 } // namespace views | 737 } // namespace views |
| OLD | NEW |