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 "athena/input/public/accelerator_manager.h" | 7 #include "athena/input/public/accelerator_manager.h" |
8 #include "athena/screen/public/screen_manager.h" | 8 #include "athena/screen/public/screen_manager.h" |
9 #include "athena/wm/window_overview_mode.h" | 9 #include "athena/wm/window_overview_mode.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "ui/aura/layout_manager.h" | 11 #include "ui/aura/layout_manager.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/wm/public/window_types.h" | 13 #include "ui/wm/public/window_types.h" |
14 | 14 |
15 namespace athena { | 15 namespace athena { |
16 namespace { | 16 namespace { |
17 | 17 |
18 class WindowManagerImpl : public WindowManager, | 18 class WindowManagerImpl : public WindowManager, |
19 public WindowOverviewModeDelegate, | 19 public WindowOverviewModeDelegate, |
20 public aura::WindowObserver, | 20 public aura::WindowObserver, |
21 public AcceleratorHandler { | 21 public AcceleratorHandler { |
22 public: | 22 public: |
23 WindowManagerImpl(); | 23 WindowManagerImpl(); |
24 virtual ~WindowManagerImpl(); | 24 virtual ~WindowManagerImpl(); |
25 | 25 |
26 void Init() { InstallAccelerators(); } | |
27 | |
28 void Layout(); | 26 void Layout(); |
29 | 27 |
30 // WindowManager: | 28 // WindowManager: |
31 virtual void ToggleOverview() OVERRIDE { | 29 virtual void ToggleOverview() OVERRIDE { |
32 if (overview_) | 30 if (overview_) |
33 overview_.reset(); | 31 overview_.reset(); |
34 else | 32 else |
35 overview_ = WindowOverviewMode::Create(container_.get(), this); | 33 overview_ = WindowOverviewMode::Create(container_.get(), this); |
36 } | 34 } |
37 | 35 |
38 private: | 36 private: |
39 enum Command { | 37 enum Command { |
40 COMMAND_TOGGLE_OVERVIEW, | 38 COMMAND_TOGGLE_OVERVIEW, |
41 }; | 39 }; |
42 | 40 |
43 void InstallAccelerators() { | 41 void InstallAccelerators() { |
44 const AcceleratorData accelerator_data[] = { | 42 const AcceleratorData accelerator_data[] = { |
45 {TRIGGER_ON_PRESS, ui::VKEY_6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, | 43 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, |
46 AF_NONE}, | 44 AF_NONE}, |
47 }; | 45 }; |
48 AcceleratorManager::Get()->RegisterAccelerators( | 46 AcceleratorManager::Get()->RegisterAccelerators( |
49 accelerator_data, arraysize(accelerator_data), this); | 47 accelerator_data, arraysize(accelerator_data), this); |
50 } | 48 } |
51 | 49 |
52 // WindowOverviewModeDelegate: | 50 // WindowOverviewModeDelegate: |
53 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { | 51 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { |
54 CHECK_EQ(container_.get(), window->parent()); | 52 CHECK_EQ(container_.get(), window->parent()); |
55 container_->StackChildAtTop(window); | 53 container_->StackChildAtTop(window); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 107 |
110 DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager); | 108 DISALLOW_COPY_AND_ASSIGN(AthenaContainerLayoutManager); |
111 }; | 109 }; |
112 | 110 |
113 WindowManagerImpl::WindowManagerImpl() | 111 WindowManagerImpl::WindowManagerImpl() |
114 : container_( | 112 : container_( |
115 ScreenManager::Get()->CreateDefaultContainer("MainContainer")) { | 113 ScreenManager::Get()->CreateDefaultContainer("MainContainer")) { |
116 container_->SetLayoutManager(new AthenaContainerLayoutManager); | 114 container_->SetLayoutManager(new AthenaContainerLayoutManager); |
117 container_->AddObserver(this); | 115 container_->AddObserver(this); |
118 instance = this; | 116 instance = this; |
| 117 InstallAccelerators(); |
119 } | 118 } |
120 | 119 |
121 WindowManagerImpl::~WindowManagerImpl() { | 120 WindowManagerImpl::~WindowManagerImpl() { |
122 if (container_) | 121 if (container_) |
123 container_->RemoveObserver(this); | 122 container_->RemoveObserver(this); |
124 container_.reset(); | 123 container_.reset(); |
125 instance = NULL; | 124 instance = NULL; |
126 } | 125 } |
127 | 126 |
128 void WindowManagerImpl::Layout() { | 127 void WindowManagerImpl::Layout() { |
(...skipping 21 matching lines...) Expand all Loading... |
150 } | 149 } |
151 | 150 |
152 // static | 151 // static |
153 void WindowManager::Shutdown() { | 152 void WindowManager::Shutdown() { |
154 DCHECK(instance); | 153 DCHECK(instance); |
155 delete instance; | 154 delete instance; |
156 DCHECK(!instance); | 155 DCHECK(!instance); |
157 } | 156 } |
158 | 157 |
159 } // namespace athena | 158 } // namespace athena |
OLD | NEW |