| 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) {
|
|
|