Chromium Code Reviews| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "services/service_manager/public/interfaces/connector.mojom.h" | 11 #include "services/service_manager/public/interfaces/connector.mojom.h" |
| 12 #include "services/ui/common/accelerator_util.h" | 12 #include "services/ui/common/accelerator_util.h" |
| 13 #include "services/ui/ws/accelerator.h" | 13 #include "services/ui/ws/accelerator.h" |
| 14 #include "services/ui/ws/cursor_location_manager.h" | 14 #include "services/ui/ws/cursor_location_manager.h" |
| 15 #include "services/ui/ws/display.h" | 15 #include "services/ui/ws/display.h" |
| 16 #include "services/ui/ws/display_manager.h" | 16 #include "services/ui/ws/display_manager.h" |
| 17 #include "services/ui/ws/platform_display.h" | 17 #include "services/ui/ws/platform_display.h" |
| 18 #include "services/ui/ws/server_window.h" | 18 #include "services/ui/ws/server_window.h" |
| 19 #include "services/ui/ws/user_display_manager.h" | 19 #include "services/ui/ws/user_display_manager.h" |
| 20 #include "services/ui/ws/user_id_tracker.h" | 20 #include "services/ui/ws/user_id_tracker.h" |
| 21 #include "services/ui/ws/window_coordinate_conversions.h" | |
| 21 #include "services/ui/ws/window_manager_display_root.h" | 22 #include "services/ui/ws/window_manager_display_root.h" |
| 22 #include "services/ui/ws/window_server.h" | 23 #include "services/ui/ws/window_server.h" |
| 23 #include "services/ui/ws/window_tree.h" | 24 #include "services/ui/ws/window_tree.h" |
| 24 #include "ui/events/event.h" | 25 #include "ui/events/event.h" |
| 25 | 26 |
| 26 namespace ui { | 27 namespace ui { |
| 27 namespace ws { | 28 namespace ws { |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // Flags that matter when checking if a key event matches an accelerator. | 31 // Flags that matter when checking if a key event matches an accelerator. |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 ->display_manager() | 575 ->display_manager() |
| 575 ->GetCursorLocationManager(user_id()) | 576 ->GetCursorLocationManager(user_id()) |
| 576 ->OnMouseCursorLocationChanged(point); | 577 ->OnMouseCursorLocationChanged(point); |
| 577 } | 578 } |
| 578 | 579 |
| 579 void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, | 580 void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, |
| 580 ClientSpecificId client_id, | 581 ClientSpecificId client_id, |
| 581 const ui::Event& event, | 582 const ui::Event& event, |
| 582 Accelerator* accelerator) { | 583 Accelerator* accelerator) { |
| 583 DCHECK(IsActive()); | 584 DCHECK(IsActive()); |
| 585 | |
| 586 std::unique_ptr<ui::Event> clone = ui::Event::Clone(event); | |
| 587 // Convert the root_location of this |event| to be from the coordinate system | |
| 588 // of the root window of the |window_tree_| to the coordinate system of the | |
| 589 // root_window of the window tree associated with this |client_id|. | |
| 590 if (client_id != window_tree_->id() && event.IsLocatedEvent()) { | |
| 591 WindowTree* target_tree = window_server()->GetTreeWithId(client_id); | |
| 592 CHECK_LE(1u, window_tree_->roots().size()); | |
| 593 CHECK_LE(1u, target_tree->roots().size()); | |
|
sadrul
2017/03/14 16:08:32
DCHECK_GE
riajiang
2017/03/14 19:03:26
Done.
| |
| 594 const ServerWindow* window_tree_root = *window_tree_->roots().begin(); | |
| 595 const ServerWindow* target_window_tree_root = *target_tree->roots().begin(); | |
|
sadrul
2017/03/14 16:08:32
I don't think these will always give you the right
riajiang
2017/03/14 19:03:26
Done.
| |
| 596 gfx::Point new_root_location = | |
| 597 ConvertPointBetweenWindows(window_tree_root, target_window_tree_root, | |
| 598 event.AsLocatedEvent()->root_location()); | |
| 599 clone->AsLocatedEvent()->set_root_location(new_root_location); | |
| 600 } | |
| 601 | |
| 584 // TODO(sky): this needs to see if another wms has capture and if so forward | 602 // TODO(sky): this needs to see if another wms has capture and if so forward |
| 585 // to it. | 603 // to it. |
| 586 if (in_flight_event_details_) { | 604 if (in_flight_event_details_) { |
| 587 std::unique_ptr<ProcessedEventTarget> processed_event_target( | 605 std::unique_ptr<ProcessedEventTarget> processed_event_target( |
| 588 new ProcessedEventTarget(target, client_id, accelerator)); | 606 new ProcessedEventTarget(target, client_id, accelerator)); |
| 589 QueueEvent(event, std::move(processed_event_target), | 607 QueueEvent(*clone, std::move(processed_event_target), |
| 590 event_processing_display_id_); | 608 event_processing_display_id_); |
| 591 return; | 609 return; |
| 592 } | 610 } |
| 593 | 611 |
| 594 base::WeakPtr<Accelerator> weak_accelerator; | 612 base::WeakPtr<Accelerator> weak_accelerator; |
| 595 if (accelerator) | 613 if (accelerator) |
| 596 weak_accelerator = accelerator->GetWeakPtr(); | 614 weak_accelerator = accelerator->GetWeakPtr(); |
| 597 DispatchInputEventToWindowImpl(target, client_id, event, weak_accelerator); | 615 DispatchInputEventToWindowImpl(target, client_id, *clone, weak_accelerator); |
| 598 } | 616 } |
| 599 | 617 |
| 600 ClientSpecificId WindowManagerState::GetEventTargetClientId( | 618 ClientSpecificId WindowManagerState::GetEventTargetClientId( |
| 601 const ServerWindow* window, | 619 const ServerWindow* window, |
| 602 bool in_nonclient_area) { | 620 bool in_nonclient_area) { |
| 603 if (in_nonclient_area) { | 621 if (in_nonclient_area) { |
| 604 // Events in the non-client area always go to the window manager. | 622 // Events in the non-client area always go to the window manager. |
| 605 return window_tree_->id(); | 623 return window_tree_->id(); |
| 606 } | 624 } |
| 607 | 625 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 window->RemoveObserver(this); | 687 window->RemoveObserver(this); |
| 670 orphaned_window_manager_display_roots_.erase(iter); | 688 orphaned_window_manager_display_roots_.erase(iter); |
| 671 return; | 689 return; |
| 672 } | 690 } |
| 673 } | 691 } |
| 674 NOTREACHED(); | 692 NOTREACHED(); |
| 675 } | 693 } |
| 676 | 694 |
| 677 } // namespace ws | 695 } // namespace ws |
| 678 } // namespace ui | 696 } // namespace ui |
| OLD | NEW |