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

Unified Diff: ash/tooltips/tooltip_controller.cc

Issue 9310008: aura: Fix a couple of tooltip related bugs: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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/shell/lock_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/tooltips/tooltip_controller.cc
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index 85f27628acd9040a995bdce04d186b8d45abc0af..c5395c5dc19450a0b391ad68a30dbdbe859e2858 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -191,6 +191,19 @@ class TooltipController::Tooltip {
tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
gfx::Rect monitor_bounds =
gfx::Screen::GetMonitorAreaNearestPoint(tooltip_rect.origin());
+
+ // If tooltip is out of bounds on the x axis, we simply shift it
+ // horizontally by the offset.
+ if (tooltip_rect.right() > monitor_bounds.right()) {
+ int h_offset = tooltip_rect.right() - monitor_bounds.right();
+ tooltip_rect.Offset(-h_offset, 0);
+ }
+
+ // If tooltip is out of bounds on the y axis, we flip it to appear above the
+ // mouse cursor instead of below.
+ if (tooltip_rect.bottom() > monitor_bounds.bottom())
+ tooltip_rect.set_y(mouse_pos.y() - tooltip_height);
+
widget_->SetBounds(tooltip_rect.AdjustToFit(monitor_bounds));
}
« no previous file with comments | « ash/shell/lock_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698