OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/host/ash_window_tree_host.h" | 5 #include "ash/host/ash_window_tree_host.h" |
6 | 6 |
7 #include "ui/aura/client/screen_position_client.h" | 7 #include "ui/aura/client/screen_position_client.h" |
8 #include "ui/aura/window_tree_host.h" | 8 #include "ui/aura/window_tree_host.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
11 | 11 |
12 namespace ash { | 12 namespace ash { |
13 | 13 |
14 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) { | 14 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) { |
15 if (event->IsTouchEvent()) | 15 if (event->IsTouchEvent()) |
16 return; | 16 return; |
17 | 17 |
18 aura::WindowTreeHost* wth = AsWindowTreeHost(); | 18 aura::WindowTreeHost* wth = AsWindowTreeHost(); |
19 aura::Window* root_window = wth->window(); | 19 aura::Window* root_window = wth->window(); |
20 aura::client::ScreenPositionClient* screen_position_client = | 20 aura::client::ScreenPositionClient* screen_position_client = |
21 aura::client::GetScreenPositionClient(root_window); | 21 aura::client::GetScreenPositionClient(root_window); |
22 gfx::Rect local(wth->GetBounds().size()); | 22 gfx::Rect local(wth->GetBounds().size()); |
23 local.Inset(GetHostInsets()); | 23 local.Inset(GetHostInsets()); |
24 | 24 |
25 if (screen_position_client && !local.Contains(event->location())) { | 25 if (screen_position_client && !local.Contains(event->location())) { |
26 gfx::Point location(event->location()); | 26 gfx::Point location(event->location()); |
27 // In order to get the correct point in screen coordinates | 27 // In order to get the correct point in screen coordinates |
28 // during passive grab, we first need to find on which host window | 28 // during passive grab, we first need to find on which host window |
29 // the mouse is on, and find out the screen coordinates on that | 29 // the mouse is on, and find out the screen coordinates on that |
30 // host window, then convert it back to this host window's coordinate. | 30 // host window, then convert it back to this host window's coordinate. |
31 screen_position_client->ConvertHostPointToScreen(root_window, &location); | 31 screen_position_client->ConvertHostPointToScreen(root_window, &location); |
32 screen_position_client->ConvertPointFromScreen(root_window, &location); | 32 screen_position_client->ConvertPointFromScreen(root_window, &location); |
33 wth->ConvertPointToHost(&location); | 33 wth->ConvertPointToHost(&location); |
34 event->set_location(location); | 34 event->set_location(location); |
35 event->set_root_location(location); | 35 event->set_root_location(location); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 } // namespace ash | 39 } // namespace ash |
OLD | NEW |