| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/window_manager_state.h" | 5 #include "services/ui/ws/window_manager_state.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "services/shell/public/interfaces/connector.mojom.h" | 10 #include "services/shell/public/interfaces/connector.mojom.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 drag_source, window, source_connection, drag_pointer, | 182 drag_source, window, source_connection, drag_pointer, |
| 183 std::move(drag_data), drag_operation); | 183 std::move(drag_data), drag_operation); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void WindowManagerState::CancelDragDrop() { | 186 void WindowManagerState::CancelDragDrop() { |
| 187 event_dispatcher_.CancelDragDrop(); | 187 event_dispatcher_.CancelDragDrop(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void WindowManagerState::EndDragDrop() { | 190 void WindowManagerState::EndDragDrop() { |
| 191 event_dispatcher_.EndDragDrop(); | 191 event_dispatcher_.EndDragDrop(); |
| 192 UpdateNativeCursorFromDispatcher(); |
| 192 } | 193 } |
| 193 | 194 |
| 194 void WindowManagerState::AddSystemModalWindow(ServerWindow* window) { | 195 void WindowManagerState::AddSystemModalWindow(ServerWindow* window) { |
| 195 DCHECK(!window->transient_parent()); | 196 DCHECK(!window->transient_parent()); |
| 196 event_dispatcher_.AddSystemModalWindow(window); | 197 event_dispatcher_.AddSystemModalWindow(window); |
| 197 } | 198 } |
| 198 | 199 |
| 199 const UserId& WindowManagerState::user_id() const { | 200 const UserId& WindowManagerState::user_id() const { |
| 200 return window_tree_->user_id(); | 201 return window_tree_->user_id(); |
| 201 } | 202 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 void WindowManagerState::DispatchInputEventToWindowImpl( | 407 void WindowManagerState::DispatchInputEventToWindowImpl( |
| 407 ServerWindow* target, | 408 ServerWindow* target, |
| 408 ClientSpecificId client_id, | 409 ClientSpecificId client_id, |
| 409 const ui::Event& event, | 410 const ui::Event& event, |
| 410 base::WeakPtr<Accelerator> accelerator) { | 411 base::WeakPtr<Accelerator> accelerator) { |
| 411 if (target && target->parent() == nullptr) | 412 if (target && target->parent() == nullptr) |
| 412 target = GetWindowManagerRoot(target); | 413 target = GetWindowManagerRoot(target); |
| 413 | 414 |
| 414 if (event.IsMousePointerEvent()) { | 415 if (event.IsMousePointerEvent()) { |
| 415 DCHECK(event_dispatcher_.mouse_cursor_source_window()); | 416 DCHECK(event_dispatcher_.mouse_cursor_source_window()); |
| 416 | 417 UpdateNativeCursorFromDispatcher(); |
| 417 int32_t cursor_id = 0; | |
| 418 if (event_dispatcher_.GetCurrentMouseCursor(&cursor_id)) { | |
| 419 WindowManagerDisplayRoot* display_root = | |
| 420 display_manager()->GetWindowManagerDisplayRoot(target); | |
| 421 display_root->display()->UpdateNativeCursor(cursor_id); | |
| 422 } | |
| 423 } | 418 } |
| 424 | 419 |
| 425 event_dispatch_phase_ = EventDispatchPhase::TARGET; | 420 event_dispatch_phase_ = EventDispatchPhase::TARGET; |
| 426 | 421 |
| 427 WindowTree* tree = window_server()->GetTreeWithId(client_id); | 422 WindowTree* tree = window_server()->GetTreeWithId(client_id); |
| 428 DCHECK(tree); | 423 DCHECK(tree); |
| 429 ScheduleInputEventTimeout(tree); | 424 ScheduleInputEventTimeout(tree); |
| 430 | 425 |
| 431 event_awaiting_input_ack_ = ui::Event::Clone(event); | 426 event_awaiting_input_ack_ = ui::Event::Clone(event); |
| 432 | 427 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 void WindowManagerState::ReleaseNativeCapture() { | 519 void WindowManagerState::ReleaseNativeCapture() { |
| 525 // Tests trigger calling this without a corresponding SetNativeCapture(). | 520 // Tests trigger calling this without a corresponding SetNativeCapture(). |
| 526 // TODO(sky): maybe abstract this away so that DCHECK can be added? | 521 // TODO(sky): maybe abstract this away so that DCHECK can be added? |
| 527 if (!platform_display_with_capture_) | 522 if (!platform_display_with_capture_) |
| 528 return; | 523 return; |
| 529 | 524 |
| 530 platform_display_with_capture_->ReleaseCapture(); | 525 platform_display_with_capture_->ReleaseCapture(); |
| 531 platform_display_with_capture_ = nullptr; | 526 platform_display_with_capture_ = nullptr; |
| 532 } | 527 } |
| 533 | 528 |
| 529 void WindowManagerState::UpdateNativeCursorFromDispatcher() { |
| 530 int32_t cursor_id = 0; |
| 531 if (event_dispatcher_.GetCurrentMouseCursor(&cursor_id)) { |
| 532 for (Display* display : display_manager()->displays()) |
| 533 display->UpdateNativeCursor(cursor_id); |
| 534 } |
| 535 } |
| 536 |
| 534 void WindowManagerState::OnCaptureChanged(ServerWindow* new_capture, | 537 void WindowManagerState::OnCaptureChanged(ServerWindow* new_capture, |
| 535 ServerWindow* old_capture) { | 538 ServerWindow* old_capture) { |
| 536 window_server()->ProcessCaptureChanged(new_capture, old_capture); | 539 window_server()->ProcessCaptureChanged(new_capture, old_capture); |
| 537 } | 540 } |
| 538 | 541 |
| 539 void WindowManagerState::OnMouseCursorLocationChanged(const gfx::Point& point) { | 542 void WindowManagerState::OnMouseCursorLocationChanged(const gfx::Point& point) { |
| 540 window_server() | 543 window_server() |
| 541 ->display_manager() | 544 ->display_manager() |
| 542 ->GetUserDisplayManager(user_id()) | 545 ->GetUserDisplayManager(user_id()) |
| 543 ->OnMouseCursorLocationChanged(point); | 546 ->OnMouseCursorLocationChanged(point); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 window->RemoveObserver(this); | 635 window->RemoveObserver(this); |
| 633 orphaned_window_manager_display_roots_.erase(iter); | 636 orphaned_window_manager_display_roots_.erase(iter); |
| 634 return; | 637 return; |
| 635 } | 638 } |
| 636 } | 639 } |
| 637 NOTREACHED(); | 640 NOTREACHED(); |
| 638 } | 641 } |
| 639 | 642 |
| 640 } // namespace ws | 643 } // namespace ws |
| 641 } // namespace ui | 644 } // namespace ui |
| OLD | NEW |