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

Side by Side Diff: ash/display/screen_position_controller.cc

Issue 2525113002: Rename WindowTreeHost functions to indicate pixels/dips. (Closed)
Patch Set: win Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/display/screen_position_controller.h" 5 #include "ash/display/screen_position_controller.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/wm/window_positioning_utils.h" 8 #include "ash/common/wm/window_positioning_utils.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 18 matching lines...) Expand all
29 namespace ash { 29 namespace ash {
30 30
31 // static 31 // static
32 void ScreenPositionController::ConvertHostPointToRelativeToRootWindow( 32 void ScreenPositionController::ConvertHostPointToRelativeToRootWindow(
33 aura::Window* root_window, 33 aura::Window* root_window,
34 const aura::Window::Windows& root_windows, 34 const aura::Window::Windows& root_windows,
35 gfx::Point* point, 35 gfx::Point* point,
36 aura::Window** target_root) { 36 aura::Window** target_root) {
37 DCHECK(!root_window->parent()); 37 DCHECK(!root_window->parent());
38 gfx::Point point_in_root(*point); 38 gfx::Point point_in_root(*point);
39 root_window->GetHost()->ConvertPointFromHost(&point_in_root); 39 root_window->GetHost()->ConvertPixelsToDIP(&point_in_root);
40 40
41 #if defined(USE_X11) || defined(USE_OZONE) 41 #if defined(USE_X11) || defined(USE_OZONE)
42 gfx::Rect host_bounds(root_window->GetHost()->GetBoundsInPixels().size()); 42 gfx::Rect host_bounds(root_window->GetHost()->GetBoundsInPixels().size());
43 if (!host_bounds.Contains(*point)) { 43 if (!host_bounds.Contains(*point)) {
44 // This conversion is necessary to deal with X's passive input 44 // This conversion is necessary to deal with X's passive input
45 // grab while dragging window. For example, if we have two 45 // grab while dragging window. For example, if we have two
46 // displays, say 1000x1000 (primary) and 500x500 (extended one 46 // displays, say 1000x1000 (primary) and 500x500 (extended one
47 // on the right), and start dragging a window at (999, 123), and 47 // on the right), and start dragging a window at (999, 123), and
48 // then move the pointer to the right, the pointer suddenly 48 // then move the pointer to the right, the pointer suddenly
49 // warps to the extended display. The destination is (0, 123) in 49 // warps to the extended display. The destination is (0, 123) in
50 // the secondary root window's coordinates, or (1000, 123) in 50 // the secondary root window's coordinates, or (1000, 123) in
51 // the screen coordinates. However, since the mouse is captured 51 // the screen coordinates. However, since the mouse is captured
52 // by X during drag, a weird LocatedEvent, something like (0, 1123) 52 // by X during drag, a weird LocatedEvent, something like (0, 1123)
53 // in the *primary* root window's coordinates, is sent to Chrome 53 // in the *primary* root window's coordinates, is sent to Chrome
54 // (Remember that in the native X11 world, the two root windows 54 // (Remember that in the native X11 world, the two root windows
55 // are always stacked vertically regardless of the display 55 // are always stacked vertically regardless of the display
56 // layout in Ash). We need to figure out that (0, 1123) in the 56 // layout in Ash). We need to figure out that (0, 1123) in the
57 // primary root window's coordinates is actually (0, 123) in the 57 // primary root window's coordinates is actually (0, 123) in the
58 // extended root window's coordinates. 58 // extended root window's coordinates.
59 // 59 //
60 // For now Ozone works in a similar manner as X11. Transitioning from one 60 // For now Ozone works in a similar manner as X11. Transitioning from one
61 // display's coordinate system to anothers may cause events in the 61 // display's coordinate system to anothers may cause events in the
62 // primary's coordinate system which fall in the extended display. 62 // primary's coordinate system which fall in the extended display.
63 63
64 gfx::Point location_in_native(point_in_root); 64 gfx::Point location_in_native(point_in_root);
65 65
66 root_window->GetHost()->ConvertPointToNativeScreen(&location_in_native); 66 root_window->GetHost()->ConvertDIPToScreenInPixels(&location_in_native);
67 67
68 for (size_t i = 0; i < root_windows.size(); ++i) { 68 for (size_t i = 0; i < root_windows.size(); ++i) {
69 aura::WindowTreeHost* host = root_windows[i]->GetHost(); 69 aura::WindowTreeHost* host = root_windows[i]->GetHost();
70 const gfx::Rect native_bounds = host->GetBoundsInPixels(); 70 const gfx::Rect native_bounds = host->GetBoundsInPixels();
71 if (native_bounds.Contains(location_in_native)) { 71 if (native_bounds.Contains(location_in_native)) {
72 *target_root = root_windows[i]; 72 *target_root = root_windows[i];
73 *point = location_in_native; 73 *point = location_in_native;
74 host->ConvertPointFromNativeScreen(point); 74 host->ConvertScreenInPixelsToDIP(point);
75 return; 75 return;
76 } 76 }
77 } 77 }
78 } 78 }
79 #endif 79 #endif
80 *target_root = root_window; 80 *target_root = root_window;
81 *point = point_in_root; 81 *point = point_in_root;
82 } 82 }
83 83
84 void ScreenPositionController::ConvertPointToScreen(const aura::Window* window, 84 void ScreenPositionController::ConvertPointToScreen(const aura::Window* window,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 const display::Display& display) { 121 const display::Display& display) {
122 if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) { 122 if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) {
123 window->SetBounds(bounds); 123 window->SetBounds(bounds);
124 return; 124 return;
125 } 125 }
126 126
127 wm::SetBoundsInScreen(WmWindowAura::Get(window), bounds, display); 127 wm::SetBoundsInScreen(WmWindowAura::Get(window), bounds, display);
128 } 128 }
129 129
130 } // namespace ash 130 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/extended_mouse_warp_controller.cc ('k') | ash/display/unified_mouse_warp_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698