| 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 "components/mus/ws/event_dispatcher.h" | 5 #include "components/mus/ws/event_dispatcher.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "cc/surfaces/surface_hittest.h" | 10 #include "cc/surfaces/surface_hittest.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 StopTrackingPointer(pointer_targets_.begin()->first); | 101 StopTrackingPointer(pointer_targets_.begin()->first); |
| 102 | 102 |
| 103 mouse_button_down_ = false; | 103 mouse_button_down_ = false; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void EventDispatcher::SetMousePointerScreenLocation( | 106 void EventDispatcher::SetMousePointerScreenLocation( |
| 107 const gfx::Point& screen_location) { | 107 const gfx::Point& screen_location) { |
| 108 DCHECK(pointer_targets_.empty()); | 108 DCHECK(pointer_targets_.empty()); |
| 109 mouse_pointer_last_location_ = screen_location; | 109 mouse_pointer_last_location_ = screen_location; |
| 110 UpdateCursorProviderByLastKnownLocation(); | 110 UpdateCursorProviderByLastKnownLocation(); |
| 111 // Write our initial location back to our shared screen coordinate. This |
| 112 // shouldn't cause problems because we already read the cursor before we |
| 113 // process any events in views during window construction. |
| 114 delegate_->OnMouseCursorLocationChanged(screen_location); |
| 111 } | 115 } |
| 112 | 116 |
| 113 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, | 117 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, |
| 114 bool in_nonclient_area) { | 118 bool in_nonclient_area) { |
| 115 if (window == capture_window_) | 119 if (window == capture_window_) |
| 116 return true; | 120 return true; |
| 117 | 121 |
| 118 // A window that is blocked by a modal window cannot gain capture. | 122 // A window that is blocked by a modal window cannot gain capture. |
| 119 if (window && window->IsBlockedByModalWindow()) | 123 if (window && window->IsBlockedByModalWindow()) |
| 120 return false; | 124 return false; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 delegate_->OnEventTargetNotFound(event); | 238 delegate_->OnEventTargetNotFound(event); |
| 235 if (post_target) | 239 if (post_target) |
| 236 delegate_->OnAccelerator(post_target->id(), event); | 240 delegate_->OnAccelerator(post_target->id(), event); |
| 237 } | 241 } |
| 238 | 242 |
| 239 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { | 243 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { |
| 240 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); | 244 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); |
| 241 const bool is_mouse_event = | 245 const bool is_mouse_event = |
| 242 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); | 246 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); |
| 243 | 247 |
| 244 if (is_mouse_event) | 248 if (is_mouse_event) { |
| 245 mouse_pointer_last_location_ = event.location(); | 249 mouse_pointer_last_location_ = event.location(); |
| 250 delegate_->OnMouseCursorLocationChanged(event.root_location()); |
| 251 } |
| 246 | 252 |
| 247 // Release capture on pointer up. For mouse we only release if there are | 253 // Release capture on pointer up. For mouse we only release if there are |
| 248 // no buttons down. | 254 // no buttons down. |
| 249 const bool is_pointer_going_up = | 255 const bool is_pointer_going_up = |
| 250 (event.type() == ui::ET_POINTER_UP || | 256 (event.type() == ui::ET_POINTER_UP || |
| 251 event.type() == ui::ET_POINTER_CANCELLED) && | 257 event.type() == ui::ET_POINTER_CANCELLED) && |
| 252 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); | 258 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); |
| 253 | 259 |
| 254 // Update mouse down state upon events which change it. | 260 // Update mouse down state upon events which change it. |
| 255 if (is_mouse_event) { | 261 if (is_mouse_event) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 456 |
| 451 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 457 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
| 452 CancelPointerEventsToTarget(window); | 458 CancelPointerEventsToTarget(window); |
| 453 | 459 |
| 454 if (mouse_cursor_source_window_ == window) | 460 if (mouse_cursor_source_window_ == window) |
| 455 mouse_cursor_source_window_ = nullptr; | 461 mouse_cursor_source_window_ = nullptr; |
| 456 } | 462 } |
| 457 | 463 |
| 458 } // namespace ws | 464 } // namespace ws |
| 459 } // namespace mus | 465 } // namespace mus |
| OLD | NEW |