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

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

Issue 2611773002: Removes code using mus client lib (Closed)
Patch Set: dont run on linux 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_ROUTER_H_
6 #define UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/observer_list.h"
11 #include "services/ui/public/cpp/window_tree_client_observer.h"
12 #include "ui/views/mus/mus_export.h"
13
14 namespace ui {
15 class PointerEvent;
16 class WindowTreeClient;
17 }
18
19 namespace views {
20
21 class PointerWatcher;
22 class PointerWatcherEventRouterTest;
23
24 // PointerWatcherEventRouter is responsible for maintaining the list of
25 // PointerWatchers and notifying appropriately. It is expected the owner of
26 // PointerWatcherEventRouter is a WindowTreeClientDelegate and calls
27 // OnPointerEventObserved().
28 class VIEWS_MUS_EXPORT PointerWatcherEventRouter
29 : public NON_EXPORTED_BASE(ui::WindowTreeClientObserver) {
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
43 explicit PointerWatcherEventRouter(ui::WindowTreeClient* client);
44 ~PointerWatcherEventRouter() override;
45
46 // Called by WindowTreeClientDelegate to notify PointerWatchers appropriately.
47 void OnPointerEventObserved(const ui::PointerEvent& event,
48 ui::Window* target);
49
50 void AddPointerWatcher(PointerWatcher* watcher, bool wants_moves);
51 void RemovePointerWatcher(PointerWatcher* watcher);
52
53 private:
54 friend class PointerWatcherEventRouterTest;
55
56 // Determines EventTypes based on the number and type of PointerWatchers.
57 EventTypes DetermineEventTypes();
58
59 // ui::WindowTreeClientObserver:
60 void OnWindowTreeCaptureChanged(ui::Window* gained_capture,
61 ui::Window* lost_capture) override;
62 void OnDidDestroyClient(ui::WindowTreeClient* client) override;
63
64 ui::WindowTreeClient* window_tree_client_;
65 // The true parameter to ObserverList indicates the list must be empty on
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;
73
74 DISALLOW_COPY_AND_ASSIGN(PointerWatcherEventRouter);
75 };
76
77 } // namespace views
78
79 #endif // UI_VIEWS_MUS_POINTER_WATCHER_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus_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