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

Side by Side Diff: components/mus/ws/event_dispatcher.h

Issue 1352043005: mus: Implement Window Server Capture Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added capture unit tests Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ 5 #ifndef COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_
6 #define COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ 6 #define COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 15 matching lines...) Expand all
26 // Handles dispatching events to the right location as well as updating focus. 26 // Handles dispatching events to the right location as well as updating focus.
27 class EventDispatcher : public ServerWindowObserver { 27 class EventDispatcher : public ServerWindowObserver {
28 public: 28 public:
29 explicit EventDispatcher(EventDispatcherDelegate* delegate); 29 explicit EventDispatcher(EventDispatcherDelegate* delegate);
30 ~EventDispatcher() override; 30 ~EventDispatcher() override;
31 31
32 void set_root(ServerWindow* root) { root_ = root; } 32 void set_root(ServerWindow* root) { root_ = root; }
33 33
34 void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; } 34 void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; }
35 35
36 ServerWindow* capture_window() { return capture_window_; }
37 const ServerWindow* capture_window() const { return capture_window_; }
38 void SetCaptureWindow(ServerWindow* capture_window);
39
36 void AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); 40 void AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher);
37 void RemoveAccelerator(uint32_t id); 41 void RemoveAccelerator(uint32_t id);
38 42
39 void OnEvent(mojom::EventPtr event); 43 void OnEvent(mojom::EventPtr event);
40 44
41 private: 45 private:
42 // Keeps track of state associated with a pointer down until the 46 // Keeps track of state associated with a pointer down until the
43 // corresponding up/cancel. 47 // corresponding up/cancel.
44 struct PointerTarget { 48 struct PointerTarget {
45 PointerTarget() : window(nullptr), in_nonclient_area(false) {} 49 PointerTarget() : window(nullptr), in_nonclient_area(false) {}
(...skipping 14 matching lines...) Expand all
60 // . move (not drag) events go to the deepest window. 64 // . move (not drag) events go to the deepest window.
61 // . when a pointer goes down all events until the corresponding up or 65 // . when a pointer goes down all events until the corresponding up or
62 // cancel go to the deepest target. For mouse events the up only occurs 66 // cancel go to the deepest target. For mouse events the up only occurs
63 // when no buttons on the mouse are down. 67 // when no buttons on the mouse are down.
64 void ProcessPointerEvent(mojom::EventPtr event); 68 void ProcessPointerEvent(mojom::EventPtr event);
65 69
66 // If |target->window| is valid, then passes the event to the delegate. 70 // If |target->window| is valid, then passes the event to the delegate.
67 void DispatchToPointerTarget(const PointerTarget& target, 71 void DispatchToPointerTarget(const PointerTarget& target,
68 mojom::EventPtr event); 72 mojom::EventPtr event);
69 73
74 // Cancels all implicit capture. This is called when the explicit capture
75 // state changes.
76 void CancelAllPointerEvents();
77
70 // Stops sending pointer events to |window|. This does not remove the entry 78 // Stops sending pointer events to |window|. This does not remove the entry
71 // for |window| from |pointer_targets_|, rather it nulls out the window. This 79 // for |window| from |pointer_targets_|, rather it nulls out the window. This
72 // way we continue to eat events until the up/cancel is received. 80 // way we continue to eat events until the up/cancel is received.
73 void CancelPointerEventsToTarget(ServerWindow* window); 81 void CancelPointerEventsToTarget(ServerWindow* window);
74 82
75 // Returns true if we're currently an observer for |window|. We are an 83 // Returns true if we're currently an observer for |window|. We are an
76 // observer for a window if any pointer events are targeting it. 84 // observer for a window if any pointer events are targeting it.
77 bool IsObservingWindow(ServerWindow* window); 85 bool IsObservingWindow(ServerWindow* window);
78 86
79 // Looks to see if there is an accelerator bound to the specified code/flags. 87 // Looks to see if there is an accelerator bound to the specified code/flags.
80 // If there is one, sets |accelerator_id| to the id of the accelerator invoked 88 // If there is one, sets |accelerator_id| to the id of the accelerator invoked
81 // and returns true. If there is none, returns false so normal key event 89 // and returns true. If there is none, returns false so normal key event
82 // processing can continue. 90 // processing can continue.
83 bool FindAccelerator(const mojom::Event& event, uint32_t* accelerator_id); 91 bool FindAccelerator(const mojom::Event& event, uint32_t* accelerator_id);
84 92
85 // ServerWindowObserver: 93 // ServerWindowObserver:
86 void OnWillChangeWindowHierarchy(ServerWindow* window, 94 void OnWillChangeWindowHierarchy(ServerWindow* window,
87 ServerWindow* new_parent, 95 ServerWindow* new_parent,
88 ServerWindow* old_parent) override; 96 ServerWindow* old_parent) override;
89 void OnWindowVisibilityChanged(ServerWindow* window) override; 97 void OnWindowVisibilityChanged(ServerWindow* window) override;
90 void OnWindowDestroyed(ServerWindow* window) override; 98 void OnWindowDestroyed(ServerWindow* window) override;
91 99
92 EventDispatcherDelegate* delegate_; 100 EventDispatcherDelegate* delegate_;
93 ServerWindow* root_; 101 ServerWindow* root_;
102 ServerWindow* capture_window_;
94 103
95 cc::SurfaceId surface_id_; 104 cc::SurfaceId surface_id_;
96 105
97 using Entry = std::pair<uint32_t, EventMatcher>; 106 using Entry = std::pair<uint32_t, EventMatcher>;
98 std::map<uint32_t, EventMatcher> accelerators_; 107 std::map<uint32_t, EventMatcher> accelerators_;
99 108
100 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; 109 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>;
101 PointerIdToTargetMap pointer_targets_; 110 PointerIdToTargetMap pointer_targets_;
102 111
103 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); 112 DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
104 }; 113 };
105 114
106 } // namespace ws 115 } // namespace ws
107 } // namespace mus 116 } // namespace mus
108 117
109 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ 118 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698