Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "ui/aura/focus_manager.h" | 21 #include "ui/aura/focus_manager.h" |
| 22 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
| 23 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 24 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| 25 | 25 |
| 26 namespace ash { | 26 namespace ash { |
| 27 namespace internal { | 27 namespace internal { |
| 28 | 28 |
| 29 // Minimum, maximum width of the dock area and a width of the gap | 29 // Minimum, maximum width of the dock area and a width of the gap |
| 30 const int DockedWindowLayoutManager::kMinDockWidth = 200; | 30 const int DockedWindowLayoutManager::kMinDockWidth = 200; |
| 31 const int DockedWindowLayoutManager::kMaxDockWidth = 450; | 31 const int DockedWindowLayoutManager::kMaxDockWidth = 360; |
| 32 const int DockedWindowLayoutManager::kMinDockGap = 2; | 32 const int DockedWindowLayoutManager::kMinDockGap = 2; |
| 33 const int kMaxVerticalPercentage = 90; | |
|
flackr
2013/09/06 02:18:43
Just to simplify this CL, adding the max vertical
varkha
2013/09/09 15:38:42
Done.
| |
| 33 const int kWindowIdealSpacing = 4; | 34 const int kWindowIdealSpacing = 4; |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 const SkColor kDockBackgroundColor = SkColorSetARGB(0xff, 0x10, 0x10, 0x10); | 38 const SkColor kDockBackgroundColor = SkColorSetARGB(0xff, 0x10, 0x10, 0x10); |
| 38 const float kDockBackgroundOpacity = 0.5f; | 39 const float kDockBackgroundOpacity = 0.5f; |
| 39 | 40 |
| 40 class DockedBackgroundWidget : public views::Widget { | 41 class DockedBackgroundWidget : public views::Widget { |
| 41 public: | 42 public: |
| 42 explicit DockedBackgroundWidget(aura::Window* container) { | 43 explicit DockedBackgroundWidget(aura::Window* container) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 void DockedWindowLayoutManager::RemoveObserver( | 187 void DockedWindowLayoutManager::RemoveObserver( |
| 187 DockedWindowLayoutManagerObserver* observer) { | 188 DockedWindowLayoutManagerObserver* observer) { |
| 188 observer_list_.RemoveObserver(observer); | 189 observer_list_.RemoveObserver(observer); |
| 189 } | 190 } |
| 190 | 191 |
| 191 void DockedWindowLayoutManager::StartDragging(aura::Window* window) { | 192 void DockedWindowLayoutManager::StartDragging(aura::Window* window) { |
| 192 DCHECK(!dragged_window_); | 193 DCHECK(!dragged_window_); |
| 193 dragged_window_ = window; | 194 dragged_window_ = window; |
| 194 // Start observing a window unless it is docked container's child in which | 195 // Start observing a window unless it is docked container's child in which |
| 195 // case it is already observed. | 196 // case it is already observed. |
| 197 LOG(INFO) << "start dragging " << window; | |
| 196 if (dragged_window_->parent() != dock_container_) | 198 if (dragged_window_->parent() != dock_container_) |
| 197 dragged_window_->AddObserver(this); | 199 dragged_window_->AddObserver(this); |
| 198 is_dragged_from_dock_ = window->parent() == dock_container_; | 200 is_dragged_from_dock_ = window->parent() == dock_container_; |
| 199 DCHECK(!is_dragged_window_docked_); | 201 DCHECK(!is_dragged_window_docked_); |
| 200 } | 202 } |
| 201 | 203 |
| 202 void DockedWindowLayoutManager::DockDraggedWindow(aura::Window* window) { | 204 void DockedWindowLayoutManager::DockDraggedWindow(aura::Window* window) { |
| 203 OnWindowDocked(window); | 205 OnWindowDocked(window); |
| 204 Relayout(); | 206 Relayout(); |
| 205 } | 207 } |
| 206 | 208 |
| 207 void DockedWindowLayoutManager::UndockDraggedWindow() { | 209 void DockedWindowLayoutManager::UndockDraggedWindow() { |
| 208 OnWindowUndocked(); | 210 OnWindowUndocked(); |
| 209 Relayout(); | 211 Relayout(); |
| 212 UpdateDockBounds(); | |
| 210 is_dragged_from_dock_ = false; | 213 is_dragged_from_dock_ = false; |
| 211 } | 214 } |
| 212 | 215 |
| 213 void DockedWindowLayoutManager::FinishDragging() { | 216 void DockedWindowLayoutManager::FinishDragging() { |
| 214 DCHECK(dragged_window_); | 217 DCHECK(dragged_window_); |
| 215 if (is_dragged_window_docked_) | 218 if (is_dragged_window_docked_) |
| 216 OnWindowUndocked(); | 219 OnWindowUndocked(); |
| 217 DCHECK (!is_dragged_window_docked_); | 220 DCHECK (!is_dragged_window_docked_); |
| 221 LOG(INFO) << "finish dragging " << dragged_window_; | |
| 218 // Stop observing a window unless it is docked container's child in which | 222 // Stop observing a window unless it is docked container's child in which |
| 219 // case it needs to keep being observed after the drag completes. | 223 // case it needs to keep being observed after the drag completes. |
| 220 if (dragged_window_->parent() != dock_container_) | 224 if (dragged_window_->parent() != dock_container_) { |
| 221 dragged_window_->RemoveObserver(this); | 225 dragged_window_->RemoveObserver(this); |
| 226 if (last_active_window_ == dragged_window_) | |
| 227 last_active_window_ = NULL; | |
| 228 } | |
| 222 dragged_window_ = NULL; | 229 dragged_window_ = NULL; |
| 230 dragged_bounds_ = gfx::Rect(); | |
| 223 Relayout(); | 231 Relayout(); |
| 224 UpdateDockBounds(); | 232 UpdateDockBounds(); |
| 225 } | 233 } |
| 226 | 234 |
| 227 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { | 235 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { |
| 228 DCHECK(!launcher_); | 236 DCHECK(!launcher_); |
| 229 DCHECK(!shelf_layout_manager_); | 237 DCHECK(!shelf_layout_manager_); |
| 230 launcher_ = launcher; | 238 launcher_ = launcher; |
| 231 if (launcher_->shelf_widget()) { | 239 if (launcher_->shelf_widget()) { |
| 232 shelf_layout_manager_ = ash::internal::ShelfLayoutManager::ForLauncher( | 240 shelf_layout_manager_ = ash::internal::ShelfLayoutManager::ForLauncher( |
| 233 launcher_->shelf_widget()->GetNativeWindow()); | 241 launcher_->shelf_widget()->GetNativeWindow()); |
| 234 WillChangeVisibilityState(shelf_layout_manager_->visibility_state()); | 242 WillChangeVisibilityState(shelf_layout_manager_->visibility_state()); |
| 235 shelf_layout_manager_->AddObserver(this); | 243 shelf_layout_manager_->AddObserver(this); |
| 236 } | 244 } |
| 237 } | 245 } |
| 238 | 246 |
| 239 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( | 247 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( |
| 240 const aura::Window* window) const { | 248 const aura::Window* window) const { |
| 241 const gfx::Rect& bounds(window->GetBoundsInScreen()); | 249 const gfx::Rect& bounds(window->GetBoundsInScreen()); |
| 242 const gfx::Rect docked_bounds = dock_container_->GetBoundsInScreen(); | |
| 243 | 250 |
| 244 // Do not allow docking if a window is vertically maximized (as is the case | 251 // Test overlap with an existing docked area first. |
| 245 // when it is snapped). | 252 if (docked_bounds_.Intersects(bounds) && |
| 246 const gfx::Rect work_area = | 253 alignment_ != DOCKED_ALIGNMENT_NONE) { |
| 247 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); | 254 // A window is being added to other docked windows (on the same side). |
| 248 if (bounds.y() == work_area.y() && bounds.height() == work_area.height()) | 255 return alignment_; |
| 249 return DOCKED_ALIGNMENT_NONE; | 256 } |
| 250 | 257 |
| 251 // Do not allow docking on the same side as launcher shelf. | 258 const gfx::Rect container_bounds = dock_container_->GetBoundsInScreen(); |
| 252 ShelfAlignment shelf_alignment = SHELF_ALIGNMENT_BOTTOM; | 259 if (bounds.x() <= container_bounds.x() && |
| 253 if (launcher_) | 260 bounds.right() > container_bounds.x()) { |
| 254 shelf_alignment = launcher_->alignment(); | |
| 255 | |
| 256 if (bounds.x() == docked_bounds.x() && | |
| 257 shelf_alignment != SHELF_ALIGNMENT_LEFT) { | |
| 258 return DOCKED_ALIGNMENT_LEFT; | 261 return DOCKED_ALIGNMENT_LEFT; |
| 259 } | 262 } else if (bounds.x() < container_bounds.right() && |
| 260 if (bounds.right() == docked_bounds.right() && | 263 bounds.right() >= container_bounds.right()) { |
| 261 shelf_alignment != SHELF_ALIGNMENT_RIGHT) { | |
| 262 return DOCKED_ALIGNMENT_RIGHT; | 264 return DOCKED_ALIGNMENT_RIGHT; |
| 263 } | 265 } |
| 264 return DOCKED_ALIGNMENT_NONE; | 266 return DOCKED_ALIGNMENT_NONE; |
| 265 } | 267 } |
| 266 | 268 |
| 267 DockedAlignment DockedWindowLayoutManager::CalculateAlignment() const { | 269 DockedAlignment DockedWindowLayoutManager::CalculateAlignment() const { |
| 268 // Find a child that is not being dragged and is not a popup. | 270 // Find a child that is not being dragged and is not a popup. |
| 269 // If such exists the current alignment is returned - even if some of the | 271 // If such exists the current alignment is returned - even if some of the |
| 270 // children are hidden or minimized (so they can be restored without losing | 272 // children are hidden or minimized (so they can be restored without losing |
| 271 // the docked state). | 273 // the docked state). |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 286 void DockedWindowLayoutManager::OnWindowResized() { | 288 void DockedWindowLayoutManager::OnWindowResized() { |
| 287 Relayout(); | 289 Relayout(); |
| 288 // When screen resizes update the insets even when dock width or alignment | 290 // When screen resizes update the insets even when dock width or alignment |
| 289 // does not change. | 291 // does not change. |
| 290 UpdateDockBounds(); | 292 UpdateDockBounds(); |
| 291 } | 293 } |
| 292 | 294 |
| 293 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 295 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| 294 if (child->type() == aura::client::WINDOW_TYPE_POPUP) | 296 if (child->type() == aura::client::WINDOW_TYPE_POPUP) |
| 295 return; | 297 return; |
| 298 LOG(INFO) << "added " << child; | |
| 296 // Dragged windows are already observed by StartDragging and do not change | 299 // Dragged windows are already observed by StartDragging and do not change |
| 297 // docked alignment during the drag. | 300 // docked alignment during the drag. |
| 298 if (child == dragged_window_) | 301 if (child == dragged_window_) |
| 299 return; | 302 return; |
| 300 // If this is the first window getting docked - update alignment. | 303 // If this is the first window getting docked - update alignment. |
| 301 if (alignment_ == DOCKED_ALIGNMENT_NONE) { | 304 if (alignment_ == DOCKED_ALIGNMENT_NONE) { |
| 302 alignment_ = GetAlignmentOfWindow(child); | 305 alignment_ = GetAlignmentOfWindow(child); |
| 303 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE); | 306 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE); |
| 304 } | 307 } |
| 305 child->AddObserver(this); | 308 child->AddObserver(this); |
| 306 Relayout(); | 309 Relayout(); |
| 307 UpdateDockBounds(); | 310 UpdateDockBounds(); |
| 308 } | 311 } |
| 309 | 312 |
| 310 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 313 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
| 311 if (child->type() == aura::client::WINDOW_TYPE_POPUP) | 314 if (child->type() == aura::client::WINDOW_TYPE_POPUP) |
| 312 return; | 315 return; |
| 316 LOG(INFO) << "removed " << child; | |
| 313 // Dragged windows are stopped being observed by FinishDragging and do not | 317 // Dragged windows are stopped being observed by FinishDragging and do not |
| 314 // change alignment during the drag. They also cannot be set to be the | 318 // change alignment during the drag. They also cannot be set to be the |
| 315 // |last_active_window_|. | 319 // |last_active_window_|. |
| 316 if (child == dragged_window_) | 320 if (child == dragged_window_) |
| 317 return; | 321 return; |
| 318 // If this is the last window, set alignment and maximize the workspace. | 322 // If this is the last window, set alignment and maximize the workspace. |
| 319 if (!IsAnyWindowDocked()) { | 323 if (!IsAnyWindowDocked()) { |
| 320 alignment_ = DOCKED_ALIGNMENT_NONE; | 324 alignment_ = DOCKED_ALIGNMENT_NONE; |
| 321 docked_width_ = 0; | 325 docked_width_ = 0; |
| 322 } | 326 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 397 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
| 394 aura::Window* window, | 398 aura::Window* window, |
| 395 const gfx::Rect& old_bounds, | 399 const gfx::Rect& old_bounds, |
| 396 const gfx::Rect& new_bounds) { | 400 const gfx::Rect& new_bounds) { |
| 397 // Only relayout if the dragged window would get docked. | 401 // Only relayout if the dragged window would get docked. |
| 398 if (window == dragged_window_ && is_dragged_window_docked_) | 402 if (window == dragged_window_ && is_dragged_window_docked_) |
| 399 Relayout(); | 403 Relayout(); |
| 400 } | 404 } |
| 401 | 405 |
| 402 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { | 406 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { |
| 407 LOG(INFO) << "destroying " << window; | |
| 403 if (dragged_window_ == window) { | 408 if (dragged_window_ == window) { |
| 404 FinishDragging(); | 409 FinishDragging(); |
| 405 DCHECK(!dragged_window_); | 410 DCHECK(!dragged_window_); |
| 406 DCHECK (!is_dragged_window_docked_); | 411 DCHECK (!is_dragged_window_docked_); |
| 407 } | 412 } |
| 408 if (window == last_active_window_) | 413 if (window == last_active_window_) |
| 409 last_active_window_ = NULL; | 414 last_active_window_ = NULL; |
| 410 } | 415 } |
| 411 | 416 |
| 412 | 417 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 window->Hide(); | 473 window->Hide(); |
| 469 if (wm::IsActiveWindow(window)) | 474 if (wm::IsActiveWindow(window)) |
| 470 wm::DeactivateWindow(window); | 475 wm::DeactivateWindow(window); |
| 471 } | 476 } |
| 472 | 477 |
| 473 void DockedWindowLayoutManager::RestoreWindow(aura::Window* window) { | 478 void DockedWindowLayoutManager::RestoreWindow(aura::Window* window) { |
| 474 window->Show(); | 479 window->Show(); |
| 475 } | 480 } |
| 476 | 481 |
| 477 void DockedWindowLayoutManager::OnWindowDocked(aura::Window* window) { | 482 void DockedWindowLayoutManager::OnWindowDocked(aura::Window* window) { |
| 483 LOG(INFO) << "docked"; | |
| 478 DCHECK(!is_dragged_window_docked_); | 484 DCHECK(!is_dragged_window_docked_); |
| 479 is_dragged_window_docked_ = true; | 485 is_dragged_window_docked_ = true; |
| 480 | 486 |
| 481 // If there are no other docked windows update alignment. | 487 // If there are no other docked windows update alignment. |
| 482 if (!IsAnyWindowDocked()) | 488 if (!IsAnyWindowDocked()) |
| 483 alignment_ = DOCKED_ALIGNMENT_NONE; | 489 alignment_ = DOCKED_ALIGNMENT_NONE; |
| 484 } | 490 } |
| 485 | 491 |
| 486 void DockedWindowLayoutManager::OnWindowUndocked() { | 492 void DockedWindowLayoutManager::OnWindowUndocked() { |
| 493 LOG(INFO) << "undocked"; | |
| 487 // If this is the first window getting docked - update alignment. | 494 // If this is the first window getting docked - update alignment. |
| 488 if (!IsAnyWindowDocked()) | 495 if (!IsAnyWindowDocked()) |
| 489 alignment_ = GetAlignmentOfWindow(dragged_window_); | 496 alignment_ = GetAlignmentOfWindow(dragged_window_); |
| 490 | 497 |
| 491 DCHECK (is_dragged_window_docked_); | 498 DCHECK (is_dragged_window_docked_); |
| 492 is_dragged_window_docked_ = false; | 499 is_dragged_window_docked_ = false; |
| 493 } | 500 } |
| 494 | 501 |
| 495 bool DockedWindowLayoutManager::IsAnyWindowDocked() { | 502 bool DockedWindowLayoutManager::IsAnyWindowDocked() { |
| 496 return CalculateAlignment() != DOCKED_ALIGNMENT_NONE; | 503 return CalculateAlignment() != DOCKED_ALIGNMENT_NONE; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 active_window = dragged_window_; | 544 active_window = dragged_window_; |
| 538 } | 545 } |
| 539 | 546 |
| 540 // Calculate free space or overlap. | 547 // Calculate free space or overlap. |
| 541 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( | 548 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( |
| 542 dock_container_); | 549 dock_container_); |
| 543 const gfx::Rect work_area = display.work_area(); | 550 const gfx::Rect work_area = display.work_area(); |
| 544 int available_room = work_area.height(); | 551 int available_room = work_area.height(); |
| 545 for (aura::Window::Windows::const_iterator iter = visible_windows.begin(); | 552 for (aura::Window::Windows::const_iterator iter = visible_windows.begin(); |
| 546 iter != visible_windows.end(); ++iter) { | 553 iter != visible_windows.end(); ++iter) { |
| 547 available_room -= (*iter)->bounds().height(); | 554 int height = (*iter)->bounds().height(); |
| 555 if (height == work_area.height()) | |
|
flackr
2013/09/06 02:18:43
This allows the height to be greater than kMaxVert
varkha
2013/09/09 15:38:42
This was intentional to target vertically maximize
| |
| 556 height = work_area.height() * kMaxVerticalPercentage / 100; | |
| 557 available_room -= height; | |
| 548 } | 558 } |
| 549 const int num_windows = visible_windows.size(); | 559 const int num_windows = visible_windows.size(); |
| 550 const float delta = (float)available_room / | 560 const float delta = (float)available_room / |
| 551 ((available_room > 0 || num_windows <= 1) ? | 561 ((available_room > 0 || num_windows <= 1) ? |
| 552 num_windows + 1 : num_windows - 1); | 562 num_windows + 1 : num_windows - 1); |
| 553 float y_pos = work_area.y() + ((available_room > 0) ? delta : 0); | 563 float y_pos = work_area.y() + ((available_room > 0) ? delta : 0); |
| 554 | 564 |
| 555 // Sort windows by their center positions and fan out overlapping | 565 // Sort windows by their center positions and fan out overlapping |
| 556 // windows. | 566 // windows. |
| 557 std::sort(visible_windows.begin(), | 567 std::sort(visible_windows.begin(), |
| 558 visible_windows.end(), | 568 visible_windows.end(), |
| 559 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL, | 569 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL, |
| 560 delta)); | 570 delta)); |
| 561 is_dragged_from_dock_ = true; | 571 is_dragged_from_dock_ = true; |
| 562 for (aura::Window::Windows::const_iterator iter = visible_windows.begin(); | 572 for (aura::Window::Windows::const_iterator iter = visible_windows.begin(); |
| 563 iter != visible_windows.end(); ++iter) { | 573 iter != visible_windows.end(); ++iter) { |
| 564 aura::Window* window = *iter; | 574 aura::Window* window = *iter; |
| 565 gfx::Rect bounds = window->GetBoundsInScreen(); | 575 gfx::Rect bounds = window->GetBoundsInScreen(); |
| 566 | 576 |
| 577 DockedAlignment alignment = alignment_; | |
| 578 if (alignment == DOCKED_ALIGNMENT_NONE && window == dragged_window_) { | |
| 579 alignment = GetAlignmentOfWindow(window); | |
| 580 if (alignment == DOCKED_ALIGNMENT_NONE) | |
| 581 bounds.set_size(gfx::Size()); | |
| 582 } | |
| 583 | |
| 584 // Restrict width. | |
| 585 if (bounds.width() > kMaxDockWidth) | |
| 586 bounds.set_width(kMaxDockWidth); | |
| 587 // Shrink height of vertically maximized windows to kMaxVerticalPercentage. | |
| 588 if (bounds.height() == work_area.height()) | |
| 589 bounds.set_height(work_area.height() * kMaxVerticalPercentage / 100); | |
| 590 | |
| 567 // Fan out windows evenly distributing the overlap or remaining free space. | 591 // Fan out windows evenly distributing the overlap or remaining free space. |
| 568 bounds.set_y(std::max(work_area.y(), | 592 bounds.set_y(std::max(work_area.y(), |
| 569 std::min(work_area.bottom() - bounds.height(), | 593 std::min(work_area.bottom() - bounds.height(), |
| 570 static_cast<int>(y_pos + 0.5)))); | 594 static_cast<int>(y_pos + 0.5)))); |
| 571 y_pos += bounds.height() + delta; | 595 y_pos += bounds.height() + delta; |
| 572 | 596 |
| 573 // All docked windows other than the one currently dragged remain stuck | 597 // All docked windows other than the one currently dragged remain stuck |
| 574 // to the screen edge. | 598 // to the screen edge. |
| 575 switch (alignment_) { | 599 switch (alignment) { |
| 576 case DOCKED_ALIGNMENT_LEFT: | 600 case DOCKED_ALIGNMENT_LEFT: |
| 577 bounds.set_x(dock_bounds.x()); | 601 bounds.set_x(dock_bounds.x()); |
| 578 break; | 602 break; |
| 579 case DOCKED_ALIGNMENT_RIGHT: | 603 case DOCKED_ALIGNMENT_RIGHT: |
| 580 bounds.set_x(dock_bounds.right() - bounds.width()); | 604 bounds.set_x(dock_bounds.right() - bounds.width()); |
| 581 break; | 605 break; |
| 582 case DOCKED_ALIGNMENT_NONE: | 606 case DOCKED_ALIGNMENT_NONE: |
| 583 break; | 607 break; |
| 584 } | 608 } |
| 585 if (window == dragged_window_) { | 609 if (window == dragged_window_) { |
| 586 dragged_bounds_ = bounds; | 610 dragged_bounds_ = bounds; |
| 587 continue; | 611 continue; |
| 588 } | 612 } |
| 613 // If the following asserts it is probably because not all the children | |
| 614 // have been removed when dock was closed. | |
| 589 DCHECK_NE(alignment_, DOCKED_ALIGNMENT_NONE); | 615 DCHECK_NE(alignment_, DOCKED_ALIGNMENT_NONE); |
| 590 // Keep the dock at least kMinDockWidth when all windows in it overhang. | 616 // Keep the dock at least kMinDockWidth when all windows in it overhang. |
| 591 docked_width_ = std::min(kMaxDockWidth, | 617 docked_width_ = std::min(kMaxDockWidth, |
| 592 std::max(docked_width_, | 618 std::max(docked_width_, |
| 593 bounds.width() > kMaxDockWidth ? | 619 bounds.width() > kMaxDockWidth ? |
| 594 kMinDockWidth : bounds.width())); | 620 kMinDockWidth : bounds.width())); |
| 595 bounds = ScreenAsh::ConvertRectFromScreen(dock_container_, bounds); | 621 bounds = ScreenAsh::ConvertRectFromScreen(dock_container_, bounds); |
| 596 SetChildBoundsDirect(window, bounds); | 622 SetChildBoundsDirect(window, bounds); |
| 597 } | 623 } |
| 598 UpdateStacking(active_window); | 624 UpdateStacking(active_window); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 | 712 |
| 687 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 713 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 688 const gfx::Rect& keyboard_bounds) { | 714 const gfx::Rect& keyboard_bounds) { |
| 689 // This bounds change will have caused a change to the Shelf which does not | 715 // This bounds change will have caused a change to the Shelf which does not |
| 690 // propagate automatically to this class, so manually recalculate bounds. | 716 // propagate automatically to this class, so manually recalculate bounds. |
| 691 UpdateDockBounds(); | 717 UpdateDockBounds(); |
| 692 } | 718 } |
| 693 | 719 |
| 694 } // namespace internal | 720 } // namespace internal |
| 695 } // namespace ash | 721 } // namespace ash |
| OLD | NEW |