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/common/container_priorities.h" | 7 #include "athena/common/container_priorities.h" |
8 #include "athena/input/public/accelerator_manager.h" | 8 #include "athena/input/public/accelerator_manager.h" |
9 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
10 #include "athena/wm/bezel_controller.h" | 10 #include "athena/wm/bezel_controller.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void InstallAccelerators(); | 45 void InstallAccelerators(); |
46 | 46 |
47 // WindowManager: | 47 // WindowManager: |
48 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE; | 48 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE; |
49 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE; | 49 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE; |
50 | 50 |
51 // WindowOverviewModeDelegate: | 51 // WindowOverviewModeDelegate: |
52 virtual void OnSelectWindow(aura::Window* window) OVERRIDE; | 52 virtual void OnSelectWindow(aura::Window* window) OVERRIDE; |
53 | 53 |
54 // aura::WindowObserver | 54 // aura::WindowObserver |
| 55 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; |
55 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 56 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
56 | 57 |
57 // AcceleratorHandler: | 58 // AcceleratorHandler: |
58 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; | 59 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; |
59 virtual bool OnAcceleratorFired(int command_id, | 60 virtual bool OnAcceleratorFired(int command_id, |
60 const ui::Accelerator& accelerator) OVERRIDE; | 61 const ui::Accelerator& accelerator) OVERRIDE; |
61 | 62 |
62 scoped_ptr<aura::Window> container_; | 63 scoped_ptr<aura::Window> container_; |
63 scoped_ptr<WindowOverviewMode> overview_; | 64 scoped_ptr<WindowOverviewMode> overview_; |
64 scoped_ptr<BezelController> bezel_controller_; | 65 scoped_ptr<BezelController> bezel_controller_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 container_->RemoveObserver(this); | 110 container_->RemoveObserver(this); |
110 container_->RemovePreTargetHandler(bezel_controller_.get()); | 111 container_->RemovePreTargetHandler(bezel_controller_.get()); |
111 } | 112 } |
112 container_.reset(); | 113 container_.reset(); |
113 instance = NULL; | 114 instance = NULL; |
114 } | 115 } |
115 | 116 |
116 void WindowManagerImpl::Layout() { | 117 void WindowManagerImpl::Layout() { |
117 if (!container_) | 118 if (!container_) |
118 return; | 119 return; |
119 SetInOverview(false); | |
120 gfx::Rect bounds = gfx::Rect(container_->bounds().size()); | 120 gfx::Rect bounds = gfx::Rect(container_->bounds().size()); |
121 const aura::Window::Windows& children = container_->children(); | 121 const aura::Window::Windows& children = container_->children(); |
122 for (aura::Window::Windows::const_iterator iter = children.begin(); | 122 for (aura::Window::Windows::const_iterator iter = children.begin(); |
123 iter != children.end(); | 123 iter != children.end(); |
124 ++iter) { | 124 ++iter) { |
125 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL || | 125 if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL) |
126 (*iter)->type() == ui::wm::WINDOW_TYPE_POPUP) | |
127 (*iter)->SetBounds(bounds); | 126 (*iter)->SetBounds(bounds); |
128 } | 127 } |
129 } | 128 } |
130 | 129 |
131 void WindowManagerImpl::ToggleOverview() { | 130 void WindowManagerImpl::ToggleOverview() { |
132 SetInOverview(overview_.get() == NULL); | 131 SetInOverview(overview_.get() == NULL); |
133 } | 132 } |
134 | 133 |
135 void WindowManagerImpl::SetInOverview(bool active) { | 134 void WindowManagerImpl::SetInOverview(bool active) { |
136 bool in_overview = !!overview_; | 135 bool in_overview = !!overview_; |
(...skipping 28 matching lines...) Expand all Loading... |
165 observers_.RemoveObserver(observer); | 164 observers_.RemoveObserver(observer); |
166 } | 165 } |
167 | 166 |
168 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 167 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
169 CHECK_EQ(container_.get(), window->parent()); | 168 CHECK_EQ(container_.get(), window->parent()); |
170 container_->StackChildAtTop(window); | 169 container_->StackChildAtTop(window); |
171 wm::ActivateWindow(window); | 170 wm::ActivateWindow(window); |
172 SetInOverview(false); | 171 SetInOverview(false); |
173 } | 172 } |
174 | 173 |
| 174 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { |
| 175 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) |
| 176 SetInOverview(false); |
| 177 } |
| 178 |
175 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { | 179 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { |
176 if (window == container_) | 180 if (window == container_) |
177 container_.reset(); | 181 container_.reset(); |
178 } | 182 } |
179 | 183 |
180 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { | 184 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
181 return true; | 185 return true; |
182 } | 186 } |
183 | 187 |
184 bool WindowManagerImpl::OnAcceleratorFired(int command_id, | 188 bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 DCHECK(!instance); | 248 DCHECK(!instance); |
245 } | 249 } |
246 | 250 |
247 // static | 251 // static |
248 WindowManager* WindowManager::GetInstance() { | 252 WindowManager* WindowManager::GetInstance() { |
249 DCHECK(instance); | 253 DCHECK(instance); |
250 return instance; | 254 return instance; |
251 } | 255 } |
252 | 256 |
253 } // namespace athena | 257 } // namespace athena |
OLD | NEW |