OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" | 5 #include "athena/wm/public/window_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "athena/common/container_priorities.h" | 9 #include "athena/common/container_priorities.h" |
10 #include "athena/input/public/accelerator_manager.h" | 10 #include "athena/input/public/accelerator_manager.h" |
11 #include "athena/screen/public/screen_manager.h" | 11 #include "athena/screen/public/screen_manager.h" |
12 #include "athena/wm/bezel_controller.h" | 12 #include "athena/wm/bezel_controller.h" |
13 #include "athena/wm/mru_window_tracker.h" | |
14 #include "athena/wm/public/window_manager_observer.h" | 13 #include "athena/wm/public/window_manager_observer.h" |
15 #include "athena/wm/split_view_controller.h" | 14 #include "athena/wm/split_view_controller.h" |
16 #include "athena/wm/title_drag_controller.h" | 15 #include "athena/wm/title_drag_controller.h" |
16 #include "athena/wm/window_list_provider_impl.h" | |
17 #include "athena/wm/window_overview_mode.h" | 17 #include "athena/wm/window_overview_mode.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "ui/aura/layout_manager.h" | 20 #include "ui/aura/layout_manager.h" |
21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
22 #include "ui/wm/core/shadow_controller.h" | 22 #include "ui/wm/core/shadow_controller.h" |
23 #include "ui/wm/core/window_util.h" | 23 #include "ui/wm/core/window_util.h" |
24 #include "ui/wm/core/wm_state.h" | 24 #include "ui/wm/core/wm_state.h" |
25 #include "ui/wm/public/activation_client.h" | 25 #include "ui/wm/public/activation_client.h" |
26 #include "ui/wm/public/window_types.h" | 26 #include "ui/wm/public/window_types.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 virtual bool OnAcceleratorFired(int command_id, | 72 virtual bool OnAcceleratorFired(int command_id, |
73 const ui::Accelerator& accelerator) OVERRIDE; | 73 const ui::Accelerator& accelerator) OVERRIDE; |
74 | 74 |
75 // TitleDragControllerDelegate: | 75 // TitleDragControllerDelegate: |
76 virtual aura::Window* GetWindowBehind(aura::Window* window) OVERRIDE; | 76 virtual aura::Window* GetWindowBehind(aura::Window* window) OVERRIDE; |
77 virtual void OnTitleDragStarted(aura::Window* window) OVERRIDE; | 77 virtual void OnTitleDragStarted(aura::Window* window) OVERRIDE; |
78 virtual void OnTitleDragCompleted(aura::Window* window) OVERRIDE; | 78 virtual void OnTitleDragCompleted(aura::Window* window) OVERRIDE; |
79 virtual void OnTitleDragCanceled(aura::Window* window) OVERRIDE; | 79 virtual void OnTitleDragCanceled(aura::Window* window) OVERRIDE; |
80 | 80 |
81 scoped_ptr<aura::Window> container_; | 81 scoped_ptr<aura::Window> container_; |
82 scoped_ptr<MruWindowTracker> mru_window_tracker_; | 82 scoped_ptr<WindowListProvider> window_list_provider_; |
83 scoped_ptr<WindowOverviewMode> overview_; | 83 scoped_ptr<WindowOverviewMode> overview_; |
84 scoped_ptr<BezelController> bezel_controller_; | 84 scoped_ptr<BezelController> bezel_controller_; |
85 scoped_ptr<SplitViewController> split_view_controller_; | 85 scoped_ptr<SplitViewController> split_view_controller_; |
86 scoped_ptr<wm::WMState> wm_state_; | 86 scoped_ptr<wm::WMState> wm_state_; |
87 scoped_ptr<TitleDragController> title_drag_controller_; | 87 scoped_ptr<TitleDragController> title_drag_controller_; |
88 scoped_ptr<wm::ShadowController> shadow_controller_; | 88 scoped_ptr<wm::ShadowController> shadow_controller_; |
89 ObserverList<WindowManagerObserver> observers_; | 89 ObserverList<WindowManagerObserver> observers_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); | 91 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); |
92 }; | 92 }; |
(...skipping 18 matching lines...) Expand all Loading... | |
111 }; | 111 }; |
112 | 112 |
113 class WindowManagerImpl* instance = NULL; | 113 class WindowManagerImpl* instance = NULL; |
114 | 114 |
115 WindowManagerImpl::WindowManagerImpl() { | 115 WindowManagerImpl::WindowManagerImpl() { |
116 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); | 116 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); |
117 params.can_activate_children = true; | 117 params.can_activate_children = true; |
118 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params)); | 118 container_.reset(ScreenManager::Get()->CreateDefaultContainer(params)); |
119 container_->SetLayoutManager(new AthenaContainerLayoutManager); | 119 container_->SetLayoutManager(new AthenaContainerLayoutManager); |
120 container_->AddObserver(this); | 120 container_->AddObserver(this); |
121 mru_window_tracker_.reset(new MruWindowTracker(container_.get())); | 121 window_list_provider_.reset(new WindowListProviderImpl(container_.get())); |
122 bezel_controller_.reset(new BezelController(container_.get())); | 122 bezel_controller_.reset(new BezelController(container_.get())); |
123 split_view_controller_.reset(new SplitViewController( | 123 split_view_controller_.reset( |
124 container_.get(), mru_window_tracker_.get(), this)); | 124 new SplitViewController(container_.get(), window_list_provider_.get())); |
125 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); | 125 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); |
126 container_->AddPreTargetHandler(bezel_controller_.get()); | 126 container_->AddPreTargetHandler(bezel_controller_.get()); |
127 title_drag_controller_.reset(new TitleDragController(container_.get(), this)); | 127 title_drag_controller_.reset(new TitleDragController(container_.get(), this)); |
128 wm_state_.reset(new wm::WMState()); | 128 wm_state_.reset(new wm::WMState()); |
129 aura::client::ActivationClient* activation_client = | 129 aura::client::ActivationClient* activation_client = |
130 aura::client::GetActivationClient(container_->GetRootWindow()); | 130 aura::client::GetActivationClient(container_->GetRootWindow()); |
131 shadow_controller_.reset(new wm::ShadowController(activation_client)); | 131 shadow_controller_.reset(new wm::ShadowController(activation_client)); |
132 instance = this; | 132 instance = this; |
133 InstallAccelerators(); | 133 InstallAccelerators(); |
134 } | 134 } |
135 | 135 |
136 WindowManagerImpl::~WindowManagerImpl() { | 136 WindowManagerImpl::~WindowManagerImpl() { |
137 overview_.reset(); | 137 overview_.reset(); |
138 split_view_controller_.reset(); | 138 split_view_controller_.reset(); |
139 mru_window_tracker_.reset(); | 139 window_list_provider_.reset(); |
140 if (container_) { | 140 if (container_) { |
141 container_->RemoveObserver(this); | 141 container_->RemoveObserver(this); |
142 container_->RemovePreTargetHandler(bezel_controller_.get()); | 142 container_->RemovePreTargetHandler(bezel_controller_.get()); |
143 } | 143 } |
144 // |title_drag_controller_| needs to be reset before |container_|. | 144 // |title_drag_controller_| needs to be reset before |container_|. |
145 title_drag_controller_.reset(); | 145 title_drag_controller_.reset(); |
146 container_.reset(); | 146 container_.reset(); |
147 instance = NULL; | 147 instance = NULL; |
148 } | 148 } |
149 | 149 |
(...skipping 16 matching lines...) Expand all Loading... | |
166 | 166 |
167 bool WindowManagerImpl::IsOverviewModeActive() { | 167 bool WindowManagerImpl::IsOverviewModeActive() { |
168 return overview_; | 168 return overview_; |
169 } | 169 } |
170 | 170 |
171 void WindowManagerImpl::SetInOverview(bool active) { | 171 void WindowManagerImpl::SetInOverview(bool active) { |
172 bool in_overview = !!overview_; | 172 bool in_overview = !!overview_; |
173 if (active == in_overview) | 173 if (active == in_overview) |
174 return; | 174 return; |
175 | 175 |
176 split_view_controller_->DeactivateSplitMode(); | |
mfomitchev
2014/08/15 18:30:51
Can we only do it when active == true? Doing it ev
sadrul
2014/08/15 18:44:18
Done.
| |
177 bezel_controller_->set_left_right_delegate( | |
178 active ? NULL : split_view_controller_.get()); | |
176 if (active) { | 179 if (active) { |
177 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 180 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
178 OnOverviewModeEnter()); | 181 OnOverviewModeEnter()); |
179 // Re-stack all windows in the order defined by mru_window_tracker_. | 182 // Re-stack all windows in the order defined by window_list_provider_. |
180 aura::Window::Windows window_list = mru_window_tracker_->GetWindowList(); | 183 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); |
181 aura::Window::Windows::iterator it; | 184 aura::Window::Windows::iterator it; |
182 for (it = window_list.begin(); it != window_list.end(); ++it) | 185 for (it = window_list.begin(); it != window_list.end(); ++it) |
183 container_->StackChildAtTop(*it); | 186 container_->StackChildAtTop(*it); |
184 overview_ = WindowOverviewMode::Create(container_.get(), | 187 overview_ = WindowOverviewMode::Create( |
185 mru_window_tracker_.get(), | 188 container_.get(), window_list_provider_.get(), this); |
186 this); | |
187 } else { | 189 } else { |
190 CHECK(!split_view_controller_->IsSplitViewModeActive()); | |
188 overview_.reset(); | 191 overview_.reset(); |
189 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 192 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
190 OnOverviewModeExit()); | 193 OnOverviewModeExit()); |
191 } | 194 } |
192 } | 195 } |
193 | 196 |
194 void WindowManagerImpl::InstallAccelerators() { | 197 void WindowManagerImpl::InstallAccelerators() { |
195 const AcceleratorData accelerator_data[] = { | 198 const AcceleratorData accelerator_data[] = { |
196 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, | 199 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, |
197 AF_NONE}, | 200 AF_NONE}, |
198 }; | 201 }; |
199 AcceleratorManager::Get()->RegisterAccelerators( | 202 AcceleratorManager::Get()->RegisterAccelerators( |
200 accelerator_data, arraysize(accelerator_data), this); | 203 accelerator_data, arraysize(accelerator_data), this); |
201 } | 204 } |
202 | 205 |
203 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { | 206 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { |
204 observers_.AddObserver(observer); | 207 observers_.AddObserver(observer); |
205 } | 208 } |
206 | 209 |
207 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { | 210 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { |
208 observers_.RemoveObserver(observer); | 211 observers_.RemoveObserver(observer); |
209 } | 212 } |
210 | 213 |
211 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 214 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
212 mru_window_tracker_->MoveToFront(window); | |
213 wm::ActivateWindow(window); | 215 wm::ActivateWindow(window); |
214 SetInOverview(false); | 216 SetInOverview(false); |
215 } | 217 } |
216 | 218 |
217 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, | 219 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, |
218 aura::Window* right) { | 220 aura::Window* right) { |
219 SetInOverview(false); | 221 SetInOverview(false); |
220 split_view_controller_->ActivateSplitMode(left, right); | 222 split_view_controller_->ActivateSplitMode(left, right); |
221 } | 223 } |
222 | 224 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 DCHECK(!instance); | 319 DCHECK(!instance); |
318 } | 320 } |
319 | 321 |
320 // static | 322 // static |
321 WindowManager* WindowManager::GetInstance() { | 323 WindowManager* WindowManager::GetInstance() { |
322 DCHECK(instance); | 324 DCHECK(instance); |
323 return instance; | 325 return instance; |
324 } | 326 } |
325 | 327 |
326 } // namespace athena | 328 } // namespace athena |
OLD | NEW |