Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: services/ui/ws/window_manager_state.cc

Issue 2696873002: Change OnWindowInputEvent to use display_id to find the host and update event root_location in WS. (Closed)
Patch Set: nits Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 DCHECK_GE(window_tree_->roots().size(), 1u);
593 DCHECK_GE(target_tree->roots().size(), 1u);
594 const ServerWindow* wm_root = window_tree_->FindRootFor(target);
595 const ServerWindow* target_root = target_tree->FindRootFor(target);
596 DCHECK(wm_root);
597 DCHECK(target_root);
598 DCHECK(wm_root->Contains(target_root));
599 gfx::Point new_root_location = ConvertPointBetweenWindows(
600 wm_root, target_root, event.AsLocatedEvent()->root_location());
601 clone->AsLocatedEvent()->set_root_location(new_root_location);
602 }
603
584 // TODO(sky): this needs to see if another wms has capture and if so forward 604 // TODO(sky): this needs to see if another wms has capture and if so forward
585 // to it. 605 // to it.
586 if (in_flight_event_details_) { 606 if (in_flight_event_details_) {
587 std::unique_ptr<ProcessedEventTarget> processed_event_target( 607 std::unique_ptr<ProcessedEventTarget> processed_event_target(
588 new ProcessedEventTarget(target, client_id, accelerator)); 608 new ProcessedEventTarget(target, client_id, accelerator));
589 QueueEvent(event, std::move(processed_event_target), 609 QueueEvent(*clone, std::move(processed_event_target),
590 event_processing_display_id_); 610 event_processing_display_id_);
591 return; 611 return;
592 } 612 }
593 613
594 base::WeakPtr<Accelerator> weak_accelerator; 614 base::WeakPtr<Accelerator> weak_accelerator;
595 if (accelerator) 615 if (accelerator)
596 weak_accelerator = accelerator->GetWeakPtr(); 616 weak_accelerator = accelerator->GetWeakPtr();
597 DispatchInputEventToWindowImpl(target, client_id, event, weak_accelerator); 617 DispatchInputEventToWindowImpl(target, client_id, *clone, weak_accelerator);
598 } 618 }
599 619
600 ClientSpecificId WindowManagerState::GetEventTargetClientId( 620 ClientSpecificId WindowManagerState::GetEventTargetClientId(
601 const ServerWindow* window, 621 const ServerWindow* window,
602 bool in_nonclient_area) { 622 bool in_nonclient_area) {
603 if (in_nonclient_area) { 623 if (in_nonclient_area) {
604 // Events in the non-client area always go to the window manager. 624 // Events in the non-client area always go to the window manager.
605 return window_tree_->id(); 625 return window_tree_->id();
606 } 626 }
607 627
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 window->RemoveObserver(this); 691 window->RemoveObserver(this);
672 orphaned_window_manager_display_roots_.erase(iter); 692 orphaned_window_manager_display_roots_.erase(iter);
673 return; 693 return;
674 } 694 }
675 } 695 }
676 NOTREACHED(); 696 NOTREACHED();
677 } 697 }
678 698
679 } // namespace ws 699 } // namespace ws
680 } // namespace ui 700 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698