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

Side by Side Diff: ash/root_window_controller.cc

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (some tests disabled on Windows) Created 7 years, 6 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
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/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/desktop_background/desktop_background_widget_controller.h" 11 #include "ash/desktop_background/desktop_background_widget_controller.h"
12 #include "ash/display/display_controller.h" 12 #include "ash/display/display_controller.h"
13 #include "ash/display/display_manager.h" 13 #include "ash/display/display_manager.h"
14 #include "ash/focus_cycler.h" 14 #include "ash/focus_cycler.h"
15 #include "ash/session_state_delegate.h" 15 #include "ash/session_state_delegate.h"
16 #include "ash/shelf/shelf_layout_manager.h" 16 #include "ash/shelf/shelf_layout_manager.h"
17 #include "ash/shelf/shelf_types.h" 17 #include "ash/shelf/shelf_types.h"
18 #include "ash/shelf/shelf_widget.h" 18 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell.h" 19 #include "ash/shell.h"
20 #include "ash/shell_delegate.h" 20 #include "ash/shell_delegate.h"
21 #include "ash/shell_factory.h" 21 #include "ash/shell_factory.h"
22 #include "ash/shell_window_ids.h" 22 #include "ash/shell_window_ids.h"
23 #include "ash/system/status_area_widget.h" 23 #include "ash/system/status_area_widget.h"
24 #include "ash/system/tray/system_tray_delegate.h" 24 #include "ash/system/tray/system_tray_delegate.h"
25 #include "ash/touch/touch_observer_hud.h" 25 #include "ash/touch/touch_observer_hud.h"
26 #include "ash/wm/base_layout_manager.h" 26 #include "ash/wm/base_layout_manager.h"
27 #include "ash/wm/boot_splash_screen.h" 27 #include "ash/wm/boot_splash_screen.h"
28 #include "ash/wm/dock/docked_window_layout_manager.h"
28 #include "ash/wm/panels/panel_layout_manager.h" 29 #include "ash/wm/panels/panel_layout_manager.h"
29 #include "ash/wm/property_util.h" 30 #include "ash/wm/property_util.h"
30 #include "ash/wm/root_window_layout_manager.h" 31 #include "ash/wm/root_window_layout_manager.h"
31 #include "ash/wm/screen_dimmer.h" 32 #include "ash/wm/screen_dimmer.h"
32 #include "ash/wm/stacking_controller.h" 33 #include "ash/wm/stacking_controller.h"
33 #include "ash/wm/status_area_layout_manager.h" 34 #include "ash/wm/status_area_layout_manager.h"
34 #include "ash/wm/system_background_controller.h" 35 #include "ash/wm/system_background_controller.h"
35 #include "ash/wm/system_modal_container_layout_manager.h" 36 #include "ash/wm/system_modal_container_layout_manager.h"
36 #include "ash/wm/toplevel_window_event_handler.h" 37 #include "ash/wm/toplevel_window_event_handler.h"
37 #include "ash/wm/window_properties.h" 38 #include "ash/wm/window_properties.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 new_parent->AddChild(window); 105 new_parent->AddChild(window);
105 if (!restore_bounds.IsEmpty()) 106 if (!restore_bounds.IsEmpty())
106 SetRestoreBoundsInParent(window, restore_bounds); 107 SetRestoreBoundsInParent(window, restore_bounds);
107 } 108 }
108 109
109 // Reparents the appropriate set of windows from |src| to |dst|. 110 // Reparents the appropriate set of windows from |src| to |dst|.
110 void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) { 111 void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) {
111 // Set of windows to move. 112 // Set of windows to move.
112 const int kContainerIdsToMove[] = { 113 const int kContainerIdsToMove[] = {
113 internal::kShellWindowId_DefaultContainer, 114 internal::kShellWindowId_DefaultContainer,
115 internal::kShellWindowId_DockContainer,
114 internal::kShellWindowId_PanelContainer, 116 internal::kShellWindowId_PanelContainer,
115 internal::kShellWindowId_AlwaysOnTopContainer, 117 internal::kShellWindowId_AlwaysOnTopContainer,
116 internal::kShellWindowId_SystemModalContainer, 118 internal::kShellWindowId_SystemModalContainer,
117 internal::kShellWindowId_LockSystemModalContainer, 119 internal::kShellWindowId_LockSystemModalContainer,
118 internal::kShellWindowId_InputMethodContainer, 120 internal::kShellWindowId_InputMethodContainer,
119 internal::kShellWindowId_UnparentedControlContainer, 121 internal::kShellWindowId_UnparentedControlContainer,
120 }; 122 };
121 // For workspace windows we need to manually reparent the windows. This way 123 // For workspace windows we need to manually reparent the windows. This way
122 // workspace can move the windows to the appropriate workspace. 124 // workspace can move the windows to the appropriate workspace.
123 std::vector<aura::Window*> windows(GetWorkspaceWindows(src)); 125 std::vector<aura::Window*> windows(GetWorkspaceWindows(src));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 162 }
161 163
162 } // namespace 164 } // namespace
163 165
164 namespace internal { 166 namespace internal {
165 167
166 RootWindowController::RootWindowController(aura::RootWindow* root_window) 168 RootWindowController::RootWindowController(aura::RootWindow* root_window)
167 : root_window_(root_window), 169 : root_window_(root_window),
168 root_window_layout_(NULL), 170 root_window_layout_(NULL),
169 shelf_(NULL), 171 shelf_(NULL),
172 dock_layout_manager_(NULL),
170 panel_layout_manager_(NULL), 173 panel_layout_manager_(NULL),
171 touch_observer_hud_(NULL) { 174 touch_observer_hud_(NULL) {
172 SetRootWindowController(root_window, this); 175 SetRootWindowController(root_window, this);
173 screen_dimmer_.reset(new ScreenDimmer(root_window)); 176 screen_dimmer_.reset(new ScreenDimmer(root_window));
174 177
175 stacking_controller_.reset(new ash::StackingController); 178 stacking_controller_.reset(new ash::StackingController);
176 aura::client::SetStackingClient(root_window, stacking_controller_.get()); 179 aura::client::SetStackingClient(root_window, stacking_controller_.get());
177 } 180 }
178 181
179 RootWindowController::~RootWindowController() { 182 RootWindowController::~RootWindowController() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 void RootWindowController::InitForPrimaryDisplay() { 268 void RootWindowController::InitForPrimaryDisplay() {
266 DCHECK(!shelf_.get()); 269 DCHECK(!shelf_.get());
267 aura::Window* shelf_container = 270 aura::Window* shelf_container =
268 GetContainer(ash::internal::kShellWindowId_ShelfContainer); 271 GetContainer(ash::internal::kShellWindowId_ShelfContainer);
269 // TODO(harrym): Remove when status area is view. 272 // TODO(harrym): Remove when status area is view.
270 aura::Window* status_container = 273 aura::Window* status_container =
271 GetContainer(ash::internal::kShellWindowId_StatusContainer); 274 GetContainer(ash::internal::kShellWindowId_StatusContainer);
272 shelf_.reset(new ash::ShelfWidget( 275 shelf_.reset(new ash::ShelfWidget(
273 shelf_container, status_container, workspace_controller())); 276 shelf_container, status_container, workspace_controller()));
274 277
278 // Create Dock layout manager
279 aura::Window* dock_container = GetContainer(
280 internal::kShellWindowId_DockContainer);
281 dock_layout_manager_ =
282 new internal::DockedWindowLayoutManager(dock_container);
283 dock_container_handler_.reset(
284 new ToplevelWindowEventHandler(dock_container));
285 dock_container->SetLayoutManager(dock_layout_manager_);
286
275 // Create Panel layout manager 287 // Create Panel layout manager
276 aura::Window* panel_container = GetContainer( 288 aura::Window* panel_container = GetContainer(
277 internal::kShellWindowId_PanelContainer); 289 internal::kShellWindowId_PanelContainer);
278 panel_layout_manager_ = 290 panel_layout_manager_ =
279 new internal::PanelLayoutManager(panel_container); 291 new internal::PanelLayoutManager(panel_container);
280 panel_container_handler_.reset( 292 panel_container_handler_.reset(
281 new ToplevelWindowEventHandler(panel_container)); 293 new ToplevelWindowEventHandler(panel_container));
282 panel_container->SetLayoutManager(panel_layout_manager_); 294 panel_container->SetLayoutManager(panel_layout_manager_);
283 295
284 // TODO(stevenjb/oshima): Remove this call to CreateLauncher() and call 296 // TODO(stevenjb/oshima): Remove this call to CreateLauncher() and call
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 switches::kAshCopyHostBackgroundAtBoot) || 331 switches::kAshCopyHostBackgroundAtBoot) ||
320 CommandLine::ForCurrentProcess()->HasSwitch( 332 CommandLine::ForCurrentProcess()->HasSwitch(
321 switches::kAshAnimateFromBootSplashScreen))) 333 switches::kAshAnimateFromBootSplashScreen)))
322 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get())); 334 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get()));
323 #endif 335 #endif
324 } 336 }
325 337
326 void RootWindowController::OnLauncherCreated() { 338 void RootWindowController::OnLauncherCreated() {
327 if (panel_layout_manager_) 339 if (panel_layout_manager_)
328 panel_layout_manager_->SetLauncher(shelf_->launcher()); 340 panel_layout_manager_->SetLauncher(shelf_->launcher());
341 if (dock_layout_manager_)
342 dock_layout_manager_->SetLauncher(shelf_->launcher());
329 } 343 }
330 344
331 void RootWindowController::ShowLauncher() { 345 void RootWindowController::ShowLauncher() {
332 if (!shelf_.get() || !shelf_->launcher()) 346 if (!shelf_.get() || !shelf_->launcher())
333 return; 347 return;
334 shelf_->launcher()->SetVisible(true); 348 shelf_->launcher()->SetVisible(true);
335 shelf_->status_area_widget()->Show(); 349 shelf_->status_area_widget()->Show();
336 } 350 }
337 351
338 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { 352 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
(...skipping 24 matching lines...) Expand all
363 system_background_->SetColor(SK_ColorBLACK); 377 system_background_->SetColor(SK_ColorBLACK);
364 boot_splash_screen_.reset(); 378 boot_splash_screen_.reset();
365 } 379 }
366 380
367 void RootWindowController::CloseChildWindows() { 381 void RootWindowController::CloseChildWindows() {
368 // panel_layout_manager_ needs to be shut down before windows are destroyed. 382 // panel_layout_manager_ needs to be shut down before windows are destroyed.
369 if (panel_layout_manager_) { 383 if (panel_layout_manager_) {
370 panel_layout_manager_->Shutdown(); 384 panel_layout_manager_->Shutdown();
371 panel_layout_manager_ = NULL; 385 panel_layout_manager_ = NULL;
372 } 386 }
387 if (dock_layout_manager_) {
388 dock_layout_manager_->Shutdown();
389 dock_layout_manager_ = NULL;
390 }
373 391
374 // TODO(harrym): Remove when Status Area Widget is a child view. 392 // TODO(harrym): Remove when Status Area Widget is a child view.
375 if (shelf_) 393 if (shelf_)
376 shelf_->ShutdownStatusAreaWidget(); 394 shelf_->ShutdownStatusAreaWidget();
377 395
378 if (shelf_.get() && shelf_->shelf_layout_manager()) 396 if (shelf_.get() && shelf_->shelf_layout_manager())
379 shelf_->shelf_layout_manager()->set_workspace_controller(NULL); 397 shelf_->shelf_layout_manager()->set_workspace_controller(NULL);
380 398
381 // Close background widget first as it depends on tooltip. 399 // Close background widget first as it depends on tooltip.
382 root_window_->SetProperty(kDesktopController, 400 root_window_->SetProperty(kDesktopController,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 aura::Window* always_on_top_container = CreateContainer( 548 aura::Window* always_on_top_container = CreateContainer(
531 kShellWindowId_AlwaysOnTopContainer, 549 kShellWindowId_AlwaysOnTopContainer,
532 "AlwaysOnTopContainer", 550 "AlwaysOnTopContainer",
533 non_lock_screen_containers); 551 non_lock_screen_containers);
534 always_on_top_container_handler_.reset( 552 always_on_top_container_handler_.reset(
535 new ToplevelWindowEventHandler(always_on_top_container)); 553 new ToplevelWindowEventHandler(always_on_top_container));
536 views::corewm::SetChildWindowVisibilityChangesAnimated( 554 views::corewm::SetChildWindowVisibilityChangesAnimated(
537 always_on_top_container); 555 always_on_top_container);
538 SetUsesScreenCoordinates(always_on_top_container); 556 SetUsesScreenCoordinates(always_on_top_container);
539 557
558 aura::Window* dock_container = CreateContainer(
559 kShellWindowId_DockContainer,
560 "DockContainer",
561 non_lock_screen_containers);
562 SetUsesScreenCoordinates(dock_container);
563
540 aura::Window* panel_container = CreateContainer( 564 aura::Window* panel_container = CreateContainer(
541 kShellWindowId_PanelContainer, 565 kShellWindowId_PanelContainer,
542 "PanelContainer", 566 "PanelContainer",
543 non_lock_screen_containers); 567 non_lock_screen_containers);
544 SetUsesScreenCoordinates(panel_container); 568 SetUsesScreenCoordinates(panel_container);
545 569
546 aura::Window* launcher_container = 570 aura::Window* launcher_container =
547 CreateContainer(kShellWindowId_ShelfContainer, 571 CreateContainer(kShellWindowId_ShelfContainer,
548 "LauncherContainer", 572 "LauncherContainer",
549 non_lock_screen_containers); 573 non_lock_screen_containers);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 "OverlayContainer", 651 "OverlayContainer",
628 lock_screen_related_containers); 652 lock_screen_related_containers);
629 SetUsesScreenCoordinates(overlay_container); 653 SetUsesScreenCoordinates(overlay_container);
630 654
631 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, 655 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
632 "PowerButtonAnimationContainer", root_window) ; 656 "PowerButtonAnimationContainer", root_window) ;
633 } 657 }
634 658
635 } // namespace internal 659 } // namespace internal
636 } // namespace ash 660 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell_window_ids.h » ('j') | ash/shell_window_ids.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698