OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/wm/dock/docked_window_layout_manager.h" | 5 #include "ash/wm/dock/docked_window_layout_manager.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
23 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
24 | 24 |
25 namespace ash { | 25 namespace ash { |
26 namespace internal { | 26 namespace internal { |
27 | 27 |
28 // Minimum, maximum width of the dock area and a width of the gap | 28 // Minimum, maximum width of the dock area and a width of the gap |
29 const int DockedWindowLayoutManager::kMinDockWidth = 200; | 29 const int DockedWindowLayoutManager::kMinDockWidth = 200; |
30 const int DockedWindowLayoutManager::kMaxDockWidth = 450; | 30 const int DockedWindowLayoutManager::kMaxDockWidth = 450; |
31 const int DockedWindowLayoutManager::kMinDockGap = 2; | 31 const int DockedWindowLayoutManager::kMinDockGap = 2; |
32 const int kWindowIdealSpacing = 4; | |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 DockedWindowLayoutManager* GetDockLayoutManager(aura::Window* window, | 36 DockedWindowLayoutManager* GetDockLayoutManager(aura::Window* window, |
36 const gfx::Point& location) { | 37 const gfx::Point& location) { |
37 gfx::Rect near_location(location, gfx::Size()); | 38 gfx::Rect near_location(location, gfx::Size()); |
38 aura::Window* dock = Shell::GetContainer( | 39 aura::Window* dock = Shell::GetContainer( |
39 wm::GetRootWindowMatching(near_location), | 40 wm::GetRootWindowMatching(near_location), |
40 kShellWindowId_DockedContainer); | 41 kShellWindowId_DockedContainer); |
41 return static_cast<internal::DockedWindowLayoutManager*>( | 42 return static_cast<internal::DockedWindowLayoutManager*>( |
42 dock->layout_manager()); | 43 dock->layout_manager()); |
43 } | 44 } |
44 | 45 |
45 // Certain windows (minimized, hidden or popups) do not matter to docking. | 46 // Certain windows (minimized, hidden or popups) do not matter to docking. |
46 bool IsUsedByLayout(aura::Window* window) { | 47 bool IsUsedByLayout(aura::Window* window) { |
47 return (window->IsVisible() && | 48 return (window->IsVisible() && |
48 !wm::IsWindowMinimized(window) && | 49 !wm::IsWindowMinimized(window) && |
49 window->type() != aura::client::WINDOW_TYPE_POPUP); | 50 window->type() != aura::client::WINDOW_TYPE_POPUP); |
50 } | 51 } |
51 | 52 |
53 bool CompareWindowPos(const aura::Window* win1, const aura::Window* win2) { | |
54 return win1->GetTargetBounds().CenterPoint().y() < | |
55 win2->GetTargetBounds().CenterPoint().y(); | |
56 } | |
57 | |
52 } // namespace | 58 } // namespace |
53 | 59 |
54 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
55 // DockLayoutManager public implementation: | 61 // DockLayoutManager public implementation: |
56 DockedWindowLayoutManager::DockedWindowLayoutManager( | 62 DockedWindowLayoutManager::DockedWindowLayoutManager( |
57 aura::Window* dock_container) | 63 aura::Window* dock_container) |
58 : dock_container_(dock_container), | 64 : dock_container_(dock_container), |
59 in_layout_(false), | 65 in_layout_(false), |
60 dragged_window_(NULL), | 66 dragged_window_(NULL), |
61 launcher_(NULL), | 67 launcher_(NULL), |
62 shelf_layout_manager_(NULL), | 68 shelf_layout_manager_(NULL), |
63 shelf_hidden_(false), | 69 shelf_hidden_(false), |
64 docked_width_(0), | 70 docked_width_(0), |
65 alignment_(DOCKED_ALIGNMENT_NONE) { | 71 alignment_(DOCKED_ALIGNMENT_NONE), |
72 last_active_window_(NULL) { | |
66 DCHECK(dock_container); | 73 DCHECK(dock_container); |
67 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 74 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
68 AddObserver(this); | 75 AddObserver(this); |
69 Shell::GetInstance()->AddShellObserver(this); | 76 Shell::GetInstance()->AddShellObserver(this); |
70 } | 77 } |
71 | 78 |
72 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 79 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
73 Shutdown(); | 80 Shutdown(); |
74 } | 81 } |
75 | 82 |
(...skipping 21 matching lines...) Expand all Loading... | |
97 } | 104 } |
98 | 105 |
99 void DockedWindowLayoutManager::StartDragging(aura::Window* window) { | 106 void DockedWindowLayoutManager::StartDragging(aura::Window* window) { |
100 if (window->parent() != dock_container_) | 107 if (window->parent() != dock_container_) |
101 return; | 108 return; |
102 DCHECK(!dragged_window_); | 109 DCHECK(!dragged_window_); |
103 dragged_window_ = window; | 110 dragged_window_ = window; |
104 Relayout(); | 111 Relayout(); |
105 } | 112 } |
106 | 113 |
107 void DockedWindowLayoutManager::FinishDragging() { | 114 void DockedWindowLayoutManager::FinishDragging() { |
flackr
2013/07/19 17:53:32
I think you need to observe OnWindowDestroying or
varkha
2013/07/20 01:26:25
True (tested). Panels layout doesn't have this tro
flackr
2013/07/22 21:19:49
Can't think of anything else, just making sure to
| |
108 if (!dragged_window_) | 115 if (!dragged_window_) |
109 return; | 116 return; |
110 | 117 |
111 // If this is the first window getting docked - update alignment. | 118 // If this is the first window getting docked - update alignment. |
112 if (alignment_ == DOCKED_ALIGNMENT_NONE) { | 119 if (alignment_ == DOCKED_ALIGNMENT_NONE) { |
113 alignment_ = AlignmentOfWindow(dragged_window_); | 120 alignment_ = AlignmentOfWindow(dragged_window_); |
114 } else { | 121 } else { |
115 // There were some docked windows before. Check if the |dragged_window_| | 122 // There were some docked windows before. Check if the |dragged_window_| |
116 // was the only one remaining and if so possibly switch alignment to | 123 // was the only one remaining and if so possibly switch alignment to |
117 // opposite side. Ignore popups. | 124 // opposite side. Ignore popups. |
118 bool found_docked_window = false; | 125 bool found_docked_window = false; |
119 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 126 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
120 aura::Window* window(dock_container_->children()[i]); | 127 aura::Window* window(dock_container_->children()[i]); |
121 if (window != dragged_window_ && | 128 if (window != dragged_window_ && |
122 window->type() != aura::client::WINDOW_TYPE_POPUP) { | 129 window->type() != aura::client::WINDOW_TYPE_POPUP) { |
123 found_docked_window = true; | 130 found_docked_window = true; |
124 break; | 131 break; |
125 } | 132 } |
126 } | 133 } |
127 if (!found_docked_window) | 134 if (!found_docked_window) |
128 alignment_ = AlignmentOfWindow(dragged_window_); | 135 alignment_ = AlignmentOfWindow(dragged_window_); |
129 } | 136 } |
130 dragged_window_ = NULL; | 137 |
138 // We no longer need to observe |dragged_window_| unless it is added back; | |
139 if (dragged_window_) { | |
140 if (dragged_window_->parent() != dock_container_) | |
141 dragged_window_->RemoveObserver(this); | |
142 dragged_window_ = NULL; | |
143 } | |
131 | 144 |
132 Relayout(); | 145 Relayout(); |
133 UpdateDockBounds(); | 146 UpdateDockBounds(); |
134 } | 147 } |
135 | 148 |
136 // static | 149 // static |
137 bool DockedWindowLayoutManager::ShouldWindowDock(aura::Window* window, | 150 bool DockedWindowLayoutManager::ShouldWindowDock(aura::Window* window, |
138 const gfx::Point& location) { | 151 const gfx::Point& location) { |
139 DockedWindowLayoutManager* layout_manager = GetDockLayoutManager(window, | 152 DockedWindowLayoutManager* layout_manager = GetDockLayoutManager(window, |
140 location); | 153 location); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 UpdateDockBounds(); | 232 UpdateDockBounds(); |
220 } | 233 } |
221 | 234 |
222 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 235 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
223 if (child->type() == aura::client::WINDOW_TYPE_POPUP) | 236 if (child->type() == aura::client::WINDOW_TYPE_POPUP) |
224 return; | 237 return; |
225 | 238 |
226 // If this is the first window getting docked - update alignment. | 239 // If this is the first window getting docked - update alignment. |
227 if (alignment_ == DOCKED_ALIGNMENT_NONE) | 240 if (alignment_ == DOCKED_ALIGNMENT_NONE) |
228 alignment_ = AlignmentOfWindow(child); | 241 alignment_ = AlignmentOfWindow(child); |
229 child->AddObserver(this); | 242 // We need to observe a child unless it is a |dragged_window_| that just got |
243 // added back in which case we are already observing it. | |
244 if (child != dragged_window_) | |
245 child->AddObserver(this); | |
230 Relayout(); | 246 Relayout(); |
231 UpdateDockBounds(); | 247 UpdateDockBounds(); |
232 } | 248 } |
233 | 249 |
234 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 250 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
235 if (child->type() == aura::client::WINDOW_TYPE_POPUP) | 251 if (child->type() == aura::client::WINDOW_TYPE_POPUP) |
236 return; | 252 return; |
237 | 253 |
238 // Try to find a child that is not a popup and is not being dragged. | 254 // Try to find a child that is not a popup and is not being dragged. |
239 bool found_docked_window = false; | 255 bool found_docked_window = false; |
240 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 256 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
241 aura::Window* window(dock_container_->children()[i]); | 257 aura::Window* window(dock_container_->children()[i]); |
242 if (window != dragged_window_ && | 258 if (window != dragged_window_ && |
243 window->type() != aura::client::WINDOW_TYPE_POPUP) { | 259 window->type() != aura::client::WINDOW_TYPE_POPUP) { |
244 found_docked_window = true; | 260 found_docked_window = true; |
245 break; | 261 break; |
246 } | 262 } |
247 } | 263 } |
248 if (!found_docked_window) | 264 if (!found_docked_window) |
249 alignment_ = DOCKED_ALIGNMENT_NONE; | 265 alignment_ = DOCKED_ALIGNMENT_NONE; |
250 | 266 |
251 child->RemoveObserver(this); | 267 // Keep track of former children if they are dragged as they can be reparented |
268 // temporarily just for the drag. | |
269 if (child != dragged_window_) | |
270 child->RemoveObserver(this); | |
271 | |
272 if (last_active_window_ == child) | |
273 last_active_window_ = NULL; | |
274 | |
252 // Close the dock and expand workspace work area. | 275 // Close the dock and expand workspace work area. |
253 Relayout(); | 276 Relayout(); |
254 | 277 |
255 // When a panel is removed from this layout manager it may still be dragged. | 278 // When a panel is removed from this layout manager it may still be dragged. |
256 // Delay updating dock and workspace bounds until the drag is completed. This | 279 // Delay updating dock and workspace bounds until the drag is completed. This |
257 // preserves the docked area width until the panel drag is finished. | 280 // preserves the docked area width until the panel drag is finished. |
258 if (child->type() != aura::client::WINDOW_TYPE_PANEL) | 281 if (child->type() != aura::client::WINDOW_TYPE_PANEL) |
259 UpdateDockBounds(); | 282 UpdateDockBounds(); |
260 } | 283 } |
261 | 284 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 // The window property will still be set, but no actual change will occur | 342 // The window property will still be set, but no actual change will occur |
320 // until WillChangeVisibilityState is called when the shelf is visible again | 343 // until WillChangeVisibilityState is called when the shelf is visible again |
321 if (shelf_hidden_) | 344 if (shelf_hidden_) |
322 return; | 345 return; |
323 if (wm::IsWindowMinimized(window)) | 346 if (wm::IsWindowMinimized(window)) |
324 MinimizeWindow(window); | 347 MinimizeWindow(window); |
325 else | 348 else |
326 RestoreWindow(window); | 349 RestoreWindow(window); |
327 } | 350 } |
328 | 351 |
352 void DockedWindowLayoutManager::OnWindowBoundsChanged( | |
353 aura::Window* window, | |
354 const gfx::Rect& old_bounds, | |
355 const gfx::Rect& new_bounds) { | |
356 if (window == dragged_window_) | |
357 Relayout(); | |
358 } | |
359 | |
329 //////////////////////////////////////////////////////////////////////////////// | 360 //////////////////////////////////////////////////////////////////////////////// |
330 // DockLayoutManager, aura::client::ActivationChangeObserver implementation: | 361 // DockLayoutManager, aura::client::ActivationChangeObserver implementation: |
331 | 362 |
332 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, | 363 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, |
333 aura::Window* lost_active) { | 364 aura::Window* lost_active) { |
334 // Ignore if the window that is not managed by this was activated. | 365 // Ignore if the window that is not managed by this was activated. |
335 aura::Window* ancestor = NULL; | 366 aura::Window* ancestor = NULL; |
336 for (aura::Window* parent = gained_active; | 367 for (aura::Window* parent = gained_active; |
337 parent; parent = parent->parent()) { | 368 parent; parent = parent->parent()) { |
338 if (parent->parent() == dock_container_) { | 369 if (parent->parent() == dock_container_) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 return DOCKED_ALIGNMENT_NONE; | 432 return DOCKED_ALIGNMENT_NONE; |
402 } | 433 } |
403 | 434 |
404 void DockedWindowLayoutManager::Relayout() { | 435 void DockedWindowLayoutManager::Relayout() { |
405 if (in_layout_ || alignment_ == DOCKED_ALIGNMENT_NONE) | 436 if (in_layout_ || alignment_ == DOCKED_ALIGNMENT_NONE) |
406 return; | 437 return; |
407 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 438 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
408 | 439 |
409 gfx::Rect dock_bounds = dock_container_->bounds(); | 440 gfx::Rect dock_bounds = dock_container_->bounds(); |
410 aura::Window* active_window = NULL; | 441 aura::Window* active_window = NULL; |
442 aura::Window::Windows visible_windows; | |
411 docked_width_ = 0; | 443 docked_width_ = 0; |
412 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 444 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
413 aura::Window* window(dock_container_->children()[i]); | 445 aura::Window* window(dock_container_->children()[i]); |
414 | 446 |
415 if (!IsUsedByLayout(window)) | 447 if (!IsUsedByLayout(window)) |
416 continue; | 448 continue; |
417 | 449 |
418 // If the shelf is currently hidden (full-screen mode), hide window until | 450 // If the shelf is currently hidden (full-screen mode), hide window until |
419 // full-screen mode is exited. | 451 // full-screen mode is exited. |
420 if (shelf_hidden_) { | 452 if (shelf_hidden_) { |
421 // The call to Hide does not set the minimize property, so the window will | 453 // The call to Hide does not set the minimize property, so the window will |
422 // be restored when the shelf becomes visible again. | 454 // be restored when the shelf becomes visible again. |
423 window->Hide(); | 455 window->Hide(); |
424 continue; | 456 continue; |
425 } | 457 } |
426 | |
427 if (window->HasFocus() || | 458 if (window->HasFocus() || |
428 window->Contains( | 459 window->Contains( |
429 aura::client::GetFocusClient(window)->GetFocusedWindow())) { | 460 aura::client::GetFocusClient(window)->GetFocusedWindow())) { |
430 DCHECK(!active_window); | 461 DCHECK(!active_window); |
431 active_window = window; | 462 active_window = window; |
432 } | 463 } |
464 visible_windows.push_back(window); | |
465 } | |
433 | 466 |
434 // all docked windows other than the one currently dragged remain stuck | 467 // Consider windows that were formerly children of the |dock_container_| |
435 // to the screen edge | 468 // when fanning out other child windows. |
469 if (dragged_window_ && dragged_window_->parent() != dock_container_) | |
470 visible_windows.push_back(dragged_window_); | |
471 | |
472 // Sort windows by their center positions and fan out overlapping | |
473 // windows. | |
474 std::sort(visible_windows.begin(), visible_windows.end(), CompareWindowPos); | |
475 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( | |
476 dock_container_); | |
477 const gfx::Rect work_area = display.work_area(); | |
478 int available_room = work_area.height(); | |
479 for (aura::Window::Windows::const_iterator iter = visible_windows.begin(); | |
480 iter != visible_windows.end(); ++iter) { | |
481 available_room -= (*iter)->bounds().height(); | |
482 } | |
483 const int num_windows = visible_windows.size(); | |
484 const int delta = available_room / | |
485 ((available_room > 0 || num_windows <= 1) ? | |
486 num_windows + 1 : num_windows - 1); | |
487 int y_pos = (available_room > 0) ? delta : 0; | |
488 | |
489 for (aura::Window::Windows::const_iterator iter = visible_windows.begin(); | |
490 iter != visible_windows.end(); ++iter) { | |
491 aura::Window* window = *iter; | |
436 gfx::Rect bounds = window->GetTargetBounds(); | 492 gfx::Rect bounds = window->GetTargetBounds(); |
437 if (window != dragged_window_) { | 493 // Do not force position of a single window. |
438 switch (alignment_) { | 494 if (num_windows == 1) |
439 case DOCKED_ALIGNMENT_LEFT: | 495 y_pos = bounds.y(); |
440 bounds.set_x(0); | 496 |
441 break; | 497 // Fan out windows evenly distributing the overlap or remaining free space. |
442 case DOCKED_ALIGNMENT_RIGHT: | 498 bounds.set_y(std::max(work_area.y(), |
443 bounds.set_x(dock_bounds.right() - bounds.width()); | 499 std::min(work_area.bottom() - bounds.height(), |
444 break; | 500 y_pos))); |
445 case DOCKED_ALIGNMENT_NONE: | 501 y_pos += bounds.height() + delta; |
446 NOTREACHED() << "Relayout called when dock alignment is 'NONE'"; | 502 |
447 break; | 503 // All docked windows other than the one currently dragged remain stuck |
448 } | 504 // to the screen edge. |
449 // Keep the dock at least kMinDockWidth when all windows in it overhang. | 505 if (window == dragged_window_) |
450 docked_width_ = std::min(kMaxDockWidth, | 506 continue; |
451 std::max(docked_width_, | 507 switch (alignment_) { |
452 bounds.width() > kMaxDockWidth ? | 508 case DOCKED_ALIGNMENT_LEFT: |
453 kMinDockWidth : bounds.width())); | 509 bounds.set_x(0); |
510 break; | |
511 case DOCKED_ALIGNMENT_RIGHT: | |
512 bounds.set_x(dock_bounds.right() - bounds.width()); | |
513 break; | |
514 case DOCKED_ALIGNMENT_NONE: | |
515 NOTREACHED() << "Relayout called when dock alignment is 'NONE'"; | |
516 break; | |
454 } | 517 } |
518 // Keep the dock at least kMinDockWidth when all windows in it overhang. | |
519 docked_width_ = std::min(kMaxDockWidth, | |
520 std::max(docked_width_, | |
521 bounds.width() > kMaxDockWidth ? | |
522 kMinDockWidth : bounds.width())); | |
455 SetChildBoundsDirect(window, bounds); | 523 SetChildBoundsDirect(window, bounds); |
456 } | 524 } |
457 UpdateStacking(active_window); | 525 UpdateStacking(active_window); |
458 } | 526 } |
459 | 527 |
460 void DockedWindowLayoutManager::UpdateDockBounds() { | 528 void DockedWindowLayoutManager::UpdateDockBounds() { |
461 int dock_inset = docked_width_ + (docked_width_ > 0 ? kMinDockGap : 0); | 529 int dock_inset = docked_width_ + (docked_width_ > 0 ? kMinDockGap : 0); |
462 gfx::Rect bounds = gfx::Rect( | 530 gfx::Rect bounds = gfx::Rect( |
463 alignment_ == DOCKED_ALIGNMENT_RIGHT ? | 531 alignment_ == DOCKED_ALIGNMENT_RIGHT ? |
464 dock_container_->bounds().right() - dock_inset: | 532 dock_container_->bounds().right() - dock_inset: |
465 dock_container_->bounds().x(), | 533 dock_container_->bounds().x(), |
466 dock_container_->bounds().y(), | 534 dock_container_->bounds().y(), |
467 dock_inset, | 535 dock_inset, |
468 dock_container_->bounds().height()); | 536 dock_container_->bounds().height()); |
469 docked_bounds_ = bounds + | 537 docked_bounds_ = bounds + |
470 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); | 538 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); |
471 FOR_EACH_OBSERVER( | 539 FOR_EACH_OBSERVER( |
472 DockedWindowLayoutManagerObserver, | 540 DockedWindowLayoutManagerObserver, |
473 observer_list_, | 541 observer_list_, |
474 OnDockBoundsChanging(bounds)); | 542 OnDockBoundsChanging(bounds)); |
475 } | 543 } |
476 | 544 |
477 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { | 545 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { |
478 // TODO(varkha): Implement restacking to ensure that all docked windows are at | 546 if (!active_window) { |
479 // least partially visible and selectable. | 547 if (!last_active_window_) |
548 return; | |
549 active_window = last_active_window_; | |
550 } | |
551 | |
552 // We want to to stack the windows like a deck of cards: | |
553 // ,------. | |
554 // |,------.| | |
555 // |,------.| | |
556 // | active | | |
557 // | window | | |
558 // |`------'| | |
559 // |`------'| | |
560 // `------' | |
561 // We use the middle of each window to figure out how to stack the window. | |
562 // This allows us to update the stacking when a window is being dragged around | |
563 // by the titlebar. | |
564 std::map<int, aura::Window*> window_ordering; | |
565 for (aura::Window::Windows::const_iterator it = | |
566 dock_container_->children().begin(); | |
567 it != dock_container_->children().end(); ++it) { | |
568 gfx::Rect bounds = (*it)->bounds(); | |
569 window_ordering.insert(std::make_pair(bounds.y() + bounds.height() / 2, | |
570 *it)); | |
571 } | |
572 int active_center_y = active_window->bounds().CenterPoint().y(); | |
573 | |
574 aura::Window* previous_window = NULL; | |
575 for (std::map<int, aura::Window*>::const_iterator it = | |
576 window_ordering.begin(); | |
577 it != window_ordering.end() && it->first < active_center_y; ++it) { | |
578 if (previous_window) | |
579 dock_container_->StackChildAbove(it->second, previous_window); | |
580 previous_window = it->second; | |
581 } | |
582 | |
583 previous_window = NULL; | |
584 for (std::map<int, aura::Window*>::const_reverse_iterator it = | |
585 window_ordering.rbegin(); | |
586 it != window_ordering.rend() && it->first > active_center_y; ++it) { | |
587 if (previous_window) | |
588 dock_container_->StackChildAbove(it->second, previous_window); | |
589 previous_window = it->second; | |
590 } | |
591 | |
592 if (active_window->parent() == dock_container_) | |
593 dock_container_->StackChildAtTop(active_window); | |
594 if (dragged_window_ && dragged_window_->parent() == dock_container_) | |
595 dock_container_->StackChildAtTop(dragged_window_); | |
596 last_active_window_ = active_window; | |
480 } | 597 } |
481 | 598 |
482 //////////////////////////////////////////////////////////////////////////////// | 599 //////////////////////////////////////////////////////////////////////////////// |
483 // keyboard::KeyboardControllerObserver implementation: | 600 // keyboard::KeyboardControllerObserver implementation: |
484 | 601 |
485 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 602 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
486 const gfx::Rect& keyboard_bounds) { | 603 const gfx::Rect& keyboard_bounds) { |
487 // This bounds change will have caused a change to the Shelf which does not | 604 // This bounds change will have caused a change to the Shelf which does not |
488 // propagate automatically to this class, so manually recalculate bounds. | 605 // propagate automatically to this class, so manually recalculate bounds. |
489 UpdateDockBounds(); | 606 UpdateDockBounds(); |
490 } | 607 } |
491 | 608 |
492 } // namespace internal | 609 } // namespace internal |
493 } // namespace ash | 610 } // namespace ash |
OLD | NEW |