aura: Fix a couple of tooltip related bugs:

1. Position tooltips correctly when they are out of screen bounds
2. Hide tooltips when lockscreen is shown

BUG=112121,110128
TEST=manual


Review URL: http://codereview.chromium.org/9310008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120086 0039d316-1c4b-4281-b951-d872f2087c98
parent 0a6ea014
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/shell/example_factory.h"
#include "ash/tooltips/tooltip_controller.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
......@@ -68,6 +69,9 @@ void CreateLockScreen() {
widget->SetContentsView(lock_view);
widget->Show();
widget->GetNativeView()->SetName("LockView");
Shell::GetInstance()->tooltip_controller()->UpdateTooltip(
widget->GetNativeView());
}
} // namespace shell
......
......@@ -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));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment