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 #include "services/ui/ws/event_dispatcher.h" | 5 #include "services/ui/ws/event_dispatcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "services/ui/ws/accelerator.h" | 10 #include "services/ui/ws/accelerator.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 | 46 |
47 for (const auto& rect : target->additional_client_areas()) { | 47 for (const auto& rect : target->additional_client_areas()) { |
48 if (rect.Contains(location)) | 48 if (rect.Contains(location)) |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 uint32_t PointerId(const ui::LocatedEvent& event) { | 55 uint32_t PointerId(const ui::LocatedEvent& event) { |
56 if (event.IsPointerEvent()) | 56 DCHECK(event.IsPointerEvent()); |
57 return event.AsPointerEvent()->pointer_id(); | 57 return event.AsPointerEvent()->pointer_id(); |
58 if (event.IsMouseWheelEvent()) | |
59 return ui::PointerEvent::kMousePointerId; | |
60 | |
61 NOTREACHED(); | |
62 return 0; | |
63 } | 58 } |
64 | 59 |
65 } // namespace | 60 } // namespace |
66 | 61 |
67 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
68 | 63 |
69 EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate) | 64 EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate) |
70 : delegate_(delegate), | 65 : delegate_(delegate), |
71 capture_window_(nullptr), | 66 capture_window_(nullptr), |
72 capture_window_client_id_(kInvalidClientId), | 67 capture_window_client_id_(kInvalidClientId), |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 delegate_->OnAccelerator( | 275 delegate_->OnAccelerator( |
281 pre_target->id(), event, | 276 pre_target->id(), event, |
282 EventDispatcherDelegate::AcceleratorPhase::PRE); | 277 EventDispatcherDelegate::AcceleratorPhase::PRE); |
283 return; | 278 return; |
284 } | 279 } |
285 } | 280 } |
286 ProcessKeyEvent(*key_event, match_phase); | 281 ProcessKeyEvent(*key_event, match_phase); |
287 return; | 282 return; |
288 } | 283 } |
289 | 284 |
290 if (event.IsPointerEvent() || event.IsMouseWheelEvent()) { | 285 if (event.IsPointerEvent()) { |
291 ProcessLocatedEvent(*event.AsLocatedEvent()); | 286 ProcessLocatedEvent(*event.AsLocatedEvent()); |
292 return; | 287 return; |
293 } | 288 } |
294 | 289 |
295 NOTREACHED(); | 290 NOTREACHED(); |
296 } | 291 } |
297 | 292 |
298 void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event, | 293 void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event, |
299 AcceleratorMatchPhase match_phase) { | 294 AcceleratorMatchPhase match_phase) { |
300 Accelerator* post_target = | 295 Accelerator* post_target = |
301 FindAccelerator(event, ui::mojom::AcceleratorPhase::POST_TARGET); | 296 FindAccelerator(event, ui::mojom::AcceleratorPhase::POST_TARGET); |
302 ServerWindow* focused_window = | 297 ServerWindow* focused_window = |
303 delegate_->GetFocusedWindowForEventDispatcher(); | 298 delegate_->GetFocusedWindowForEventDispatcher(); |
304 if (focused_window) { | 299 if (focused_window) { |
305 // Assume key events are for the client area. | 300 // Assume key events are for the client area. |
306 const bool in_nonclient_area = false; | 301 const bool in_nonclient_area = false; |
307 const ClientSpecificId client_id = | 302 const ClientSpecificId client_id = |
308 delegate_->GetEventTargetClientId(focused_window, in_nonclient_area); | 303 delegate_->GetEventTargetClientId(focused_window, in_nonclient_area); |
309 delegate_->DispatchInputEventToWindow(focused_window, client_id, event, | 304 delegate_->DispatchInputEventToWindow(focused_window, client_id, event, |
310 post_target); | 305 post_target); |
311 return; | 306 return; |
312 } | 307 } |
313 delegate_->OnEventTargetNotFound(event); | 308 delegate_->OnEventTargetNotFound(event); |
314 if (post_target) | 309 if (post_target) |
315 delegate_->OnAccelerator(post_target->id(), event, | 310 delegate_->OnAccelerator(post_target->id(), event, |
316 EventDispatcherDelegate::AcceleratorPhase::POST); | 311 EventDispatcherDelegate::AcceleratorPhase::POST); |
317 } | 312 } |
318 | 313 |
319 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { | 314 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { |
sadrul
2016/08/19 04:18:27
May we can now call this ProcessPointerEvent(const
riajiang
2016/08/19 16:19:39
Right now ScrollEvent is handled by MouseWheelEven
sadrul
2016/08/19 16:38:58
Yes. ScrollEvents should be treated identically to
| |
320 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); | 315 // TODO(moshayedi): crbug.com/602859. Handle scroll events as |
321 const bool is_mouse_event = | 316 // they are once we have proper support for scroll events. |
322 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); | 317 DCHECK(event.IsPointerEvent()); |
318 const bool is_mouse_event = event.IsMousePointerEvent(); | |
323 | 319 |
324 if (is_mouse_event) { | 320 if (is_mouse_event) { |
325 mouse_pointer_last_location_ = event.root_location(); | 321 mouse_pointer_last_location_ = event.root_location(); |
326 delegate_->OnMouseCursorLocationChanged(event.root_location()); | 322 delegate_->OnMouseCursorLocationChanged(event.root_location()); |
327 } | 323 } |
328 | 324 |
329 // Release capture on pointer up. For mouse we only release if there are | 325 // Release capture on pointer up. For mouse we only release if there are |
330 // no buttons down. | 326 // no buttons down. |
331 const bool is_pointer_going_up = | 327 const bool is_pointer_going_up = |
332 (event.type() == ui::ET_POINTER_UP || | 328 (event.type() == ui::ET_POINTER_UP || |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 | 566 |
571 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 567 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
572 CancelPointerEventsToTarget(window); | 568 CancelPointerEventsToTarget(window); |
573 | 569 |
574 if (mouse_cursor_source_window_ == window) | 570 if (mouse_cursor_source_window_ == window) |
575 mouse_cursor_source_window_ = nullptr; | 571 mouse_cursor_source_window_ = nullptr; |
576 } | 572 } |
577 | 573 |
578 } // namespace ws | 574 } // namespace ws |
579 } // namespace ui | 575 } // namespace ui |
OLD | NEW |