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

Side by Side Diff: ash/aura/pointer_watcher_adapter.h

Issue 2271393002: Wires up drags to pointer watcher adapter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Rebased. Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef ASH_AURA_POINTER_WATCHER_ADAPTER_H_ 5 #ifndef ASH_AURA_POINTER_WATCHER_ADAPTER_H_
6 #define ASH_AURA_POINTER_WATCHER_ADAPTER_H_ 6 #define ASH_AURA_POINTER_WATCHER_ADAPTER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "ui/events/event_handler.h" 11 #include "ui/events/event_handler.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 class Point; 14 class Point;
15 } 15 }
16 16
17 namespace ui { 17 namespace ui {
18 class LocatedEvent; 18 class LocatedEvent;
19 class PointerEvent; 19 class PointerEvent;
20 } 20 }
21 21
22 namespace views { 22 namespace views {
23 class PointerWatcher; 23 class PointerWatcher;
24 enum class PointerWatcherEventTypes;
24 class Widget; 25 class Widget;
25 } 26 }
26 27
27 namespace ash { 28 namespace ash {
28 29
29 // Support for PointerWatchers in non-mus ash, implemented with a pre-target 30 // Support for PointerWatchers in non-mus ash, implemented with a pre-target
30 // EventHandler on the Shell. 31 // EventHandler on the Shell.
31 class ASH_EXPORT PointerWatcherAdapter : public ui::EventHandler { 32 class ASH_EXPORT PointerWatcherAdapter : public ui::EventHandler {
32 public: 33 public:
33 PointerWatcherAdapter(); 34 PointerWatcherAdapter();
34 ~PointerWatcherAdapter() override; 35 ~PointerWatcherAdapter() override;
35 36
36 // See WmShell::AddPointerWatcher() for details. 37 // See WmShell::AddPointerWatcher() for details.
37 void AddPointerWatcher(views::PointerWatcher* watcher, bool wants_moves); 38 void AddPointerWatcher(views::PointerWatcher* watcher,
39 views::PointerWatcherEventTypes events);
38 void RemovePointerWatcher(views::PointerWatcher* watcher); 40 void RemovePointerWatcher(views::PointerWatcher* watcher);
39 41
40 // ui::EventHandler: 42 // ui::EventHandler:
41 void OnMouseEvent(ui::MouseEvent* event) override; 43 void OnMouseEvent(ui::MouseEvent* event) override;
42 void OnTouchEvent(ui::TouchEvent* event) override; 44 void OnTouchEvent(ui::TouchEvent* event) override;
43 45
44 private: 46 private:
45 gfx::Point GetLocationInScreen(const ui::LocatedEvent& event) const; 47 gfx::Point GetLocationInScreen(const ui::LocatedEvent& event) const;
46 views::Widget* GetTargetWidget(const ui::LocatedEvent& event) const; 48 views::Widget* GetTargetWidget(const ui::LocatedEvent& event) const;
47 49
48 // Calls OnPointerEventObserved() on the appropriate set of watchers as 50 // Calls OnPointerEventObserved() on the appropriate set of watchers as
49 // determined by the type of event. |original_event| is the original 51 // determined by the type of event. |original_event| is the original
50 // event supplied to OnMouseEvent()/OnTouchEvent(), |pointer_event| is 52 // event supplied to OnMouseEvent()/OnTouchEvent(), |pointer_event| is
51 // |original_event| converted to a PointerEvent. 53 // |original_event| converted to a PointerEvent.
52 void NotifyWatchers(const ui::PointerEvent& pointer_event, 54 void NotifyWatchers(const ui::PointerEvent& pointer_event,
53 const ui::LocatedEvent& original_event); 55 const ui::LocatedEvent& original_event);
54 56
55 // The true parameter to ObserverList indicates the list must be empty on 57 // The true parameter to ObserverList indicates the list must be empty on
56 // destruction. Two sets of observers are maintained, one for observers not 58 // destruction. Two sets of observers are maintained, one for observers not
57 // needing moves |non_move_watchers_| and |move_watchers_| for those 59 // needing moves |non_move_watchers_| and |move_watchers_| for those
58 // observers wanting moves too. 60 // observers wanting moves too.
59 base::ObserverList<views::PointerWatcher, true> non_move_watchers_; 61 base::ObserverList<views::PointerWatcher, true> non_move_watchers_;
60 base::ObserverList<views::PointerWatcher, true> move_watchers_; 62 base::ObserverList<views::PointerWatcher, true> move_watchers_;
63 base::ObserverList<views::PointerWatcher, true> drag_watchers_;
61 64
62 DISALLOW_COPY_AND_ASSIGN(PointerWatcherAdapter); 65 DISALLOW_COPY_AND_ASSIGN(PointerWatcherAdapter);
63 }; 66 };
64 67
65 } // namespace ash 68 } // namespace ash
66 69
67 #endif // ASH_AURA_POINTER_WATCHER_ADAPTER_H_ 70 #endif // ASH_AURA_POINTER_WATCHER_ADAPTER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/aura/pointer_watcher_adapter.cc » ('j') | ash/aura/pointer_watcher_adapter_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698