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