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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 // |capture_window_| will receive all input. See window_tree.mojom for | 55 // |capture_window_| will receive all input. See window_tree.mojom for |
56 // details. | 56 // details. |
57 ServerWindow* capture_window() { return capture_window_; } | 57 ServerWindow* capture_window() { return capture_window_; } |
58 const ServerWindow* capture_window() const { return capture_window_; } | 58 const ServerWindow* capture_window() const { return capture_window_; } |
59 // Setting capture can fail if the window is blocked by a modal window | 59 // Setting capture can fail if the window is blocked by a modal window |
60 // (indicated by returning |false|). | 60 // (indicated by returning |false|). |
61 bool SetCaptureWindow(ServerWindow* capture_window, bool in_nonclient_area); | 61 bool SetCaptureWindow(ServerWindow* capture_window, bool in_nonclient_area); |
62 | 62 |
| 63 ServerWindow* system_modal_window() { return system_modal_window_; } |
| 64 const ServerWindow* system_modal_window() const { |
| 65 return system_modal_window_; |
| 66 } |
| 67 |
| 68 // |window| cannot be nullptr. The only way to unset system modal window is by |
| 69 // destroying it. |
| 70 bool SetSystemModalWindow(ServerWindow* window); |
| 71 |
63 // Retrieves the ServerWindow of the last mouse move. | 72 // Retrieves the ServerWindow of the last mouse move. |
64 ServerWindow* mouse_cursor_source_window() const { | 73 ServerWindow* mouse_cursor_source_window() const { |
65 return mouse_cursor_source_window_; | 74 return mouse_cursor_source_window_; |
66 } | 75 } |
67 | 76 |
68 // Possibly updates the cursor. If we aren't in an implicit capture, we take | 77 // Possibly updates the cursor. If we aren't in an implicit capture, we take |
69 // the last known location of the mouse pointer, and look for the | 78 // the last known location of the mouse pointer, and look for the |
70 // ServerWindow* under it. | 79 // ServerWindow* under it. |
71 void UpdateCursorProviderByLastKnownLocation(); | 80 void UpdateCursorProviderByLastKnownLocation(); |
72 | 81 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 150 |
142 // If |target->window| is valid, then passes the event to the delegate. | 151 // If |target->window| is valid, then passes the event to the delegate. |
143 void DispatchToPointerTarget(const PointerTarget& target, | 152 void DispatchToPointerTarget(const PointerTarget& target, |
144 const ui::LocatedEvent& event); | 153 const ui::LocatedEvent& event); |
145 | 154 |
146 // Stops sending pointer events to |window|. This does not remove the entry | 155 // Stops sending pointer events to |window|. This does not remove the entry |
147 // for |window| from |pointer_targets_|, rather it nulls out the window. This | 156 // for |window| from |pointer_targets_|, rather it nulls out the window. This |
148 // way we continue to eat events until the up/cancel is received. | 157 // way we continue to eat events until the up/cancel is received. |
149 void CancelPointerEventsToTarget(ServerWindow* window); | 158 void CancelPointerEventsToTarget(ServerWindow* window); |
150 | 159 |
151 // Returns true if we're currently an observer for |window|. We are an | 160 // Used to observe a window. Can be called multiple times on a window. To |
152 // observer for a window if any pointer events are targeting it. | 161 // unobserve a window, UnobserveWindow() should be called the same number of |
153 bool IsObservingWindow(ServerWindow* window); | 162 // times. |
| 163 void ObserveWindow(ServerWindow* winodw); |
| 164 void UnobserveWindow(ServerWindow* winodw); |
154 | 165 |
155 // Returns an Accelerator bound to the specified code/flags, and of the | 166 // Returns an Accelerator bound to the specified code/flags, and of the |
156 // matching |phase|. Otherwise returns null. | 167 // matching |phase|. Otherwise returns null. |
157 Accelerator* FindAccelerator(const ui::KeyEvent& event, | 168 Accelerator* FindAccelerator(const ui::KeyEvent& event, |
158 const mojom::AcceleratorPhase phase); | 169 const mojom::AcceleratorPhase phase); |
159 | 170 |
160 // ServerWindowObserver: | 171 // ServerWindowObserver: |
161 void OnWillChangeWindowHierarchy(ServerWindow* window, | 172 void OnWillChangeWindowHierarchy(ServerWindow* window, |
162 ServerWindow* new_parent, | 173 ServerWindow* new_parent, |
163 ServerWindow* old_parent) override; | 174 ServerWindow* old_parent) override; |
164 void OnWindowVisibilityChanged(ServerWindow* window) override; | 175 void OnWindowVisibilityChanged(ServerWindow* window) override; |
165 void OnWindowDestroyed(ServerWindow* window) override; | 176 void OnWindowDestroyed(ServerWindow* window) override; |
166 | 177 |
167 EventDispatcherDelegate* delegate_; | 178 EventDispatcherDelegate* delegate_; |
168 ServerWindow* root_; | 179 ServerWindow* root_; |
| 180 |
169 ServerWindow* capture_window_; | 181 ServerWindow* capture_window_; |
| 182 bool capture_window_in_nonclient_area_; |
170 | 183 |
171 bool capture_window_in_nonclient_area_; | 184 ServerWindow* system_modal_window_; |
| 185 |
172 bool mouse_button_down_; | 186 bool mouse_button_down_; |
173 ServerWindow* mouse_cursor_source_window_; | 187 ServerWindow* mouse_cursor_source_window_; |
174 | 188 |
175 // The on screen location of the mouse pointer. This can be outside the | 189 // The on screen location of the mouse pointer. This can be outside the |
176 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. | 190 // bounds of |mouse_cursor_source_window_|, which can capture the cursor. |
177 gfx::Point mouse_pointer_last_location_; | 191 gfx::Point mouse_pointer_last_location_; |
178 | 192 |
179 cc::SurfaceId surface_id_; | 193 cc::SurfaceId surface_id_; |
180 | 194 |
181 using Entry = std::pair<uint32_t, scoped_ptr<Accelerator>>; | 195 using Entry = std::pair<uint32_t, scoped_ptr<Accelerator>>; |
182 std::map<uint32_t, scoped_ptr<Accelerator>> accelerators_; | 196 std::map<uint32_t, scoped_ptr<Accelerator>> accelerators_; |
183 | 197 |
184 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; | 198 using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; |
185 // |pointer_targets_| contains the active pointers. For a mouse based pointer | 199 // |pointer_targets_| contains the active pointers. For a mouse based pointer |
186 // a PointerTarget is always active (and present in |pointer_targets_|). For | 200 // a PointerTarget is always active (and present in |pointer_targets_|). For |
187 // touch based pointers the pointer is active while down and removed on | 201 // touch based pointers the pointer is active while down and removed on |
188 // cancel or up. | 202 // cancel or up. |
189 PointerIdToTargetMap pointer_targets_; | 203 PointerIdToTargetMap pointer_targets_; |
190 | 204 |
| 205 // Keeps track of number of observe requests for observed windows. |
| 206 std::map<const ServerWindow*, uint8_t> observed_windows_; |
| 207 |
191 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); | 208 DISALLOW_COPY_AND_ASSIGN(EventDispatcher); |
192 }; | 209 }; |
193 | 210 |
194 } // namespace ws | 211 } // namespace ws |
195 } // namespace mus | 212 } // namespace mus |
196 | 213 |
197 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ | 214 #endif // COMPONENTS_MUS_WS_EVENT_DISPATCHER_H_ |
OLD | NEW |