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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
10 #include "ash/shelf/shelf_constants.h" | 10 #include "ash/shelf/shelf_constants.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // No docked windows remain other than possibly the window being dragged. | 525 // No docked windows remain other than possibly the window being dragged. |
526 // Return |NONE| to indicate that windows may get docked on either side. | 526 // Return |NONE| to indicate that windows may get docked on either side. |
527 return DOCKED_ALIGNMENT_NONE; | 527 return DOCKED_ALIGNMENT_NONE; |
528 } | 528 } |
529 | 529 |
530 bool DockedWindowLayoutManager::CanDockWindow(aura::Window* window, | 530 bool DockedWindowLayoutManager::CanDockWindow(aura::Window* window, |
531 SnapType edge) { | 531 SnapType edge) { |
532 if (!switches::UseDockedWindows()) | 532 if (!switches::UseDockedWindows()) |
533 return false; | 533 return false; |
534 // Don't allow interactive docking of windows with transient parents such as | 534 // Don't allow interactive docking of windows with transient parents such as |
535 // modal browser dialogs. | 535 // modal browser dialogs. Prevent docking of panels attached to shelf during |
536 if (IsPopupOrTransient(window)) | 536 // the drag. |
| 537 wm::WindowState* window_state = wm::GetWindowState(window); |
| 538 bool should_attach_to_shelf = window_state->drag_details() && |
| 539 window_state->drag_details()->should_attach_to_shelf; |
| 540 if (IsPopupOrTransient(window) || should_attach_to_shelf) |
537 return false; | 541 return false; |
538 // If a window is wide and cannot be resized down to maximum width allowed | 542 // If a window is wide and cannot be resized down to maximum width allowed |
539 // then it cannot be docked. | 543 // then it cannot be docked. |
540 // TODO(varkha). Prevent windows from changing size programmatically while | 544 // TODO(varkha). Prevent windows from changing size programmatically while |
541 // they are docked. The size will take effect only once a window is undocked. | 545 // they are docked. The size will take effect only once a window is undocked. |
542 // See http://crbug.com/307792. | 546 // See http://crbug.com/307792. |
543 if (window->bounds().width() > kMaxDockWidth && | 547 if (window->bounds().width() > kMaxDockWidth && |
544 (!wm::GetWindowState(window)->CanResize() || | 548 (!window_state->CanResize() || |
545 (window->delegate() && | 549 (window->delegate() && |
546 window->delegate()->GetMinimumSize().width() != 0 && | 550 window->delegate()->GetMinimumSize().width() != 0 && |
547 window->delegate()->GetMinimumSize().width() > kMaxDockWidth))) { | 551 window->delegate()->GetMinimumSize().width() > kMaxDockWidth))) { |
548 return false; | 552 return false; |
549 } | 553 } |
550 // If a window is tall and cannot be resized down to maximum height allowed | 554 // If a window is tall and cannot be resized down to maximum height allowed |
551 // then it cannot be docked. | 555 // then it cannot be docked. |
552 const gfx::Rect work_area = | 556 const gfx::Rect work_area = |
553 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); | 557 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); |
554 if (GetWindowHeightCloseTo(window, work_area.height()) > work_area.height()) | 558 if (GetWindowHeightCloseTo(window, work_area.height()) > work_area.height()) |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1247 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
1244 const gfx::Rect& keyboard_bounds) { | 1248 const gfx::Rect& keyboard_bounds) { |
1245 // This bounds change will have caused a change to the Shelf which does not | 1249 // This bounds change will have caused a change to the Shelf which does not |
1246 // propagate automatically to this class, so manually recalculate bounds. | 1250 // propagate automatically to this class, so manually recalculate bounds. |
1247 Relayout(); | 1251 Relayout(); |
1248 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1252 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
1249 } | 1253 } |
1250 | 1254 |
1251 } // namespace internal | 1255 } // namespace internal |
1252 } // namespace ash | 1256 } // namespace ash |
OLD | NEW |