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

Side by Side Diff: ash/wm/user_activity_detector.cc

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/event.h"
11 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/base/event.h"
12 12
13 namespace ash { 13 namespace ash {
14 14
15 const double UserActivityDetector::kNotifyIntervalSec = 1.0; 15 const double UserActivityDetector::kNotifyIntervalSec = 1.0;
16 16
17 UserActivityDetector::UserActivityDetector() { 17 UserActivityDetector::UserActivityDetector() {
18 } 18 }
19 19
20 UserActivityDetector::~UserActivityDetector() { 20 UserActivityDetector::~UserActivityDetector() {
21 } 21 }
22 22
23 void UserActivityDetector::AddObserver(UserActivityObserver* observer) { 23 void UserActivityDetector::AddObserver(UserActivityObserver* observer) {
24 observers_.AddObserver(observer); 24 observers_.AddObserver(observer);
25 } 25 }
26 26
27 void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) { 27 void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) {
28 observers_.RemoveObserver(observer); 28 observers_.RemoveObserver(observer);
29 } 29 }
30 30
31 bool UserActivityDetector::PreHandleKeyEvent(aura::Window* target, 31 bool UserActivityDetector::PreHandleKeyEvent(aura::Window* target,
32 aura::KeyEvent* event) { 32 ui::KeyEvent* event) {
33 // Ignore input events on secondary displays in non extended desktop 33 // Ignore input events on secondary displays in non extended desktop
34 // mode. Remove this once this mode is gone. crbug.com/135245. 34 // mode. Remove this once this mode is gone. crbug.com/135245.
35 if (!GetRootWindowController(target->GetRootWindow())) 35 if (!GetRootWindowController(target->GetRootWindow()))
36 return true; 36 return true;
37 MaybeNotify(); 37 MaybeNotify();
38 return false; 38 return false;
39 } 39 }
40 40
41 bool UserActivityDetector::PreHandleMouseEvent(aura::Window* target, 41 bool UserActivityDetector::PreHandleMouseEvent(aura::Window* target,
42 aura::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 aura::TouchEvent* event) { 52 ui::TouchEventImpl* 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 aura::GestureEvent* 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
OLDNEW
« 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