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

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

Issue 2524873002: Rename WindowTreeHost G|SetBounds to indicate they are in pixels. (Closed)
Patch Set: rebase 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
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/extended_mouse_warp_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/display/display_util.h" 5 #include "ash/display/display_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/system/system_notifier.h" 10 #include "ash/common/system/system_notifier.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest 80 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest
81 // that injects MockScreen. 81 // that injects MockScreen.
82 if (manager->GetNumDisplays() < 2 || manager->num_connected_displays() < 2) 82 if (manager->GetNumDisplays() < 2 || manager->num_connected_displays() < 2)
83 return base::MakeUnique<NullMouseWarpController>(); 83 return base::MakeUnique<NullMouseWarpController>();
84 return base::MakeUnique<ExtendedMouseWarpController>(drag_source); 84 return base::MakeUnique<ExtendedMouseWarpController>(drag_source);
85 } 85 }
86 86
87 gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host, 87 gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host,
88 const gfx::Rect& bounds_in_screen) { 88 const gfx::Rect& bounds_in_screen) {
89 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); 89 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
90 gfx::Rect native_bounds = host->GetBounds(); 90 gfx::Rect native_bounds = host->GetBoundsInPixels();
91 native_bounds.Inset(ash_host->GetHostInsets()); 91 native_bounds.Inset(ash_host->GetHostInsets());
92 gfx::Point start_in_native = bounds_in_screen.origin(); 92 gfx::Point start_in_native = bounds_in_screen.origin();
93 gfx::Point end_in_native = bounds_in_screen.bottom_right(); 93 gfx::Point end_in_native = bounds_in_screen.bottom_right();
94 94
95 ConvertPointFromScreenToNative(host, &start_in_native); 95 ConvertPointFromScreenToNative(host, &start_in_native);
96 ConvertPointFromScreenToNative(host, &end_in_native); 96 ConvertPointFromScreenToNative(host, &end_in_native);
97 97
98 if (std::abs(start_in_native.x() - end_in_native.x()) < 98 if (std::abs(start_in_native.x() - end_in_native.x()) <
99 std::abs(start_in_native.y() - end_in_native.y())) { 99 std::abs(start_in_native.y() - end_in_native.y())) {
100 // vertical in native 100 // vertical in native
(...skipping 18 matching lines...) Expand all
119 // the point_in_screen, which is outside of the root window. 119 // the point_in_screen, which is outside of the root window.
120 void MoveCursorTo(AshWindowTreeHost* ash_host, 120 void MoveCursorTo(AshWindowTreeHost* ash_host,
121 const gfx::Point& point_in_screen, 121 const gfx::Point& point_in_screen,
122 bool update_last_location_now) { 122 bool update_last_location_now) {
123 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); 123 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
124 gfx::Point point_in_native = point_in_screen; 124 gfx::Point point_in_native = point_in_screen;
125 ::wm::ConvertPointFromScreen(host->window(), &point_in_native); 125 ::wm::ConvertPointFromScreen(host->window(), &point_in_native);
126 host->ConvertPointToNativeScreen(&point_in_native); 126 host->ConvertPointToNativeScreen(&point_in_native);
127 127
128 // now fit the point inside the native bounds. 128 // now fit the point inside the native bounds.
129 gfx::Rect native_bounds = host->GetBounds(); 129 gfx::Rect native_bounds = host->GetBoundsInPixels();
130 gfx::Point native_origin = native_bounds.origin(); 130 gfx::Point native_origin = native_bounds.origin();
131 native_bounds.Inset(ash_host->GetHostInsets()); 131 native_bounds.Inset(ash_host->GetHostInsets());
132 // Shrink further so that the mouse doesn't warp on the 132 // Shrink further so that the mouse doesn't warp on the
133 // edge. The right/bottom needs to be shrink by 2 to subtract 133 // edge. The right/bottom needs to be shrink by 2 to subtract
134 // the 1 px from width/height value. 134 // the 1 px from width/height value.
135 native_bounds.Inset(1, 1, 2, 2); 135 native_bounds.Inset(1, 1, 2, 2);
136 136
137 // Ensure that |point_in_native| is inside the |native_bounds|. 137 // Ensure that |point_in_native| is inside the |native_bounds|.
138 point_in_native.SetToMax(native_bounds.origin()); 138 point_in_native.SetToMax(native_bounds.origin());
139 point_in_native.SetToMin(native_bounds.bottom_right()); 139 point_in_native.SetToMin(native_bounds.bottom_right());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 message_center::NotificationList::Notifications notifications = 191 message_center::NotificationList::Notifications notifications =
192 message_center::MessageCenter::Get()->GetVisibleNotifications(); 192 message_center::MessageCenter::Get()->GetVisibleNotifications();
193 for (auto* const notification : notifications) { 193 for (auto* const notification : notifications) {
194 if (notification->id() == kDisplayErrorNotificationId) 194 if (notification->id() == kDisplayErrorNotificationId)
195 return notification->message(); 195 return notification->message();
196 } 196 }
197 return base::string16(); 197 return base::string16();
198 } 198 }
199 199
200 } // namespace ash 200 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/extended_mouse_warp_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698