Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: ui/display/chromeos/update_display_configuration_task.cc

Issue 1861593002: chromeos: Turn off displays on suspend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chromeos: Add functions for configuring cached displays Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/display/chromeos/update_display_configuration_task.cc
diff --git a/ui/display/chromeos/update_display_configuration_task.cc b/ui/display/chromeos/update_display_configuration_task.cc
index 5fa7ac7f9fb303d72afa24fc5ab02ff590c4203d..d734a8a6f69b6e86b3dd86cdaf7a2a8f2c4bbf70 100644
--- a/ui/display/chromeos/update_display_configuration_task.cc
+++ b/ui/display/chromeos/update_display_configuration_task.cc
@@ -20,6 +20,7 @@ UpdateDisplayConfigurationTask::UpdateDisplayConfigurationTask(
int power_flags,
uint32_t background_color_argb,
bool force_configure,
+ bool configure_cached_displays,
const ResponseCallback& callback)
: delegate_(delegate),
layout_manager_(layout_manager),
@@ -28,6 +29,7 @@ UpdateDisplayConfigurationTask::UpdateDisplayConfigurationTask(
power_flags_(power_flags),
background_color_argb_(background_color_argb),
force_configure_(force_configure),
+ configure_cached_displays_(configure_cached_displays),
callback_(callback),
force_dpms_(false),
weak_ptr_factory_(this) {
@@ -38,12 +40,42 @@ UpdateDisplayConfigurationTask::~UpdateDisplayConfigurationTask() {
delegate_->UngrabServer();
}
+void DoNothing(ConfigureDisplaysTask::Status status) {
+}
+
void UpdateDisplayConfigurationTask::Run() {
+ // In the default case where the displays haven't changed, try to configure
+ // without probing the display devices to speed things up.
+ if (configure_cached_displays_)
+ delegate_->GetCachedDisplays(
+ base::Bind(&UpdateDisplayConfigurationTask::OnCachedDisplaysRetrieved,
+ weak_ptr_factory_.GetWeakPtr()));
+
delegate_->GetDisplays(
base::Bind(&UpdateDisplayConfigurationTask::OnDisplaysUpdated,
weak_ptr_factory_.GetWeakPtr()));
}
+void UpdateDisplayConfigurationTask::OnCachedDisplaysRetrieved(
+ const std::vector<DisplaySnapshot*>& displays) {
+ cached_displays_ = displays;
+
+ if (cached_displays_.size() > 1 && background_color_argb_)
+ delegate_->SetBackgroundColor(background_color_argb_);
+
+ // If the user hasn't requested a display state, update it using the requested
+ // power state.
+ if (new_display_state_ == MULTIPLE_DISPLAY_STATE_INVALID)
+ new_display_state_ = ChooseDisplayState();
+
+ // If there has been any change in the requested power state and the displays
+ // aren't being turned off force a change in DPMS state.
+ force_dpms_ = ShouldForceDpms() && ShouldConfigure();
+
+ if (ShouldConfigure())
+ EnterState(base::Bind(&DoNothing));
+}
+
void UpdateDisplayConfigurationTask::OnDisplaysUpdated(
const std::vector<DisplaySnapshot*>& displays) {
cached_displays_ = displays;

Powered by Google App Engine
This is Rietveld 408576698