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" |
11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/wm/always_on_top_controller.h" | 13 #include "ash/wm/always_on_top_controller.h" |
14 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
15 #include "ash/wm/window_positioner.h" | 15 #include "ash/wm/window_positioner.h" |
16 #include "ash/wm/window_properties.h" | 16 #include "ash/wm/window_properties.h" |
17 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
19 #include "ash/wm/wm_event.h" | 19 #include "ash/wm/wm_event.h" |
| 20 #include "ash/wm/workspace/workspace_layout_manager_delegate.h" |
20 #include "ui/aura/client/activation_client.h" | 21 #include "ui/aura/client/activation_client.h" |
21 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
23 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
24 #include "ui/base/ui_base_types.h" | 25 #include "ui/base/ui_base_types.h" |
25 #include "ui/compositor/layer.h" | 26 #include "ui/compositor/layer.h" |
26 #include "ui/events/event.h" | 27 #include "ui/events/event.h" |
27 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
28 #include "ui/views/corewm/window_util.h" | 29 #include "ui/views/corewm/window_util.h" |
29 | 30 |
(...skipping 13 matching lines...) Expand all Loading... |
43 is_fullscreen_(GetRootWindowController( | 44 is_fullscreen_(GetRootWindowController( |
44 window->GetRootWindow())->GetWindowForFullscreenMode() != NULL) { | 45 window->GetRootWindow())->GetWindowForFullscreenMode() != NULL) { |
45 Shell::GetInstance()->activation_client()->AddObserver(this); | 46 Shell::GetInstance()->activation_client()->AddObserver(this); |
46 Shell::GetInstance()->AddShellObserver(this); | 47 Shell::GetInstance()->AddShellObserver(this); |
47 root_window_->AddObserver(this); | 48 root_window_->AddObserver(this); |
48 } | 49 } |
49 | 50 |
50 WorkspaceLayoutManager::~WorkspaceLayoutManager() { | 51 WorkspaceLayoutManager::~WorkspaceLayoutManager() { |
51 if (root_window_) | 52 if (root_window_) |
52 root_window_->RemoveObserver(this); | 53 root_window_->RemoveObserver(this); |
53 for (WindowSet::const_iterator i = windows_.begin(); | 54 for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i) |
54 i != windows_.end(); | |
55 ++i) { | |
56 (*i)->RemoveObserver(this); | 55 (*i)->RemoveObserver(this); |
57 wm::GetWindowState(*i)->RemoveObserver(this); | |
58 } | |
59 Shell::GetInstance()->RemoveShellObserver(this); | 56 Shell::GetInstance()->RemoveShellObserver(this); |
60 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 57 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
61 } | 58 } |
62 | 59 |
63 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) { | 60 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) { |
64 shelf_ = shelf; | 61 shelf_ = shelf; |
65 } | 62 } |
66 | 63 |
| 64 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate( |
| 65 scoped_ptr<WorkspaceLayoutManagerDelegate> delegate) { |
| 66 backdrop_delegate_.reset(delegate.release()); |
| 67 } |
| 68 |
67 ////////////////////////////////////////////////////////////////////////////// | 69 ////////////////////////////////////////////////////////////////////////////// |
68 // WorkspaceLayoutManager, aura::LayoutManager implementation: | 70 // WorkspaceLayoutManager, aura::LayoutManager implementation: |
69 | 71 |
70 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) { | 72 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) { |
71 wm::WindowState* window_state = wm::GetWindowState(child); | 73 wm::WindowState* window_state = wm::GetWindowState(child); |
72 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); | 74 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); |
73 window_state->OnWMEvent(&event); | 75 window_state->OnWMEvent(&event); |
74 windows_.insert(child); | 76 windows_.insert(child); |
75 child->AddObserver(this); | 77 child->AddObserver(this); |
76 window_state->AddObserver(this); | 78 window_state->AddObserver(this); |
77 UpdateShelfVisibility(); | 79 UpdateShelfVisibility(); |
78 UpdateFullscreenState(); | 80 UpdateFullscreenState(); |
| 81 if (backdrop_delegate_) |
| 82 backdrop_delegate_->OnWindowAddedToLayout(child); |
79 WindowPositioner::RearrangeVisibleWindowOnShow(child); | 83 WindowPositioner::RearrangeVisibleWindowOnShow(child); |
80 } | 84 } |
81 | 85 |
82 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { | 86 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { |
83 windows_.erase(child); | 87 windows_.erase(child); |
84 child->RemoveObserver(this); | 88 child->RemoveObserver(this); |
85 wm::GetWindowState(child)->RemoveObserver(this); | 89 wm::GetWindowState(child)->RemoveObserver(this); |
86 | 90 |
87 if (child->TargetVisibility()) | 91 if (child->TargetVisibility()) |
88 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); | 92 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); |
89 } | 93 } |
90 | 94 |
91 void WorkspaceLayoutManager::OnWindowRemovedFromLayout(Window* child) { | 95 void WorkspaceLayoutManager::OnWindowRemovedFromLayout(Window* child) { |
92 UpdateShelfVisibility(); | 96 UpdateShelfVisibility(); |
93 UpdateFullscreenState(); | 97 UpdateFullscreenState(); |
| 98 if (backdrop_delegate_) |
| 99 backdrop_delegate_->OnWindowRemovedFromLayout(child); |
94 } | 100 } |
95 | 101 |
96 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, | 102 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, |
97 bool visible) { | 103 bool visible) { |
98 wm::WindowState* window_state = wm::GetWindowState(child); | 104 wm::WindowState* window_state = wm::GetWindowState(child); |
99 // Attempting to show a minimized window. Unminimize it. | 105 // Attempting to show a minimized window. Unminimize it. |
100 if (visible && window_state->IsMinimized()) | 106 if (visible && window_state->IsMinimized()) |
101 window_state->Unminimize(); | 107 window_state->Unminimize(); |
102 | 108 |
103 if (child->TargetVisibility()) | 109 if (child->TargetVisibility()) |
104 WindowPositioner::RearrangeVisibleWindowOnShow(child); | 110 WindowPositioner::RearrangeVisibleWindowOnShow(child); |
105 else | 111 else |
106 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); | 112 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); |
107 UpdateFullscreenState(); | 113 UpdateFullscreenState(); |
108 UpdateShelfVisibility(); | 114 UpdateShelfVisibility(); |
| 115 if (backdrop_delegate_) |
| 116 backdrop_delegate_->OnChildWindowVisibilityChanged(child, visible); |
109 } | 117 } |
110 | 118 |
111 void WorkspaceLayoutManager::SetChildBounds( | 119 void WorkspaceLayoutManager::SetChildBounds( |
112 Window* child, | 120 Window* child, |
113 const gfx::Rect& requested_bounds) { | 121 const gfx::Rect& requested_bounds) { |
114 wm::WindowState* window_state = wm::GetWindowState(child); | 122 wm::WindowState* window_state = wm::GetWindowState(child); |
115 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); | 123 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); |
116 window_state->OnWMEvent(&event); | 124 window_state->OnWMEvent(&event); |
117 UpdateShelfVisibility(); | 125 UpdateShelfVisibility(); |
118 } | 126 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (key == aura::client::kAlwaysOnTopKey && | 167 if (key == aura::client::kAlwaysOnTopKey && |
160 window->GetProperty(aura::client::kAlwaysOnTopKey)) { | 168 window->GetProperty(aura::client::kAlwaysOnTopKey)) { |
161 GetRootWindowController(window->GetRootWindow())-> | 169 GetRootWindowController(window->GetRootWindow())-> |
162 always_on_top_controller()->GetContainer(window)->AddChild(window); | 170 always_on_top_controller()->GetContainer(window)->AddChild(window); |
163 } | 171 } |
164 } | 172 } |
165 | 173 |
166 void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) { | 174 void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) { |
167 UpdateShelfVisibility(); | 175 UpdateShelfVisibility(); |
168 UpdateFullscreenState(); | 176 UpdateFullscreenState(); |
| 177 if (backdrop_delegate_) |
| 178 backdrop_delegate_->OnWindowStackingChanged(window); |
169 } | 179 } |
170 | 180 |
171 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) { | 181 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) { |
172 if (root_window_ == window) { | 182 if (root_window_ == window) { |
173 root_window_->RemoveObserver(this); | 183 root_window_->RemoveObserver(this); |
174 root_window_ = NULL; | 184 root_window_ = NULL; |
175 } | 185 } |
176 } | 186 } |
177 | 187 |
178 void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window, | 188 void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window, |
(...skipping 28 matching lines...) Expand all Loading... |
207 wm::WindowState* window_state, | 217 wm::WindowState* window_state, |
208 wm::WindowStateType old_type) { | 218 wm::WindowStateType old_type) { |
209 | 219 |
210 // Notify observers that fullscreen state may be changing. | 220 // Notify observers that fullscreen state may be changing. |
211 if (window_state->IsFullscreen() || | 221 if (window_state->IsFullscreen() || |
212 old_type == wm::WINDOW_STATE_TYPE_FULLSCREEN) { | 222 old_type == wm::WINDOW_STATE_TYPE_FULLSCREEN) { |
213 UpdateFullscreenState(); | 223 UpdateFullscreenState(); |
214 } | 224 } |
215 | 225 |
216 UpdateShelfVisibility(); | 226 UpdateShelfVisibility(); |
| 227 if (backdrop_delegate_) |
| 228 backdrop_delegate_->OnPostWindowStateTypeChange(window_state, old_type); |
217 } | 229 } |
218 | 230 |
219 ////////////////////////////////////////////////////////////////////////////// | 231 ////////////////////////////////////////////////////////////////////////////// |
220 // WorkspaceLayoutManager, private: | 232 // WorkspaceLayoutManager, private: |
221 | 233 |
222 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( | 234 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( |
223 const wm::WMEvent* event) { | 235 const wm::WMEvent* event) { |
224 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || | 236 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || |
225 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); | 237 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); |
226 | 238 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; | 276 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; |
265 if (is_fullscreen != is_fullscreen_) { | 277 if (is_fullscreen != is_fullscreen_) { |
266 ash::Shell::GetInstance()->NotifyFullscreenStateChange( | 278 ash::Shell::GetInstance()->NotifyFullscreenStateChange( |
267 is_fullscreen, window_->GetRootWindow()); | 279 is_fullscreen, window_->GetRootWindow()); |
268 is_fullscreen_ = is_fullscreen; | 280 is_fullscreen_ = is_fullscreen; |
269 } | 281 } |
270 } | 282 } |
271 | 283 |
272 } // namespace internal | 284 } // namespace internal |
273 } // namespace ash | 285 } // namespace ash |
OLD | NEW |