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

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

Issue 2884463002: Make event-targeting asynchronous in window server. (Closed)
Patch Set: comments 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
160 // Called after we found the target for the current mouse cursor to see if
161 // |mouse_pointer_last_location_| and |mouse_pointer_display_id_| need to be
162 // updated based on the new target we found. No need to call delegate's
163 // OnMouseCursorLocationChanged since mouse location is the same in
164 // screen-coord.
165 // TODO(riajiang): No need to update mouse location after ozone drm can tell
166 // us the right display the cursor is on for drag-n-drop events.
167 // crbug.com/726470
168 void UpdateMousePointerLocation(const gfx::Point& new_mouse_location,
sky 2017/06/02 21:17:51 Update -> Set i.e. SetMousePointerLocation.
riajiang 2017/06/02 22:56:17 Done.
169 const int64_t new_mouse_display_id);
sky 2017/06/02 21:17:51 Generally we don't use const for primitive types.
riajiang 2017/06/02 22:56:17 I see, removed.
170
156 void ProcessKeyEvent(const ui::KeyEvent& event, 171 void ProcessKeyEvent(const ui::KeyEvent& event,
157 AcceleratorMatchPhase match_phase); 172 AcceleratorMatchPhase match_phase);
158 173
159 bool IsTrackingPointer(int32_t pointer_id) const { 174 bool IsTrackingPointer(int32_t pointer_id) const {
160 return pointer_targets_.count(pointer_id) > 0; 175 return pointer_targets_.count(pointer_id) > 0;
161 } 176 }
162 177
163 // EventDispatcher provides the following logic for pointer events: 178 // EventDispatcher provides the following logic for pointer events:
164 // . wheel events go to the current target of the associated pointer. If 179 // . wheel events go to the current target of the associated pointer. If
165 // there is no target, they go to the deepest window. 180 // there is no target, they go to the deepest window.
166 // . move (not drag) events go to the deepest window. 181 // . move (not drag) events go to the deepest window.
167 // . when a pointer goes down all events until the corresponding up or 182 // . 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 183 // cancel go to the deepest target. For mouse events the up only occurs
169 // when no buttons on the mouse are down. 184 // when no buttons on the mouse are down.
170 // This also generates exit events as appropriate. For example, if the mouse 185 // 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. 186 // moves between one window to another an exit is generated on the first.
172 void ProcessPointerEvent(const ui::PointerEvent& event); 187 // |pointer_target_found| is the PointerTarget for |event| based on the
188 // |deepest_window|, the deepest visible window for the root_location
189 // of the |event|. |location_in_display| and |display_id| are updated values
190 // for root_location and |event_display_id_| (e.g. during drag-n-drop).
191 void ProcessPointerEventOnFoundTarget(
192 const ui::PointerEvent& event,
193 const PointerTarget& pointer_target_found,
194 const DeepestWindow& deepest_window,
195 const gfx::Point& location_in_display,
196 const int64_t display_id);
197
198 void UpdateNonClientAreaForCurrentWindowOnFoundWindow(
199 const DeepestWindow& deepest_window,
200 const gfx::Point& location_in_display,
201 const int64_t display_id);
202 void UpdateCursorProviderByLastKnownLocationOnFoundWindow(
203 const DeepestWindow& deepest_window,
204 const gfx::Point& location_in_display,
205 const int64_t display_id);
206 void UpdateCursorProviderByLastKnownLocationWithWindow(
207 const DeepestWindow& deepest_window,
208 const gfx::Point& location_in_display,
209 const int64_t display_id);
173 210
174 // Adds |pointer_target| to |pointer_targets_|. 211 // Adds |pointer_target| to |pointer_targets_|.
175 void StartTrackingPointer(int32_t pointer_id, 212 void StartTrackingPointer(int32_t pointer_id,
176 const PointerTarget& pointer_target); 213 const PointerTarget& pointer_target);
177 214
178 // Removes a PointerTarget from |pointer_targets_|. 215 // Removes a PointerTarget from |pointer_targets_|.
179 void StopTrackingPointer(int32_t pointer_id); 216 void StopTrackingPointer(int32_t pointer_id);
180 217
181 // Starts tracking the pointer for |event|, or if already tracking the 218 // Starts tracking the pointer for |event|, or if already tracking the
182 // pointer sends the appropriate event to the delegate and updates the 219 // pointer sends the appropriate event to the delegate and updates the
183 // currently tracked PointerTarget appropriately. 220 // currently tracked PointerTarget appropriately.
184 void UpdateTargetForPointer(int32_t pointer_id, 221 void UpdateTargetForPointer(int32_t pointer_id,
185 const ui::LocatedEvent& event); 222 const ui::PointerEvent& event,
223 const PointerTarget& pointer_target_found);
186 224
187 // Returns true if any pointers are in the pressed/down state. 225 // Returns true if any pointers are in the pressed/down state.
188 bool AreAnyPointersDown() const; 226 bool AreAnyPointersDown() const;
189 227
190 // If |target->window| is valid, then passes the event to the delegate. 228 // If |target->window| is valid, then passes the event to the delegate.
191 void DispatchToPointerTarget(const PointerTarget& target, 229 void DispatchToPointerTarget(const PointerTarget& target,
192 const ui::LocatedEvent& event); 230 const ui::LocatedEvent& event);
193 231
194 // Dispatch |event| to the delegate. 232 // Dispatch |event| to the delegate.
195 void DispatchToClient(ServerWindow* window, 233 void DispatchToClient(ServerWindow* window,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 AcceleratorMatchPhase::ANY; 309 AcceleratorMatchPhase::ANY;
272 #endif 310 #endif
273 311
274 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); 312 DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
275 }; 313 };
276 314
277 } // namespace ws 315 } // namespace ws
278 } // namespace ui 316 } // namespace ui
279 317
280 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ 318 #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