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 "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 ui::MouseEvent* event) { | 42 ui::MouseEvent* event) { |
43 if (!GetRootWindowController(target->GetRootWindow())) | 43 if (!GetRootWindowController(target->GetRootWindow())) |
44 return true; | 44 return true; |
45 if (!(event->flags() & ui::EF_IS_SYNTHESIZED)) | 45 if (!(event->flags() & ui::EF_IS_SYNTHESIZED)) |
46 MaybeNotify(); | 46 MaybeNotify(); |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 ui::TouchStatus UserActivityDetector::PreHandleTouchEvent( | 50 ui::TouchStatus UserActivityDetector::PreHandleTouchEvent( |
51 aura::Window* target, | 51 aura::Window* target, |
52 ui::TouchEventImpl* event) { | 52 ui::TouchEvent* event) { |
53 if (!GetRootWindowController(target->GetRootWindow())) | 53 if (!GetRootWindowController(target->GetRootWindow())) |
54 return ui::TOUCH_STATUS_END; | 54 return ui::TOUCH_STATUS_END; |
55 MaybeNotify(); | 55 MaybeNotify(); |
56 return ui::TOUCH_STATUS_UNKNOWN; | 56 return ui::TOUCH_STATUS_UNKNOWN; |
57 } | 57 } |
58 | 58 |
59 ui::GestureStatus UserActivityDetector::PreHandleGestureEvent( | 59 ui::GestureStatus UserActivityDetector::PreHandleGestureEvent( |
60 aura::Window* target, | 60 aura::Window* target, |
61 ui::GestureEventImpl* event) { | 61 ui::GestureEventImpl* event) { |
62 if (!GetRootWindowController(target->GetRootWindow())) | 62 if (!GetRootWindowController(target->GetRootWindow())) |
63 return ui::GESTURE_STATUS_CONSUMED; | 63 return ui::GESTURE_STATUS_CONSUMED; |
64 MaybeNotify(); | 64 MaybeNotify(); |
65 return ui::GESTURE_STATUS_UNKNOWN; | 65 return ui::GESTURE_STATUS_UNKNOWN; |
66 } | 66 } |
67 | 67 |
68 void UserActivityDetector::MaybeNotify() { | 68 void UserActivityDetector::MaybeNotify() { |
69 base::TimeTicks now = | 69 base::TimeTicks now = |
70 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); | 70 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); |
71 if (last_observer_notification_time_.is_null() || | 71 if (last_observer_notification_time_.is_null() || |
72 (now - last_observer_notification_time_).InSecondsF() >= | 72 (now - last_observer_notification_time_).InSecondsF() >= |
73 kNotifyIntervalSec) { | 73 kNotifyIntervalSec) { |
74 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity()); | 74 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity()); |
75 last_observer_notification_time_ = now; | 75 last_observer_notification_time_ = now; |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 } // namespace ash | 79 } // namespace ash |
OLD | NEW |