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

Side by Side Diff: ash/pointer_down_watcher_delegate_aura.cc

Issue 2167643005: Revert of mus: Rename .*PointerWatcher.* to .*PointerDownWatcher.*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve conflicts Created 4 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
« no previous file with comments | « ash/pointer_down_watcher_delegate_aura.h ('k') | ash/pointer_watcher_delegate_aura.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_down_watcher_delegate_aura.h"
6
7 #include "ash/shell.h"
8 #include "ui/aura/client/screen_position_client.h"
9 #include "ui/aura/window.h"
10 #include "ui/events/event.h"
11 #include "ui/events/event_constants.h"
12 #include "ui/gfx/geometry/point.h"
13 #include "ui/views/pointer_down_watcher.h"
14 #include "ui/views/widget/widget.h"
15
16 namespace ash {
17
18 PointerDownWatcherDelegateAura::PointerDownWatcherDelegateAura() {
19 Shell::GetInstance()->AddPreTargetHandler(this);
20 }
21
22 PointerDownWatcherDelegateAura::~PointerDownWatcherDelegateAura() {
23 Shell::GetInstance()->RemovePreTargetHandler(this);
24 }
25
26 void PointerDownWatcherDelegateAura::AddPointerDownWatcher(
27 views::PointerDownWatcher* watcher) {
28 pointer_down_watchers_.AddObserver(watcher);
29 }
30
31 void PointerDownWatcherDelegateAura::RemovePointerDownWatcher(
32 views::PointerDownWatcher* watcher) {
33 pointer_down_watchers_.RemoveObserver(watcher);
34 }
35
36 void PointerDownWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) {
37 if (event->type() == ui::ET_MOUSE_PRESSED)
38 FOR_EACH_OBSERVER(views::PointerDownWatcher, pointer_down_watchers_,
39 OnMousePressed(*event, GetLocationInScreen(*event),
40 GetTargetWidget(*event)));
41 }
42
43 void PointerDownWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) {
44 if (event->type() == ui::ET_TOUCH_PRESSED)
45 FOR_EACH_OBSERVER(views::PointerDownWatcher, pointer_down_watchers_,
46 OnTouchPressed(*event, GetLocationInScreen(*event),
47 GetTargetWidget(*event)));
48 }
49
50 gfx::Point PointerDownWatcherDelegateAura::GetLocationInScreen(
51 const ui::LocatedEvent& event) const {
52 aura::Window* target = static_cast<aura::Window*>(event.target());
53 gfx::Point location_in_screen = event.location();
54 aura::client::GetScreenPositionClient(target->GetRootWindow())
55 ->ConvertPointToScreen(target, &location_in_screen);
56 return location_in_screen;
57 }
58
59 views::Widget* PointerDownWatcherDelegateAura::GetTargetWidget(
60 const ui::LocatedEvent& event) const {
61 aura::Window* window = static_cast<aura::Window*>(event.target());
62 return views::Widget::GetTopLevelWidgetForNativeView(window);
63 }
64
65 } // namespace ash
OLDNEW
« no previous file with comments | « ash/pointer_down_watcher_delegate_aura.h ('k') | ash/pointer_watcher_delegate_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698