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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "athena/common/container_priorities.h" | 9 #include "athena/common/container_priorities.h" |
10 #include "athena/input/public/accelerator_manager.h" | 10 #include "athena/input/public/accelerator_manager.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 const ui::Accelerator& accelerator) { | 238 const ui::Accelerator& accelerator) { |
239 switch (command_id) { | 239 switch (command_id) { |
240 case CMD_TOGGLE_OVERVIEW: | 240 case CMD_TOGGLE_OVERVIEW: |
241 ToggleOverview(); | 241 ToggleOverview(); |
242 break; | 242 break; |
243 } | 243 } |
244 return true; | 244 return true; |
245 } | 245 } |
246 | 246 |
247 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { | 247 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { |
248 const aura::Window::Windows& windows = container_->children(); | 248 const aura::Window::Windows& windows = container_->children(); |
Jun Mukai
2014/08/13 23:38:59
Possibly you should use mru_window_tracker_ here.
mfomitchev
2014/08/14 14:38:13
+1
sadrul
2014/08/15 19:00:20
Done.
| |
249 aura::Window::Windows::const_iterator iter = | 249 aura::Window::Windows::const_reverse_iterator iter = |
250 std::find(windows.begin(), windows.end(), window); | 250 std::find(windows.rbegin(), windows.rend(), window); |
251 CHECK(iter != windows.end()); | 251 CHECK(iter != windows.rend()); |
252 return (iter == windows.begin()) ? NULL : *(iter - 1); | 252 ++iter; |
253 aura::Window* behind = NULL; | |
254 if (iter != windows.rend()) | |
255 behind = *iter++; | |
256 | |
257 if (split_view_controller_->IsSplitViewModeActive()) { | |
258 CHECK(window == split_view_controller_->left_window() || | |
259 window == split_view_controller_->right_window()); | |
260 if (window == split_view_controller_->left_window() && | |
261 behind == split_view_controller_->right_window() && | |
262 iter != windows.rend()) { | |
263 behind = *iter; | |
mfomitchev
2014/08/14 14:38:13
We need to set behind to NULL if iter == windows.r
sadrul
2014/08/15 19:00:20
Good catch. Done.
mfomitchev
2014/08/15 19:15:03
Nit: I still prefer the code I suggested above - l
sadrul
2014/08/15 19:34:54
This doesn't work right because the CHECK would tr
sadrul
2014/08/15 19:46:43
Mikhail pointed out that this actually does do the
| |
264 } | |
265 | |
266 if (window == split_view_controller_->right_window() && | |
267 behind == split_view_controller_->left_window() && | |
268 iter != windows.rend()) { | |
269 behind = *iter; | |
270 } | |
271 } | |
272 | |
273 return behind; | |
253 } | 274 } |
254 | 275 |
255 void WindowManagerImpl::OnTitleDragStarted(aura::Window* window) { | 276 void WindowManagerImpl::OnTitleDragStarted(aura::Window* window) { |
277 aura::Window* next_window = GetWindowBehind(window); | |
278 if (!next_window) | |
279 return; | |
280 // Make sure |window| is active. Also make sure that |next_window| is visible, | |
281 // and positioned to match the top-left edge of |window|. | |
282 wm::ActivateWindow(window); | |
283 next_window->Show(); | |
284 int dx = window->bounds().x() - next_window->bounds().x(); | |
285 if (dx) { | |
286 gfx::Transform transform; | |
287 transform.Translate(dx, 0); | |
288 next_window->SetTransform(transform); | |
289 } | |
256 } | 290 } |
257 | 291 |
258 void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) { | 292 void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) { |
259 aura::Window* next_window = GetWindowBehind(window); | 293 aura::Window* next_window = GetWindowBehind(window); |
260 if (next_window) | 294 if (!next_window) |
295 return; | |
296 if (split_view_controller_->IsSplitViewModeActive()) | |
297 split_view_controller_->ReplaceWindow(window, next_window); | |
298 else | |
261 OnSelectWindow(next_window); | 299 OnSelectWindow(next_window); |
300 wm::ActivateWindow(next_window); | |
262 } | 301 } |
263 | 302 |
264 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) { | 303 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) { |
304 aura::Window* next_window = GetWindowBehind(window); | |
305 if (!next_window) | |
306 return; | |
307 next_window->SetTransform(gfx::Transform()); | |
308 next_window->Hide(); | |
265 } | 309 } |
266 | 310 |
267 AthenaContainerLayoutManager::AthenaContainerLayoutManager() { | 311 AthenaContainerLayoutManager::AthenaContainerLayoutManager() { |
268 } | 312 } |
269 | 313 |
270 AthenaContainerLayoutManager::~AthenaContainerLayoutManager() { | 314 AthenaContainerLayoutManager::~AthenaContainerLayoutManager() { |
271 } | 315 } |
272 | 316 |
273 void AthenaContainerLayoutManager::OnWindowResized() { | 317 void AthenaContainerLayoutManager::OnWindowResized() { |
274 instance->Layout(); | 318 instance->Layout(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 DCHECK(!instance); | 361 DCHECK(!instance); |
318 } | 362 } |
319 | 363 |
320 // static | 364 // static |
321 WindowManager* WindowManager::GetInstance() { | 365 WindowManager* WindowManager::GetInstance() { |
322 DCHECK(instance); | 366 DCHECK(instance); |
323 return instance; | 367 return instance; |
324 } | 368 } |
325 | 369 |
326 } // namespace athena | 370 } // namespace athena |
OLD | NEW |