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

Unified Diff: ash/display/display_util.cc

Issue 1132303005: Correctly convert warp bounds from screen to native. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added SupportsMultipleDisplays check Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_util.h ('k') | ash/display/display_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_util.cc
diff --git a/ash/display/display_util.cc b/ash/display/display_util.cc
index 2bb842eb2d704cc6f18e1e8ecf604f5dcc39333f..90d2f95a497a9fd3109b77981dec3371b017b383 100644
--- a/ash/display/display_util.cc
+++ b/ash/display/display_util.cc
@@ -164,31 +164,21 @@ gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host,
aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
gfx::Rect native_bounds = host->GetBounds();
native_bounds.Inset(ash_host->GetHostInsets());
-
- bool vertical = bounds_in_screen.width() < bounds_in_screen.height();
- gfx::Point start_in_native;
- gfx::Point end_in_native;
-
- if (vertical) {
- start_in_native = bounds_in_screen.origin();
- end_in_native = start_in_native;
- end_in_native.set_y(bounds_in_screen.bottom());
- } else {
- start_in_native = bounds_in_screen.origin();
- end_in_native = start_in_native;
- end_in_native.set_x(bounds_in_screen.right());
- }
+ gfx::Point start_in_native = bounds_in_screen.origin();
+ gfx::Point end_in_native = bounds_in_screen.bottom_right();
ConvertPointFromScreenToNative(host, &start_in_native);
ConvertPointFromScreenToNative(host, &end_in_native);
- if (vertical) {
+
+ if (std::abs(start_in_native.x() - end_in_native.x()) <
+ std::abs(start_in_native.y() - end_in_native.y())) {
// vertical in native
int x = std::abs(native_bounds.x() - start_in_native.x()) <
std::abs(native_bounds.right() - start_in_native.x())
? native_bounds.x()
: native_bounds.right() - 1;
return gfx::Rect(x, std::min(start_in_native.y(), end_in_native.y()), 1,
- end_in_native.y() - start_in_native.y());
+ std::abs(end_in_native.y() - start_in_native.y()));
} else {
// horizontal in native
int y = std::abs(native_bounds.y() - start_in_native.y()) <
@@ -196,7 +186,7 @@ gfx::Rect GetNativeEdgeBounds(AshWindowTreeHost* ash_host,
? native_bounds.y()
: native_bounds.bottom() - 1;
return gfx::Rect(std::min(start_in_native.x(), end_in_native.x()), y,
- end_in_native.x() - start_in_native.x(), 1);
+ std::abs(end_in_native.x() - start_in_native.x()), 1);
}
}
« no previous file with comments | « ash/display/display_util.h ('k') | ash/display/display_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698