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

Side by Side Diff: ash/host/ash_window_tree_host.cc

Issue 1421713002: Explicitly convert Point to PointF for event code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wip
Patch Set: pointfconvert-prod: . Created 5 years, 2 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 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/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
11 11
12 namespace ash { 12 namespace ash {
13 13
14 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) { 14 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) {
15 } 15 }
16 16
17 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) { 17 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) {
18 if (event->IsTouchEvent()) 18 if (event->IsTouchEvent())
19 return; 19 return;
20 20
21 aura::WindowTreeHost* wth = AsWindowTreeHost(); 21 aura::WindowTreeHost* wth = AsWindowTreeHost();
22 aura::Window* root_window = wth->window(); 22 aura::Window* root_window = wth->window();
23 aura::client::ScreenPositionClient* screen_position_client = 23 aura::client::ScreenPositionClient* screen_position_client =
24 aura::client::GetScreenPositionClient(root_window); 24 aura::client::GetScreenPositionClient(root_window);
25 gfx::Rect local(wth->GetBounds().size()); 25 gfx::Rect local(wth->GetBounds().size());
26 local.Inset(GetHostInsets()); 26 local.Inset(GetHostInsets());
27 27
28 if (screen_position_client && !local.Contains(event->location())) { 28 if (screen_position_client && !local.Contains(event->location())) {
sky 2015/10/23 21:13:13 I got to hear and got sad that in most cases we ef
29 gfx::Point location(event->location()); 29 gfx::Point location(event->location());
30 // In order to get the correct point in screen coordinates 30 // In order to get the correct point in screen coordinates
31 // during passive grab, we first need to find on which host window 31 // during passive grab, we first need to find on which host window
32 // the mouse is on, and find out the screen coordinates on that 32 // the mouse is on, and find out the screen coordinates on that
33 // host window, then convert it back to this host window's coordinate. 33 // host window, then convert it back to this host window's coordinate.
34 screen_position_client->ConvertHostPointToScreen(root_window, &location); 34 screen_position_client->ConvertHostPointToScreen(root_window, &location);
35 screen_position_client->ConvertPointFromScreen(root_window, &location); 35 screen_position_client->ConvertPointFromScreen(root_window, &location);
36 wth->ConvertPointToHost(&location); 36 wth->ConvertPointToHost(&location);
37 event->set_location(location); 37 event->set_location(gfx::PointF(location));
38 event->set_root_location(location); 38 event->set_root_location(gfx::PointF(location));
39 } 39 }
40 } 40 }
41 41
42 } // namespace ash 42 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698