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

Side by Side Diff: ash/pointer_watcher_delegate_aura.cc

Issue 1921673005: mus: Add PointerWatcher for passively observing mouse and touch events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ash_shell_with_content Created 4 years, 8 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
« no previous file with comments | « ash/pointer_watcher_delegate_aura.h ('k') | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « ash/pointer_watcher_delegate_aura.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698