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

Unified Diff: ash/wm/user_activity_detector.cc

Issue 12391004: chromeos: Add DisplayPowerServiceProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ugh, TrayDisplay was including output_configurator.h on windows Created 7 years, 9 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
« no previous file with comments | « ash/wm/user_activity_detector.h ('k') | ash/wm/user_activity_detector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/user_activity_detector.cc
diff --git a/ash/wm/user_activity_detector.cc b/ash/wm/user_activity_detector.cc
index fccc6d8e7d01d7129752eb0eb0850cf431b7b588..b6b3bded16538bb062b137e16c613a40a5f01a7d 100644
--- a/ash/wm/user_activity_detector.cc
+++ b/ash/wm/user_activity_detector.cc
@@ -10,9 +10,14 @@
namespace ash {
-const double UserActivityDetector::kNotifyIntervalMs = 200.0;
+const int UserActivityDetector::kNotifyIntervalMs = 200;
-UserActivityDetector::UserActivityDetector() : ignore_next_mouse_event_(false) {
+// Too low and mouse events generated at the tail end of reconfiguration
+// will be reported as user activity and turn the screen back on; too high
+// and we'll ignore legitimate activity.
+const int UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs = 1000;
+
+UserActivityDetector::UserActivityDetector() {
}
UserActivityDetector::~UserActivityDetector() {
@@ -30,8 +35,9 @@ void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) {
observers_.RemoveObserver(observer);
}
-void UserActivityDetector::OnAllOutputsTurnedOff() {
- ignore_next_mouse_event_ = true;
+void UserActivityDetector::OnDisplayPowerChanging() {
+ honor_mouse_events_time_ = GetCurrentTime() +
+ base::TimeDelta::FromMilliseconds(kDisplayPowerChangeIgnoreMouseMs);
}
void UserActivityDetector::OnKeyEvent(ui::KeyEvent* event) {
@@ -39,11 +45,13 @@ void UserActivityDetector::OnKeyEvent(ui::KeyEvent* event) {
}
void UserActivityDetector::OnMouseEvent(ui::MouseEvent* event) {
- VLOG_IF(1, ignore_next_mouse_event_) << "ignoring mouse event";
- if (!(event->flags() & ui::EF_IS_SYNTHESIZED) &&
- !ignore_next_mouse_event_)
- MaybeNotify();
- ignore_next_mouse_event_ = false;
+ if (event->flags() & ui::EF_IS_SYNTHESIZED)
+ return;
+ if (!honor_mouse_events_time_.is_null() &&
+ GetCurrentTime() < honor_mouse_events_time_)
+ return;
+
+ MaybeNotify();
}
void UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) {
@@ -58,9 +66,12 @@ void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) {
MaybeNotify();
}
+base::TimeTicks UserActivityDetector::GetCurrentTime() const {
+ return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
+}
+
void UserActivityDetector::MaybeNotify() {
- base::TimeTicks now =
- !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
+ base::TimeTicks now = GetCurrentTime();
if (last_observer_notification_time_.is_null() ||
(now - last_observer_notification_time_).InMillisecondsF() >=
kNotifyIntervalMs) {
« no previous file with comments | « ash/wm/user_activity_detector.h ('k') | ash/wm/user_activity_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698