diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 04:26:22 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 04:26:22 +0000 |
commit | 3d1df54872badcea24026122d0494fd2a0b30841 (patch) | |
tree | 35f10d6c541e5b08ea54d50db9dc1caef94a5b5f /chromeos/display/output_configurator.h | |
parent | 0d36d1e2825dd5d5949cc5294ee3d4ed3955ad62 (diff) | |
download | chromium_src-3d1df54872badcea24026122d0494fd2a0b30841.zip chromium_src-3d1df54872badcea24026122d0494fd2a0b30841.tar.gz chromium_src-3d1df54872badcea24026122d0494fd2a0b30841.tar.bz2 |
chromeos: Update cached displays whenever fetching state.
This updates OutputConfigurator to update its cached outputs
whenever it fetches the current state via XRandR.
Previously, it only updated the cached outputs after
successfully configuring them. If an output was added and
configuration failed due to e.g. a request to enter an
invalid state, the new output wouldn't be present in the
cached list. This wasn't much of a problem before, since the
cached outputs were only used to ignore subsequent XRandR
notifications and to notify observers about changes (also,
we shouldn't be requesting invalid states), but having stale
outputs may be more of a problem if output-protection code
expects to be able to use the cached outputs as a mostly-up-
to-date snapshot of currently-connected outputs.
BUG=none
Review URL: https://chromiumcodereview.appspot.com/23447052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224890 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/display/output_configurator.h')
-rw-r--r-- | chromeos/display/output_configurator.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/chromeos/display/output_configurator.h b/chromeos/display/output_configurator.h index 2ff4484..ec45fc9 100644 --- a/chromeos/display/output_configurator.h +++ b/chromeos/display/output_configurator.h @@ -190,7 +190,8 @@ class CHROMEOS_EXPORT OutputConfigurator // Returns information about the current outputs. This method may block for // 60 milliseconds or more. The returned outputs are not fully initialized; - // the rest of the work happens in OutputConfigurator::GetOutputs(). + // the rest of the work happens in + // OutputConfigurator::UpdateCachedOutputs(). virtual std::vector<OutputSnapshot> GetOutputs() = 0; // Adds |mode| to |output|. @@ -232,6 +233,10 @@ class CHROMEOS_EXPORT OutputConfigurator xrandr_event_base_(xrandr_event_base) {} ~TestApi() {} + const std::vector<OutputSnapshot>& cached_outputs() const { + return configurator_->cached_outputs_; + } + // Dispatches an RRScreenChangeNotify event to |configurator_|. void SendScreenChangeEvent(); @@ -335,8 +340,7 @@ class CHROMEOS_EXPORT OutputConfigurator // Overridden from base::MessagePumpObserver: virtual base::EventStatus WillProcessEvent( const base::NativeEvent& event) OVERRIDE; - virtual void DidProcessEvent( - const base::NativeEvent& event) OVERRIDE; + virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); @@ -359,15 +363,15 @@ class CHROMEOS_EXPORT OutputConfigurator void ScheduleConfigureOutputs(); private: - // Returns currently-connected outputs. This method is a wrapper around - // |delegate_->GetOutputs()| that does additional work, like finding the - // mirror mode and setting user-preferred modes. Note that the server must - // be grabbed via |delegate_->GrabServer()| first. - std::vector<OutputSnapshot> GetOutputs(); - - // Helper method for GetOutputs() that initializes the passed-in outputs' - // |mirror_mode| fields by looking for a mode in |internal_output| and - // |external_output| having the same resolution. Returns false if a shared + // Updates |cached_outputs_| to contain currently-connected outputs. Calls + // |delegate_->GetOutputs()| and then does additional work, like finding the + // mirror mode and setting user-preferred modes. Note that the server must be + // grabbed via |delegate_->GrabServer()| first. + void UpdateCachedOutputs(); + + // Helper method for UpdateCachedOutputs() that initializes the passed-in + // outputs' |mirror_mode| fields by looking for a mode in |internal_output| + // and |external_output| having the same resolution. Returns false if a shared // mode wasn't found or created. // // |try_panel_fitting| allows creating a panel-fitting mode for @@ -395,20 +399,16 @@ class CHROMEOS_EXPORT OutputConfigurator // and returns true. bool EnterStateOrFallBackToSoftwareMirroring( OutputState output_state, - DisplayPowerState power_state, - const std::vector<OutputSnapshot>& outputs); + DisplayPowerState power_state); // Switches to the state specified in |output_state| and |power_state|. // On success, updates |output_state_|, |power_state_|, and // |cached_outputs_| and returns true. - bool EnterState(OutputState output_state, - DisplayPowerState power_state, - const std::vector<OutputSnapshot>& outputs); - - // Returns the output state that should be used with |outputs| connected - // while in |power_state|. - OutputState GetOutputState(const std::vector<OutputSnapshot>& outputs, - DisplayPowerState power_state) const; + bool EnterState(OutputState output_state, DisplayPowerState power_state); + + // Returns the output state that should be used with |cached_outputs_| while + // in |power_state|. + OutputState ChooseOutputState(DisplayPowerState power_state) const; // Computes the relevant transformation for mirror mode. // |output| is the output on which mirror mode is being applied. |