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