| 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 COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 5 #ifndef COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
| 6 #define COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 6 #define COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/surfaces/surface_id.h" | 11 #include "cc/surfaces/surface_id.h" |
| 12 #include "ui/gfx/geometry/rect_f.h" | 12 #include "ui/gfx/geometry/rect_f.h" |
| 13 #include "ui/mojo/events/input_event_constants.mojom.h" | 13 #include "ui/mojo/events/input_event_constants.mojom.h" |
| 14 #include "ui/mojo/events/input_event_matcher.mojom.h" | 14 #include "ui/mojo/events/input_event_matcher.mojom.h" |
| 15 #include "ui/mojo/events/input_events.mojom.h" | 15 #include "ui/mojo/events/input_events.mojom.h" |
| 16 #include "ui/mojo/events/input_key_codes.mojom.h" | 16 #include "ui/mojo/events/input_key_codes.mojom.h" |
| 17 | 17 |
| 18 namespace gfx { | |
| 19 class Point; | |
| 20 } | |
| 21 | |
| 22 namespace mus { | 18 namespace mus { |
| 23 namespace ws { | 19 namespace ws { |
| 24 | 20 |
| 25 class EventDispatcherDelegate; | 21 class EventDispatcherDelegate; |
| 26 class MoveLoop; | 22 class EventMatcher; |
| 27 class ServerWindow; | 23 class ServerWindow; |
| 28 | 24 |
| 29 class EventMatcher; | |
| 30 | |
| 31 // Handles dispatching events to the right location as well as updating focus. | 25 // Handles dispatching events to the right location as well as updating focus. |
| 32 class EventDispatcher { | 26 class EventDispatcher { |
| 33 public: | 27 public: |
| 34 explicit EventDispatcher(EventDispatcherDelegate* delegate); | 28 explicit EventDispatcher(EventDispatcherDelegate* delegate); |
| 35 ~EventDispatcher(); | 29 ~EventDispatcher(); |
| 36 | 30 |
| 37 void set_root(ServerWindow* root) { root_ = root; } | 31 void set_root(ServerWindow* root) { root_ = root; } |
| 38 | 32 |
| 39 void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; } | 33 void set_surface_id(cc::SurfaceId surface_id) { surface_id_ = surface_id; } |
| 40 | 34 |
| 41 void AddAccelerator(uint32_t id, mojo::EventMatcherPtr event_matcher); | 35 void AddAccelerator(uint32_t id, mojo::EventMatcherPtr event_matcher); |
| 42 void RemoveAccelerator(uint32_t id); | 36 void RemoveAccelerator(uint32_t id); |
| 43 | 37 |
| 44 void OnEvent(mojo::EventPtr event); | 38 void OnEvent(mojo::EventPtr event); |
| 45 | 39 |
| 46 private: | 40 private: |
| 47 // Looks to see if there is an accelerator bound to the specified code/flags. | 41 // Looks to see if there is an accelerator bound to the specified code/flags. |
| 48 // If there is one, sets |accelerator_id| to the id of the accelerator invoked | 42 // If there is one, sets |accelerator_id| to the id of the accelerator invoked |
| 49 // and returns true. If there is none, returns false so normal key event | 43 // and returns true. If there is none, returns false so normal key event |
| 50 // processing can continue. | 44 // processing can continue. |
| 51 bool FindAccelerator(const mojo::Event& event, uint32_t* accelerator_id); | 45 bool FindAccelerator(const mojo::Event& event, uint32_t* accelerator_id); |
| 52 | 46 |
| 53 // Returns the ServerWindow that should receive |event|. If |event| is a | 47 // Returns the ServerWindow that should receive |event|. If |event| is a |
| 54 // pointer-type event, then this function also updates the event location to | 48 // pointer-type event, then this function also updates the event location to |
| 55 // make sure it is in the returned target's coordinate space. | 49 // make sure it is in the returned target's coordinate space. |
| 56 ServerWindow* FindEventTarget(mojo::Event* event); | 50 ServerWindow* FindEventTarget(mojo::Event* event); |
| 57 | 51 |
| 58 void ResetCaptureWindowIfPointerUp(const mojo::Event& event); | |
| 59 | |
| 60 EventDispatcherDelegate* delegate_; | 52 EventDispatcherDelegate* delegate_; |
| 61 ServerWindow* root_; | 53 ServerWindow* root_; |
| 62 | 54 |
| 63 cc::SurfaceId surface_id_; | 55 cc::SurfaceId surface_id_; |
| 64 ServerWindow* capture_window_; | 56 ServerWindow* capture_window_; |
| 65 | 57 |
| 58 // Was the capture the result of clicking in the non-client area? |
| 59 bool capture_in_nonclient_area_; |
| 60 |
| 66 using Entry = std::pair<uint32_t, EventMatcher>; | 61 using Entry = std::pair<uint32_t, EventMatcher>; |
| 67 std::map<uint32_t, EventMatcher> accelerators_; | 62 std::map<uint32_t, EventMatcher> accelerators_; |
| 68 | 63 |
| 69 scoped_ptr<MoveLoop> move_loop_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 64 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
| 72 }; | 65 }; |
| 73 | 66 |
| 74 } // namespace ws | 67 } // namespace ws |
| 75 } // namespace mus | 68 } // namespace mus |
| 76 | 69 |
| 77 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 70 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
| OLD | NEW |