Chromium Code Reviews| 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 delegate_->OnMouseCursorLocationChanged(screen_location); | |
|
sky
2016/04/27 20:10:28
I worry that the way you have things results in up
| |
| 111 } | 112 } |
| 112 | 113 |
| 113 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, | 114 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, |
| 114 bool in_nonclient_area) { | 115 bool in_nonclient_area) { |
| 115 if (window == capture_window_) | 116 if (window == capture_window_) |
| 116 return true; | 117 return true; |
| 117 | 118 |
| 118 // A window that is blocked by a modal window cannot gain capture. | 119 // A window that is blocked by a modal window cannot gain capture. |
| 119 if (window && window->IsBlockedByModalWindow()) | 120 if (window && window->IsBlockedByModalWindow()) |
| 120 return false; | 121 return false; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 delegate_->OnEventTargetNotFound(event); | 235 delegate_->OnEventTargetNotFound(event); |
| 235 if (post_target) | 236 if (post_target) |
| 236 delegate_->OnAccelerator(post_target->id(), event); | 237 delegate_->OnAccelerator(post_target->id(), event); |
| 237 } | 238 } |
| 238 | 239 |
| 239 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { | 240 void EventDispatcher::ProcessLocatedEvent(const ui::LocatedEvent& event) { |
| 240 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); | 241 DCHECK(event.IsPointerEvent() || event.IsMouseWheelEvent()); |
| 241 const bool is_mouse_event = | 242 const bool is_mouse_event = |
| 242 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); | 243 event.IsMousePointerEvent() || event.IsMouseWheelEvent(); |
| 243 | 244 |
| 244 if (is_mouse_event) | 245 if (is_mouse_event) { |
| 245 mouse_pointer_last_location_ = event.location(); | 246 mouse_pointer_last_location_ = event.location(); |
| 247 delegate_->OnMouseCursorLocationChanged(event.root_location()); | |
| 248 } | |
| 246 | 249 |
| 247 // Release capture on pointer up. For mouse we only release if there are | 250 // Release capture on pointer up. For mouse we only release if there are |
| 248 // no buttons down. | 251 // no buttons down. |
| 249 const bool is_pointer_going_up = | 252 const bool is_pointer_going_up = |
| 250 (event.type() == ui::ET_POINTER_UP || | 253 (event.type() == ui::ET_POINTER_UP || |
| 251 event.type() == ui::ET_POINTER_CANCELLED) && | 254 event.type() == ui::ET_POINTER_CANCELLED) && |
| 252 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); | 255 (!is_mouse_event || IsOnlyOneMouseButtonDown(event.flags())); |
| 253 | 256 |
| 254 // Update mouse down state upon events which change it. | 257 // Update mouse down state upon events which change it. |
| 255 if (is_mouse_event) { | 258 if (is_mouse_event) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 | 453 |
| 451 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 454 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
| 452 CancelPointerEventsToTarget(window); | 455 CancelPointerEventsToTarget(window); |
| 453 | 456 |
| 454 if (mouse_cursor_source_window_ == window) | 457 if (mouse_cursor_source_window_ == window) |
| 455 mouse_cursor_source_window_ = nullptr; | 458 mouse_cursor_source_window_ = nullptr; |
| 456 } | 459 } |
| 457 | 460 |
| 458 } // namespace ws | 461 } // namespace ws |
| 459 } // namespace mus | 462 } // namespace mus |
| OLD | NEW |