| 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/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "ui/aura/window_property.h" | 33 #include "ui/aura/window_property.h" |
| 34 #include "ui/aura/window_tracker.h" | 34 #include "ui/aura/window_tracker.h" |
| 35 #include "ui/aura/window_tree_host.h" | 35 #include "ui/aura/window_tree_host.h" |
| 36 #include "ui/compositor/compositor.h" | 36 #include "ui/compositor/compositor.h" |
| 37 #include "ui/compositor/compositor_vsync_manager.h" | 37 #include "ui/compositor/compositor_vsync_manager.h" |
| 38 #include "ui/gfx/display.h" | 38 #include "ui/gfx/display.h" |
| 39 #include "ui/gfx/screen.h" | 39 #include "ui/gfx/screen.h" |
| 40 #include "ui/wm/public/activation_client.h" | 40 #include "ui/wm/public/activation_client.h" |
| 41 | 41 |
| 42 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 #include "ash/display/output_configurator_animation.h" | 43 #include "ash/display/display_configurator_animation.h" |
| 44 #include "base/sys_info.h" | 44 #include "base/sys_info.h" |
| 45 #include "base/time/time.h" | 45 #include "base/time/time.h" |
| 46 #if defined(USE_X11) | 46 #if defined(USE_X11) |
| 47 #include "ui/base/x/x11_util.h" | 47 #include "ui/base/x/x11_util.h" |
| 48 #include "ui/gfx/x/x11_types.h" | 48 #include "ui/gfx/x/x11_types.h" |
| 49 | 49 |
| 50 // Including this at the bottom to avoid other | 50 // Including this at the bottom to avoid other |
| 51 // potential conflict with chrome headers. | 51 // potential conflict with chrome headers. |
| 52 #include <X11/extensions/Xrandr.h> | 52 #include <X11/extensions/Xrandr.h> |
| 53 #undef RootWindow | 53 #undef RootWindow |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 if (display_manager->num_connected_displays() <= 1) | 375 if (display_manager->num_connected_displays() <= 1) |
| 376 return; | 376 return; |
| 377 | 377 |
| 378 if (limiter_) { | 378 if (limiter_) { |
| 379 if (limiter_->IsThrottled()) | 379 if (limiter_->IsThrottled()) |
| 380 return; | 380 return; |
| 381 limiter_->SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); | 381 limiter_->SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); |
| 382 } | 382 } |
| 383 #if defined(OS_CHROMEOS) | 383 #if defined(OS_CHROMEOS) |
| 384 Shell* shell = Shell::GetInstance(); | 384 Shell* shell = Shell::GetInstance(); |
| 385 OutputConfiguratorAnimation* animation = | 385 DisplayConfiguratorAnimation* animation = |
| 386 shell->output_configurator_animation(); | 386 shell->display_configurator_animation(); |
| 387 animation->StartFadeOutAnimation( | 387 animation->StartFadeOutAnimation( |
| 388 base::Bind(base::IgnoreResult(&DisplayManager::SetMirrorMode), | 388 base::Bind(base::IgnoreResult(&DisplayManager::SetMirrorMode), |
| 389 base::Unretained(display_manager), | 389 base::Unretained(display_manager), |
| 390 !display_manager->IsMirrored())); | 390 !display_manager->IsMirrored())); |
| 391 #endif | 391 #endif |
| 392 } | 392 } |
| 393 | 393 |
| 394 void DisplayController::SwapPrimaryDisplay() { | 394 void DisplayController::SwapPrimaryDisplay() { |
| 395 if (limiter_) { | 395 if (limiter_) { |
| 396 if (limiter_->IsThrottled()) | 396 if (limiter_->IsThrottled()) |
| 397 return; | 397 return; |
| 398 limiter_->SetThrottleTimeout(kSwapDisplayThrottleTimeoutMs); | 398 limiter_->SetThrottleTimeout(kSwapDisplayThrottleTimeoutMs); |
| 399 } | 399 } |
| 400 | 400 |
| 401 if (Shell::GetScreen()->GetNumDisplays() > 1) { | 401 if (Shell::GetScreen()->GetNumDisplays() > 1) { |
| 402 #if defined(OS_CHROMEOS) | 402 #if defined(OS_CHROMEOS) |
| 403 OutputConfiguratorAnimation* animation = | 403 DisplayConfiguratorAnimation* animation = |
| 404 Shell::GetInstance()->output_configurator_animation(); | 404 Shell::GetInstance()->display_configurator_animation(); |
| 405 if (animation) { | 405 if (animation) { |
| 406 animation->StartFadeOutAnimation(base::Bind( | 406 animation->StartFadeOutAnimation(base::Bind( |
| 407 &DisplayController::OnFadeOutForSwapDisplayFinished, | 407 &DisplayController::OnFadeOutForSwapDisplayFinished, |
| 408 base::Unretained(this))); | 408 base::Unretained(this))); |
| 409 } else { | 409 } else { |
| 410 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 410 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
| 411 } | 411 } |
| 412 #else | 412 #else |
| 413 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 413 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
| 414 #endif | 414 #endif |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 switches::kAshConstrainPointerToRoot); | 725 switches::kAshConstrainPointerToRoot); |
| 726 if (base::SysInfo::IsRunningOnChromeOS() || force_constrain_pointer_to_root) | 726 if (base::SysInfo::IsRunningOnChromeOS() || force_constrain_pointer_to_root) |
| 727 ash_host->ConfineCursorToRootWindow(); | 727 ash_host->ConfineCursorToRootWindow(); |
| 728 #endif | 728 #endif |
| 729 return ash_host; | 729 return ash_host; |
| 730 } | 730 } |
| 731 | 731 |
| 732 void DisplayController::OnFadeOutForSwapDisplayFinished() { | 732 void DisplayController::OnFadeOutForSwapDisplayFinished() { |
| 733 #if defined(OS_CHROMEOS) | 733 #if defined(OS_CHROMEOS) |
| 734 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 734 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
| 735 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); | 735 Shell::GetInstance()->display_configurator_animation() |
| 736 ->StartFadeInAnimation(); |
| 736 #endif | 737 #endif |
| 737 } | 738 } |
| 738 | 739 |
| 739 void DisplayController::UpdateHostWindowNames() { | 740 void DisplayController::UpdateHostWindowNames() { |
| 740 #if defined(USE_X11) | 741 #if defined(USE_X11) |
| 741 // crbug.com/120229 - set the window title for the primary dislpay | 742 // crbug.com/120229 - set the window title for the primary dislpay |
| 742 // to "aura_root_0" so gtalk can find the primary root window to broadcast. | 743 // to "aura_root_0" so gtalk can find the primary root window to broadcast. |
| 743 // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting. | 744 // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting. |
| 744 aura::Window* primary = Shell::GetPrimaryRootWindow(); | 745 aura::Window* primary = Shell::GetPrimaryRootWindow(); |
| 745 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 746 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 746 for (size_t i = 0; i < root_windows.size(); ++i) { | 747 for (size_t i = 0; i < root_windows.size(); ++i) { |
| 747 std::string name = | 748 std::string name = |
| 748 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 749 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
| 749 gfx::AcceleratedWidget xwindow = | 750 gfx::AcceleratedWidget xwindow = |
| 750 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 751 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
| 751 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 752 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
| 752 } | 753 } |
| 753 #endif | 754 #endif |
| 754 } | 755 } |
| 755 | 756 |
| 756 } // namespace ash | 757 } // namespace ash |
| OLD | NEW |