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/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/session_state_delegate.h" | 10 #include "ash/session_state_delegate.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 UpdateFullscreenState(); | 87 UpdateFullscreenState(); |
88 } | 88 } |
89 | 89 |
90 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, | 90 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, |
91 bool visible) { | 91 bool visible) { |
92 wm::WindowState* window_state = wm::GetWindowState(child); | 92 wm::WindowState* window_state = wm::GetWindowState(child); |
93 // Attempting to show a minimized window. Unminimize it. | 93 // Attempting to show a minimized window. Unminimize it. |
94 if (visible && window_state->IsMinimized()) | 94 if (visible && window_state->IsMinimized()) |
95 window_state->Unminimize(); | 95 window_state->Unminimize(); |
96 | 96 |
97 if (child->TargetVisibility()) { | 97 if (child->TargetVisibility()) |
98 WindowPositioner::RearrangeVisibleWindowOnShow(child); | 98 WindowPositioner::RearrangeVisibleWindowOnShow(child); |
99 } else { | 99 else |
100 if (wm::GetWindowState(child)->IsFullscreen()) | |
101 UpdateFullscreenState(); | |
102 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); | 100 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); |
103 } | 101 UpdateFullscreenState(); |
104 UpdateShelfVisibility(); | 102 UpdateShelfVisibility(); |
105 } | 103 } |
106 | 104 |
107 void WorkspaceLayoutManager::SetChildBounds( | 105 void WorkspaceLayoutManager::SetChildBounds( |
108 Window* child, | 106 Window* child, |
109 const gfx::Rect& requested_bounds) { | 107 const gfx::Rect& requested_bounds) { |
110 wm::WindowState* window_state = wm::GetWindowState(child); | 108 wm::WindowState* window_state = wm::GetWindowState(child); |
111 window_state->RequestBounds(requested_bounds); | 109 window_state->RequestBounds(requested_bounds); |
112 UpdateShelfVisibility(); | 110 UpdateShelfVisibility(); |
113 } | 111 } |
114 | 112 |
115 ////////////////////////////////////////////////////////////////////////////// | 113 ////////////////////////////////////////////////////////////////////////////// |
116 // WorkspaceLayoutManager, ash::ShellObserver implementation: | 114 // WorkspaceLayoutManager, ash::ShellObserver implementation: |
117 | 115 |
118 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 116 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
119 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( | 117 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( |
120 window_, | 118 window_, |
121 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())); | 119 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())); |
122 if (work_area != work_area_in_parent_) | 120 if (work_area != work_area_in_parent_) |
123 AdjustAllWindowsBoundsForWorkAreaChange(wm::WORKAREA_BOUNDS_CHANGED); | 121 AdjustAllWindowsBoundsForWorkAreaChange(wm::WORKAREA_BOUNDS_CHANGED); |
124 } | 122 } |
125 | 123 |
126 ////////////////////////////////////////////////////////////////////////////// | 124 ////////////////////////////////////////////////////////////////////////////// |
127 // WorkspaceLayoutManager, aura::WindowObserver implementation: | 125 // WorkspaceLayoutManager, aura::WindowObserver implementation: |
128 | 126 |
| 127 void WorkspaceLayoutManager::OnWindowHierarchyChanged( |
| 128 const WindowObserver::HierarchyChangeParams& params) { |
| 129 if (!wm::GetWindowState(params.target)->IsActive()) |
| 130 return; |
| 131 // If the window is already tracked by the workspace this update would be |
| 132 // redundant as the fullscreen and shelf state would have been handled in |
| 133 // OnWindowAddedToLayout. |
| 134 if (windows_.find(params.target) != windows_.end()) |
| 135 return; |
| 136 |
| 137 // If the active window has moved to this root window then update the |
| 138 // fullscreen state. |
| 139 // TODO(flackr): Track the active window leaving this root window and update |
| 140 // the fullscreen state accordingly. |
| 141 if (params.new_parent && params.new_parent->GetRootWindow() == root_window_) { |
| 142 UpdateFullscreenState(); |
| 143 UpdateShelfVisibility(); |
| 144 } |
| 145 } |
| 146 |
129 void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window, | 147 void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window, |
130 const void* key, | 148 const void* key, |
131 intptr_t old) { | 149 intptr_t old) { |
132 if (key == aura::client::kAlwaysOnTopKey && | 150 if (key == aura::client::kAlwaysOnTopKey && |
133 window->GetProperty(aura::client::kAlwaysOnTopKey)) { | 151 window->GetProperty(aura::client::kAlwaysOnTopKey)) { |
134 GetRootWindowController(window->GetRootWindow())-> | 152 GetRootWindowController(window->GetRootWindow())-> |
135 always_on_top_controller()->GetContainer(window)->AddChild(window); | 153 always_on_top_controller()->GetContainer(window)->AddChild(window); |
136 } | 154 } |
137 } | 155 } |
138 | 156 |
(...skipping 21 matching lines...) Expand all Loading... |
160 // aura::client::ActivationChangeObserver implementation: | 178 // aura::client::ActivationChangeObserver implementation: |
161 | 179 |
162 void WorkspaceLayoutManager::OnWindowActivated(aura::Window* gained_active, | 180 void WorkspaceLayoutManager::OnWindowActivated(aura::Window* gained_active, |
163 aura::Window* lost_active) { | 181 aura::Window* lost_active) { |
164 wm::WindowState* window_state = wm::GetWindowState(gained_active); | 182 wm::WindowState* window_state = wm::GetWindowState(gained_active); |
165 if (window_state && window_state->IsMinimized() && | 183 if (window_state && window_state->IsMinimized() && |
166 !gained_active->IsVisible()) { | 184 !gained_active->IsVisible()) { |
167 window_state->Unminimize(); | 185 window_state->Unminimize(); |
168 DCHECK(!window_state->IsMinimized()); | 186 DCHECK(!window_state->IsMinimized()); |
169 } | 187 } |
| 188 UpdateFullscreenState(); |
| 189 UpdateShelfVisibility(); |
170 } | 190 } |
171 | 191 |
172 ////////////////////////////////////////////////////////////////////////////// | 192 ////////////////////////////////////////////////////////////////////////////// |
173 // WorkspaceLayoutManager, wm::WindowStateObserver implementation: | 193 // WorkspaceLayoutManager, wm::WindowStateObserver implementation: |
174 | 194 |
175 void WorkspaceLayoutManager::OnPostWindowShowTypeChange( | 195 void WorkspaceLayoutManager::OnPostWindowShowTypeChange( |
176 wm::WindowState* window_state, | 196 wm::WindowState* window_state, |
177 wm::WindowShowType old_type) { | 197 wm::WindowShowType old_type) { |
178 | 198 |
179 // Notify observers that fullscreen state may be changing. | 199 // Notify observers that fullscreen state may be changing. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 wm::GetWindowState(*it)->OnWMEvent(event); | 233 wm::GetWindowState(*it)->OnWMEvent(event); |
214 } | 234 } |
215 } | 235 } |
216 | 236 |
217 void WorkspaceLayoutManager::UpdateShelfVisibility() { | 237 void WorkspaceLayoutManager::UpdateShelfVisibility() { |
218 if (shelf_) | 238 if (shelf_) |
219 shelf_->UpdateVisibilityState(); | 239 shelf_->UpdateVisibilityState(); |
220 } | 240 } |
221 | 241 |
222 void WorkspaceLayoutManager::UpdateFullscreenState() { | 242 void WorkspaceLayoutManager::UpdateFullscreenState() { |
| 243 // TODO(flackr): The fullscreen state is currently tracked per workspace |
| 244 // but the shell notification implies a per root window state. Currently |
| 245 // only windows in the default workspace container will go fullscreen but |
| 246 // this should really be tracked by the RootWindowController since |
| 247 // technically any container could get a fullscreen window. |
| 248 if (!shelf_) |
| 249 return; |
223 bool is_fullscreen = GetRootWindowController( | 250 bool is_fullscreen = GetRootWindowController( |
224 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; | 251 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; |
225 if (is_fullscreen != is_fullscreen_) { | 252 if (is_fullscreen != is_fullscreen_) { |
226 ash::Shell::GetInstance()->NotifyFullscreenStateChange( | 253 ash::Shell::GetInstance()->NotifyFullscreenStateChange( |
227 is_fullscreen, window_->GetRootWindow()); | 254 is_fullscreen, window_->GetRootWindow()); |
228 is_fullscreen_ = is_fullscreen; | 255 is_fullscreen_ = is_fullscreen; |
229 } | 256 } |
230 } | 257 } |
231 | 258 |
232 } // namespace internal | 259 } // namespace internal |
233 } // namespace ash | 260 } // namespace ash |
OLD | NEW |