| 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 <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/ash_root_window_transformer.h" | 10 #include "ash/ash_root_window_transformer.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
| 29 #include "ui/aura/root_window.h" | 29 #include "ui/aura/root_window.h" |
| 30 #include "ui/aura/window.h" | 30 #include "ui/aura/window.h" |
| 31 #include "ui/aura/window_property.h" | 31 #include "ui/aura/window_property.h" |
| 32 #include "ui/compositor/compositor.h" | 32 #include "ui/compositor/compositor.h" |
| 33 #include "ui/compositor/dip_util.h" | 33 #include "ui/compositor/dip_util.h" |
| 34 #include "ui/gfx/display.h" | 34 #include "ui/gfx/display.h" |
| 35 #include "ui/gfx/screen.h" | 35 #include "ui/gfx/screen.h" |
| 36 | 36 |
| 37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 38 #include "ash/display/output_configurator_animation.h" | |
| 39 #include "base/chromeos/chromeos_version.h" | 38 #include "base/chromeos/chromeos_version.h" |
| 40 #include "base/time.h" | 39 #include "base/time.h" |
| 40 #if defined(USE_X11) |
| 41 #include "ash/display/output_configurator_animation.h" |
| 41 #include "chromeos/display/output_configurator.h" | 42 #include "chromeos/display/output_configurator.h" |
| 42 #include "ui/base/x/x11_util.h" | 43 #include "ui/base/x/x11_util.h" |
| 43 | 44 |
| 44 // Including this at the bottom to avoid other | 45 // Including this at the bottom to avoid other |
| 45 // potential conflict with chrome headers. | 46 // potential conflict with chrome headers. |
| 46 #include <X11/extensions/Xrandr.h> | 47 #include <X11/extensions/Xrandr.h> |
| 47 #undef RootWindow | 48 #undef RootWindow |
| 49 #endif // defined(USE_X11) |
| 48 #endif // defined(OS_CHROMEOS) | 50 #endif // defined(OS_CHROMEOS) |
| 49 | 51 |
| 50 DECLARE_WINDOW_PROPERTY_TYPE(gfx::Display::Rotation); | 52 DECLARE_WINDOW_PROPERTY_TYPE(gfx::Display::Rotation); |
| 51 | 53 |
| 52 namespace ash { | 54 namespace ash { |
| 53 namespace { | 55 namespace { |
| 54 | 56 |
| 55 DEFINE_WINDOW_PROPERTY_KEY(gfx::Display::Rotation, kRotationPropertyKey, | 57 DEFINE_WINDOW_PROPERTY_KEY(gfx::Display::Rotation, kRotationPropertyKey, |
| 56 gfx::Display::ROTATE_0); | 58 gfx::Display::ROTATE_0); |
| 57 | 59 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 reverse_rotate, | 176 reverse_rotate, |
| 175 info.GetOverscanInsetsInPixel(), | 177 info.GetOverscanInsetsInPixel(), |
| 176 info.ui_scale())); | 178 info.ui_scale())); |
| 177 root_window->SetRootWindowTransformer(transformer.Pass()); | 179 root_window->SetRootWindowTransformer(transformer.Pass()); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, | 182 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, |
| 181 const gfx::Display& display) { | 183 const gfx::Display& display) { |
| 182 internal::DisplayInfo info = | 184 internal::DisplayInfo info = |
| 183 GetDisplayManager()->GetDisplayInfo(display.id()); | 185 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 184 #if defined(OS_CHROMEOS) | 186 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 185 // Native window property (Atom in X11) that specifies the display's | 187 // Native window property (Atom in X11) that specifies the display's |
| 186 // rotation, scale factor and if it's internal display. They are | 188 // rotation, scale factor and if it's internal display. They are |
| 187 // read and used by touchpad/mouse driver directly on X (contact | 189 // read and used by touchpad/mouse driver directly on X (contact |
| 188 // adlr@ for more details on touchpad/mouse driver side). The value | 190 // adlr@ for more details on touchpad/mouse driver side). The value |
| 189 // of the rotation is one of 0 (normal), 1 (90 degrees clockwise), 2 | 191 // of the rotation is one of 0 (normal), 1 (90 degrees clockwise), 2 |
| 190 // (180 degree) or 3 (270 degrees clockwise). The value of the | 192 // (180 degree) or 3 (270 degrees clockwise). The value of the |
| 191 // scale factor is in percent (100, 140, 200 etc). | 193 // scale factor is in percent (100, 140, 200 etc). |
| 192 const char kRotationProp[] = "_CHROME_DISPLAY_ROTATION"; | 194 const char kRotationProp[] = "_CHROME_DISPLAY_ROTATION"; |
| 193 const char kScaleFactorProp[] = "_CHROME_DISPLAY_SCALE_FACTOR"; | 195 const char kScaleFactorProp[] = "_CHROME_DISPLAY_SCALE_FACTOR"; |
| 194 const char kInternalProp[] = "_CHROME_DISPLAY_INTERNAL"; | 196 const char kInternalProp[] = "_CHROME_DISPLAY_INTERNAL"; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 paired_layouts_.find(pair); | 600 paired_layouts_.find(pair); |
| 599 return iter != paired_layouts_.end() ? iter->second : default_display_layout_; | 601 return iter != paired_layouts_.end() ? iter->second : default_display_layout_; |
| 600 } | 602 } |
| 601 | 603 |
| 602 void DisplayController::CycleDisplayMode() { | 604 void DisplayController::CycleDisplayMode() { |
| 603 if (limiter_.get()) { | 605 if (limiter_.get()) { |
| 604 if (limiter_->IsThrottled()) | 606 if (limiter_->IsThrottled()) |
| 605 return; | 607 return; |
| 606 limiter_->SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); | 608 limiter_->SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); |
| 607 } | 609 } |
| 608 #if defined(OS_CHROMEOS) | 610 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 609 Shell* shell = Shell::GetInstance(); | 611 Shell* shell = Shell::GetInstance(); |
| 610 internal::DisplayManager* display_manager = GetDisplayManager(); | 612 internal::DisplayManager* display_manager = GetDisplayManager(); |
| 611 if (!base::chromeos::IsRunningOnChromeOS()) { | 613 if (!base::chromeos::IsRunningOnChromeOS()) { |
| 612 internal::DisplayManager::CycleDisplay(); | 614 internal::DisplayManager::CycleDisplay(); |
| 613 } else if (display_manager->num_connected_displays() > 1) { | 615 } else if (display_manager->num_connected_displays() > 1) { |
| 614 chromeos::OutputState new_state = display_manager->IsMirrored() ? | 616 chromeos::OutputState new_state = display_manager->IsMirrored() ? |
| 615 chromeos::STATE_DUAL_EXTENDED : chromeos::STATE_DUAL_MIRROR; | 617 chromeos::STATE_DUAL_EXTENDED : chromeos::STATE_DUAL_MIRROR; |
| 616 internal::OutputConfiguratorAnimation* animation = | 618 internal::OutputConfiguratorAnimation* animation = |
| 617 shell->output_configurator_animation(); | 619 shell->output_configurator_animation(); |
| 618 animation->StartFadeOutAnimation(base::Bind( | 620 animation->StartFadeOutAnimation(base::Bind( |
| 619 base::IgnoreResult(&chromeos::OutputConfigurator::SetDisplayMode), | 621 base::IgnoreResult(&chromeos::OutputConfigurator::SetDisplayMode), |
| 620 base::Unretained(shell->output_configurator()), | 622 base::Unretained(shell->output_configurator()), |
| 621 new_state)); | 623 new_state)); |
| 622 } | 624 } |
| 623 #endif | 625 #endif |
| 624 } | 626 } |
| 625 | 627 |
| 626 void DisplayController::SwapPrimaryDisplay() { | 628 void DisplayController::SwapPrimaryDisplay() { |
| 627 if (limiter_.get()) { | 629 if (limiter_.get()) { |
| 628 if (limiter_->IsThrottled()) | 630 if (limiter_->IsThrottled()) |
| 629 return; | 631 return; |
| 630 limiter_->SetThrottleTimeout(kSwapDisplayThrottleTimeoutMs); | 632 limiter_->SetThrottleTimeout(kSwapDisplayThrottleTimeoutMs); |
| 631 } | 633 } |
| 632 | 634 |
| 633 if (Shell::GetScreen()->GetNumDisplays() > 1) { | 635 if (Shell::GetScreen()->GetNumDisplays() > 1) { |
| 634 #if defined(OS_CHROMEOS) | 636 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 635 internal::OutputConfiguratorAnimation* animation = | 637 internal::OutputConfiguratorAnimation* animation = |
| 636 Shell::GetInstance()->output_configurator_animation(); | 638 Shell::GetInstance()->output_configurator_animation(); |
| 637 if (animation) { | 639 if (animation) { |
| 638 animation->StartFadeOutAnimation(base::Bind( | 640 animation->StartFadeOutAnimation(base::Bind( |
| 639 &DisplayController::OnFadeOutForSwapDisplayFinished, | 641 &DisplayController::OnFadeOutForSwapDisplayFinished, |
| 640 base::Unretained(this))); | 642 base::Unretained(this))); |
| 641 } else { | 643 } else { |
| 642 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); | 644 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); |
| 643 } | 645 } |
| 644 #else | 646 #else |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 int64 id1, | 933 int64 id1, |
| 932 int64 id2, | 934 int64 id2, |
| 933 const DisplayLayout& layout, | 935 const DisplayLayout& layout, |
| 934 bool override) { | 936 bool override) { |
| 935 DisplayIdPair pair = std::make_pair(id1, id2); | 937 DisplayIdPair pair = std::make_pair(id1, id2); |
| 936 if (override || paired_layouts_.find(pair) == paired_layouts_.end()) | 938 if (override || paired_layouts_.find(pair) == paired_layouts_.end()) |
| 937 paired_layouts_[pair] = layout; | 939 paired_layouts_[pair] = layout; |
| 938 } | 940 } |
| 939 | 941 |
| 940 void DisplayController::OnFadeOutForSwapDisplayFinished() { | 942 void DisplayController::OnFadeOutForSwapDisplayFinished() { |
| 941 #if defined(OS_CHROMEOS) | 943 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 942 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); | 944 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); |
| 943 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); | 945 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); |
| 944 #endif | 946 #endif |
| 945 } | 947 } |
| 946 | 948 |
| 947 } // namespace ash | 949 } // namespace ash |
| OLD | NEW |