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 21 matching lines...) Expand all Loading... |
32 #include "ui/aura/window_event_dispatcher.h" | 32 #include "ui/aura/window_event_dispatcher.h" |
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/compositor/compositor.h" | 35 #include "ui/compositor/compositor.h" |
36 #include "ui/compositor/compositor_vsync_manager.h" | 36 #include "ui/compositor/compositor_vsync_manager.h" |
37 #include "ui/gfx/display.h" | 37 #include "ui/gfx/display.h" |
38 #include "ui/gfx/screen.h" | 38 #include "ui/gfx/screen.h" |
39 #include "ui/wm/public/activation_client.h" | 39 #include "ui/wm/public/activation_client.h" |
40 | 40 |
41 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 42 #include "ash/display/output_configurator_animation.h" |
42 #include "base/sys_info.h" | 43 #include "base/sys_info.h" |
43 #include "base/time/time.h" | 44 #include "base/time/time.h" |
44 #if defined(USE_X11) | 45 #if defined(USE_X11) |
45 #include "ash/display/output_configurator_animation.h" | |
46 #include "ui/base/x/x11_util.h" | 46 #include "ui/base/x/x11_util.h" |
47 #include "ui/gfx/x/x11_types.h" | 47 #include "ui/gfx/x/x11_types.h" |
48 | 48 |
49 // Including this at the bottom to avoid other | 49 // Including this at the bottom to avoid other |
50 // potential conflict with chrome headers. | 50 // potential conflict with chrome headers. |
51 #include <X11/extensions/Xrandr.h> | 51 #include <X11/extensions/Xrandr.h> |
52 #undef RootWindow | 52 #undef RootWindow |
53 #endif // defined(USE_X11) | 53 #endif // defined(USE_X11) |
54 #endif // defined(OS_CHROMEOS) | 54 #endif // defined(OS_CHROMEOS) |
55 | 55 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 void DisplayController::ToggleMirrorMode() { | 366 void DisplayController::ToggleMirrorMode() { |
367 internal::DisplayManager* display_manager = GetDisplayManager(); | 367 internal::DisplayManager* display_manager = GetDisplayManager(); |
368 if (display_manager->num_connected_displays() <= 1) | 368 if (display_manager->num_connected_displays() <= 1) |
369 return; | 369 return; |
370 | 370 |
371 if (limiter_) { | 371 if (limiter_) { |
372 if (limiter_->IsThrottled()) | 372 if (limiter_->IsThrottled()) |
373 return; | 373 return; |
374 limiter_->SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); | 374 limiter_->SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); |
375 } | 375 } |
376 #if defined(OS_CHROMEOS) && defined(USE_X11) | 376 #if defined(OS_CHROMEOS) |
377 Shell* shell = Shell::GetInstance(); | 377 Shell* shell = Shell::GetInstance(); |
378 internal::OutputConfiguratorAnimation* animation = | 378 internal::OutputConfiguratorAnimation* animation = |
379 shell->output_configurator_animation(); | 379 shell->output_configurator_animation(); |
380 animation->StartFadeOutAnimation(base::Bind( | 380 animation->StartFadeOutAnimation(base::Bind( |
381 base::IgnoreResult(&internal::DisplayManager::SetMirrorMode), | 381 base::IgnoreResult(&internal::DisplayManager::SetMirrorMode), |
382 base::Unretained(display_manager), | 382 base::Unretained(display_manager), |
383 !display_manager->IsMirrored())); | 383 !display_manager->IsMirrored())); |
384 #endif | 384 #endif |
385 } | 385 } |
386 | 386 |
387 void DisplayController::SwapPrimaryDisplay() { | 387 void DisplayController::SwapPrimaryDisplay() { |
388 if (limiter_) { | 388 if (limiter_) { |
389 if (limiter_->IsThrottled()) | 389 if (limiter_->IsThrottled()) |
390 return; | 390 return; |
391 limiter_->SetThrottleTimeout(kSwapDisplayThrottleTimeoutMs); | 391 limiter_->SetThrottleTimeout(kSwapDisplayThrottleTimeoutMs); |
392 } | 392 } |
393 | 393 |
394 if (Shell::GetScreen()->GetNumDisplays() > 1) { | 394 if (Shell::GetScreen()->GetNumDisplays() > 1) { |
395 #if defined(OS_CHROMEOS) && defined(USE_X11) | 395 #if defined(OS_CHROMEOS) |
396 internal::OutputConfiguratorAnimation* animation = | 396 internal::OutputConfiguratorAnimation* animation = |
397 Shell::GetInstance()->output_configurator_animation(); | 397 Shell::GetInstance()->output_configurator_animation(); |
398 if (animation) { | 398 if (animation) { |
399 animation->StartFadeOutAnimation(base::Bind( | 399 animation->StartFadeOutAnimation(base::Bind( |
400 &DisplayController::OnFadeOutForSwapDisplayFinished, | 400 &DisplayController::OnFadeOutForSwapDisplayFinished, |
401 base::Unretained(this))); | 401 base::Unretained(this))); |
402 } else { | 402 } else { |
403 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 403 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
404 } | 404 } |
405 #else | 405 #else |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 static bool force_constrain_pointer_to_root = | 715 static bool force_constrain_pointer_to_root = |
716 CommandLine::ForCurrentProcess()->HasSwitch( | 716 CommandLine::ForCurrentProcess()->HasSwitch( |
717 switches::kAshConstrainPointerToRoot); | 717 switches::kAshConstrainPointerToRoot); |
718 if (base::SysInfo::IsRunningOnChromeOS() || force_constrain_pointer_to_root) | 718 if (base::SysInfo::IsRunningOnChromeOS() || force_constrain_pointer_to_root) |
719 host->ConfineCursorToRootWindow(); | 719 host->ConfineCursorToRootWindow(); |
720 #endif | 720 #endif |
721 return host; | 721 return host; |
722 } | 722 } |
723 | 723 |
724 void DisplayController::OnFadeOutForSwapDisplayFinished() { | 724 void DisplayController::OnFadeOutForSwapDisplayFinished() { |
725 #if defined(OS_CHROMEOS) && defined(USE_X11) | 725 #if defined(OS_CHROMEOS) |
726 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 726 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
727 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); | 727 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); |
728 #endif | 728 #endif |
729 } | 729 } |
730 | 730 |
731 void DisplayController::UpdateHostWindowNames() { | 731 void DisplayController::UpdateHostWindowNames() { |
732 #if defined(USE_X11) | 732 #if defined(USE_X11) |
733 // crbug.com/120229 - set the window title for the primary dislpay | 733 // crbug.com/120229 - set the window title for the primary dislpay |
734 // to "aura_root_0" so gtalk can find the primary root window to broadcast. | 734 // to "aura_root_0" so gtalk can find the primary root window to broadcast. |
735 // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting. | 735 // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting. |
736 aura::Window* primary = Shell::GetPrimaryRootWindow(); | 736 aura::Window* primary = Shell::GetPrimaryRootWindow(); |
737 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 737 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
738 for (size_t i = 0; i < root_windows.size(); ++i) { | 738 for (size_t i = 0; i < root_windows.size(); ++i) { |
739 std::string name = | 739 std::string name = |
740 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 740 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
741 gfx::AcceleratedWidget xwindow = | 741 gfx::AcceleratedWidget xwindow = |
742 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 742 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
743 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 743 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
744 } | 744 } |
745 #endif | 745 #endif |
746 } | 746 } |
747 | 747 |
748 } // namespace ash | 748 } // namespace ash |
OLD | NEW |