| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 DCHECK(pointer_targets_.empty()); | 97 DCHECK(pointer_targets_.empty()); |
| 98 mouse_pointer_last_location_ = screen_location; | 98 mouse_pointer_last_location_ = screen_location; |
| 99 UpdateCursorProviderByLastKnownLocation(); | 99 UpdateCursorProviderByLastKnownLocation(); |
| 100 // Write our initial location back to our shared screen coordinate. This | 100 // Write our initial location back to our shared screen coordinate. This |
| 101 // shouldn't cause problems because we already read the cursor before we | 101 // shouldn't cause problems because we already read the cursor before we |
| 102 // process any events in views during window construction. | 102 // process any events in views during window construction. |
| 103 delegate_->OnMouseCursorLocationChanged(screen_location); | 103 delegate_->OnMouseCursorLocationChanged(screen_location); |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool EventDispatcher::GetCurrentMouseCursor(int32_t* cursor_out) { | 106 bool EventDispatcher::GetCurrentMouseCursor(int32_t* cursor_out) { |
| 107 if (drag_controller_) { |
| 108 *cursor_out = drag_controller_->current_cursor(); |
| 109 return true; |
| 110 } |
| 111 |
| 107 if (!mouse_cursor_source_window_) | 112 if (!mouse_cursor_source_window_) |
| 108 return false; | 113 return false; |
| 109 | 114 |
| 110 *cursor_out = mouse_cursor_in_non_client_area_ | 115 *cursor_out = mouse_cursor_in_non_client_area_ |
| 111 ? mouse_cursor_source_window_->non_client_cursor() | 116 ? mouse_cursor_source_window_->non_client_cursor() |
| 112 : mouse_cursor_source_window_->cursor(); | 117 : mouse_cursor_source_window_->cursor(); |
| 113 return true; | 118 return true; |
| 114 } | 119 } |
| 115 | 120 |
| 116 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, | 121 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 170 |
| 166 void EventDispatcher::SetDragDropSourceWindow( | 171 void EventDispatcher::SetDragDropSourceWindow( |
| 167 DragSource* drag_source, | 172 DragSource* drag_source, |
| 168 ServerWindow* window, | 173 ServerWindow* window, |
| 169 DragTargetConnection* source_connection, | 174 DragTargetConnection* source_connection, |
| 170 int32_t drag_pointer, | 175 int32_t drag_pointer, |
| 171 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, | 176 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, |
| 172 uint32_t drag_operations) { | 177 uint32_t drag_operations) { |
| 173 CancelImplicitCaptureExcept(nullptr); | 178 CancelImplicitCaptureExcept(nullptr); |
| 174 drag_controller_ = base::MakeUnique<DragController>( | 179 drag_controller_ = base::MakeUnique<DragController>( |
| 175 drag_source, window, source_connection, drag_pointer, | 180 this, drag_source, window, source_connection, drag_pointer, |
| 176 std::move(mime_data), drag_operations); | 181 std::move(mime_data), drag_operations); |
| 177 } | 182 } |
| 178 | 183 |
| 179 void EventDispatcher::CancelDragDrop() { | 184 void EventDispatcher::CancelDragDrop() { |
| 180 if (drag_controller_) | 185 if (drag_controller_) |
| 181 drag_controller_->Cancel(); | 186 drag_controller_->Cancel(); |
| 182 } | 187 } |
| 183 | 188 |
| 184 void EventDispatcher::EndDragDrop() { | 189 void EventDispatcher::EndDragDrop() { |
| 185 drag_controller_.reset(); | 190 drag_controller_.reset(); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 CancelPointerEventsToTarget(window); | 610 CancelPointerEventsToTarget(window); |
| 606 } | 611 } |
| 607 | 612 |
| 608 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { | 613 void EventDispatcher::OnWindowDestroyed(ServerWindow* window) { |
| 609 CancelPointerEventsToTarget(window); | 614 CancelPointerEventsToTarget(window); |
| 610 | 615 |
| 611 if (mouse_cursor_source_window_ == window) | 616 if (mouse_cursor_source_window_ == window) |
| 612 mouse_cursor_source_window_ = nullptr; | 617 mouse_cursor_source_window_ = nullptr; |
| 613 } | 618 } |
| 614 | 619 |
| 620 void EventDispatcher::OnDragCursorUpdated() { |
| 621 delegate_->UpdateNativeCursorFromDispatcher(); |
| 622 } |
| 623 |
| 615 } // namespace ws | 624 } // namespace ws |
| 616 } // namespace ui | 625 } // namespace ui |
| OLD | NEW |