OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/user_activity_detector.h" | 5 #include "ash/wm/user_activity_detector.h" |
6 | 6 |
7 #include "ash/wm/property_util.h" | 7 #include "ash/wm/property_util.h" |
8 #include "ash/wm/user_activity_observer.h" | 8 #include "ash/wm/user_activity_observer.h" |
9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 void UserActivityDetector::OnAllOutputsTurnedOff() { | 33 void UserActivityDetector::OnAllOutputsTurnedOff() { |
34 ignore_next_mouse_event_ = true; | 34 ignore_next_mouse_event_ = true; |
35 } | 35 } |
36 | 36 |
37 void UserActivityDetector::OnKeyEvent(ui::KeyEvent* event) { | 37 void UserActivityDetector::OnKeyEvent(ui::KeyEvent* event) { |
38 MaybeNotify(); | 38 MaybeNotify(); |
39 } | 39 } |
40 | 40 |
41 ui::EventResult UserActivityDetector::OnMouseEvent(ui::MouseEvent* event) { | 41 void UserActivityDetector::OnMouseEvent(ui::MouseEvent* event) { |
42 VLOG_IF(1, ignore_next_mouse_event_) << "ignoring mouse event"; | 42 VLOG_IF(1, ignore_next_mouse_event_) << "ignoring mouse event"; |
43 if (!(event->flags() & ui::EF_IS_SYNTHESIZED) && | 43 if (!(event->flags() & ui::EF_IS_SYNTHESIZED) && |
44 !ignore_next_mouse_event_) | 44 !ignore_next_mouse_event_) |
45 MaybeNotify(); | 45 MaybeNotify(); |
46 ignore_next_mouse_event_ = false; | 46 ignore_next_mouse_event_ = false; |
47 return ui::ER_UNHANDLED; | |
48 } | 47 } |
49 | 48 |
50 void UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) { | 49 void UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) { |
51 MaybeNotify(); | 50 MaybeNotify(); |
52 } | 51 } |
53 | 52 |
54 void UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) { | 53 void UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) { |
55 MaybeNotify(); | 54 MaybeNotify(); |
56 } | 55 } |
57 | 56 |
58 void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) { | 57 void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) { |
59 MaybeNotify(); | 58 MaybeNotify(); |
60 } | 59 } |
61 | 60 |
62 void UserActivityDetector::MaybeNotify() { | 61 void UserActivityDetector::MaybeNotify() { |
63 base::TimeTicks now = | 62 base::TimeTicks now = |
64 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); | 63 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); |
65 if (last_observer_notification_time_.is_null() || | 64 if (last_observer_notification_time_.is_null() || |
66 (now - last_observer_notification_time_).InMillisecondsF() >= | 65 (now - last_observer_notification_time_).InMillisecondsF() >= |
67 kNotifyIntervalMs) { | 66 kNotifyIntervalMs) { |
68 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity()); | 67 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity()); |
69 last_observer_notification_time_ = now; | 68 last_observer_notification_time_ = now; |
70 } | 69 } |
71 } | 70 } |
72 | 71 |
73 } // namespace ash | 72 } // namespace ash |
OLD | NEW |