| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/display/chromeos/update_display_configuration_task.h" | 5 #include "ui/display/chromeos/update_display_configuration_task.h" |
| 6 | 6 |
| 7 #include "ui/display/chromeos/configure_displays_task.h" | 7 #include "ui/display/chromeos/configure_displays_task.h" |
| 8 #include "ui/display/chromeos/display_util.h" | 8 #include "ui/display/chromeos/display_util.h" |
| 9 #include "ui/display/types/display_snapshot.h" | 9 #include "ui/display/types/display_snapshot.h" |
| 10 #include "ui/display/types/native_display_delegate.h" | 10 #include "ui/display/types/native_display_delegate.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 void UpdateDisplayConfigurationTask::Run() { | 40 void UpdateDisplayConfigurationTask::Run() { |
| 41 delegate_->GetDisplays( | 41 delegate_->GetDisplays( |
| 42 base::Bind(&UpdateDisplayConfigurationTask::OnDisplaysUpdated, | 42 base::Bind(&UpdateDisplayConfigurationTask::OnDisplaysUpdated, |
| 43 weak_ptr_factory_.GetWeakPtr())); | 43 weak_ptr_factory_.GetWeakPtr())); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void UpdateDisplayConfigurationTask::OnDisplaysUpdated( | 46 void UpdateDisplayConfigurationTask::OnDisplaysUpdated( |
| 47 const std::vector<DisplaySnapshot*>& displays) { | 47 const std::vector<DisplaySnapshot*>& displays) { |
| 48 cached_displays_ = layout_manager_->ParseDisplays(displays); | 48 cached_displays_ = displays; |
| 49 | 49 |
| 50 if (cached_displays_.size() > 1 && background_color_argb_) | 50 if (cached_displays_.size() > 1 && background_color_argb_) |
| 51 delegate_->SetBackgroundColor(background_color_argb_); | 51 delegate_->SetBackgroundColor(background_color_argb_); |
| 52 | 52 |
| 53 // If the user hasn't requested a display state, update it using the requested | 53 // If the user hasn't requested a display state, update it using the requested |
| 54 // power state. | 54 // power state. |
| 55 if (new_display_state_ == MULTIPLE_DISPLAY_STATE_INVALID) | 55 if (new_display_state_ == MULTIPLE_DISPLAY_STATE_INVALID) |
| 56 new_display_state_ = ChooseDisplayState(); | 56 new_display_state_ = ChooseDisplayState(); |
| 57 | 57 |
| 58 VLOG(1) << "OnDisplaysUpdated: new_display_state=" | 58 VLOG(1) << "OnDisplaysUpdated: new_display_state=" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return new_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF && | 152 return new_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF && |
| 153 (layout_manager_->GetPowerState() != new_power_state_ || | 153 (layout_manager_->GetPowerState() != new_power_state_ || |
| 154 (power_flags_ & DisplayConfigurator::kSetDisplayPowerForceProbe)); | 154 (power_flags_ & DisplayConfigurator::kSetDisplayPowerForceProbe)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool UpdateDisplayConfigurationTask::ShouldConfigure() const { | 157 bool UpdateDisplayConfigurationTask::ShouldConfigure() const { |
| 158 if (force_configure_) | 158 if (force_configure_) |
| 159 return true; | 159 return true; |
| 160 | 160 |
| 161 if (cached_displays_.size() == 1 && | 161 if (cached_displays_.size() == 1 && |
| 162 cached_displays_[0].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL) | 162 cached_displays_[0]->type() == DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 163 return true; | 163 return true; |
| 164 | 164 |
| 165 if (!(power_flags_ & | 165 if (!(power_flags_ & |
| 166 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay)) | 166 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay)) |
| 167 return true; | 167 return true; |
| 168 | 168 |
| 169 if (new_display_state_ != layout_manager_->GetDisplayState()) | 169 if (new_display_state_ != layout_manager_->GetDisplayState()) |
| 170 return true; | 170 return true; |
| 171 | 171 |
| 172 return false; | 172 return false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 189 } | 189 } |
| 190 if (num_on_displays >= 3) { | 190 if (num_on_displays >= 3) { |
| 191 return MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED; | 191 return MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED; |
| 192 } else if (cached_displays_.size() == 2) { | 192 } else if (cached_displays_.size() == 2) { |
| 193 if (!layout_manager_->GetStateController()) | 193 if (!layout_manager_->GetStateController()) |
| 194 return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; | 194 return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; |
| 195 // With either both displays on or both displays off, use one of the | 195 // With either both displays on or both displays off, use one of the |
| 196 // dual modes. | 196 // dual modes. |
| 197 std::vector<int64_t> display_ids; | 197 std::vector<int64_t> display_ids; |
| 198 for (size_t i = 0; i < cached_displays_.size(); ++i) | 198 for (size_t i = 0; i < cached_displays_.size(); ++i) |
| 199 display_ids.push_back(cached_displays_[i].display->display_id()); | 199 display_ids.push_back(cached_displays_[i]->display_id()); |
| 200 | 200 |
| 201 return layout_manager_->GetStateController()->GetStateForDisplayIds( | 201 return layout_manager_->GetStateController()->GetStateForDisplayIds( |
| 202 display_ids); | 202 display_ids); |
| 203 } | 203 } |
| 204 NOTREACHED(); | 204 NOTREACHED(); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 return MULTIPLE_DISPLAY_STATE_INVALID; | 207 return MULTIPLE_DISPLAY_STATE_INVALID; |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace ui | 210 } // namespace ui |
| OLD | NEW |