Chromium Code Reviews| Index: ash/wm/dock/docked_window_layout_manager.cc |
| diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc |
| index 14ccaa37329ea6a35b616c08f37d6c41097d51dd..b6a0c69227b716dc41bff261e46051749c340c77 100644 |
| --- a/ash/wm/dock/docked_window_layout_manager.cc |
| +++ b/ash/wm/dock/docked_window_layout_manager.cc |
| @@ -576,16 +576,21 @@ DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( |
| } |
| DockedAlignment DockedWindowLayoutManager::CalculateAlignment() const { |
| - // Find a child that is not being dragged and is not a popup. |
| + return CalculateAlignment(dragged_window_); |
| +} |
| + |
| +DockedAlignment DockedWindowLayoutManager::CalculateAlignment( |
| + const aura::Window* query_window) const { |
| + // Find a child that is not the window being queried and is not a popup. |
| // If such exists the current alignment is returned - even if some of the |
| // children are hidden or minimized (so they can be restored without losing |
| // the docked state). |
| for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
| aura::Window* window(dock_container_->children()[i]); |
|
varkha
2014/09/29 18:59:28
nit: s/window/child and s/query_window/window.
dtapuska
2014/09/29 20:59:56
Done.
|
| - if (window != dragged_window_ && !IsPopupOrTransient(window)) |
| + if (window != query_window && !IsPopupOrTransient(window)) |
| return alignment_; |
| } |
| - // No docked windows remain other than possibly the window being dragged. |
| + // No docked windows remain other than possibly the window being queried. |
| // Return |NONE| to indicate that windows may get docked on either side. |
| return DOCKED_ALIGNMENT_NONE; |
| } |
| @@ -620,7 +625,7 @@ bool DockedWindowLayoutManager::CanDockWindow( |
| if (GetWindowHeightCloseTo(window, work_area.height()) > work_area.height()) |
| return false; |
| // Cannot dock on the other size from an existing dock. |
| - const DockedAlignment alignment = CalculateAlignment(); |
| + const DockedAlignment alignment = CalculateAlignment(window); |
| if (desired_alignment != DOCKED_ALIGNMENT_NONE && |
| alignment != DOCKED_ALIGNMENT_NONE && |
| alignment != desired_alignment) { |
| @@ -639,6 +644,28 @@ bool DockedWindowLayoutManager::CanDockWindow( |
| return true; |
| } |
| +void DockedWindowLayoutManager::SetDockedAlignment( |
| + DockedAlignment desired_alignment) |
| +{ |
| + if (desired_alignment == alignment_ || |
| + desired_alignment == DOCKED_ALIGNMENT_NONE || |
| + alignment_ == DOCKED_ALIGNMENT_NONE) |
|
varkha
2014/09/29 18:59:28
nit: curly braces are recommended and seem to be a
dtapuska
2014/09/29 20:59:56
Done.
|
| + return; |
| + ShelfAlignment shelf_alignment = SHELF_ALIGNMENT_BOTTOM; |
| + if (shelf_) |
| + shelf_alignment = shelf_->alignment(); |
| + if ((desired_alignment == DOCKED_ALIGNMENT_LEFT && |
| + shelf_alignment == SHELF_ALIGNMENT_LEFT) || |
| + (desired_alignment == DOCKED_ALIGNMENT_RIGHT && |
| + shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { |
| + return; |
| + } |
| + alignment_ = desired_alignment; |
| + |
| + Relayout(); |
| + UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| +} |
| + |
| void DockedWindowLayoutManager::OnShelfBoundsChanged() { |
| Relayout(); |
| UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); |
| @@ -700,8 +727,10 @@ void DockedWindowLayoutManager::OnChildWindowVisibilityChanged( |
| bool visible) { |
| if (IsPopupOrTransient(child)) |
| return; |
| - if (visible) |
| - wm::GetWindowState(child)->Restore(); |
| + |
| + wm::WindowState* window_state = wm::GetWindowState(child); |
| + if (visible && window_state->IsMinimized()) |
| + window_state->Restore(); |
| Relayout(); |
| UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| } |
| @@ -815,15 +844,15 @@ void DockedWindowLayoutManager::OnPreWindowStateTypeChange( |
| // until OnFullscreenStateChange is called when exiting fullscreen. |
| if (in_fullscreen_) |
| return; |
| - if (window_state->IsMinimized()) { |
| - MinimizeDockedWindow(window_state); |
| - } else if (window_state->IsMaximizedOrFullscreen() || |
| - window_state->IsSnapped()) { |
| + if (!window_state->IsDocked()) { |
| if (window != dragged_window_) { |
| UndockWindow(window); |
| - RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| + if (window_state->IsMaximizedOrFullscreen()) |
| + RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| } |
| - } else if (old_type == wm::WINDOW_STATE_TYPE_MINIMIZED) { |
| + } else if (window_state->IsMinimized()) { |
| + MinimizeDockedWindow(window_state); |
| + } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { |
| RestoreDockedWindow(window_state); |
| } |
| } |