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

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

Issue 2884463002: Make event-targeting asynchronous in window server. (Closed)
Patch Set: rebase and 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_targeter.h » ('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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 POST_ONLY, 55 POST_ONLY,
56 }; 56 };
57 57
58 explicit EventDispatcher(EventDispatcherDelegate* delegate); 58 explicit EventDispatcher(EventDispatcherDelegate* delegate);
59 ~EventDispatcher() override; 59 ~EventDispatcher() override;
60 60
61 // Cancels capture and stops tracking any pointer events. This does not send 61 // Cancels capture and stops tracking any pointer events. This does not send
62 // any events to the delegate. 62 // any events to the delegate.
63 void Reset(); 63 void Reset();
64 64
65 const EventTargeter* event_targeter() const { return event_targeter_.get(); }
sky 2017/06/02 23:28:20 EventTargeter is an implementation detail of Event
riajiang 2017/06/05 23:56:15 True, done.
66
65 void SetMousePointerDisplayLocation(const gfx::Point& display_location, 67 void SetMousePointerDisplayLocation(const gfx::Point& display_location,
66 const int64_t display_id); 68 int64_t display_id);
67 const gfx::Point& mouse_pointer_last_location() const { 69 const gfx::Point& mouse_pointer_last_location() const {
68 return mouse_pointer_last_location_; 70 return mouse_pointer_last_location_;
69 } 71 }
70 int64_t mouse_pointer_display_id() const { return mouse_pointer_display_id_; } 72 int64_t mouse_pointer_display_id() const { return mouse_pointer_display_id_; }
71 73
72 // Returns the cursor for the current target, or POINTER if the mouse is not 74 // Returns the cursor for the current target, or POINTER if the mouse is not
73 // over a valid target. 75 // over a valid target.
74 ui::CursorData GetCurrentMouseCursor() const; 76 ui::CursorData GetCurrentMouseCursor() const;
75 77
76 // |capture_window_| will receive all input. See window_tree.mojom for 78 // |capture_window_| will receive all input. See window_tree.mojom for
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // is not added. Returns whether adding the accelerator was successful or not. 142 // is not added. Returns whether adding the accelerator was successful or not.
141 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); 143 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher);
142 144
143 void RemoveAccelerator(uint32_t id); 145 void RemoveAccelerator(uint32_t id);
144 146
145 // Processes the supplied event, informing the delegate as approriate. This 147 // Processes the supplied event, informing the delegate as approriate. This
146 // may result in generating any number of events. If |match_phase| is 148 // may result in generating any number of events. If |match_phase| is
147 // ANY and there is a matching accelerator with PRE_TARGET found, than only 149 // ANY and there is a matching accelerator with PRE_TARGET found, than only
148 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been 150 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been
149 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY. 151 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY.
152 // This may be asynchronous if we need to find the target window for |event|
153 // asynchronously.
150 void ProcessEvent(const ui::Event& event, 154 void ProcessEvent(const ui::Event& event,
151 const int64_t display_id, 155 int64_t display_id,
152 AcceleratorMatchPhase match_phase); 156 AcceleratorMatchPhase match_phase);
153 157
154 // EventTargeterDelegate: 158 // EventTargeterDelegate:
155 ServerWindow* GetRootWindowContaining(gfx::Point* location_in_display, 159 ServerWindow* GetRootWindowContaining(gfx::Point* location_in_display,
156 int64_t* display_id) override; 160 int64_t* display_id) override;
161 void ProcessNextEventFromQueue() override;
157 162
158 private: 163 private:
159 friend class test::EventDispatcherTestApi; 164 friend class test::EventDispatcherTestApi;
160 165
161 void SetMouseCursorSourceWindow(ServerWindow* window); 166 void SetMouseCursorSourceWindow(ServerWindow* window);
162 167
168 // Called after we found the target for the current mouse cursor to see if
169 // |mouse_pointer_last_location_| and |mouse_pointer_display_id_| need to be
170 // updated based on the new target we found. No need to call delegate's
171 // OnMouseCursorLocationChanged since mouse location is the same in
172 // screen-coord.
173 // TODO(riajiang): No need to update mouse location after ozone drm can tell
174 // us the right display the cursor is on for drag-n-drop events.
175 // crbug.com/726470
176 void SetMousePointerLocation(const gfx::Point& new_mouse_location,
177 int64_t new_mouse_display_id);
178
163 void ProcessKeyEvent(const ui::KeyEvent& event, 179 void ProcessKeyEvent(const ui::KeyEvent& event,
164 AcceleratorMatchPhase match_phase); 180 AcceleratorMatchPhase match_phase);
165 181
166 bool IsTrackingPointer(int32_t pointer_id) const { 182 bool IsTrackingPointer(int32_t pointer_id) const {
167 return pointer_targets_.count(pointer_id) > 0; 183 return pointer_targets_.count(pointer_id) > 0;
168 } 184 }
169 185
170 // EventDispatcher provides the following logic for pointer events: 186 // EventDispatcher provides the following logic for pointer events:
171 // . wheel events go to the current target of the associated pointer. If 187 // . wheel events go to the current target of the associated pointer. If
172 // there is no target, they go to the deepest window. 188 // there is no target, they go to the deepest window.
173 // . move (not drag) events go to the deepest window. 189 // . move (not drag) events go to the deepest window.
174 // . when a pointer goes down all events until the corresponding up or 190 // . when a pointer goes down all events until the corresponding up or
175 // cancel go to the deepest target. For mouse events the up only occurs 191 // cancel go to the deepest target. For mouse events the up only occurs
176 // when no buttons on the mouse are down. 192 // when no buttons on the mouse are down.
177 // This also generates exit events as appropriate. For example, if the mouse 193 // This also generates exit events as appropriate. For example, if the mouse
178 // moves between one window to another an exit is generated on the first. 194 // moves between one window to another an exit is generated on the first.
179 void ProcessPointerEvent(const ui::PointerEvent& event); 195 // |pointer_target| is the PointerTarget for |event| based on the
196 // |deepest_window|, the deepest visible window for the root_location
197 // of the |event|. |location_in_display| and |display_id| are updated values
198 // for root_location and |event_display_id_| (e.g. during drag-n-drop).
199 void ProcessPointerEventOnFoundTarget(const ui::PointerEvent& event,
200 const PointerTarget& pointer_target,
201 const DeepestWindow& deepest_window,
202 const gfx::Point& location_in_display,
203 int64_t display_id);
204
205 void UpdateNonClientAreaForCurrentWindowOnFoundWindow(
206 const DeepestWindow& deepest_window,
207 const gfx::Point& location_in_display,
208 int64_t display_id);
209 void UpdateCursorProviderByLastKnownLocationOnFoundWindow(
210 const DeepestWindow& deepest_window,
211 const gfx::Point& location_in_display,
212 int64_t display_id);
180 213
181 // Adds |pointer_target| to |pointer_targets_|. 214 // Adds |pointer_target| to |pointer_targets_|.
182 void StartTrackingPointer(int32_t pointer_id, 215 void StartTrackingPointer(int32_t pointer_id,
183 const PointerTarget& pointer_target); 216 const PointerTarget& pointer_target);
184 217
185 // Removes a PointerTarget from |pointer_targets_|. 218 // Removes a PointerTarget from |pointer_targets_|.
186 void StopTrackingPointer(int32_t pointer_id); 219 void StopTrackingPointer(int32_t pointer_id);
187 220
188 // Starts tracking the pointer for |event|, or if already tracking the 221 // Starts tracking the pointer for |event|, or if already tracking the
189 // pointer sends the appropriate event to the delegate and updates the 222 // pointer sends the appropriate event to the delegate and updates the
190 // currently tracked PointerTarget appropriately. 223 // currently tracked PointerTarget appropriately.
191 void UpdateTargetForPointer(int32_t pointer_id, 224 void UpdateTargetForPointer(int32_t pointer_id,
192 const ui::LocatedEvent& event); 225 const ui::PointerEvent& event,
226 const PointerTarget& pointer_target);
193 227
194 // Returns true if any pointers are in the pressed/down state. 228 // Returns true if any pointers are in the pressed/down state.
195 bool AreAnyPointersDown() const; 229 bool AreAnyPointersDown() const;
196 230
197 // If |target->window| is valid, then passes the event to the delegate. 231 // If |target->window| is valid, then passes the event to the delegate.
198 void DispatchToPointerTarget(const PointerTarget& target, 232 void DispatchToPointerTarget(const PointerTarget& target,
199 const ui::LocatedEvent& event); 233 const ui::LocatedEvent& event);
200 234
201 // Dispatch |event| to the delegate. 235 // Dispatch |event| to the delegate.
202 void DispatchToClient(ServerWindow* window, 236 void DispatchToClient(ServerWindow* window,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 AcceleratorMatchPhase::ANY; 312 AcceleratorMatchPhase::ANY;
279 #endif 313 #endif
280 314
281 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); 315 DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
282 }; 316 };
283 317
284 } // namespace ws 318 } // namespace ws
285 } // namespace ui 319 } // namespace ui
286 320
287 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ 321 #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_targeter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698