Index: services/ui/ws/window_manager_state.cc |
diff --git a/services/ui/ws/window_manager_state.cc b/services/ui/ws/window_manager_state.cc |
index d9b9ed52c760fc9feb2932ce2b94462aeabe3a55..10de4a173f6eb76a02af581b99c2d45856ab563e 100644 |
--- a/services/ui/ws/window_manager_state.cc |
+++ b/services/ui/ws/window_manager_state.cc |
@@ -18,6 +18,7 @@ |
#include "services/ui/ws/server_window.h" |
#include "services/ui/ws/user_display_manager.h" |
#include "services/ui/ws/user_id_tracker.h" |
+#include "services/ui/ws/window_coordinate_conversions.h" |
#include "services/ui/ws/window_manager_display_root.h" |
#include "services/ui/ws/window_server.h" |
#include "services/ui/ws/window_tree.h" |
@@ -581,12 +582,31 @@ void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, |
const ui::Event& event, |
Accelerator* accelerator) { |
DCHECK(IsActive()); |
+ |
+ std::unique_ptr<ui::Event> clone = ui::Event::Clone(event); |
+ // Convert the root_location of this |event| to be from the coordinate system |
+ // of the root window of the |window_tree_| to the coordinate system of the |
+ // root_window of the window tree associated with this |client_id|. |
+ if (client_id != window_tree_->id() && event.IsLocatedEvent()) { |
+ WindowTree* target_tree = window_server()->GetTreeWithId(client_id); |
+ DCHECK_GE(window_tree_->roots().size(), 1u); |
+ DCHECK_GE(target_tree->roots().size(), 1u); |
+ const ServerWindow* wm_root = window_tree_->FindRootFor(target); |
+ const ServerWindow* target_root = target_tree->FindRootFor(target); |
+ DCHECK(wm_root); |
+ DCHECK(target_root); |
+ DCHECK(wm_root->Contains(target_root)); |
+ gfx::Point new_root_location = ConvertPointBetweenWindows( |
+ wm_root, target_root, event.AsLocatedEvent()->root_location()); |
+ clone->AsLocatedEvent()->set_root_location(new_root_location); |
+ } |
+ |
// TODO(sky): this needs to see if another wms has capture and if so forward |
// to it. |
if (in_flight_event_details_) { |
std::unique_ptr<ProcessedEventTarget> processed_event_target( |
new ProcessedEventTarget(target, client_id, accelerator)); |
- QueueEvent(event, std::move(processed_event_target), |
+ QueueEvent(*clone, std::move(processed_event_target), |
event_processing_display_id_); |
return; |
} |
@@ -594,7 +614,7 @@ void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, |
base::WeakPtr<Accelerator> weak_accelerator; |
if (accelerator) |
weak_accelerator = accelerator->GetWeakPtr(); |
- DispatchInputEventToWindowImpl(target, client_id, event, weak_accelerator); |
+ DispatchInputEventToWindowImpl(target, client_id, *clone, weak_accelerator); |
} |
ClientSpecificId WindowManagerState::GetEventTargetClientId( |