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/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 !wm::GetWindowState(window)->IsMinimized() && | 94 !wm::GetWindowState(window)->IsMinimized() && |
95 !IsPopupOrTransient(window)); | 95 !IsPopupOrTransient(window)); |
96 } | 96 } |
97 | 97 |
98 void UndockWindow(aura::Window* window) { | 98 void UndockWindow(aura::Window* window) { |
99 gfx::Rect previous_bounds = window->bounds(); | 99 gfx::Rect previous_bounds = window->bounds(); |
100 aura::Window* previous_parent = window->parent(); | 100 aura::Window* previous_parent = window->parent(); |
101 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); | 101 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); |
102 if (window->parent() != previous_parent) | 102 if (window->parent() != previous_parent) |
103 wm::ReparentTransientChildrenOfChild(window->parent(), window); | 103 wm::ReparentTransientChildrenOfChild(window->parent(), window); |
104 wm::WindowState* window_state = wm::GetWindowState(window); | |
pkotwicz
2013/11/27 20:24:43
Can we nuke the early return?
varkha
2013/11/28 01:09:37
Done. Possible now.
| |
105 // Windows that are right- or left-snapped out of the dock are have their | |
106 // bounds already set and the animation started when the undocking happens. | |
107 // There is no need to reset the layer bounds since correct original bounds | |
108 // were used for animation. | |
109 if (window_state->IsSnapped()) | |
110 return; | |
104 // Start maximize or fullscreen (affecting packaged apps) animation from | 111 // Start maximize or fullscreen (affecting packaged apps) animation from |
105 // previous window bounds. | 112 // previous window bounds. |
106 window->layer()->SetBounds(previous_bounds); | 113 window->layer()->SetBounds(previous_bounds); |
107 } | 114 } |
108 | 115 |
109 // Returns width that is as close as possible to |target_width| while being | 116 // Returns width that is as close as possible to |target_width| while being |
110 // consistent with docked min and max restrictions and respects the |window|'s | 117 // consistent with docked min and max restrictions and respects the |window|'s |
111 // minimum and maximum size. | 118 // minimum and maximum size. |
112 int GetWindowWidthCloseTo(const aura::Window* window, int target_width) { | 119 int GetWindowWidthCloseTo(const aura::Window* window, int target_width) { |
113 if (!wm::GetWindowState(window)->CanResize()) { | 120 if (!wm::GetWindowState(window)->CanResize()) { |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 wm::WindowShowType old_type) { | 565 wm::WindowShowType old_type) { |
559 aura::Window* window = window_state->window(); | 566 aura::Window* window = window_state->window(); |
560 if (IsPopupOrTransient(window)) | 567 if (IsPopupOrTransient(window)) |
561 return; | 568 return; |
562 // The window property will still be set, but no actual change will occur | 569 // The window property will still be set, but no actual change will occur |
563 // until OnFullscreenStateChange is called when exiting fullscreen. | 570 // until OnFullscreenStateChange is called when exiting fullscreen. |
564 if (in_fullscreen_) | 571 if (in_fullscreen_) |
565 return; | 572 return; |
566 if (window_state->IsMinimized()) { | 573 if (window_state->IsMinimized()) { |
567 MinimizeDockedWindow(window_state); | 574 MinimizeDockedWindow(window_state); |
568 } else if (window_state->IsMaximizedOrFullscreen()) { | 575 } else if (window_state->IsMaximizedOrFullscreen() || |
569 // Reparenting changes the source bounds for the animation if a window is | 576 window_state->IsSnapped()) { |
570 // visible so hide it here and show later when it is already in the desktop. | 577 if (window != dragged_window_) { |
571 UndockWindow(window); | 578 UndockWindow(window); |
572 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); | 579 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
580 } | |
573 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { | 581 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { |
574 RestoreDockedWindow(window_state); | 582 RestoreDockedWindow(window_state); |
575 } | 583 } |
576 } | 584 } |
577 | 585 |
578 ///////////////////////////////////////////////////////////////////////////// | 586 ///////////////////////////////////////////////////////////////////////////// |
579 // DockLayoutManager, WindowObserver implementation: | 587 // DockLayoutManager, WindowObserver implementation: |
580 | 588 |
581 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 589 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
582 aura::Window* window, | 590 aura::Window* window, |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1054 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1062 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
1055 const gfx::Rect& keyboard_bounds) { | 1063 const gfx::Rect& keyboard_bounds) { |
1056 // This bounds change will have caused a change to the Shelf which does not | 1064 // This bounds change will have caused a change to the Shelf which does not |
1057 // propagate automatically to this class, so manually recalculate bounds. | 1065 // propagate automatically to this class, so manually recalculate bounds. |
1058 Relayout(); | 1066 Relayout(); |
1059 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1067 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
1060 } | 1068 } |
1061 | 1069 |
1062 } // namespace internal | 1070 } // namespace internal |
1063 } // namespace ash | 1071 } // namespace ash |
OLD | NEW |