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

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

Issue 10828037: ash: Remove wm::GetRootWindowController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/system_gesture_event_filter.cc ('k') | ash/wm/window_util.h » ('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/user_activity_observer.h" 8 #include "ash/wm/user_activity_observer.h"
8 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
9 #include "ui/aura/event.h" 10 #include "ui/aura/event.h"
10 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
11 12
12 namespace ash { 13 namespace ash {
13 14
14 const double UserActivityDetector::kNotifyIntervalSec = 1.0; 15 const double UserActivityDetector::kNotifyIntervalSec = 1.0;
15 16
16 UserActivityDetector::UserActivityDetector() { 17 UserActivityDetector::UserActivityDetector() {
17 } 18 }
18 19
19 UserActivityDetector::~UserActivityDetector() { 20 UserActivityDetector::~UserActivityDetector() {
20 } 21 }
21 22
22 void UserActivityDetector::AddObserver(UserActivityObserver* observer) { 23 void UserActivityDetector::AddObserver(UserActivityObserver* observer) {
23 observers_.AddObserver(observer); 24 observers_.AddObserver(observer);
24 } 25 }
25 26
26 void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) { 27 void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) {
27 observers_.RemoveObserver(observer); 28 observers_.RemoveObserver(observer);
28 } 29 }
29 30
30 bool UserActivityDetector::PreHandleKeyEvent(aura::Window* target, 31 bool UserActivityDetector::PreHandleKeyEvent(aura::Window* target,
31 aura::KeyEvent* event) { 32 aura::KeyEvent* event) {
32 // Ignore input events on secondary displays in non extended desktop 33 // Ignore input events on secondary displays in non extended desktop
33 // mode. Remove this once this mode is gone. crbug.com/135245. 34 // mode. Remove this once this mode is gone. crbug.com/135245.
34 if (!wm::GetRootWindowController(target->GetRootWindow())) 35 if (!GetRootWindowController(target->GetRootWindow()))
35 return true; 36 return true;
36 MaybeNotify(); 37 MaybeNotify();
37 return false; 38 return false;
38 } 39 }
39 40
40 bool UserActivityDetector::PreHandleMouseEvent(aura::Window* target, 41 bool UserActivityDetector::PreHandleMouseEvent(aura::Window* target,
41 aura::MouseEvent* event) { 42 aura::MouseEvent* event) {
42 if (!wm::GetRootWindowController(target->GetRootWindow())) 43 if (!GetRootWindowController(target->GetRootWindow()))
43 return true; 44 return true;
44 if (!(event->flags() & ui::EF_IS_SYNTHESIZED)) 45 if (!(event->flags() & ui::EF_IS_SYNTHESIZED))
45 MaybeNotify(); 46 MaybeNotify();
46 return false; 47 return false;
47 } 48 }
48 49
49 ui::TouchStatus UserActivityDetector::PreHandleTouchEvent( 50 ui::TouchStatus UserActivityDetector::PreHandleTouchEvent(
50 aura::Window* target, 51 aura::Window* target,
51 aura::TouchEvent* event) { 52 aura::TouchEvent* event) {
52 if (!wm::GetRootWindowController(target->GetRootWindow())) 53 if (!GetRootWindowController(target->GetRootWindow()))
53 return ui::TOUCH_STATUS_END; 54 return ui::TOUCH_STATUS_END;
54 MaybeNotify(); 55 MaybeNotify();
55 return ui::TOUCH_STATUS_UNKNOWN; 56 return ui::TOUCH_STATUS_UNKNOWN;
56 } 57 }
57 58
58 ui::GestureStatus UserActivityDetector::PreHandleGestureEvent( 59 ui::GestureStatus UserActivityDetector::PreHandleGestureEvent(
59 aura::Window* target, 60 aura::Window* target,
60 aura::GestureEvent* event) { 61 aura::GestureEvent* event) {
61 if (!wm::GetRootWindowController(target->GetRootWindow())) 62 if (!GetRootWindowController(target->GetRootWindow()))
62 return ui::GESTURE_STATUS_CONSUMED; 63 return ui::GESTURE_STATUS_CONSUMED;
63 MaybeNotify(); 64 MaybeNotify();
64 return ui::GESTURE_STATUS_UNKNOWN; 65 return ui::GESTURE_STATUS_UNKNOWN;
65 } 66 }
66 67
67 void UserActivityDetector::MaybeNotify() { 68 void UserActivityDetector::MaybeNotify() {
68 base::TimeTicks now = 69 base::TimeTicks now =
69 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); 70 !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
70 if (last_observer_notification_time_.is_null() || 71 if (last_observer_notification_time_.is_null() ||
71 (now - last_observer_notification_time_).InSecondsF() >= 72 (now - last_observer_notification_time_).InSecondsF() >=
72 kNotifyIntervalSec) { 73 kNotifyIntervalSec) {
73 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity()); 74 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity());
74 last_observer_notification_time_ = now; 75 last_observer_notification_time_ = now;
75 } 76 }
76 } 77 }
77 78
78 } // namespace ash 79 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/system_gesture_event_filter.cc ('k') | ash/wm/window_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698