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

Side by Side Diff: ash/system/chromeos/power/power_event_observer.cc

Issue 2427843002: Delay display configuration after waking up from suspend with multi displays (Closed)
Patch Set: derat's comments Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/system/chromeos/power/power_event_observer.h" 5 #include "ash/system/chromeos/power/power_event_observer.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/system/tray/system_tray_notifier.h" 8 #include "ash/common/system/tray/system_tray_notifier.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 23 matching lines...) Expand all
34 void ResumeRenderingRequests() { 34 void ResumeRenderingRequests() {
35 for (aura::Window* window : Shell::GetAllRootWindows()) 35 for (aura::Window* window : Shell::GetAllRootWindows())
36 window->GetHost()->compositor()->SetVisible(true); 36 window->GetHost()->compositor()->SetVisible(true);
37 } 37 }
38 38
39 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback, 39 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback,
40 bool status) { 40 bool status) {
41 suspend_callback.Run(); 41 suspend_callback.Run();
42 } 42 }
43 43
44 void DoNothing(bool) {}
45
44 } // namespace 46 } // namespace
45 47
46 PowerEventObserver::PowerEventObserver() 48 PowerEventObserver::PowerEventObserver()
47 : screen_locked_(false), waiting_for_lock_screen_animations_(false) { 49 : screen_locked_(false), waiting_for_lock_screen_animations_(false) {
48 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( 50 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
49 this); 51 this);
50 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver( 52 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(
51 this); 53 this);
52 } 54 }
53 55
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 120 }
119 121
120 ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); 122 ui::UserActivityDetector::Get()->OnDisplayPowerChanging();
121 Shell::GetInstance()->display_configurator()->SuspendDisplays(base::Bind( 123 Shell::GetInstance()->display_configurator()->SuspendDisplays(base::Bind(
122 &OnSuspendDisplaysCompleted, chromeos::DBusThreadManager::Get() 124 &OnSuspendDisplaysCompleted, chromeos::DBusThreadManager::Get()
123 ->GetPowerManagerClient() 125 ->GetPowerManagerClient()
124 ->GetSuspendReadinessCallback())); 126 ->GetSuspendReadinessCallback()));
125 } 127 }
126 128
127 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) { 129 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) {
128 Shell::GetInstance()->display_configurator()->ResumeDisplays(); 130 Shell::GetInstance()->display_configurator()->ResumeDisplays(
131 base::Bind(&DoNothing));
129 WmShell::Get()->system_tray_notifier()->NotifyRefreshClock(); 132 WmShell::Get()->system_tray_notifier()->NotifyRefreshClock();
130 133
131 // If the suspend request was being blocked while waiting for the lock 134 // If the suspend request was being blocked while waiting for the lock
132 // animation to complete, clear the blocker since the suspend has already 135 // animation to complete, clear the blocker since the suspend has already
133 // completed. This prevents rendering requests from being blocked after a 136 // completed. This prevents rendering requests from being blocked after a
134 // resume if the lock screen took too long to show. 137 // resume if the lock screen took too long to show.
135 screen_lock_callback_.Reset(); 138 screen_lock_callback_.Reset();
136 139
137 ResumeRenderingRequests(); 140 ResumeRenderingRequests();
138 } 141 }
139 142
140 void PowerEventObserver::ScreenIsLocked() { 143 void PowerEventObserver::ScreenIsLocked() {
141 screen_locked_ = true; 144 screen_locked_ = true;
142 waiting_for_lock_screen_animations_ = true; 145 waiting_for_lock_screen_animations_ = true;
143 146
144 // The screen is now locked but the pending suspend, if any, will be blocked 147 // The screen is now locked but the pending suspend, if any, will be blocked
145 // until all the animations have completed. 148 // until all the animations have completed.
146 if (!screen_lock_callback_.is_null()) { 149 if (!screen_lock_callback_.is_null()) {
147 VLOG(1) << "Screen locked due to suspend"; 150 VLOG(1) << "Screen locked due to suspend";
148 } else { 151 } else {
149 VLOG(1) << "Screen locked without suspend"; 152 VLOG(1) << "Screen locked without suspend";
150 } 153 }
151 } 154 }
152 155
153 void PowerEventObserver::ScreenIsUnlocked() { 156 void PowerEventObserver::ScreenIsUnlocked() {
154 screen_locked_ = false; 157 screen_locked_ = false;
155 } 158 }
156 159
157 } // namespace ash 160 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/display/chromeos/display_configurator.h » ('j') | ui/display/chromeos/display_configurator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698