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/common/container_priorities.h" | 9 #include "athena/common/container_priorities.h" |
10 #include "athena/screen/public/screen_manager.h" | 10 #include "athena/screen/public/screen_manager.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 overview_.reset(); | 185 overview_.reset(); |
186 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 186 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
187 OnOverviewModeExit()); | 187 OnOverviewModeExit()); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 void WindowManagerImpl::InstallAccelerators() { | 191 void WindowManagerImpl::InstallAccelerators() { |
192 const AcceleratorData accelerator_data[] = { | 192 const AcceleratorData accelerator_data[] = { |
193 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, | 193 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, |
194 AF_NONE}, | 194 AF_NONE}, |
195 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, | |
196 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, | |
195 }; | 197 }; |
196 AcceleratorManager::Get()->RegisterAccelerators( | 198 AcceleratorManager::Get()->RegisterAccelerators( |
197 accelerator_data, arraysize(accelerator_data), this); | 199 accelerator_data, arraysize(accelerator_data), this); |
198 } | 200 } |
199 | 201 |
200 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { | 202 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { |
201 observers_.AddObserver(observer); | 203 observers_.AddObserver(observer); |
202 } | 204 } |
203 | 205 |
204 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { | 206 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { |
205 observers_.RemoveObserver(observer); | 207 observers_.RemoveObserver(observer); |
206 } | 208 } |
207 | 209 |
208 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 210 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
209 wm::ActivateWindow(window); | 211 wm::ActivateWindow(window); |
210 SetInOverview(false); | 212 SetInOverview(false); |
211 } | 213 } |
212 | 214 |
213 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, | 215 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, |
214 aura::Window* right) { | 216 aura::Window* right) { |
215 SetInOverview(false); | 217 SetInOverview(false); |
216 split_view_controller_->ActivateSplitMode(left, right); | 218 split_view_controller_->ActivateSplitMode(left, right); |
217 } | 219 } |
218 | 220 |
219 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { | 221 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { |
222 // TODO(oshima): Creating a new window should updates the ovewview mode | |
223 // instead of exitting. | |
220 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) | 224 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) |
221 SetInOverview(false); | 225 SetInOverview(false); |
222 } | 226 } |
223 | 227 |
224 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { | 228 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { |
225 if (window == container_) | 229 if (window == container_) |
226 container_.reset(); | 230 container_.reset(); |
227 } | 231 } |
228 | 232 |
229 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { | 233 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
230 return true; | 234 return true; |
231 } | 235 } |
232 | 236 |
233 bool WindowManagerImpl::OnAcceleratorFired(int command_id, | 237 bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
234 const ui::Accelerator& accelerator) { | 238 const ui::Accelerator& accelerator) { |
235 switch (command_id) { | 239 switch (command_id) { |
236 case CMD_TOGGLE_OVERVIEW: | 240 case CMD_TOGGLE_OVERVIEW: |
237 ToggleOverview(); | 241 ToggleOverview(); |
238 break; | 242 break; |
243 case CMD_TOGGLE_SPLIT_VIEW: | |
244 ToggleSplitview(); | |
245 break; | |
239 } | 246 } |
240 return true; | 247 return true; |
241 } | 248 } |
242 | 249 |
250 void WindowManagerImpl::ToggleSplitview() { | |
251 // TODO(oshima): Figure out what to do. | |
252 if (IsOverviewModeActive()) | |
253 return; | |
254 | |
255 if (split_view_controller_->IsSplitViewModeActive()) { | |
256 split_view_controller_->DeactivateSplitMode(); | |
257 // Relayout so that windows are maximzied. | |
258 container_->layout_manager()->OnWindowResized(); | |
259 } else if (window_list_provider_->GetWindowList().size() > 1) { | |
260 const aura::Window::Windows& windows = | |
261 window_list_provider_->GetWindowList(); | |
262 aura::Window* left = *windows.rbegin(); | |
263 aura::Window* right = *(windows.rbegin() + 1); | |
264 split_view_controller_->ActivateSplitMode(left, right); | |
sadrul
2014/08/19 16:27:53
Doing ActivateSplitMode(NULL, NULL) should also wo
oshima
2014/08/19 17:05:33
good to know. done.
| |
265 } | |
266 } | |
267 | |
243 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { | 268 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { |
244 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); | 269 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); |
245 aura::Window::Windows::const_reverse_iterator iter = | 270 aura::Window::Windows::const_reverse_iterator iter = |
246 std::find(windows.rbegin(), windows.rend(), window); | 271 std::find(windows.rbegin(), windows.rend(), window); |
247 CHECK(iter != windows.rend()); | 272 CHECK(iter != windows.rend()); |
248 ++iter; | 273 ++iter; |
249 aura::Window* behind = NULL; | 274 aura::Window* behind = NULL; |
250 if (iter != windows.rend()) | 275 if (iter != windows.rend()) |
251 behind = *iter++; | 276 behind = *iter++; |
252 | 277 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 DCHECK(!instance); | 335 DCHECK(!instance); |
311 } | 336 } |
312 | 337 |
313 // static | 338 // static |
314 WindowManager* WindowManager::GetInstance() { | 339 WindowManager* WindowManager::GetInstance() { |
315 DCHECK(instance); | 340 DCHECK(instance); |
316 return instance; | 341 return instance; |
317 } | 342 } |
318 | 343 |
319 } // namespace athena | 344 } // namespace athena |
OLD | NEW |