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> |
| 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/event_matcher.mojom.h" | 16 #include "services/ui/public/interfaces/event_matcher.mojom.h" |
| 17 #include "services/ui/ws/current_drag_operation_delegate.h" | |
| 17 #include "services/ui/ws/modal_window_controller.h" | 18 #include "services/ui/ws/modal_window_controller.h" |
| 18 #include "services/ui/ws/server_window_observer.h" | 19 #include "services/ui/ws/server_window_observer.h" |
| 19 #include "ui/gfx/geometry/rect_f.h" | 20 #include "ui/gfx/geometry/rect_f.h" |
| 20 | 21 |
| 21 namespace ui { | 22 namespace ui { |
| 22 class Event; | 23 class Event; |
| 23 class KeyEvent; | 24 class KeyEvent; |
| 24 class LocatedEvent; | 25 class LocatedEvent; |
| 25 | 26 |
| 26 namespace ws { | 27 namespace ws { |
| 27 | 28 |
| 28 class Accelerator; | 29 class Accelerator; |
| 30 class CurrentDragOperation; | |
| 29 class EventDispatcherDelegate; | 31 class EventDispatcherDelegate; |
| 30 class ServerWindow; | 32 class ServerWindow; |
| 33 class WindowTree; | |
| 31 | 34 |
| 32 namespace test { | 35 namespace test { |
| 33 class EventDispatcherTestApi; | 36 class EventDispatcherTestApi; |
| 34 } | 37 } |
| 35 | 38 |
| 36 // Handles dispatching events to the right location as well as updating focus. | 39 // Handles dispatching events to the right location as well as updating focus. |
| 37 class EventDispatcher : public ServerWindowObserver { | 40 class EventDispatcher : public ServerWindowObserver, |
| 41 public CurrentDragOperationDelegate { | |
| 38 public: | 42 public: |
| 39 enum class AcceleratorMatchPhase { | 43 enum class AcceleratorMatchPhase { |
| 40 // Both pre and post should be considered. | 44 // Both pre and post should be considered. |
| 41 ANY, | 45 ANY, |
| 42 | 46 |
| 43 // PRE_TARGETs are not considered, only the actual target and any | 47 // PRE_TARGETs are not considered, only the actual target and any |
| 44 // accelerators registered with POST_TARGET. | 48 // accelerators registered with POST_TARGET. |
| 45 POST_ONLY, | 49 POST_ONLY, |
| 46 }; | 50 }; |
| 47 | 51 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 68 // Setting capture can fail if the window is blocked by a modal window | 72 // Setting capture can fail if the window is blocked by a modal window |
| 69 // (indicated by returning |false|). | 73 // (indicated by returning |false|). |
| 70 bool SetCaptureWindow(ServerWindow* capture_window, | 74 bool SetCaptureWindow(ServerWindow* capture_window, |
| 71 ClientSpecificId client_id); | 75 ClientSpecificId client_id); |
| 72 | 76 |
| 73 // Id of the client that capture events are sent to. | 77 // Id of the client that capture events are sent to. |
| 74 ClientSpecificId capture_window_client_id() const { | 78 ClientSpecificId capture_window_client_id() const { |
| 75 return capture_window_client_id_; | 79 return capture_window_client_id_; |
| 76 } | 80 } |
| 77 | 81 |
| 82 // TODO(erg): Am I not supposed to pass window_tree here? | |
| 83 void SetDragDropSourceWindow( | |
|
sky
2016/08/24 00:08:57
I recommend having this take an interface rather t
| |
| 84 uint32_t change_id, | |
| 85 WindowTree* window_tree, | |
| 86 ServerWindow* capture_window, | |
| 87 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, | |
| 88 uint32_t drag_operations); | |
| 89 | |
| 78 // Adds a system modal window. The window remains modal to system until it is | 90 // Adds a system modal window. The window remains modal to system until it is |
| 79 // destroyed. There can exist multiple system modal windows, in which case the | 91 // destroyed. There can exist multiple system modal windows, in which case the |
| 80 // one that is visible and added most recently or shown most recently would be | 92 // one that is visible and added most recently or shown most recently would be |
| 81 // the active one. | 93 // the active one. |
| 82 void AddSystemModalWindow(ServerWindow* window); | 94 void AddSystemModalWindow(ServerWindow* window); |
| 83 | 95 |
| 84 // Checks if |modal_window| is a visible modal window that blocks current | 96 // Checks if |modal_window| is a visible modal window that blocks current |
| 85 // capture window and if that's the case, releases the capture. | 97 // capture window and if that's the case, releases the capture. |
| 86 void ReleaseCaptureBlockedByModalWindow(const ServerWindow* modal_window); | 98 void ReleaseCaptureBlockedByModalWindow(const ServerWindow* modal_window); |
| 87 | 99 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 110 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); | 122 bool AddAccelerator(uint32_t id, mojom::EventMatcherPtr event_matcher); |
| 111 void RemoveAccelerator(uint32_t id); | 123 void RemoveAccelerator(uint32_t id); |
| 112 | 124 |
| 113 // Processes the supplied event, informing the delegate as approriate. This | 125 // Processes the supplied event, informing the delegate as approriate. This |
| 114 // may result in generating any number of events. If |match_phase| is | 126 // may result in generating any number of events. If |match_phase| is |
| 115 // ANY and there is a matching accelerator with PRE_TARGET found, than only | 127 // ANY and there is a matching accelerator with PRE_TARGET found, than only |
| 116 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been | 128 // OnAccelerator() is called. The expectation is after the PRE_TARGET has been |
| 117 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY. | 129 // handled this is again called with an AcceleratorMatchPhase of POST_ONLY. |
| 118 void ProcessEvent(const ui::Event& event, AcceleratorMatchPhase match_phase); | 130 void ProcessEvent(const ui::Event& event, AcceleratorMatchPhase match_phase); |
| 119 | 131 |
| 132 ServerWindow* FindDeepestVisibleWindowForEvents(gfx::Point* location); | |
| 133 | |
| 120 private: | 134 private: |
| 121 friend class test::EventDispatcherTestApi; | 135 friend class test::EventDispatcherTestApi; |
| 122 | 136 |
| 123 // Keeps track of state associated with an active pointer. | 137 // Keeps track of state associated with an active pointer. |
| 124 struct PointerTarget { | 138 struct PointerTarget { |
| 125 PointerTarget() | 139 PointerTarget() |
| 126 : window(nullptr), | 140 : window(nullptr), |
| 127 is_mouse_event(false), | 141 is_mouse_event(false), |
| 128 in_nonclient_area(false), | 142 in_nonclient_area(false), |
| 129 is_pointer_down(false) {} | 143 is_pointer_down(false) {} |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 // unobserve a window, UnobserveWindow() should be called the same number of | 209 // unobserve a window, UnobserveWindow() should be called the same number of |
| 196 // times. | 210 // times. |
| 197 void ObserveWindow(ServerWindow* winodw); | 211 void ObserveWindow(ServerWindow* winodw); |
| 198 void UnobserveWindow(ServerWindow* winodw); | 212 void UnobserveWindow(ServerWindow* winodw); |
| 199 | 213 |
| 200 // Returns an Accelerator bound to the specified code/flags, and of the | 214 // Returns an Accelerator bound to the specified code/flags, and of the |
| 201 // matching |phase|. Otherwise returns null. | 215 // matching |phase|. Otherwise returns null. |
| 202 Accelerator* FindAccelerator(const ui::KeyEvent& event, | 216 Accelerator* FindAccelerator(const ui::KeyEvent& event, |
| 203 const ui::mojom::AcceleratorPhase phase); | 217 const ui::mojom::AcceleratorPhase phase); |
| 204 | 218 |
| 205 ServerWindow* FindDeepestVisibleWindowForEvents(gfx::Point* location); | |
| 206 | |
| 207 // ServerWindowObserver: | 219 // ServerWindowObserver: |
| 208 void OnWillChangeWindowHierarchy(ServerWindow* window, | 220 void OnWillChangeWindowHierarchy(ServerWindow* window, |
| 209 ServerWindow* new_parent, | 221 ServerWindow* new_parent, |
| 210 ServerWindow* old_parent) override; | 222 ServerWindow* old_parent) override; |
| 211 void OnWindowVisibilityChanged(ServerWindow* window) override; | 223 void OnWindowVisibilityChanged(ServerWindow* window) override; |
| 212 void OnWindowDestroyed(ServerWindow* window) override; | 224 void OnWindowDestroyed(ServerWindow* window) override; |
| 213 | 225 |
| 226 // CurrentDragOperationDelegate: | |
| 227 void OnDragOver(bool success) override; | |
| 228 | |
| 214 EventDispatcherDelegate* delegate_; | 229 EventDispatcherDelegate* delegate_; |
| 215 | 230 |
| 216 ServerWindow* capture_window_; | 231 ServerWindow* capture_window_; |
| 217 ClientSpecificId capture_window_client_id_; | 232 ClientSpecificId capture_window_client_id_; |
| 218 | 233 |
| 234 std::unique_ptr<CurrentDragOperation> current_drag_drop_operation_; | |
| 235 | |
| 219 ModalWindowController modal_window_controller_; | 236 ModalWindowController modal_window_controller_; |
| 220 | 237 |
| 221 bool mouse_button_down_; | 238 bool mouse_button_down_; |
| 222 ServerWindow* mouse_cursor_source_window_; | 239 ServerWindow* mouse_cursor_source_window_; |
| 223 bool mouse_cursor_in_non_client_area_; | 240 bool mouse_cursor_in_non_client_area_; |
| 224 | 241 |
| 225 // The on screen location of the mouse pointer. This can be outside the | 242 // The on screen location of the mouse pointer. This can be outside the |
| 226 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. | 243 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. |
| 227 gfx::Point mouse_pointer_last_location_; | 244 gfx::Point mouse_pointer_last_location_; |
| 228 | 245 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 244 AcceleratorMatchPhase::ANY; | 261 AcceleratorMatchPhase::ANY; |
| 245 #endif | 262 #endif |
| 246 | 263 |
| 247 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 264 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
| 248 }; | 265 }; |
| 249 | 266 |
| 250 } // namespace ws | 267 } // namespace ws |
| 251 } // namespace ui | 268 } // namespace ui |
| 252 | 269 |
| 253 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ | 270 #endif // SERVICES_UI_WS_EVENT_DISPATCHER_H_ |
| OLD | NEW |