Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: ash/root_window_controller.cc

Issue 11093050: Move shelf/launcher/status_area_widget/panel_layout_manager to RootWindowController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-added launcher.h This seems to be removed from other header it is including. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/desktop_background/desktop_background_widget_controller.h" 9 #include "ash/desktop_background/desktop_background_widget_controller.h"
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
11 #include "ash/display/multi_display_manager.h" 11 #include "ash/display/multi_display_manager.h"
12 #include "ash/focus_cycler.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_delegate.h"
13 #include "ash/shell_factory.h" 15 #include "ash/shell_factory.h"
14 #include "ash/shell_window_ids.h" 16 #include "ash/shell_window_ids.h"
17 #include "ash/system/status_area_widget.h"
15 #include "ash/wm/base_layout_manager.h" 18 #include "ash/wm/base_layout_manager.h"
19 #include "ash/wm/panel_layout_manager.h"
20 #include "ash/wm/panel_window_event_filter.h"
16 #include "ash/wm/property_util.h" 21 #include "ash/wm/property_util.h"
17 #include "ash/wm/root_window_layout_manager.h" 22 #include "ash/wm/root_window_layout_manager.h"
18 #include "ash/wm/screen_dimmer.h" 23 #include "ash/wm/screen_dimmer.h"
24 #include "ash/wm/shelf_layout_manager.h"
25 #include "ash/wm/shelf_types.h"
26 #include "ash/wm/status_area_layout_manager.h"
19 #include "ash/wm/system_modal_container_layout_manager.h" 27 #include "ash/wm/system_modal_container_layout_manager.h"
20 #include "ash/wm/toplevel_window_event_handler.h" 28 #include "ash/wm/toplevel_window_event_handler.h"
21 #include "ash/wm/visibility_controller.h" 29 #include "ash/wm/visibility_controller.h"
22 #include "ash/wm/window_properties.h" 30 #include "ash/wm/window_properties.h"
23 #include "ash/wm/workspace/colored_window_controller.h" 31 #include "ash/wm/workspace/colored_window_controller.h"
24 #include "ash/wm/workspace_controller.h" 32 #include "ash/wm/workspace_controller.h"
25 #include "ui/aura/client/activation_client.h" 33 #include "ui/aura/client/activation_client.h"
26 #include "ui/aura/client/aura_constants.h" 34 #include "ui/aura/client/aura_constants.h"
27 #include "ui/aura/client/capture_client.h" 35 #include "ui/aura/client/capture_client.h"
28 #include "ui/aura/client/tooltip_client.h" 36 #include "ui/aura/client/tooltip_client.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // use the virtual screeen coordinates instead of parent. 142 // use the virtual screeen coordinates instead of parent.
135 void SetUsesScreenCoordinates(aura::Window* container) { 143 void SetUsesScreenCoordinates(aura::Window* container) {
136 container->SetProperty(internal::kUsesScreenCoordinatesKey, true); 144 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
137 } 145 }
138 146
139 } // namespace 147 } // namespace
140 148
141 namespace internal { 149 namespace internal {
142 150
143 RootWindowController::RootWindowController(aura::RootWindow* root_window) 151 RootWindowController::RootWindowController(aura::RootWindow* root_window)
144 : root_window_(root_window) { 152 : root_window_(root_window),
153 root_window_layout_(NULL),
154 status_area_widget_(NULL),
155 shelf_(NULL),
156 panel_layout_manager_(NULL) {
145 SetRootWindowController(root_window, this); 157 SetRootWindowController(root_window, this);
146 screen_dimmer_.reset(new ScreenDimmer(root_window)); 158 screen_dimmer_.reset(new ScreenDimmer(root_window));
147 } 159 }
148 160
149 RootWindowController::~RootWindowController() { 161 RootWindowController::~RootWindowController() {
150 Shutdown(); 162 Shutdown();
151 root_window_.reset(); 163 root_window_.reset();
152 } 164 }
153 165
154 void RootWindowController::Shutdown() { 166 void RootWindowController::Shutdown() {
155 CloseChildWindows(); 167 CloseChildWindows();
156 if (Shell::GetActiveRootWindow() == root_window_.get()) { 168 if (Shell::GetActiveRootWindow() == root_window_.get()) {
157 Shell::GetInstance()->set_active_root_window( 169 Shell::GetInstance()->set_active_root_window(
158 Shell::GetPrimaryRootWindow() == root_window_.get() ? 170 Shell::GetPrimaryRootWindow() == root_window_.get() ?
159 NULL : Shell::GetPrimaryRootWindow()); 171 NULL : Shell::GetPrimaryRootWindow());
160 } 172 }
161 SetRootWindowController(root_window_.get(), NULL); 173 SetRootWindowController(root_window_.get(), NULL);
162 screen_dimmer_.reset(); 174 screen_dimmer_.reset();
163 workspace_controller_.reset(); 175 workspace_controller_.reset();
164 // Forget with the display ID so that display lookup 176 // Forget with the display ID so that display lookup
165 // ends up with invalid display. 177 // ends up with invalid display.
166 root_window_->ClearProperty(kDisplayIdKey); 178 root_window_->ClearProperty(kDisplayIdKey);
167 // And this root window should no longer process events. 179 // And this root window should no longer process events.
168 root_window_->PrepareForShutdown(); 180 root_window_->PrepareForShutdown();
181
182 // Launcher widget has an InputMethodBridge that references to
183 // |input_method_filter_|'s |input_method_|. So explicitly release
184 // |launcher_| before |input_method_filter_|. And this needs to be
185 // after we delete all containers in case there are still live
186 // browser windows which access LauncherModel during close.
187 launcher_.reset();
169 } 188 }
170 189
171 SystemModalContainerLayoutManager* 190 SystemModalContainerLayoutManager*
172 RootWindowController::GetSystemModalLayoutManager() { 191 RootWindowController::GetSystemModalLayoutManager() {
173 return static_cast<SystemModalContainerLayoutManager*>( 192 return static_cast<SystemModalContainerLayoutManager*>(
174 GetContainer(kShellWindowId_SystemModalContainer)->layout_manager()); 193 GetContainer(kShellWindowId_SystemModalContainer)->layout_manager());
175 } 194 }
176 195
177 aura::Window* RootWindowController::GetContainer(int container_id) { 196 aura::Window* RootWindowController::GetContainer(int container_id) {
178 return root_window_->GetChildById(container_id); 197 return root_window_->GetChildById(container_id);
(...skipping 10 matching lines...) Expand all
189 workspace_controller_.reset( 208 workspace_controller_.reset(
190 new WorkspaceController(default_container)); 209 new WorkspaceController(default_container));
191 210
192 aura::Window* always_on_top_container = 211 aura::Window* always_on_top_container =
193 GetContainer(kShellWindowId_AlwaysOnTopContainer); 212 GetContainer(kShellWindowId_AlwaysOnTopContainer);
194 always_on_top_container->SetLayoutManager( 213 always_on_top_container->SetLayoutManager(
195 new BaseLayoutManager( 214 new BaseLayoutManager(
196 always_on_top_container->GetRootWindow())); 215 always_on_top_container->GetRootWindow()));
197 } 216 }
198 217
218 void RootWindowController::InitForPrimaryDisplay() {
219 DCHECK(!status_area_widget_);
220 ShellDelegate* delegate = Shell::GetInstance()->delegate();
221
222 // Initialize Primary RootWindow specific items.
223 status_area_widget_ = new internal::StatusAreaWidget();
224 status_area_widget_->CreateTrayViews(delegate);
225 // Login screen manages status area visibility by itself.
226 if (delegate && delegate->IsSessionStarted())
227 status_area_widget_->Show();
228
229 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_);
230
231 internal::ShelfLayoutManager* shelf_layout_manager =
232 new internal::ShelfLayoutManager(status_area_widget_);
233 GetContainer(internal::kShellWindowId_LauncherContainer)->
234 SetLayoutManager(shelf_layout_manager);
235 shelf_ = shelf_layout_manager;
236
237 internal::StatusAreaLayoutManager* status_area_layout_manager =
238 new internal::StatusAreaLayoutManager(shelf_layout_manager);
239 GetContainer(internal::kShellWindowId_StatusContainer)->
240 SetLayoutManager(status_area_layout_manager);
241
242 shelf_layout_manager->set_workspace_controller(
243 workspace_controller());
244
245 workspace_controller()->SetShelf(shelf_);
246
247 // Create Panel layout manager
248 aura::Window* panel_container = GetContainer(
249 internal::kShellWindowId_PanelContainer);
250 panel_layout_manager_ =
251 new internal::PanelLayoutManager(panel_container);
252 panel_container->SetEventFilter(
253 new internal::PanelWindowEventFilter(
254 panel_container, panel_layout_manager_));
255 panel_container->SetLayoutManager(panel_layout_manager_);
256
257 if (!delegate || delegate->IsUserLoggedIn())
258 CreateLauncher();
259 }
260
199 void RootWindowController::CreateContainers() { 261 void RootWindowController::CreateContainers() {
200 CreateContainersInRootWindow(root_window_.get()); 262 CreateContainersInRootWindow(root_window_.get());
201 } 263 }
202 264
203 void RootWindowController::CreateSystemBackground( 265 void RootWindowController::CreateSystemBackground(
204 bool is_first_run_after_boot) { 266 bool is_first_run_after_boot) {
205 SkColor color = SK_ColorBLACK; 267 SkColor color = SK_ColorBLACK;
206 #if defined(OS_CHROMEOS) 268 #if defined(OS_CHROMEOS)
207 if (is_first_run_after_boot) 269 if (is_first_run_after_boot)
208 color = kBootSystemBackgroundColor; 270 color = kBootSystemBackgroundColor;
209 #endif 271 #endif
210 background_.reset(new ColoredWindowController( 272 background_.reset(new ColoredWindowController(
211 root_window_->GetChildById(kShellWindowId_SystemBackgroundContainer), 273 root_window_->GetChildById(kShellWindowId_SystemBackgroundContainer),
212 "SystemBackground")); 274 "SystemBackground"));
213 background_->SetColor(color); 275 background_->SetColor(color);
214 background_->GetWidget()->Show(); 276 background_->GetWidget()->Show();
215 } 277 }
216 278
279 void RootWindowController::CreateLauncher() {
280 if (launcher_.get())
281 return;
282
283 aura::Window* default_container =
284 GetContainer(internal::kShellWindowId_DefaultContainer);
285 launcher_.reset(new Launcher(default_container, shelf_));
286
287 launcher_->SetFocusCycler(Shell::GetInstance()->focus_cycler());
288 shelf_->SetLauncher(launcher_.get());
289
290 if (panel_layout_manager_)
291 panel_layout_manager_->SetLauncher(launcher_.get());
292
293 ShellDelegate* delegate = Shell::GetInstance()->delegate();
294 if (delegate)
295 launcher_->SetVisible(delegate->IsSessionStarted());
296 launcher_->widget()->Show();
297 }
298
299 void RootWindowController::ShowLauncher() {
300 if (!launcher_.get())
301 return;
302 launcher_->SetVisible(true);
303 }
304
217 void RootWindowController::HandleDesktopBackgroundVisible() { 305 void RootWindowController::HandleDesktopBackgroundVisible() {
218 if (background_.get()) 306 if (background_.get())
219 background_->SetColor(SK_ColorBLACK); 307 background_->SetColor(SK_ColorBLACK);
220 } 308 }
221 309
222 void RootWindowController::CloseChildWindows() { 310 void RootWindowController::CloseChildWindows() {
311 // The status area needs to be shut down before the windows are destroyed.
312 if (status_area_widget_)
313 status_area_widget_->Shutdown();
314
315 // Closing the windows frees the workspace controller.
316 if (shelf_)
317 shelf_->set_workspace_controller(NULL);
318
223 // Close background widget first as it depends on tooltip. 319 // Close background widget first as it depends on tooltip.
224 root_window_->SetProperty(kDesktopController, 320 root_window_->SetProperty(kDesktopController,
225 static_cast<DesktopBackgroundWidgetController*>(NULL)); 321 static_cast<DesktopBackgroundWidgetController*>(NULL));
226 root_window_->SetProperty(kAnimatingDesktopController, 322 root_window_->SetProperty(kAnimatingDesktopController,
227 static_cast<AnimatingDesktopController*>(NULL)); 323 static_cast<AnimatingDesktopController*>(NULL));
228 324
229 workspace_controller_.reset(); 325 workspace_controller_.reset();
230 aura::client::SetTooltipClient(root_window_.get(), NULL); 326 aura::client::SetTooltipClient(root_window_.get(), NULL);
231 327
232 while (!root_window_->children().empty()) { 328 while (!root_window_->children().empty()) {
233 aura::Window* child = root_window_->children()[0]; 329 aura::Window* child = root_window_->children()[0];
234 delete child; 330 delete child;
235 } 331 }
332 // TODO(oshima): Closing window triggers access to status area widget
333 // in ShelfLayoutManager. We probably should disalb/remove shelf layout
334 // manager before destorying windows?
335 status_area_widget_ = NULL;
336
337 // All containers are deleted, so reset shelf_.
338 shelf_ = NULL;
236 } 339 }
237 340
238 bool RootWindowController::IsInMaximizedMode() const { 341 bool RootWindowController::IsInMaximizedMode() const {
239 return workspace_controller_->IsInMaximizedMode(); 342 return workspace_controller_->IsInMaximizedMode();
240 } 343 }
241 344
242 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) { 345 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) {
243 aura::Window* focused = dst->GetFocusManager()->GetFocusedWindow(); 346 aura::Window* focused = dst->GetFocusManager()->GetFocusedWindow();
244 aura::WindowTracker tracker; 347 aura::WindowTracker tracker;
245 if (focused) 348 if (focused)
(...skipping 17 matching lines...) Expand all
263 ReparentAllWindows(root_window_.get(), dst); 366 ReparentAllWindows(root_window_.get(), dst);
264 367
265 // Restore focused or active window if it's still alive. 368 // Restore focused or active window if it's still alive.
266 if (focused && tracker.Contains(focused) && dst->Contains(focused)) { 369 if (focused && tracker.Contains(focused) && dst->Contains(focused)) {
267 dst->GetFocusManager()->SetFocusedWindow(focused, NULL); 370 dst->GetFocusManager()->SetFocusedWindow(focused, NULL);
268 } else if (active && tracker.Contains(active) && dst->Contains(active)) { 371 } else if (active && tracker.Contains(active) && dst->Contains(active)) {
269 activation_client->ActivateWindow(active); 372 activation_client->ActivateWindow(active);
270 } 373 }
271 } 374 }
272 375
376 void RootWindowController::UpdateShelfVisibility() {
377 shelf_->UpdateVisibilityState();
378 }
379
380 void RootWindowController::SetShelfAutoHideBehavior(
381 ShelfAutoHideBehavior behavior) {
382 shelf_->SetAutoHideBehavior(behavior);
383 }
384
385 ShelfAutoHideBehavior RootWindowController::GetShelfAutoHideBehavior() const {
386 return shelf_->auto_hide_behavior();
387 }
388
389 bool RootWindowController::SetShelfAlignment(ShelfAlignment alignment) {
390 return shelf_->SetAlignment(alignment);
391 }
392
393 ShelfAlignment RootWindowController::GetShelfAlignment() {
394 return shelf_->alignment();
395 }
396
273 //////////////////////////////////////////////////////////////////////////////// 397 ////////////////////////////////////////////////////////////////////////////////
274 // RootWindowController, private: 398 // RootWindowController, private:
275 399
276 void RootWindowController::CreateContainersInRootWindow( 400 void RootWindowController::CreateContainersInRootWindow(
277 aura::RootWindow* root_window) { 401 aura::RootWindow* root_window) {
278 // These containers are just used by PowerButtonController to animate groups 402 // These containers are just used by PowerButtonController to animate groups
279 // of containers simultaneously without messing up the current transformations 403 // of containers simultaneously without messing up the current transformations
280 // on those containers. These are direct children of the root window; all of 404 // on those containers. These are direct children of the root window; all of
281 // the other containers are their children. 405 // the other containers are their children.
282 // Desktop and lock screen background containers are not part of the 406 // Desktop and lock screen background containers are not part of the
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 548
425 aura::Window* overlay_container = CreateContainer( 549 aura::Window* overlay_container = CreateContainer(
426 kShellWindowId_OverlayContainer, 550 kShellWindowId_OverlayContainer,
427 "OverlayContainer", 551 "OverlayContainer",
428 lock_screen_related_containers); 552 lock_screen_related_containers);
429 SetUsesScreenCoordinates(overlay_container); 553 SetUsesScreenCoordinates(overlay_container);
430 } 554 }
431 555
432 } // namespace internal 556 } // namespace internal
433 } // namespace ash 557 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698