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

Side by Side Diff: ash/root_window_controller.cc

Issue 2618143002: cros: Remove some OS platform ifdefs from ash (Closed)
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/root_window_controller_unittest.cc » ('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 <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_touch_exploration_manager_chromeos.h"
10 #include "ash/aura/aura_layout_manager_adapter.h" 11 #include "ash/aura/aura_layout_manager_adapter.h"
11 #include "ash/aura/wm_root_window_controller_aura.h" 12 #include "ash/aura/wm_root_window_controller_aura.h"
12 #include "ash/aura/wm_shelf_aura.h" 13 #include "ash/aura/wm_shelf_aura.h"
13 #include "ash/aura/wm_window_aura.h" 14 #include "ash/aura/wm_window_aura.h"
14 #include "ash/common/ash_constants.h" 15 #include "ash/common/ash_constants.h"
15 #include "ash/common/ash_switches.h" 16 #include "ash/common/ash_switches.h"
16 #include "ash/common/focus_cycler.h" 17 #include "ash/common/focus_cycler.h"
17 #include "ash/common/login_status.h" 18 #include "ash/common/login_status.h"
18 #include "ash/common/session/session_state_delegate.h" 19 #include "ash/common/session/session_state_delegate.h"
19 #include "ash/common/shelf/shelf_delegate.h" 20 #include "ash/common/shelf/shelf_delegate.h"
(...skipping 21 matching lines...) Expand all
41 #include "ash/high_contrast/high_contrast_controller.h" 42 #include "ash/high_contrast/high_contrast_controller.h"
42 #include "ash/host/ash_window_tree_host.h" 43 #include "ash/host/ash_window_tree_host.h"
43 #include "ash/public/cpp/shelf_types.h" 44 #include "ash/public/cpp/shelf_types.h"
44 #include "ash/public/cpp/shell_window_ids.h" 45 #include "ash/public/cpp/shell_window_ids.h"
45 #include "ash/root_window_settings.h" 46 #include "ash/root_window_settings.h"
46 #include "ash/shelf/shelf_window_targeter.h" 47 #include "ash/shelf/shelf_window_targeter.h"
47 #include "ash/shell.h" 48 #include "ash/shell.h"
48 #include "ash/touch/touch_hud_debug.h" 49 #include "ash/touch/touch_hud_debug.h"
49 #include "ash/touch/touch_hud_projection.h" 50 #include "ash/touch/touch_hud_projection.h"
50 #include "ash/touch/touch_observer_hud.h" 51 #include "ash/touch/touch_observer_hud.h"
52 #include "ash/wm/boot_splash_screen_chromeos.h"
51 #include "ash/wm/panels/attached_panel_window_targeter.h" 53 #include "ash/wm/panels/attached_panel_window_targeter.h"
52 #include "ash/wm/panels/panel_window_event_handler.h" 54 #include "ash/wm/panels/panel_window_event_handler.h"
53 #include "ash/wm/stacking_controller.h" 55 #include "ash/wm/stacking_controller.h"
54 #include "ash/wm/system_wallpaper_controller.h" 56 #include "ash/wm/system_wallpaper_controller.h"
55 #include "ash/wm/window_properties.h" 57 #include "ash/wm/window_properties.h"
56 #include "ash/wm/window_state_aura.h" 58 #include "ash/wm/window_state_aura.h"
57 #include "ash/wm/window_util.h" 59 #include "ash/wm/window_util.h"
58 #include "base/command_line.h" 60 #include "base/command_line.h"
59 #include "base/macros.h" 61 #include "base/macros.h"
60 #include "base/memory/ptr_util.h" 62 #include "base/memory/ptr_util.h"
61 #include "base/time/time.h" 63 #include "base/time/time.h"
64 #include "chromeos/chromeos_switches.h"
62 #include "ui/aura/client/aura_constants.h" 65 #include "ui/aura/client/aura_constants.h"
63 #include "ui/aura/client/drag_drop_client.h" 66 #include "ui/aura/client/drag_drop_client.h"
64 #include "ui/aura/client/screen_position_client.h" 67 #include "ui/aura/client/screen_position_client.h"
65 #include "ui/aura/window.h" 68 #include "ui/aura/window.h"
66 #include "ui/aura/window_event_dispatcher.h" 69 #include "ui/aura/window_event_dispatcher.h"
67 #include "ui/aura/window_observer.h" 70 #include "ui/aura/window_observer.h"
68 #include "ui/aura/window_tracker.h" 71 #include "ui/aura/window_tracker.h"
72 #include "ui/chromeos/touch_exploration_controller.h"
69 #include "ui/display/types/display_constants.h" 73 #include "ui/display/types/display_constants.h"
70 #include "ui/keyboard/keyboard_controller.h" 74 #include "ui/keyboard/keyboard_controller.h"
71 #include "ui/keyboard/keyboard_util.h" 75 #include "ui/keyboard/keyboard_util.h"
72 #include "ui/views/view_model.h" 76 #include "ui/views/view_model.h"
73 #include "ui/views/view_model_utils.h" 77 #include "ui/views/view_model_utils.h"
74 #include "ui/wm/core/capture_controller.h" 78 #include "ui/wm/core/capture_controller.h"
75 #include "ui/wm/core/visibility_controller.h" 79 #include "ui/wm/core/visibility_controller.h"
76 #include "ui/wm/core/window_util.h" 80 #include "ui/wm/core/window_util.h"
77 #include "ui/wm/public/tooltip_client.h" 81 #include "ui/wm/public/tooltip_client.h"
78 #include "ui/wm/public/window_types.h" 82 #include "ui/wm/public/window_types.h"
79 83
80 #if defined(OS_CHROMEOS)
81 #include "ash/ash_touch_exploration_manager_chromeos.h"
82 #include "ash/wm/boot_splash_screen_chromeos.h"
83 #include "chromeos/chromeos_switches.h"
84 #include "ui/chromeos/touch_exploration_controller.h"
85 #endif
86
87 namespace ash { 84 namespace ash {
88 namespace { 85 namespace {
89 86
90 #if defined(OS_CHROMEOS)
91 // Duration for the animation that hides the boot splash screen, in 87 // Duration for the animation that hides the boot splash screen, in
92 // milliseconds. This should be short enough in relation to 88 // milliseconds. This should be short enough in relation to
93 // wm/window_animation.cc's brightness/grayscale fade animation that the login 89 // wm/window_animation.cc's brightness/grayscale fade animation that the login
94 // wallpaper image animation isn't hidden by the splash screen animation. 90 // wallpaper image animation isn't hidden by the splash screen animation.
95 const int kBootSplashScreenHideDurationMs = 500; 91 const int kBootSplashScreenHideDurationMs = 500;
96 #endif
97 92
98 bool IsWindowAboveContainer(aura::Window* window, 93 bool IsWindowAboveContainer(aura::Window* window,
99 aura::Window* blocking_container) { 94 aura::Window* blocking_container) {
100 std::vector<aura::Window*> target_path; 95 std::vector<aura::Window*> target_path;
101 std::vector<aura::Window*> blocking_path; 96 std::vector<aura::Window*> blocking_path;
102 97
103 while (window) { 98 while (window) {
104 target_path.push_back(window); 99 target_path.push_back(window);
105 window = window->parent(); 100 window = window->parent();
106 } 101 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return GetHost()->window(); 186 return GetHost()->window();
192 } 187 }
193 188
194 WorkspaceController* RootWindowController::workspace_controller() { 189 WorkspaceController* RootWindowController::workspace_controller() {
195 return wm_root_window_controller_->workspace_controller(); 190 return wm_root_window_controller_->workspace_controller();
196 } 191 }
197 192
198 void RootWindowController::Shutdown() { 193 void RootWindowController::Shutdown() {
199 WmShell::Get()->RemoveShellObserver(this); 194 WmShell::Get()->RemoveShellObserver(this);
200 195
201 #if defined(OS_CHROMEOS)
202 touch_exploration_manager_.reset(); 196 touch_exploration_manager_.reset();
203 #endif
204 197
205 wm_root_window_controller_->ResetRootForNewWindowsIfNecessary(); 198 wm_root_window_controller_->ResetRootForNewWindowsIfNecessary();
206 199
207 CloseChildWindows(); 200 CloseChildWindows();
208 aura::Window* root_window = GetRootWindow(); 201 aura::Window* root_window = GetRootWindow();
209 GetRootWindowSettings(root_window)->controller = NULL; 202 GetRootWindowSettings(root_window)->controller = NULL;
210 // Forget with the display ID so that display lookup 203 // Forget with the display ID so that display lookup
211 // ends up with invalid display. 204 // ends up with invalid display.
212 GetRootWindowSettings(root_window)->display_id = display::kInvalidDisplayId; 205 GetRootWindowSettings(root_window)->display_id = display::kInvalidDisplayId;
213 ash_host_->PrepareForShutdown(); 206 ash_host_->PrepareForShutdown();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 256
264 aura::Window* RootWindowController::GetContainer(int container_id) { 257 aura::Window* RootWindowController::GetContainer(int container_id) {
265 return GetRootWindow()->GetChildById(container_id); 258 return GetRootWindow()->GetChildById(container_id);
266 } 259 }
267 260
268 const aura::Window* RootWindowController::GetContainer(int container_id) const { 261 const aura::Window* RootWindowController::GetContainer(int container_id) const {
269 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); 262 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id);
270 } 263 }
271 264
272 void RootWindowController::OnInitialWallpaperAnimationStarted() { 265 void RootWindowController::OnInitialWallpaperAnimationStarted() {
273 #if defined(OS_CHROMEOS)
274 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 266 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
275 switches::kAshAnimateFromBootSplashScreen) && 267 switches::kAshAnimateFromBootSplashScreen) &&
276 boot_splash_screen_.get()) { 268 boot_splash_screen_.get()) {
277 // Make the splash screen fade out so it doesn't obscure the wallpaper's 269 // Make the splash screen fade out so it doesn't obscure the wallpaper's
278 // brightness/grayscale animation. 270 // brightness/grayscale animation.
279 boot_splash_screen_->StartHideAnimation( 271 boot_splash_screen_->StartHideAnimation(
280 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs)); 272 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
281 } 273 }
282 #endif
283 } 274 }
284 275
285 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) { 276 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
286 // Make sure the wallpaper is visible. 277 // Make sure the wallpaper is visible.
287 system_wallpaper_->SetColor(SK_ColorBLACK); 278 system_wallpaper_->SetColor(SK_ColorBLACK);
288 #if defined(OS_CHROMEOS)
289 boot_splash_screen_.reset(); 279 boot_splash_screen_.reset();
290 #endif
291 } 280 }
292 281
293 void RootWindowController::CloseChildWindows() { 282 void RootWindowController::CloseChildWindows() {
294 // Remove observer as deactivating keyboard causes 283 // Remove observer as deactivating keyboard causes
295 // docked_window_layout_manager() to fire notifications. 284 // docked_window_layout_manager() to fire notifications.
296 if (docked_window_layout_manager() && 285 if (docked_window_layout_manager() &&
297 wm_shelf_aura_->shelf_layout_manager()) { 286 wm_shelf_aura_->shelf_layout_manager()) {
298 docked_window_layout_manager()->RemoveObserver( 287 docked_window_layout_manager()->RemoveObserver(
299 wm_shelf_aura_->shelf_layout_manager()); 288 wm_shelf_aura_->shelf_layout_manager());
300 } 289 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 376 }
388 } 377 }
389 378
390 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { 379 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) {
391 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 380 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
392 return parent ? parent->Contains(window) : false; 381 return parent ? parent->Contains(window) : false;
393 } 382 }
394 383
395 void RootWindowController::SetTouchAccessibilityAnchorPoint( 384 void RootWindowController::SetTouchAccessibilityAnchorPoint(
396 const gfx::Point& anchor_point) { 385 const gfx::Point& anchor_point) {
397 #if defined(OS_CHROMEOS)
398 if (touch_exploration_manager_) 386 if (touch_exploration_manager_)
399 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); 387 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point);
400 #endif // defined(OS_CHROMEOS)
401 } 388 }
402 389
403 //////////////////////////////////////////////////////////////////////////////// 390 ////////////////////////////////////////////////////////////////////////////////
404 // RootWindowController, private: 391 // RootWindowController, private:
405 392
406 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) 393 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host)
407 : ash_host_(ash_host), 394 : ash_host_(ash_host),
408 wm_shelf_aura_(new WmShelfAura), 395 wm_shelf_aura_(new WmShelfAura),
409 touch_hud_debug_(NULL), 396 touch_hud_debug_(NULL),
410 touch_hud_projection_(NULL) { 397 touch_hud_projection_(NULL) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 ash_host_->AsWindowTreeHost()->Show(); 436 ash_host_->AsWindowTreeHost()->Show();
450 437
451 // Create a shelf if a user is already logged in. 438 // Create a shelf if a user is already logged in.
452 if (WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers()) 439 if (WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers())
453 wm_root_window_controller_->CreateShelf(); 440 wm_root_window_controller_->CreateShelf();
454 441
455 // Notify shell observers about new root window. 442 // Notify shell observers about new root window.
456 shell->OnRootWindowAdded(WmWindowAura::Get(root_window)); 443 shell->OnRootWindowAdded(WmWindowAura::Get(root_window));
457 } 444 }
458 445
459 #if defined(OS_CHROMEOS)
460 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 446 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
461 switches::kAshDisableTouchExplorationMode)) { 447 switches::kAshDisableTouchExplorationMode)) {
462 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); 448 touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
463 } 449 }
464 #endif
465 } 450 }
466 451
467 void RootWindowController::InitLayoutManagers() { 452 void RootWindowController::InitLayoutManagers() {
468 // Create the shelf and status area widgets. 453 // Create the shelf and status area widgets.
469 DCHECK(!wm_shelf_aura_->shelf_widget()); 454 DCHECK(!wm_shelf_aura_->shelf_widget());
470 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); 455 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
471 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); 456 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
472 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); 457 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container);
473 WmWindow* wm_status_container = WmWindowAura::Get(status_container); 458 WmWindow* wm_status_container = WmWindowAura::Get(status_container);
474 459
(...skipping 27 matching lines...) Expand all
502 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 487 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
503 if (command_line->HasSwitch(switches::kAshTouchHud)) 488 if (command_line->HasSwitch(switches::kAshTouchHud))
504 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); 489 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
505 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) 490 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
506 EnableTouchHudProjection(); 491 EnableTouchHudProjection();
507 } 492 }
508 493
509 void RootWindowController::CreateSystemWallpaper( 494 void RootWindowController::CreateSystemWallpaper(
510 RootWindowType root_window_type) { 495 RootWindowType root_window_type) {
511 SkColor color = SK_ColorBLACK; 496 SkColor color = SK_ColorBLACK;
512 #if defined(OS_CHROMEOS)
513 // The splash screen appears on the primary display at boot. If this is a 497 // The splash screen appears on the primary display at boot. If this is a
514 // secondary monitor (either connected at boot or connected later) or if the 498 // secondary monitor (either connected at boot or connected later) or if the
515 // browser restarted for a second login then don't use the boot color. 499 // browser restarted for a second login then don't use the boot color.
516 const bool is_boot_splash_screen = 500 const bool is_boot_splash_screen =
517 root_window_type == PRIMARY && 501 root_window_type == PRIMARY &&
518 base::CommandLine::ForCurrentProcess()->HasSwitch( 502 base::CommandLine::ForCurrentProcess()->HasSwitch(
519 chromeos::switches::kFirstExecAfterBoot); 503 chromeos::switches::kFirstExecAfterBoot);
520 if (is_boot_splash_screen) 504 if (is_boot_splash_screen)
521 color = kChromeOsBootColor; 505 color = kChromeOsBootColor;
522 #endif
523 system_wallpaper_.reset( 506 system_wallpaper_.reset(
524 new SystemWallpaperController(GetRootWindow(), color)); 507 new SystemWallpaperController(GetRootWindow(), color));
525 508
526 #if defined(OS_CHROMEOS)
527 // Make a copy of the system's boot splash screen so we can composite it 509 // Make a copy of the system's boot splash screen so we can composite it
528 // onscreen until the wallpaper is ready. 510 // onscreen until the wallpaper is ready.
529 if (is_boot_splash_screen && 511 if (is_boot_splash_screen &&
530 (base::CommandLine::ForCurrentProcess()->HasSwitch( 512 (base::CommandLine::ForCurrentProcess()->HasSwitch(
531 switches::kAshCopyHostBackgroundAtBoot) || 513 switches::kAshCopyHostBackgroundAtBoot) ||
532 base::CommandLine::ForCurrentProcess()->HasSwitch( 514 base::CommandLine::ForCurrentProcess()->HasSwitch(
533 switches::kAshAnimateFromBootSplashScreen))) 515 switches::kAshAnimateFromBootSplashScreen)))
534 boot_splash_screen_.reset(new BootSplashScreen(GetHost())); 516 boot_splash_screen_.reset(new BootSplashScreen(GetHost()));
535 #endif
536 } 517 }
537 518
538 void RootWindowController::EnableTouchHudProjection() { 519 void RootWindowController::EnableTouchHudProjection() {
539 if (touch_hud_projection_) 520 if (touch_hud_projection_)
540 return; 521 return;
541 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); 522 set_touch_hud_projection(new TouchHudProjection(GetRootWindow()));
542 } 523 }
543 524
544 void RootWindowController::DisableTouchHudProjection() { 525 void RootWindowController::DisableTouchHudProjection() {
545 if (!touch_hud_projection_) 526 if (!touch_hud_projection_)
(...skipping 19 matching lines...) Expand all
565 EnableTouchHudProjection(); 546 EnableTouchHudProjection();
566 else 547 else
567 DisableTouchHudProjection(); 548 DisableTouchHudProjection();
568 } 549 }
569 550
570 RootWindowController* GetRootWindowController(const aura::Window* root_window) { 551 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
571 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; 552 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
572 } 553 }
573 554
574 } // namespace ash 555 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698