OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/aura/wm_window_aura.h" | 5 #include "ash/aura/wm_window_aura.h" |
6 | 6 |
7 #include "ash/aura/aura_layout_manager_adapter.h" | 7 #include "ash/aura/aura_layout_manager_adapter.h" |
8 #include "ash/aura/wm_root_window_controller_aura.h" | 8 #include "ash/aura/wm_root_window_controller_aura.h" |
9 #include "ash/aura/wm_shell_aura.h" | 9 #include "ash/aura/wm_shell_aura.h" |
10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ash/wm/window_animations.h" | 22 #include "ash/wm/window_animations.h" |
23 #include "ash/wm/window_mirror_view.h" | 23 #include "ash/wm/window_mirror_view.h" |
24 #include "ash/wm/window_properties.h" | 24 #include "ash/wm/window_properties.h" |
25 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
27 #include "base/memory/ptr_util.h" | 27 #include "base/memory/ptr_util.h" |
28 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 28 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
29 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
30 #include "ui/aura/client/focus_client.h" | 30 #include "ui/aura/client/focus_client.h" |
31 #include "ui/aura/client/window_parenting_client.h" | 31 #include "ui/aura/client/window_parenting_client.h" |
| 32 #include "ui/aura/env.h" |
32 #include "ui/aura/layout_manager.h" | 33 #include "ui/aura/layout_manager.h" |
33 #include "ui/aura/window.h" | 34 #include "ui/aura/window.h" |
34 #include "ui/aura/window_delegate.h" | 35 #include "ui/aura/window_delegate.h" |
35 #include "ui/aura/window_property.h" | 36 #include "ui/aura/window_property.h" |
36 #include "ui/base/hit_test.h" | 37 #include "ui/base/hit_test.h" |
37 #include "ui/compositor/layer_tree_owner.h" | 38 #include "ui/compositor/layer_tree_owner.h" |
38 #include "ui/compositor/scoped_layer_animation_settings.h" | 39 #include "ui/compositor/scoped_layer_animation_settings.h" |
39 #include "ui/display/screen.h" | 40 #include "ui/display/screen.h" |
40 #include "ui/gfx/geometry/insets.h" | 41 #include "ui/gfx/geometry/insets.h" |
41 #include "ui/views/widget/widget.h" | 42 #include "ui/views/widget/widget.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void SetBounds(aura::Window* window, const gfx::Rect& bounds) { | 79 void SetBounds(aura::Window* window, const gfx::Rect& bounds) { |
79 SetChildBoundsDirect(window, bounds); | 80 SetChildBoundsDirect(window, bounds); |
80 } | 81 } |
81 | 82 |
82 private: | 83 private: |
83 DISALLOW_COPY_AND_ASSIGN(BoundsSetter); | 84 DISALLOW_COPY_AND_ASSIGN(BoundsSetter); |
84 }; | 85 }; |
85 | 86 |
86 } // namespace | 87 } // namespace |
87 | 88 |
88 WmWindowAura::WmWindowAura(aura::Window* window) | |
89 : window_(window), | |
90 // Mirrors that of aura::Window. | |
91 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { | |
92 window_->AddObserver(this); | |
93 window_->SetProperty(kWmWindowKey, this); | |
94 } | |
95 | |
96 WmWindowAura::~WmWindowAura() { | 89 WmWindowAura::~WmWindowAura() { |
97 if (added_transient_observer_) | 90 if (added_transient_observer_) |
98 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); | 91 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); |
99 | 92 |
100 window_->RemoveObserver(this); | 93 window_->RemoveObserver(this); |
101 } | 94 } |
102 | 95 |
103 // static | 96 // static |
104 const WmWindow* WmWindowAura::Get(const aura::Window* window) { | 97 const WmWindow* WmWindowAura::Get(const aura::Window* window) { |
105 if (!window) | 98 if (!window) |
106 return nullptr; | 99 return nullptr; |
107 | 100 |
108 const WmWindow* wm_window = window->GetProperty(kWmWindowKey); | 101 const WmWindow* wm_window = window->GetProperty(kWmWindowKey); |
109 if (wm_window) | 102 if (wm_window) |
110 return wm_window; | 103 return wm_window; |
| 104 DCHECK_EQ(aura::Env::Mode::LOCAL, aura::Env::GetInstance()->mode()); |
111 // WmWindowAura is owned by the aura::Window. | 105 // WmWindowAura is owned by the aura::Window. |
112 // TODO(sky): fix constness. | 106 // TODO(sky): fix constness. |
113 return new WmWindowAura(const_cast<aura::Window*>(window)); | 107 return new WmWindowAura(const_cast<aura::Window*>(window)); |
114 } | 108 } |
115 | 109 |
116 // static | 110 // static |
117 std::vector<WmWindow*> WmWindowAura::FromAuraWindows( | 111 std::vector<WmWindow*> WmWindowAura::FromAuraWindows( |
118 const std::vector<aura::Window*>& aura_windows) { | 112 const std::vector<aura::Window*>& aura_windows) { |
119 std::vector<WmWindow*> result(aura_windows.size()); | 113 std::vector<WmWindow*> result(aura_windows.size()); |
120 for (size_t i = 0; i < aura_windows.size(); ++i) | 114 for (size_t i = 0; i < aura_windows.size(); ++i) |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 | 825 |
832 void WmWindowAura::AddLimitedPreTargetHandler(ui::EventHandler* handler) { | 826 void WmWindowAura::AddLimitedPreTargetHandler(ui::EventHandler* handler) { |
833 // This behaves differently from WmWindowMus for child and embedded windows. | 827 // This behaves differently from WmWindowMus for child and embedded windows. |
834 window_->AddPreTargetHandler(handler); | 828 window_->AddPreTargetHandler(handler); |
835 } | 829 } |
836 | 830 |
837 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { | 831 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { |
838 window_->RemovePreTargetHandler(handler); | 832 window_->RemovePreTargetHandler(handler); |
839 } | 833 } |
840 | 834 |
| 835 WmWindowAura::WmWindowAura(aura::Window* window) |
| 836 : window_(window), |
| 837 // Mirrors that of aura::Window. |
| 838 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 839 window_->AddObserver(this); |
| 840 window_->SetProperty(kWmWindowKey, this); |
| 841 } |
| 842 |
| 843 // static |
| 844 bool WmWindowAura::HasInstance(const aura::Window* window) { |
| 845 return window->GetProperty(kWmWindowKey) != nullptr; |
| 846 } |
| 847 |
841 void WmWindowAura::OnWindowHierarchyChanging( | 848 void WmWindowAura::OnWindowHierarchyChanging( |
842 const HierarchyChangeParams& params) { | 849 const HierarchyChangeParams& params) { |
843 WmWindowObserver::TreeChangeParams wm_params; | 850 WmWindowObserver::TreeChangeParams wm_params; |
844 wm_params.target = Get(params.target); | 851 wm_params.target = Get(params.target); |
845 wm_params.new_parent = Get(params.new_parent); | 852 wm_params.new_parent = Get(params.new_parent); |
846 wm_params.old_parent = Get(params.old_parent); | 853 wm_params.old_parent = Get(params.old_parent); |
847 for (auto& observer : observers_) | 854 for (auto& observer : observers_) |
848 observer.OnWindowTreeChanging(this, wm_params); | 855 observer.OnWindowTreeChanging(this, wm_params); |
849 } | 856 } |
850 | 857 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 observer.OnTransientChildAdded(this, Get(transient)); | 946 observer.OnTransientChildAdded(this, Get(transient)); |
940 } | 947 } |
941 | 948 |
942 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, | 949 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, |
943 aura::Window* transient) { | 950 aura::Window* transient) { |
944 for (auto& observer : transient_observers_) | 951 for (auto& observer : transient_observers_) |
945 observer.OnTransientChildRemoved(this, Get(transient)); | 952 observer.OnTransientChildRemoved(this, Get(transient)); |
946 } | 953 } |
947 | 954 |
948 } // namespace ash | 955 } // namespace ash |
OLD | NEW |