| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "services/ui/common/types.h" | 15 #include "services/ui/common/types.h" |
| 16 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" | 16 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" |
| 17 #include "services/ui/public/interfaces/window_manager.mojom.h" | 17 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 18 #include "services/ui/ws/drag_cursor_updater.h" | 18 #include "services/ui/ws/drag_cursor_updater.h" |
| 19 #include "services/ui/ws/event_targeter.h" | 19 #include "services/ui/ws/event_targeter.h" |
| 20 #include "services/ui/ws/event_targeter_delegate.h" |
| 20 #include "services/ui/ws/modal_window_controller.h" | 21 #include "services/ui/ws/modal_window_controller.h" |
| 21 #include "services/ui/ws/server_window_observer.h" | 22 #include "services/ui/ws/server_window_observer.h" |
| 22 #include "ui/gfx/geometry/rect_f.h" | 23 #include "ui/gfx/geometry/rect_f.h" |
| 23 | 24 |
| 24 namespace ui { | 25 namespace ui { |
| 25 class Event; | 26 class Event; |
| 26 class KeyEvent; | 27 class KeyEvent; |
| 27 class LocatedEvent; | 28 class LocatedEvent; |
| 28 class PointerEvent; | 29 class PointerEvent; |
| 29 | 30 |
| 30 namespace ws { | 31 namespace ws { |
| 31 | 32 |
| 32 class Accelerator; | 33 class Accelerator; |
| 33 class DragController; | 34 class DragController; |
| 34 class DragSource; | 35 class DragSource; |
| 35 class DragTargetConnection; | 36 class DragTargetConnection; |
| 36 class EventDispatcherDelegate; | 37 class EventDispatcherDelegate; |
| 37 class ServerWindow; | 38 class ServerWindow; |
| 38 | 39 |
| 39 namespace test { | 40 namespace test { |
| 40 class EventDispatcherTestApi; | 41 class EventDispatcherTestApi; |
| 41 } | 42 } |
| 42 | 43 |
| 43 // Handles dispatching events to the right location as well as updating focus. | 44 // Handles dispatching events to the right location as well as updating focus. |
| 44 class EventDispatcher : public ServerWindowObserver, public DragCursorUpdater { | 45 class EventDispatcher : public ServerWindowObserver, |
| 46 public DragCursorUpdater, |
| 47 public EventTargeterDelegate { |
| 45 public: | 48 public: |
| 46 enum class AcceleratorMatchPhase { | 49 enum class AcceleratorMatchPhase { |
| 47 // Both pre and post should be considered. | 50 // Both pre and post should be considered. |
| 48 ANY, | 51 ANY, |
| 49 | 52 |
| 50 // PRE_TARGETs are not considered, only the actual target and any | 53 // PRE_TARGETs are not considered, only the actual target and any |
| 51 // accelerators registered with POST_TARGET. | 54 // accelerators registered with POST_TARGET. |
| 52 POST_ONLY, | 55 POST_ONLY, |
| 53 }; | 56 }; |
| 54 | 57 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 144 |
| 142 // Processes the supplied event, informing the delegate as approriate. This | 145 // Processes the supplied event, informing the delegate as approriate. This |
| 143 // may result in generating any number of events. If |match_phase| is | 146 // 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 | 147 // 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 | 148 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been |
| 146 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY. | 149 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY. |
| 147 void ProcessEvent(const ui::Event& event, | 150 void ProcessEvent(const ui::Event& event, |
| 148 const int64_t display_id, | 151 const int64_t display_id, |
| 149 AcceleratorMatchPhase match_phase); | 152 AcceleratorMatchPhase match_phase); |
| 150 | 153 |
| 154 // EventTargeterDelegate: |
| 155 ServerWindow* GetRootWindowContaining(gfx::Point* location_in_display, |
| 156 int64_t* display_id) override; |
| 157 |
| 151 private: | 158 private: |
| 152 friend class test::EventDispatcherTestApi; | 159 friend class test::EventDispatcherTestApi; |
| 153 | 160 |
| 154 void SetMouseCursorSourceWindow(ServerWindow* window); | 161 void SetMouseCursorSourceWindow(ServerWindow* window); |
| 155 | 162 |
| 156 void ProcessKeyEvent(const ui::KeyEvent& event, | 163 void ProcessKeyEvent(const ui::KeyEvent& event, |
| 157 AcceleratorMatchPhase match_phase); | 164 AcceleratorMatchPhase match_phase); |
| 158 | 165 |
| 159 bool IsTrackingPointer(int32_t pointer_id) const { | 166 bool IsTrackingPointer(int32_t pointer_id) const { |
| 160 return pointer_targets_.count(pointer_id) > 0; | 167 return pointer_targets_.count(pointer_id) > 0; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 AcceleratorMatchPhase::ANY; | 278 AcceleratorMatchPhase::ANY; |
| 272 #endif | 279 #endif |
| 273 | 280 |
| 274 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 281 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
| 275 }; | 282 }; |
| 276 | 283 |
| 277 } // namespace ws | 284 } // namespace ws |
| 278 } // namespace ui | 285 } // namespace ui |
| 279 | 286 |
| 280 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ | 287 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ |
| OLD | NEW |