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/window_manager_impl.h" | 5 #include "athena/wm/window_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
10 #include "athena/util/container_priorities.h" | 10 #include "athena/util/container_priorities.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 // Relayout so that windows are maximzied. | 186 // Relayout so that windows are maximzied. |
187 container_->layout_manager()->OnWindowResized(); | 187 container_->layout_manager()->OnWindowResized(); |
188 } else if (split_view_controller_->CanActivateSplitViewMode()) { | 188 } else if (split_view_controller_->CanActivateSplitViewMode()) { |
189 FOR_EACH_OBSERVER(WindowManagerObserver, | 189 FOR_EACH_OBSERVER(WindowManagerObserver, |
190 observers_, | 190 observers_, |
191 OnSplitViewModeEnter()); | 191 OnSplitViewModeEnter()); |
192 split_view_controller_->ActivateSplitMode(NULL, NULL, NULL); | 192 split_view_controller_->ActivateSplitMode(NULL, NULL, NULL); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void WindowManagerImpl::ToggleOverview() { | 196 // Wraps SetInOverview(), and also activates old active window upon deactivation |
197 if (IsOverviewModeActive()) { | 197 void WindowManagerImpl::ActivateOverview(bool activate) { |
198 SetInOverview(false); | 198 if (IsOverviewModeActive() == activate) |
199 return; | |
199 | 200 |
201 SetInOverview(activate); | |
202 if (!activate) { | |
200 // Activate the window which was active prior to entering overview. | 203 // Activate the window which was active prior to entering overview. |
201 const aura::Window::Windows windows = | 204 const aura::Window::Windows windows = |
202 window_list_provider_->GetWindowList(); | 205 window_list_provider_->GetWindowList(); |
203 if (!windows.empty()) { | 206 if (!windows.empty()) { |
204 aura::Window* window = windows.back(); | 207 aura::Window* window = windows.back(); |
205 // Show the window in case the exit overview animation has finished and | 208 // Show the window in case the exit overview animation has finished and |
206 // |window| was hidden. | 209 // |window| was hidden. |
207 window->Show(); | 210 window->Show(); |
208 | 211 |
209 wm::ActivateWindow(window); | 212 wm::ActivateWindow(window); |
210 } | 213 } |
211 } else { | |
212 SetInOverview(true); | |
213 } | 214 } |
214 } | 215 } |
215 | 216 |
216 bool WindowManagerImpl::IsOverviewModeActive() { | 217 bool WindowManagerImpl::IsOverviewModeActive() { |
217 return overview_; | 218 return overview_; |
218 } | 219 } |
219 | 220 |
220 void WindowManagerImpl::SetInOverview(bool active) { | 221 void WindowManagerImpl::SetInOverview(bool active) { |
pkotwicz
2014/10/07 01:30:26
+oshima for his opinion. I remember that the archi
oshima
2014/10/08 00:45:45
Yes, that'd be better, although this CL is unrelat
Greg Levin
2014/10/08 18:21:13
Acknowledged.
Greg Levin
2014/10/08 18:21:13
As per Oshima's suggestion, I'll do this refactor
pkotwicz
2014/10/08 19:45:25
I would recommend either:
a) Splitting WindowManag
| |
221 bool in_overview = !!overview_; | 222 bool in_overview = !!overview_; |
222 if (active == in_overview) | 223 if (active == in_overview) |
223 return; | 224 return; |
224 | 225 |
226 const AcceleratorData esc_accelerator_data = {TRIGGER_ON_PRESS, | |
227 ui::VKEY_ESCAPE, | |
228 ui::EF_NONE, | |
229 CMD_EXIT_OVERVIEW, | |
230 AF_NONE}; | |
231 | |
225 bezel_controller_->set_left_right_delegate( | 232 bezel_controller_->set_left_right_delegate( |
226 active ? NULL : split_view_controller_.get()); | 233 active ? NULL : split_view_controller_.get()); |
227 if (active) { | 234 if (active) { |
228 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); | 235 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); |
229 | 236 |
230 // Note: The window_list_provider_ resembles the exact window list of the | 237 // Note: The window_list_provider_ resembles the exact window list of the |
231 // container, so no re-stacking is required before showing the OverviewMode. | 238 // container, so no re-stacking is required before showing the OverviewMode. |
232 overview_ = WindowOverviewMode::Create( | 239 overview_ = WindowOverviewMode::Create( |
233 container_.get(), window_list_provider_.get(), | 240 container_.get(), window_list_provider_.get(), |
234 split_view_controller_.get(), this); | 241 split_view_controller_.get(), this); |
242 AcceleratorManager::Get()->RegisterAccelerator(esc_accelerator_data, this); | |
235 } else { | 243 } else { |
236 overview_.reset(); | 244 overview_.reset(); |
237 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); | 245 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
246 AcceleratorManager::Get()->UnregisterAccelerator(esc_accelerator_data, | |
247 this); | |
238 } | 248 } |
239 } | 249 } |
240 | 250 |
241 void WindowManagerImpl::InstallAccelerators() { | 251 void WindowManagerImpl::InstallAccelerators() { |
242 const AcceleratorData accelerator_data[] = { | 252 const AcceleratorData accelerator_data[] = { |
243 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, | 253 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, |
244 AF_NONE}, | 254 AF_NONE}, |
245 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, | 255 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, |
246 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, | 256 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, |
247 }; | 257 }; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 container_.reset(); | 325 container_.reset(); |
316 } | 326 } |
317 | 327 |
318 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { | 328 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
319 return true; | 329 return true; |
320 } | 330 } |
321 | 331 |
322 bool WindowManagerImpl::OnAcceleratorFired(int command_id, | 332 bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
323 const ui::Accelerator& accelerator) { | 333 const ui::Accelerator& accelerator) { |
324 switch (command_id) { | 334 switch (command_id) { |
335 case CMD_EXIT_OVERVIEW: | |
336 ActivateOverview(false); | |
337 break; | |
325 case CMD_TOGGLE_OVERVIEW: | 338 case CMD_TOGGLE_OVERVIEW: |
326 ToggleOverview(); | 339 ActivateOverview(!IsOverviewModeActive()); |
327 break; | 340 break; |
328 case CMD_TOGGLE_SPLIT_VIEW: | 341 case CMD_TOGGLE_SPLIT_VIEW: |
329 ToggleSplitView(); | 342 ToggleSplitView(); |
330 break; | 343 break; |
331 } | 344 } |
332 return true; | 345 return true; |
333 } | 346 } |
334 | 347 |
335 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { | 348 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { |
336 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); | 349 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 DCHECK(!instance); | 438 DCHECK(!instance); |
426 } | 439 } |
427 | 440 |
428 // static | 441 // static |
429 WindowManager* WindowManager::Get() { | 442 WindowManager* WindowManager::Get() { |
430 DCHECK(instance); | 443 DCHECK(instance); |
431 return instance; | 444 return instance; |
432 } | 445 } |
433 | 446 |
434 } // namespace athena | 447 } // namespace athena |
OLD | NEW |