diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-22 02:42:08 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-22 02:42:08 +0000 |
commit | a776fee6fafa74cf2d312264882a16628cac866f (patch) | |
tree | e49aa4e8df8ab963dc52212386f77b8153919fd7 | |
parent | 4ed0d1c1474294a2b9c8808ff2b5f458bac9b92d (diff) | |
download | chromium_src-a776fee6fafa74cf2d312264882a16628cac866f.zip chromium_src-a776fee6fafa74cf2d312264882a16628cac866f.tar.gz chromium_src-a776fee6fafa74cf2d312264882a16628cac866f.tar.bz2 |
Use OutputConfigurator::SetDislpayMode for ctrl-fullscreen
DisplayManager knows the mirroring state, so no need to rely on
OutputConfigurator to move to next state. There is a chance
that dislpay may be disconnected when SetDisplayMode, but that's
harmless as it simply returns false.
BUG=180443
TEST=manual. see bug.
Review URL: https://codereview.chromium.org/12496020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189738 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/display/display_controller.cc | 10 | ||||
-rw-r--r-- | ash/display/display_manager.cc | 4 | ||||
-rw-r--r-- | ash/display/display_manager.h | 2 | ||||
-rw-r--r-- | chromeos/display/output_configurator.cc | 39 | ||||
-rw-r--r-- | chromeos/display/output_configurator.h | 10 |
5 files changed, 15 insertions, 50 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc index 8ce4c2f..af5e2d6 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/display_controller.cc @@ -560,14 +560,18 @@ void DisplayController::CycleDisplayMode() { } #if defined(OS_CHROMEOS) Shell* shell = Shell::GetInstance(); + internal::DisplayManager* display_manager = GetDisplayManager(); if (!base::chromeos::IsRunningOnChromeOS()) { internal::DisplayManager::CycleDisplay(); - } else if (shell->output_configurator()->connected_output_count() > 1) { + } else if (display_manager->num_connected_displays() > 1) { + chromeos::OutputState new_state = display_manager->IsMirrored() ? + chromeos::STATE_DUAL_EXTENDED : chromeos::STATE_DUAL_MIRROR; internal::OutputConfiguratorAnimation* animation = shell->output_configurator_animation(); animation->StartFadeOutAnimation(base::Bind( - base::IgnoreResult(&chromeos::OutputConfigurator::CycleDisplayMode), - base::Unretained(shell->output_configurator()))); + base::IgnoreResult(&chromeos::OutputConfigurator::SetDisplayMode), + base::Unretained(shell->output_configurator()), + new_state)); } #endif } diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index bf4d188..e577571 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -441,6 +441,10 @@ size_t DisplayManager::GetNumDisplays() const { return displays_.size(); } +bool DisplayManager::IsMirrored() const { + return mirrored_display_id_ != gfx::Display::kInvalidDisplayID; +} + const gfx::Display& DisplayManager::GetDisplayNearestWindow( const Window* window) const { if (!window) diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h index ce51512..4fc72f6 100644 --- a/ash/display/display_manager.h +++ b/ash/display/display_manager.h @@ -122,6 +122,8 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { // when displays are mirrored. size_t num_connected_displays() const { return num_connected_displays_; } + // Returns the mirroring status. + bool IsMirrored() const; int64 mirrored_display_id() const { return mirrored_display_id_; } // Returns the display object nearest given |window|. diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc index cb8210f..3031b83b 100644 --- a/chromeos/display/output_configurator.cc +++ b/chromeos/display/output_configurator.cc @@ -622,45 +622,6 @@ void OutputConfigurator::Stop() { configure_display_ = false; } -bool OutputConfigurator::CycleDisplayMode() { - TRACE_EVENT0("chromeos", "OutputConfigurator::CycleDisplayMode"); - VLOG(1) << "CycleDisplayMode"; - if (!configure_display_) - return false; - - bool did_change = false; - Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); - CHECK(display != NULL); - XGrabServer(display); - Window window = DefaultRootWindow(display); - XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); - CHECK(screen != NULL); - - std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); - connected_output_count_ = outputs.size(); - OutputState original = InferCurrentState(display, screen, outputs); - OutputState next_state = GetNextState(display, screen, original, outputs); - if (original != next_state && - EnterState(display, screen, window, next_state, power_state_, outputs)) { - did_change = true; - } - // We have seen cases where the XRandR data can get out of sync with our own - // cache so over-write it with whatever we detected, even if we didn't think - // anything changed. - output_state_ = next_state; - - XRRFreeScreenResources(screen); - XUngrabServer(display); - - if (did_change) { - NotifyOnDisplayChanged(); - } else { - FOR_EACH_OBSERVER( - Observer, observers_, OnDisplayModeChangeFailed(next_state)); - } - return did_change; -} - bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state, bool force_probe) { TRACE_EVENT0("chromeos", "OutputConfigurator::SetDisplayPower"); diff --git a/chromeos/display/output_configurator.h b/chromeos/display/output_configurator.h index 4f93598..f65a6cc 100644 --- a/chromeos/display/output_configurator.h +++ b/chromeos/display/output_configurator.h @@ -79,11 +79,6 @@ class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher { // Stop handling display configuration events/requests. void Stop(); - // Called when the user hits ctrl-F4 to request a display mode change. - // This method should only return false if it was called in a single-head or - // headless mode. - bool CycleDisplayMode(); - // Called when powerd notifies us that some set of displays should be turned // on or off. This requires enabling or disabling the CRTC associated with // the display(s) in question so that the low power state is engaged. @@ -91,9 +86,8 @@ class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher { // |power_state| matches |power_state_|. bool SetDisplayPower(DisplayPowerState power_state, bool force_probe); - // Force switching the display mode to |new_state|. This method is used when - // the user explicitly changes the display mode in the options UI. Returns - // false if it was called in a single-head or headless mode. + // Force switching the display mode to |new_state|. Returns false if + // it was called in a single-head or headless mode. bool SetDisplayMode(OutputState new_state); // Called when an RRNotify event is received. The implementation is |