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

Side by Side Diff: ui/views/mus/pointer_watcher_event_router.h

Issue 2248263003: Updates PointerEventRouter to handle switching move type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge again Created 4 years, 4 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 | « services/ui/ws/window_tree_unittest.cc ('k') | ui/views/mus/pointer_watcher_event_router.cc » ('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 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 UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_ 5 #ifndef UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_
6 #define UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_ 6 #define UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.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 "services/ui/public/cpp/window_tree_client_observer.h" 11 #include "services/ui/public/cpp/window_tree_client_observer.h"
12 #include "ui/views/mus/mus_export.h" 12 #include "ui/views/mus/mus_export.h"
13 13
14 namespace ui { 14 namespace ui {
15 class PointerEvent; 15 class PointerEvent;
16 class WindowTreeClient; 16 class WindowTreeClient;
17 } 17 }
18 18
19 namespace views { 19 namespace views {
20 20
21 class PointerWatcher; 21 class PointerWatcher;
22 class PointerWatcherEventRouterTest;
22 23
23 // PointerWatcherEventRouter is responsible for maintaining the list of 24 // PointerWatcherEventRouter is responsible for maintaining the list of
24 // PointerWatchers and notifying appropriately. It is expected the owner of 25 // PointerWatchers and notifying appropriately. It is expected the owner of
25 // PointerWatcherEventRouter is a WindowTreeClientDelegate and calls 26 // PointerWatcherEventRouter is a WindowTreeClientDelegate and calls
26 // OnPointerEventObserved(). 27 // OnPointerEventObserved().
27 class VIEWS_MUS_EXPORT PointerWatcherEventRouter 28 class VIEWS_MUS_EXPORT PointerWatcherEventRouter
28 : public NON_EXPORTED_BASE(ui::WindowTreeClientObserver) { 29 : public NON_EXPORTED_BASE(ui::WindowTreeClientObserver) {
29 public: 30 public:
31 // Public solely for tests.
32 enum EventTypes {
33 // No PointerWatchers have been added.
34 NONE,
35
36 // Used when the only PointerWatchers added do not want moves.
37 NON_MOVE_EVENTS,
38
39 // Used when at least one PointerWatcher has been added that wants moves.
40 MOVE_EVENTS,
41 };
42
30 explicit PointerWatcherEventRouter(ui::WindowTreeClient* client); 43 explicit PointerWatcherEventRouter(ui::WindowTreeClient* client);
31 ~PointerWatcherEventRouter() override; 44 ~PointerWatcherEventRouter() override;
32 45
33 // Called by WindowTreeClientDelegate to notify PointerWatchers appropriately. 46 // Called by WindowTreeClientDelegate to notify PointerWatchers appropriately.
34 void OnPointerEventObserved(const ui::PointerEvent& event, 47 void OnPointerEventObserved(const ui::PointerEvent& event,
35 ui::Window* target); 48 ui::Window* target);
36 49
37 void AddPointerWatcher(PointerWatcher* watcher, bool want_moves); 50 void AddPointerWatcher(PointerWatcher* watcher, bool wants_moves);
38 void RemovePointerWatcher(PointerWatcher* watcher); 51 void RemovePointerWatcher(PointerWatcher* watcher);
39 52
40 private: 53 private:
41 // Returns true if there is one or more watchers for this client. 54 friend class PointerWatcherEventRouterTest;
42 bool HasPointerWatcher(); 55
56 // Determines EventTypes based on the number and type of PointerWatchers.
57 EventTypes DetermineEventTypes();
43 58
44 // ui::WindowTreeClientObserver: 59 // ui::WindowTreeClientObserver:
45 void OnWindowTreeCaptureChanged(ui::Window* gained_capture, 60 void OnWindowTreeCaptureChanged(ui::Window* gained_capture,
46 ui::Window* lost_capture) override; 61 ui::Window* lost_capture) override;
47 void OnDidDestroyClient(ui::WindowTreeClient* client) override; 62 void OnDidDestroyClient(ui::WindowTreeClient* client) override;
48 63
49 ui::WindowTreeClient* window_tree_client_; 64 ui::WindowTreeClient* window_tree_client_;
50 base::ObserverList<PointerWatcher, true> pointer_watchers_; 65 // The true parameter to ObserverList indicates the list must be empty on
51 bool pointer_watcher_want_moves_ = false; 66 // destruction. Two sets of observers are maintained, one for observers not
67 // needing moves |non_move_watchers_| and |move_watchers_| for those
68 // observers wanting moves too.
69 base::ObserverList<views::PointerWatcher, true> non_move_watchers_;
70 base::ObserverList<views::PointerWatcher, true> move_watchers_;
71
72 EventTypes event_types_ = EventTypes::NONE;
52 73
53 DISALLOW_COPY_AND_ASSIGN(PointerWatcherEventRouter); 74 DISALLOW_COPY_AND_ASSIGN(PointerWatcherEventRouter);
54 }; 75 };
55 76
56 } // namespace views 77 } // namespace views
57 78
58 #endif // UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_ 79 #endif // UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree_unittest.cc ('k') | ui/views/mus/pointer_watcher_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698