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

Side by Side Diff: services/ui/ws/event_dispatcher.h

Issue 2884463002: Make event-targeting asynchronous in window server. (Closed)
Patch Set: rebase and use EventTargeter Created 3 years, 6 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 | « no previous file | services/ui/ws/event_dispatcher.cc » ('j') | services/ui/ws/event_dispatcher.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SERVICES_UI_WS_EVENT_DISPATCHER_H_ 5 #ifndef SERVICES_UI_WS_EVENT_DISPATCHER_H_
6 #define SERVICES_UI_WS_EVENT_DISPATCHER_H_ 6 #define SERVICES_UI_WS_EVENT_DISPATCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 POST_ONLY, 52 POST_ONLY,
53 }; 53 };
54 54
55 explicit EventDispatcher(EventDispatcherDelegate* delegate); 55 explicit EventDispatcher(EventDispatcherDelegate* delegate);
56 ~EventDispatcher() override; 56 ~EventDispatcher() override;
57 57
58 // Cancels capture and stops tracking any pointer events. This does not send 58 // Cancels capture and stops tracking any pointer events. This does not send
59 // any events to the delegate. 59 // any events to the delegate.
60 void Reset(); 60 void Reset();
61 61
62 const EventTargeter* event_targeter() const { return event_targeter_.get(); }
63
62 void SetMousePointerDisplayLocation(const gfx::Point& display_location, 64 void SetMousePointerDisplayLocation(const gfx::Point& display_location,
63 const int64_t display_id); 65 const int64_t display_id);
64 const gfx::Point& mouse_pointer_last_location() const { 66 const gfx::Point& mouse_pointer_last_location() const {
65 return mouse_pointer_last_location_; 67 return mouse_pointer_last_location_;
66 } 68 }
67 int64_t mouse_pointer_display_id() const { return mouse_pointer_display_id_; } 69 int64_t mouse_pointer_display_id() const { return mouse_pointer_display_id_; }
68 70
69 // Returns the cursor for the current target, or POINTER if the mouse is not 71 // Returns the cursor for the current target, or POINTER if the mouse is not
70 // over a valid target. 72 // over a valid target.
71 ui::CursorData GetCurrentMouseCursor() const; 73 ui::CursorData GetCurrentMouseCursor() const;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // is not added. Returns whether adding the accelerator was successful or not. 139 // is not added. Returns whether adding the accelerator was successful or not.
138 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); 140 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher);
139 141
140 void RemoveAccelerator(uint32_t id); 142 void RemoveAccelerator(uint32_t id);
141 143
142 // Processes the supplied event, informing the delegate as approriate. This 144 // Processes the supplied event, informing the delegate as approriate. This
143 // may result in generating any number of events. If |match_phase| is 145 // may result in generating any number of events. If |match_phase| is
144 // ANY and there is a matching accelerator with PRE_TARGET found, than only 146 // ANY and there is a matching accelerator with PRE_TARGET found, than only
145 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been 147 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been
146 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY. 148 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY.
149 // This may be asynchronous if we need to find the target window for |event|
150 // asynchronously.
147 void ProcessEvent(const ui::Event& event, 151 void ProcessEvent(const ui::Event& event,
148 const int64_t display_id, 152 const int64_t display_id,
149 AcceleratorMatchPhase match_phase); 153 AcceleratorMatchPhase match_phase);
150 154
151 private: 155 private:
152 friend class test::EventDispatcherTestApi; 156 friend class test::EventDispatcherTestApi;
153 157
154 void SetMouseCursorSourceWindow(ServerWindow* window); 158 void SetMouseCursorSourceWindow(ServerWindow* window);
155 159
156 void ProcessKeyEvent(const ui::KeyEvent& event, 160 void ProcessKeyEvent(const ui::KeyEvent& event,
157 AcceleratorMatchPhase match_phase); 161 AcceleratorMatchPhase match_phase);
158 162
159 bool IsTrackingPointer(int32_t pointer_id) const { 163 bool IsTrackingPointer(int32_t pointer_id) const {
160 return pointer_targets_.count(pointer_id) > 0; 164 return pointer_targets_.count(pointer_id) > 0;
161 } 165 }
162 166
163 // EventDispatcher provides the following logic for pointer events: 167 // EventDispatcher provides the following logic for pointer events:
164 // . wheel events go to the current target of the associated pointer. If 168 // . wheel events go to the current target of the associated pointer. If
165 // there is no target, they go to the deepest window. 169 // there is no target, they go to the deepest window.
166 // . move (not drag) events go to the deepest window. 170 // . move (not drag) events go to the deepest window.
167 // . when a pointer goes down all events until the corresponding up or 171 // . when a pointer goes down all events until the corresponding up or
168 // cancel go to the deepest target. For mouse events the up only occurs 172 // cancel go to the deepest target. For mouse events the up only occurs
169 // when no buttons on the mouse are down. 173 // when no buttons on the mouse are down.
170 // This also generates exit events as appropriate. For example, if the mouse 174 // This also generates exit events as appropriate. For example, if the mouse
171 // moves between one window to another an exit is generated on the first. 175 // moves between one window to another an exit is generated on the first.
172 void ProcessPointerEvent(const ui::PointerEvent& event); 176 void ProcessPointerEvent(const ui::PointerEvent& event);
177 void ProcessPointerEventOnFoundTarget(const ui::PointerEvent& event,
178 PointerTarget pointer_target_found);
173 179
174 // Adds |pointer_target| to |pointer_targets_|. 180 // Adds |pointer_target| to |pointer_targets_|.
175 void StartTrackingPointer(int32_t pointer_id, 181 void StartTrackingPointer(int32_t pointer_id,
176 const PointerTarget& pointer_target); 182 const PointerTarget& pointer_target);
177 183
178 // Removes a PointerTarget from |pointer_targets_|. 184 // Removes a PointerTarget from |pointer_targets_|.
179 void StopTrackingPointer(int32_t pointer_id); 185 void StopTrackingPointer(int32_t pointer_id);
180 186
181 // Starts tracking the pointer for |event|, or if already tracking the 187 // Starts tracking the pointer for |event|, or if already tracking the
182 // pointer sends the appropriate event to the delegate and updates the 188 // pointer sends the appropriate event to the delegate and updates the
183 // currently tracked PointerTarget appropriately. 189 // currently tracked PointerTarget appropriately.
184 void UpdateTargetForPointer(int32_t pointer_id, 190 void UpdateTargetForPointer(int32_t pointer_id,
185 const ui::LocatedEvent& event); 191 const ui::PointerEvent& event,
192 const PointerTarget& pointer_target_found);
193
194 void UpdateNonClientAreaForCurrentWindowOnFoundWindow(
195 DeepestWindow deepest_window);
196
197 void UpdateCursorProviderByLastKnownLocationOnFoundWindow(
198 DeepestWindow deepest_window);
sky 2017/05/30 17:26:02 const DeepestWindow& here and bove?
riajiang 2017/05/31 22:44:03 Done.
186 199
187 // Returns true if any pointers are in the pressed/down state. 200 // Returns true if any pointers are in the pressed/down state.
188 bool AreAnyPointersDown() const; 201 bool AreAnyPointersDown() const;
189 202
190 // If |target->window| is valid, then passes the event to the delegate. 203 // If |target->window| is valid, then passes the event to the delegate.
191 void DispatchToPointerTarget(const PointerTarget& target, 204 void DispatchToPointerTarget(const PointerTarget& target,
192 const ui::LocatedEvent& event); 205 const ui::LocatedEvent& event);
193 206
194 // Dispatch |event| to the delegate. 207 // Dispatch |event| to the delegate.
195 void DispatchToClient(ServerWindow* window, 208 void DispatchToClient(ServerWindow* window,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 AcceleratorMatchPhase::ANY; 284 AcceleratorMatchPhase::ANY;
272 #endif 285 #endif
273 286
274 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); 287 DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
275 }; 288 };
276 289
277 } // namespace ws 290 } // namespace ws
278 } // namespace ui 291 } // namespace ui
279 292
280 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ 293 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | services/ui/ws/event_dispatcher.cc » ('j') | services/ui/ws/event_dispatcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698