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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void WindowManagerImpl::ToggleOverview() { |
197 if (IsOverviewModeActive()) { | 197 ActivateOverview(!IsOverviewModeActive()); |
198 SetInOverview(false); | 198 } |
199 | 199 |
| 200 // Wraps SetInOverview(), and also activates old active window upon deactivation |
| 201 void WindowManagerImpl::ActivateOverview(bool activate) { |
| 202 if (IsOverviewModeActive() == activate) |
| 203 return; |
| 204 |
| 205 SetInOverview(activate); |
| 206 if (!activate) { |
200 // Activate the window which was active prior to entering overview. | 207 // Activate the window which was active prior to entering overview. |
201 const aura::Window::Windows windows = | 208 const aura::Window::Windows windows = |
202 window_list_provider_->GetWindowList(); | 209 window_list_provider_->GetWindowList(); |
203 if (!windows.empty()) { | 210 if (!windows.empty()) { |
204 aura::Window* window = windows.back(); | 211 aura::Window* window = windows.back(); |
205 // Show the window in case the exit overview animation has finished and | 212 // Show the window in case the exit overview animation has finished and |
206 // |window| was hidden. | 213 // |window| was hidden. |
207 window->Show(); | 214 window->Show(); |
208 | 215 |
209 wm::ActivateWindow(window); | 216 wm::ActivateWindow(window); |
210 } | 217 } |
211 } else { | |
212 SetInOverview(true); | |
213 } | 218 } |
214 } | 219 } |
215 | 220 |
216 bool WindowManagerImpl::IsOverviewModeActive() { | 221 bool WindowManagerImpl::IsOverviewModeActive() { |
217 return overview_; | 222 return overview_; |
218 } | 223 } |
219 | 224 |
220 void WindowManagerImpl::SetInOverview(bool active) { | 225 void WindowManagerImpl::SetInOverview(bool active) { |
221 bool in_overview = !!overview_; | 226 bool in_overview = !!overview_; |
222 if (active == in_overview) | 227 if (active == in_overview) |
223 return; | 228 return; |
224 | 229 |
| 230 const AcceleratorData esc_accelerator_data = {TRIGGER_ON_PRESS, |
| 231 ui::VKEY_ESCAPE, |
| 232 ui::EF_NONE, |
| 233 CMD_EXIT_OVERVIEW, |
| 234 AF_NONE}; |
| 235 |
225 bezel_controller_->set_left_right_delegate( | 236 bezel_controller_->set_left_right_delegate( |
226 active ? NULL : split_view_controller_.get()); | 237 active ? NULL : split_view_controller_.get()); |
227 if (active) { | 238 if (active) { |
228 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); | 239 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); |
229 | 240 |
230 // Note: The window_list_provider_ resembles the exact window list of the | 241 // Note: The window_list_provider_ resembles the exact window list of the |
231 // container, so no re-stacking is required before showing the OverviewMode. | 242 // container, so no re-stacking is required before showing the OverviewMode. |
232 overview_ = WindowOverviewMode::Create( | 243 overview_ = WindowOverviewMode::Create( |
233 container_.get(), window_list_provider_.get(), | 244 container_.get(), window_list_provider_.get(), |
234 split_view_controller_.get(), this); | 245 split_view_controller_.get(), this); |
| 246 AcceleratorManager::Get()->RegisterAccelerator(esc_accelerator_data, this); |
235 } else { | 247 } else { |
236 overview_.reset(); | 248 overview_.reset(); |
237 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); | 249 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
| 250 AcceleratorManager::Get()->UnregisterAccelerator(esc_accelerator_data, |
| 251 this); |
238 } | 252 } |
239 } | 253 } |
240 | 254 |
241 void WindowManagerImpl::InstallAccelerators() { | 255 void WindowManagerImpl::InstallAccelerators() { |
242 const AcceleratorData accelerator_data[] = { | 256 const AcceleratorData accelerator_data[] = { |
243 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, | 257 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, |
244 AF_NONE}, | 258 AF_NONE}, |
245 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, | 259 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, |
246 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, | 260 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, |
247 }; | 261 }; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 container_.reset(); | 329 container_.reset(); |
316 } | 330 } |
317 | 331 |
318 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { | 332 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
319 return true; | 333 return true; |
320 } | 334 } |
321 | 335 |
322 bool WindowManagerImpl::OnAcceleratorFired(int command_id, | 336 bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
323 const ui::Accelerator& accelerator) { | 337 const ui::Accelerator& accelerator) { |
324 switch (command_id) { | 338 switch (command_id) { |
| 339 case CMD_EXIT_OVERVIEW: |
| 340 ActivateOverview(false); |
| 341 break; |
325 case CMD_TOGGLE_OVERVIEW: | 342 case CMD_TOGGLE_OVERVIEW: |
326 ToggleOverview(); | 343 ToggleOverview(); |
327 break; | 344 break; |
328 case CMD_TOGGLE_SPLIT_VIEW: | 345 case CMD_TOGGLE_SPLIT_VIEW: |
329 ToggleSplitView(); | 346 ToggleSplitView(); |
330 break; | 347 break; |
331 } | 348 } |
332 return true; | 349 return true; |
333 } | 350 } |
334 | 351 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 DCHECK(!instance); | 442 DCHECK(!instance); |
426 } | 443 } |
427 | 444 |
428 // static | 445 // static |
429 WindowManager* WindowManager::Get() { | 446 WindowManager* WindowManager::Get() { |
430 DCHECK(instance); | 447 DCHECK(instance); |
431 return instance; | 448 return instance; |
432 } | 449 } |
433 | 450 |
434 } // namespace athena | 451 } // namespace athena |
OLD | NEW |