OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/workspace/workspace_layout_manager.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
8 #include "ash/wm/property_util.h" | 8 #include "ash/wm/property_util.h" |
9 #include "ash/wm/window_animations.h" | 9 #include "ash/wm/window_animations.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 void WorkspaceLayoutManager::SetChildBounds( | 92 void WorkspaceLayoutManager::SetChildBounds( |
93 aura::Window* child, | 93 aura::Window* child, |
94 const gfx::Rect& requested_bounds) { | 94 const gfx::Rect& requested_bounds) { |
95 if (GetTrackedByWorkspace(child)) | 95 if (GetTrackedByWorkspace(child)) |
96 BaseLayoutManager::SetChildBounds(child, requested_bounds); | 96 BaseLayoutManager::SetChildBounds(child, requested_bounds); |
97 else | 97 else |
98 SetChildBoundsDirect(child, requested_bounds); | 98 SetChildBoundsDirect(child, requested_bounds); |
99 } | 99 workspace_manager_->UpdateShelfVisibility(); |
100 | |
101 void WorkspaceLayoutManager::OnRootWindowResized(const gfx::Size& new_size) { | |
102 workspace_manager_->SetWorkspaceSize(new_size); | |
103 } | 100 } |
104 | 101 |
105 void WorkspaceLayoutManager::OnMonitorWorkAreaInsetsChanged() { | 102 void WorkspaceLayoutManager::OnMonitorWorkAreaInsetsChanged() { |
106 workspace_manager_->OnMonitorWorkAreaInsetsChanged(); | 103 // The workspace is currently the only one that updates the shelf, so we can |
| 104 // safely ignore this. If we don't there are timing issues when transitioning |
| 105 // between maximized/fullscreen windows and normal windows. |
107 } | 106 } |
108 | 107 |
109 void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window, | 108 void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window, |
110 const void* key, | 109 const void* key, |
111 intptr_t old) { | 110 intptr_t old) { |
112 BaseLayoutManager::OnWindowPropertyChanged(window, key, old); | 111 BaseLayoutManager::OnWindowPropertyChanged(window, key, old); |
113 if (key == aura::client::kShowStateKey && | 112 if (key == aura::client::kShowStateKey && |
114 workspace_manager_->IsManagedWindow(window)) { | 113 workspace_manager_->IsManagedWindow(window)) { |
115 ui::WindowShowState last_show_state = static_cast<ui::WindowShowState>(old); | 114 ShowStateChanged(window, static_cast<ui::WindowShowState>(old)); |
116 if (wm::IsWindowMinimized(window)) { | |
117 // Save the previous show state so that we can correctly restore it. | |
118 window->SetProperty(kRestoreShowStateKey, last_show_state); | |
119 workspace_manager_->RemoveWindow(window); | |
120 SetWindowVisibilityAnimationType( | |
121 window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); | |
122 | |
123 // Effectively hide the window. | |
124 window->Hide(); | |
125 // Activate another window. | |
126 if (wm::IsActiveWindow(window)) | |
127 wm::DeactivateWindow(window); | |
128 return; | |
129 } | |
130 // We can end up here if the window was minimized and we are transitioning | |
131 // to another state. In that case the window is hidden. | |
132 if ((window->TargetVisibility() || | |
133 (last_show_state == ui::SHOW_STATE_MINIMIZED)) && | |
134 !workspace_manager_->IsManagingWindow(window)) { | |
135 workspace_manager_->AddWindow(window); | |
136 if (!window->layer()->visible()) { | |
137 // The layer may be hidden if the window was previously minimized. Make | |
138 // sure it's visible. | |
139 window->Show(); | |
140 } | |
141 return; | |
142 } | |
143 workspace_manager_->ShowStateChanged(window); | |
144 } else if (key == ash::kWindowTrackedByWorkspaceSplitPropKey && | 115 } else if (key == ash::kWindowTrackedByWorkspaceSplitPropKey && |
145 ash::GetTrackedByWorkspace(window)) { | 116 ash::GetTrackedByWorkspace(window)) { |
146 // We currently don't need to support transitioning from true to false, so | 117 // We currently don't need to support transitioning from true to false, so |
147 // we ignore it. | 118 // we ignore it. |
148 workspace_manager_->AddWindow(window); | 119 workspace_manager_->AddWindow(window); |
149 } | 120 } |
150 } | 121 } |
151 | 122 |
| 123 void WorkspaceLayoutManager::ShowStateChanged( |
| 124 aura::Window* window, |
| 125 ui::WindowShowState last_show_state) { |
| 126 if (wm::IsWindowMinimized(window)) { |
| 127 // Save the previous show state so that we can correctly restore it. |
| 128 window->SetProperty(kRestoreShowStateKey, last_show_state); |
| 129 workspace_manager_->RemoveWindow(window); |
| 130 SetWindowVisibilityAnimationType( |
| 131 window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
| 132 |
| 133 // Hide the window. |
| 134 window->Hide(); |
| 135 // Activate another window. |
| 136 if (wm::IsActiveWindow(window)) |
| 137 wm::DeactivateWindow(window); |
| 138 return; |
| 139 } |
| 140 // We can end up here if the window was minimized and we are transitioning |
| 141 // to another state. In that case the window is hidden. |
| 142 if ((window->TargetVisibility() || |
| 143 (last_show_state == ui::SHOW_STATE_MINIMIZED)) && |
| 144 !workspace_manager_->IsManagingWindow(window)) { |
| 145 workspace_manager_->AddWindow(window); |
| 146 if (!window->layer()->visible()) { |
| 147 // The layer may be hidden if the window was previously minimized. Make |
| 148 // sure it's visible. |
| 149 window->Show(); |
| 150 } |
| 151 return; |
| 152 } |
| 153 workspace_manager_->ShowStateChanged(window); |
| 154 } |
| 155 |
152 } // namespace internal | 156 } // namespace internal |
153 } // namespace ash | 157 } // namespace ash |
OLD | NEW |