| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 delegate_->OnAccelerator(post_target->id(), event, | 313 delegate_->OnAccelerator(post_target->id(), event, |
| 314 EventDispatcherDelegate::AcceleratorPhase::POST); | 314 EventDispatcherDelegate::AcceleratorPhase::POST); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { | 317 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { |
| 318 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); | 318 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); |
| 319 const bool is_mouse_event = | 319 const bool is_mouse_event = |
| 320 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); | 320 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); |
| 321 | 321 |
| 322 if (is_mouse_event) { | 322 if (is_mouse_event) { |
| 323 mouse_pointer_last_location_ = event.location(); | 323 mouse_pointer_last_location_ = event.root_location(); |
| 324 delegate_->OnMouseCursorLocationChanged(event.root_location()); | 324 delegate_->OnMouseCursorLocationChanged(event.root_location()); |
| 325 } | 325 } |
| 326 | 326 |
| 327 // Release capture on pointer up. For mouse we only release if there are | 327 // Release capture on pointer up. For mouse we only release if there are |
| 328 // no buttons down. | 328 // no buttons down. |
| 329 const bool is_pointer_going_up = | 329 const bool is_pointer_going_up = |
| 330 (event.type() == ui::ET_POINTER_UP || | 330 (event.type() == ui::ET_POINTER_UP || |
| 331 event.type() == ui::ET_POINTER_CANCELLED) && | 331 event.type() == ui::ET_POINTER_CANCELLED) && |
| 332 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); | 332 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); |
| 333 | 333 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 430 |
| 431 // Technically we're updating in place, but calling start then stop makes for | 431 // Technically we're updating in place, but calling start then stop makes for |
| 432 // simpler code. | 432 // simpler code. |
| 433 StopTrackingPointer(pointer_id); | 433 StopTrackingPointer(pointer_id); |
| 434 StartTrackingPointer(pointer_id, pointer_target); | 434 StartTrackingPointer(pointer_id, pointer_target); |
| 435 } | 435 } |
| 436 | 436 |
| 437 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( | 437 EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( |
| 438 const ui::LocatedEvent& event) { | 438 const ui::LocatedEvent& event) { |
| 439 PointerTarget pointer_target; | 439 PointerTarget pointer_target; |
| 440 gfx::Point location(event.location()); | 440 gfx::Point location(event.root_location()); |
| 441 ServerWindow* target_window = FindDeepestVisibleWindowForEvents(&location); | 441 ServerWindow* target_window = FindDeepestVisibleWindowForEvents(&location); |
| 442 pointer_target.window = | 442 pointer_target.window = |
| 443 modal_window_controller_.GetTargetForWindow(target_window); | 443 modal_window_controller_.GetTargetForWindow(target_window); |
| 444 pointer_target.is_mouse_event = event.IsMousePointerEvent(); | 444 pointer_target.is_mouse_event = event.IsMousePointerEvent(); |
| 445 pointer_target.in_nonclient_area = | 445 pointer_target.in_nonclient_area = |
| 446 target_window != pointer_target.window || | 446 target_window != pointer_target.window || |
| 447 IsLocationInNonclientArea(pointer_target.window, location); | 447 IsLocationInNonclientArea(pointer_target.window, location); |
| 448 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; | 448 pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; |
| 449 return pointer_target; | 449 return pointer_target; |
| 450 } | 450 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 const ui::mojom::AcceleratorPhase phase) { | 531 const ui::mojom::AcceleratorPhase phase) { |
| 532 for (const auto& pair : accelerators_) { | 532 for (const auto& pair : accelerators_) { |
| 533 if (pair.second->MatchesEvent(event, phase)) | 533 if (pair.second->MatchesEvent(event, phase)) |
| 534 return pair.second.get(); | 534 return pair.second.get(); |
| 535 } | 535 } |
| 536 return nullptr; | 536 return nullptr; |
| 537 } | 537 } |
| 538 | 538 |
| 539 ServerWindow* EventDispatcher::FindDeepestVisibleWindowForEvents( | 539 ServerWindow* EventDispatcher::FindDeepestVisibleWindowForEvents( |
| 540 gfx::Point* location) { | 540 gfx::Point* location) { |
| 541 ServerWindow* root = delegate_->GetRootWindowContaining(*location); | 541 ServerWindow* root = delegate_->GetRootWindowContaining(location); |
| 542 if (!root) | 542 if (!root) |
| 543 return nullptr; | 543 return nullptr; |
| 544 | 544 |
| 545 return ui::ws::FindDeepestVisibleWindowForEvents(root, location); | 545 return ui::ws::FindDeepestVisibleWindowForEvents(root, location); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void EventDispatcher::OnWillChangeWindowHierarchy(ServerWindow* window, | 548 void EventDispatcher::OnWillChangeWindowHierarchy(ServerWindow* window, |
| 549 ServerWindow* new_parent, | 549 ServerWindow* new_parent, |
| 550 ServerWindow* old_parent) { | 550 ServerWindow* old_parent) { |
| 551 // TODO(sky): moving to a different root likely needs to transfer capture. | 551 // TODO(sky): moving to a different root likely needs to transfer capture. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 568 | 568 |
| 569 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 569 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
| 570 CancelPointerEventsToTarget(window); | 570 CancelPointerEventsToTarget(window); |
| 571 | 571 |
| 572 if (mouse_cursor_source_window_ == window) | 572 if (mouse_cursor_source_window_ == window) |
| 573 mouse_cursor_source_window_ = nullptr; | 573 mouse_cursor_source_window_ = nullptr; |
| 574 } | 574 } |
| 575 | 575 |
| 576 } // namespace ws | 576 } // namespace ws |
| 577 } // namespace ui | 577 } // namespace ui |
| OLD | NEW |