Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 SetMousePointerDisplayLocation(const gfx::Point& display_location, |
|
sky
2017/05/25 22:10:19
InDips?
riajiang
2017/05/25 22:59:23
mouse_pointer_location is in display-coord and pix
| |
| 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 Loading... | |
| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 // unobserve a window, UnobserveWindow() should be called the same number of | 231 // unobserve a window, UnobserveWindow() should be called the same number of |
| 228 // times. | 232 // times. |
| 229 void ObserveWindow(ServerWindow* winodw); | 233 void ObserveWindow(ServerWindow* winodw); |
| 230 void UnobserveWindow(ServerWindow* winodw); | 234 void UnobserveWindow(ServerWindow* winodw); |
| 231 | 235 |
| 232 // Returns an Accelerator bound to the specified code/flags, and of the | 236 // Returns an Accelerator bound to the specified code/flags, and of the |
| 233 // matching |phase|. Otherwise returns null. | 237 // matching |phase|. Otherwise returns null. |
| 234 Accelerator* FindAccelerator(const ui::KeyEvent& event, | 238 Accelerator* FindAccelerator(const ui::KeyEvent& event, |
| 235 const ui::mojom::AcceleratorPhase phase); | 239 const ui::mojom::AcceleratorPhase phase); |
| 236 | 240 |
| 237 DeepestWindow FindDeepestVisibleWindowForEvents(const gfx::Point& location); | 241 DeepestWindow FindDeepestVisibleWindowForEvents(gfx::Point* location, |
| 242 int64_t* display_id); | |
| 238 | 243 |
| 239 // Clears the implicit captures in |pointer_targets_|, with the exception of | 244 // Clears the implicit captures in |pointer_targets_|, with the exception of |
| 240 // |window|. |window| may be null. |client_id| is the target client of | 245 // |window|. |window| may be null. |client_id| is the target client of |
| 241 // |window|. | 246 // |window|. |
| 242 void CancelImplicitCaptureExcept(ServerWindow* window, | 247 void CancelImplicitCaptureExcept(ServerWindow* window, |
| 243 ClientSpecificId client_id); | 248 ClientSpecificId client_id); |
| 244 | 249 |
| 245 // ServerWindowObserver: | 250 // ServerWindowObserver: |
| 246 void OnWillChangeWindowHierarchy(ServerWindow* window, | 251 void OnWillChangeWindowHierarchy(ServerWindow* window, |
| 247 ServerWindow* new_parent, | 252 ServerWindow* new_parent, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 258 ClientSpecificId capture_window_client_id_; | 263 ClientSpecificId capture_window_client_id_; |
| 259 | 264 |
| 260 std::unique_ptr<DragController> drag_controller_; | 265 std::unique_ptr<DragController> drag_controller_; |
| 261 | 266 |
| 262 ModalWindowController modal_window_controller_; | 267 ModalWindowController modal_window_controller_; |
| 263 | 268 |
| 264 bool mouse_button_down_; | 269 bool mouse_button_down_; |
| 265 ServerWindow* mouse_cursor_source_window_; | 270 ServerWindow* mouse_cursor_source_window_; |
| 266 bool mouse_cursor_in_non_client_area_; | 271 bool mouse_cursor_in_non_client_area_; |
| 267 | 272 |
| 268 // The on screen location of the mouse pointer. This can be outside the | 273 // The location of the mouse pointer in display coordinates. This can be |
| 269 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. | 274 // outside the bounds of |mouse_cursor_source_window_|, which can capture the |
| 275 // cursor. | |
| 270 gfx::Point mouse_pointer_last_location_; | 276 gfx::Point mouse_pointer_last_location_; |
| 277 // Id of the display |mouse_pointer_last_location_| is on. | |
| 278 int64_t mouse_pointer_display_id_ = 0; | |
|
sky
2017/05/25 22:10:19
kInvalidDisplayId.
riajiang
2017/05/25 22:59:23
Done.
| |
| 279 | |
| 280 // Id of the display the most recent event is on. | |
| 281 int64_t event_display_id_ = 0; | |
|
sky
2017/05/25 22:10:19
kInvalidDisplayId
riajiang
2017/05/25 22:59:23
Done.
| |
| 271 | 282 |
| 272 std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_; | 283 std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_; |
| 273 | 284 |
| 274 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; | 285 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; |
| 275 // |pointer_targets_| contains the active pointers. For a mouse based pointer | 286 // |pointer_targets_| contains the active pointers. For a mouse based pointer |
| 276 // a PointerTarget is always active (and present in |pointer_targets_|). For | 287 // a PointerTarget is always active (and present in |pointer_targets_|). For |
| 277 // touch based pointers the pointer is active while down and removed on | 288 // touch based pointers the pointer is active while down and removed on |
| 278 // cancel or up. | 289 // cancel or up. |
| 279 PointerIdToTargetMap pointer_targets_; | 290 PointerIdToTargetMap pointer_targets_; |
| 280 | 291 |
| 281 // Keeps track of number of observe requests for each observed window. | 292 // Keeps track of number of observe requests for each observed window. |
| 282 std::map<const ServerWindow*, uint8_t> observed_windows_; | 293 std::map<const ServerWindow*, uint8_t> observed_windows_; |
| 283 | 294 |
| 284 #if !defined(NDEBUG) | 295 #if !defined(NDEBUG) |
| 285 std::unique_ptr<ui::Event> previous_event_; | 296 std::unique_ptr<ui::Event> previous_event_; |
| 286 AcceleratorMatchPhase previous_accelerator_match_phase_ = | 297 AcceleratorMatchPhase previous_accelerator_match_phase_ = |
| 287 AcceleratorMatchPhase::ANY; | 298 AcceleratorMatchPhase::ANY; |
| 288 #endif | 299 #endif |
| 289 | 300 |
| 290 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 301 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
| 291 }; | 302 }; |
| 292 | 303 |
| 293 } // namespace ws | 304 } // namespace ws |
| 294 } // namespace ui | 305 } // namespace ui |
| 295 | 306 |
| 296 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ | 307 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ |
| OLD | NEW |