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

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

Issue 2778943005: Keep root_location to be in pixels and display coordinates in WS. (Closed)
Patch Set: . Created 3 years, 7 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
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 void SetMousePointerScreenLocation(const gfx::Point& screen_location); 62 void SetMousePointerDisplayLocationAndId(const gfx::Point& display_location,
sky 2017/05/17 16:53:41 optional: the new name is rather verbose. Leave th
riajiang 2017/05/19 20:45:05 Done.
63 const int64_t display_id);
63 const gfx::Point& mouse_pointer_last_location() const { 64 const gfx::Point& mouse_pointer_last_location() const {
64 return mouse_pointer_last_location_; 65 return mouse_pointer_last_location_;
65 } 66 }
67 int64_t mouse_pointer_display_id() const { return mouse_pointer_display_id_; }
66 68
67 // Returns the cursor for the current target, or POINTER if the mouse is not 69 // Returns the cursor for the current target, or POINTER if the mouse is not
68 // over a valid target. 70 // over a valid target.
69 ui::CursorData GetCurrentMouseCursor() const; 71 ui::CursorData GetCurrentMouseCursor() const;
70 72
71 // |capture_window_| will receive all input. See window_tree.mojom for 73 // |capture_window_| will receive all input. See window_tree.mojom for
72 // details. 74 // details.
73 ServerWindow* capture_window() { return capture_window_; } 75 ServerWindow* capture_window() { return capture_window_; }
74 const ServerWindow* capture_window() const { return capture_window_; } 76 const ServerWindow* capture_window() const { return capture_window_; }
75 // Setting capture can fail if the window is blocked by a modal window 77 // Setting capture can fail if the window is blocked by a modal window
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // is not added. Returns whether adding the accelerator was successful or not. 137 // is not added. Returns whether adding the accelerator was successful or not.
136 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); 138 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher);
137 139
138 void RemoveAccelerator(uint32_t id); 140 void RemoveAccelerator(uint32_t id);
139 141
140 // Processes the supplied event, informing the delegate as approriate. This 142 // Processes the supplied event, informing the delegate as approriate. This
141 // may result in generating any number of events. If |match_phase| is 143 // may result in generating any number of events. If |match_phase| is
142 // ANY and there is a matching accelerator with PRE_TARGET found, than only 144 // ANY and there is a matching accelerator with PRE_TARGET found, than only
143 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been 145 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been
144 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY. 146 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY.
145 void ProcessEvent(const ui::Event& event, AcceleratorMatchPhase match_phase); 147 void ProcessEvent(const ui::Event& event,
148 const int64_t display_id,
149 AcceleratorMatchPhase match_phase);
146 150
147 private: 151 private:
148 friend class test::EventDispatcherTestApi; 152 friend class test::EventDispatcherTestApi;
149 153
150 // Keeps track of state associated with an active pointer. 154 // Keeps track of state associated with an active pointer.
151 struct PointerTarget { 155 struct PointerTarget {
152 PointerTarget() 156 PointerTarget()
153 : window(nullptr), 157 : window(nullptr),
154 is_mouse_event(false), 158 is_mouse_event(false),
155 in_nonclient_area(false), 159 in_nonclient_area(false),
(...skipping 23 matching lines...) Expand all
179 183
180 // EventDispatcher provides the following logic for pointer events: 184 // EventDispatcher provides the following logic for pointer events:
181 // . wheel events go to the current target of the associated pointer. If 185 // . wheel events go to the current target of the associated pointer. If
182 // there is no target, they go to the deepest window. 186 // there is no target, they go to the deepest window.
183 // . move (not drag) events go to the deepest window. 187 // . move (not drag) events go to the deepest window.
184 // . when a pointer goes down all events until the corresponding up or 188 // . when a pointer goes down all events until the corresponding up or
185 // cancel go to the deepest target. For mouse events the up only occurs 189 // cancel go to the deepest target. For mouse events the up only occurs
186 // when no buttons on the mouse are down. 190 // when no buttons on the mouse are down.
187 // This also generates exit events as appropriate. For example, if the mouse 191 // This also generates exit events as appropriate. For example, if the mouse
188 // moves between one window to another an exit is generated on the first. 192 // moves between one window to another an exit is generated on the first.
189 void ProcessPointerEvent(const ui::PointerEvent& event); 193 void ProcessPointerEvent(const ui::PointerEvent& event,
194 const int64_t display_id);
190 195
191 // Adds |pointer_target| to |pointer_targets_|. 196 // Adds |pointer_target| to |pointer_targets_|.
192 void StartTrackingPointer(int32_t pointer_id, 197 void StartTrackingPointer(int32_t pointer_id,
193 const PointerTarget& pointer_target); 198 const PointerTarget& pointer_target);
194 199
195 // Removes a PointerTarget from |pointer_targets_|. 200 // Removes a PointerTarget from |pointer_targets_|.
196 void StopTrackingPointer(int32_t pointer_id); 201 void StopTrackingPointer(int32_t pointer_id);
197 202
198 // Starts tracking the pointer for |event|, or if already tracking the 203 // Starts tracking the pointer for |event|, or if already tracking the
199 // pointer sends the appropriate event to the delegate and updates the 204 // pointer sends the appropriate event to the delegate and updates the
(...skipping 27 matching lines...) Expand all
227 // unobserve a window, UnobserveWindow() should be called the same number of 232 // unobserve a window, UnobserveWindow() should be called the same number of
228 // times. 233 // times.
229 void ObserveWindow(ServerWindow* winodw); 234 void ObserveWindow(ServerWindow* winodw);
230 void UnobserveWindow(ServerWindow* winodw); 235 void UnobserveWindow(ServerWindow* winodw);
231 236
232 // Returns an Accelerator bound to the specified code/flags, and of the 237 // Returns an Accelerator bound to the specified code/flags, and of the
233 // matching |phase|. Otherwise returns null. 238 // matching |phase|. Otherwise returns null.
234 Accelerator* FindAccelerator(const ui::KeyEvent& event, 239 Accelerator* FindAccelerator(const ui::KeyEvent& event,
235 const ui::mojom::AcceleratorPhase phase); 240 const ui::mojom::AcceleratorPhase phase);
236 241
237 DeepestWindow FindDeepestVisibleWindowForEvents(const gfx::Point& location); 242 DeepestWindow FindDeepestVisibleWindowForEvents(gfx::Point* location,
243 int64_t* display_id);
238 244
239 // Clears the implicit captures in |pointer_targets_|, with the exception of 245 // Clears the implicit captures in |pointer_targets_|, with the exception of
240 // |window|. |window| may be null. |client_id| is the target client of 246 // |window|. |window| may be null. |client_id| is the target client of
241 // |window|. 247 // |window|.
242 void CancelImplicitCaptureExcept(ServerWindow* window, 248 void CancelImplicitCaptureExcept(ServerWindow* window,
243 ClientSpecificId client_id); 249 ClientSpecificId client_id);
244 250
245 // ServerWindowObserver: 251 // ServerWindowObserver:
246 void OnWillChangeWindowHierarchy(ServerWindow* window, 252 void OnWillChangeWindowHierarchy(ServerWindow* window,
247 ServerWindow* new_parent, 253 ServerWindow* new_parent,
(...skipping 10 matching lines...) Expand all
258 ClientSpecificId capture_window_client_id_; 264 ClientSpecificId capture_window_client_id_;
259 265
260 std::unique_ptr<DragController> drag_controller_; 266 std::unique_ptr<DragController> drag_controller_;
261 267
262 ModalWindowController modal_window_controller_; 268 ModalWindowController modal_window_controller_;
263 269
264 bool mouse_button_down_; 270 bool mouse_button_down_;
265 ServerWindow* mouse_cursor_source_window_; 271 ServerWindow* mouse_cursor_source_window_;
266 bool mouse_cursor_in_non_client_area_; 272 bool mouse_cursor_in_non_client_area_;
267 273
268 // The on screen location of the mouse pointer. This can be outside the 274 // The location of the mouse pointer in display coordinates. This can be
269 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. 275 // outside the bounds of |mouse_cursor_source_window_|, which can capture the
276 // cursor.
270 gfx::Point mouse_pointer_last_location_; 277 gfx::Point mouse_pointer_last_location_;
278 // Id of the display |mouse_pointer_last_location_| is on.
279 int64_t mouse_pointer_display_id_ = 0;
280
281 // Id of the display the most recent event is on.
sky 2017/05/17 16:53:41 Under what circumstances is mouse_pointer_display_
riajiang 2017/05/19 20:45:05 We don't update mouse specific info (mouse_pointer
282 int64_t event_display_id_ = 0;
271 283
272 std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_; 284 std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_;
273 285
274 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; 286 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>;
275 // |pointer_targets_| contains the active pointers. For a mouse based pointer 287 // |pointer_targets_| contains the active pointers. For a mouse based pointer
276 // a PointerTarget is always active (and present in |pointer_targets_|). For 288 // a PointerTarget is always active (and present in |pointer_targets_|). For
277 // touch based pointers the pointer is active while down and removed on 289 // touch based pointers the pointer is active while down and removed on
278 // cancel or up. 290 // cancel or up.
279 PointerIdToTargetMap pointer_targets_; 291 PointerIdToTargetMap pointer_targets_;
280 292
281 // Keeps track of number of observe requests for each observed window. 293 // Keeps track of number of observe requests for each observed window.
282 std::map<const ServerWindow*, uint8_t> observed_windows_; 294 std::map<const ServerWindow*, uint8_t> observed_windows_;
283 295
284 #if !defined(NDEBUG) 296 #if !defined(NDEBUG)
285 std::unique_ptr<ui::Event> previous_event_; 297 std::unique_ptr<ui::Event> previous_event_;
286 AcceleratorMatchPhase previous_accelerator_match_phase_ = 298 AcceleratorMatchPhase previous_accelerator_match_phase_ =
287 AcceleratorMatchPhase::ANY; 299 AcceleratorMatchPhase::ANY;
288 #endif 300 #endif
289 301
290 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); 302 DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
291 }; 303 };
292 304
293 } // namespace ws 305 } // namespace ws
294 } // namespace ui 306 } // namespace ui
295 307
296 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ 308 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698