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