| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 ui::EventType event_type = pair.second.is_mouse_event | 150 ui::EventType event_type = pair.second.is_mouse_event |
| 151 ? ui::ET_POINTER_EXITED | 151 ? ui::ET_POINTER_EXITED |
| 152 : ui::ET_POINTER_CANCELLED; | 152 : ui::ET_POINTER_CANCELLED; |
| 153 ui::EventPointerType pointer_type = | 153 ui::EventPointerType pointer_type = |
| 154 pair.second.is_mouse_event ? ui::EventPointerType::POINTER_TYPE_MOUSE | 154 pair.second.is_mouse_event ? ui::EventPointerType::POINTER_TYPE_MOUSE |
| 155 : ui::EventPointerType::POINTER_TYPE_TOUCH; | 155 : ui::EventPointerType::POINTER_TYPE_TOUCH; |
| 156 // TODO(jonross): Track previous location in PointerTarget for sending | 156 // TODO(jonross): Track previous location in PointerTarget for sending |
| 157 // cancels. | 157 // cancels. |
| 158 ui::PointerEvent event( | 158 ui::PointerEvent event( |
| 159 event_type, gfx::Point(), gfx::Point(), ui::EF_NONE, pair.first, | 159 event_type, gfx::Point(), gfx::Point(), ui::EF_NONE, pair.first, |
| 160 ui::PointerDetails(pointer_type), ui::EventTimeForNow()); | 160 0 /* changed_button_flags */, ui::PointerDetails(pointer_type), |
| 161 ui::EventTimeForNow()); |
| 161 DispatchToPointerTarget(pair.second, event); | 162 DispatchToPointerTarget(pair.second, event); |
| 162 } | 163 } |
| 163 pointer_targets_.clear(); | 164 pointer_targets_.clear(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 // Set the capture before changing native capture; otherwise, the callback | 167 // Set the capture before changing native capture; otherwise, the callback |
| 167 // from native platform might try to set the capture again. | 168 // from native platform might try to set the capture again. |
| 168 const bool had_capture_window = capture_window_ != nullptr; | 169 const bool had_capture_window = capture_window_ != nullptr; |
| 169 ServerWindow* old_capture_window = capture_window_; | 170 ServerWindow* old_capture_window = capture_window_; |
| 170 capture_window_ = window; | 171 capture_window_ = window; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 if (pointer_target.is_pointer_down) | 419 if (pointer_target.is_pointer_down) |
| 419 pointer_targets_[pointer_id].is_pointer_down = true; | 420 pointer_targets_[pointer_id].is_pointer_down = true; |
| 420 return; | 421 return; |
| 421 } | 422 } |
| 422 | 423 |
| 423 // The targets are changing. Send an exit if appropriate. | 424 // The targets are changing. Send an exit if appropriate. |
| 424 if (event.IsMousePointerEvent()) { | 425 if (event.IsMousePointerEvent()) { |
| 425 ui::PointerEvent exit_event( | 426 ui::PointerEvent exit_event( |
| 426 ui::ET_POINTER_EXITED, event.location(), event.root_location(), | 427 ui::ET_POINTER_EXITED, event.location(), event.root_location(), |
| 427 event.flags(), ui::PointerEvent::kMousePointerId, | 428 event.flags(), ui::PointerEvent::kMousePointerId, |
| 429 0 /* changed_button_flags */, |
| 428 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE), | 430 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE), |
| 429 event.time_stamp()); | 431 event.time_stamp()); |
| 430 DispatchToPointerTarget(pointer_targets_[pointer_id], exit_event); | 432 DispatchToPointerTarget(pointer_targets_[pointer_id], exit_event); |
| 431 } | 433 } |
| 432 | 434 |
| 433 // Technically we're updating in place, but calling start then stop makes for | 435 // Technically we're updating in place, but calling start then stop makes for |
| 434 // simpler code. | 436 // simpler code. |
| 435 StopTrackingPointer(pointer_id); | 437 StopTrackingPointer(pointer_id); |
| 436 StartTrackingPointer(pointer_id, pointer_target); | 438 StartTrackingPointer(pointer_id, pointer_target); |
| 437 } | 439 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 572 |
| 571 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 573 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
| 572 CancelPointerEventsToTarget(window); | 574 CancelPointerEventsToTarget(window); |
| 573 | 575 |
| 574 if (mouse_cursor_source_window_ == window) | 576 if (mouse_cursor_source_window_ == window) |
| 575 mouse_cursor_source_window_ = nullptr; | 577 mouse_cursor_source_window_ = nullptr; |
| 576 } | 578 } |
| 577 | 579 |
| 578 } // namespace ws | 580 } // namespace ws |
| 579 } // namespace ui | 581 } // namespace ui |
| OLD | NEW |