OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/pointer_watcher_delegate_aura.h" | |
6 | |
7 #include "ash/shell.h" | |
8 #include "ui/events/event.h" | |
9 #include "ui/events/event_constants.h" | |
10 #include "ui/views/pointer_watcher.h" | |
11 | |
12 namespace ash { | |
13 | |
14 PointerWatcherDelegateAura::PointerWatcherDelegateAura() {} | |
15 | |
16 PointerWatcherDelegateAura::~PointerWatcherDelegateAura() {} | |
17 | |
18 void PointerWatcherDelegateAura::AddPointerWatcher( | |
19 views::PointerWatcher* watcher) { | |
20 bool had_observers = pointer_watchers_.might_have_observers(); | |
21 pointer_watchers_.AddObserver(watcher); | |
22 if (!had_observers) { | |
23 Shell::GetInstance()->AddPreTargetHandler(this); | |
24 } | |
25 } | |
26 | |
27 void PointerWatcherDelegateAura::RemovePointerWatcher( | |
28 views::PointerWatcher* watcher) { | |
29 pointer_watchers_.RemoveObserver(watcher); | |
30 if (!pointer_watchers_.might_have_observers()) { | |
sky
2016/04/26 21:44:45
One question here. This is named might for a reaso
James Cook
2016/04/26 23:19:05
Discussed offline. I converted this one to always
| |
31 // We removed the last PointerWatcher, so no need to monitor events. | |
32 Shell::GetInstance()->RemovePreTargetHandler(this); | |
33 } | |
34 } | |
35 | |
36 void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) { | |
37 if (event->type() == ui::ET_MOUSE_PRESSED) | |
38 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_, | |
39 OnMousePressed(*event)); | |
40 } | |
41 | |
42 void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) { | |
43 if (event->type() == ui::ET_TOUCH_PRESSED) | |
44 FOR_EACH_OBSERVER(views::PointerWatcher, pointer_watchers_, | |
45 OnTouchPressed(*event)); | |
46 } | |
47 | |
48 } // namespace ash | |
OLD | NEW |