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

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

Issue 2610063002: Cleanup after removing views-mus code (Closed)
Patch Set: merge Created 3 years, 11 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
(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 #ifndef UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER2_H_
6 #define UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER2_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/observer_list.h"
11 #include "ui/aura/client/capture_client_observer.h"
12 #include "ui/aura/mus/window_tree_client_observer.h"
13 #include "ui/views/mus/mus_export.h"
14
15 namespace aura {
16 class WindowTreeClient;
17 }
18
19 namespace ui {
20 class PointerEvent;
21 }
22
23 namespace views {
24
25 class PointerWatcher;
26 class PointerWatcherEventRouter2Test;
27
28 // PointerWatcherEventRouter2 is responsible for maintaining the list of
29 // PointerWatchers and notifying appropriately. It is expected the owner of
30 // PointerWatcherEventRouter2 is a WindowTreeClientDelegate and calls
31 // OnPointerEventObserved().
32 // TODO(sky): Nuke existing PointerWatcherEventRouter and rename this.
33 class VIEWS_MUS_EXPORT PointerWatcherEventRouter2
34 : public aura::WindowTreeClientObserver,
35 public aura::client::CaptureClientObserver {
36 public:
37 // Public solely for tests.
38 enum EventTypes {
39 // No PointerWatchers have been added.
40 NONE,
41
42 // Used when the only PointerWatchers added do not want moves.
43 NON_MOVE_EVENTS,
44
45 // Used when at least one PointerWatcher has been added that wants moves.
46 MOVE_EVENTS,
47 };
48
49 explicit PointerWatcherEventRouter2(
50 aura::WindowTreeClient* window_tree_client);
51 ~PointerWatcherEventRouter2() override;
52
53 // Called by WindowTreeClientDelegate to notify PointerWatchers appropriately.
54 void OnPointerEventObserved(const ui::PointerEvent& event,
55 aura::Window* target);
56
57 void AddPointerWatcher(PointerWatcher* watcher, bool wants_moves);
58 void RemovePointerWatcher(PointerWatcher* watcher);
59
60 private:
61 friend class PointerWatcherEventRouter2Test;
62
63 // Determines EventTypes based on the number and type of PointerWatchers.
64 EventTypes DetermineEventTypes();
65
66 // aura::WindowTreeClientObserver:
67 void OnDidDestroyClient(aura::WindowTreeClient* client) override;
68
69 // aura::client::CaptureClientObserver:
70 void OnCaptureChanged(aura::Window* lost_capture,
71 aura::Window* gained_capture) override;
72
73 aura::WindowTreeClient* window_tree_client_;
74 // The true parameter to ObserverList indicates the list must be empty on
75 // destruction. Two sets of observers are maintained, one for observers not
76 // needing moves |non_move_watchers_| and |move_watchers_| for those
77 // observers wanting moves too.
78 base::ObserverList<views::PointerWatcher, true> non_move_watchers_;
79 base::ObserverList<views::PointerWatcher, true> move_watchers_;
80
81 EventTypes event_types_ = EventTypes::NONE;
82
83 DISALLOW_COPY_AND_ASSIGN(PointerWatcherEventRouter2);
84 };
85
86 } // namespace views
87
88 #endif // UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER2_H_
OLDNEW
« no previous file with comments | « ui/views/mus/pointer_watcher_event_router.cc ('k') | ui/views/mus/pointer_watcher_event_router2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698