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

Unified Diff: ui/views/corewm/tooltip_win.cc

Issue 225403022: Fixed positioning of tooltips in multi monitor setups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unhardcoded cursor size hence simplifying DIP to screen conversions Created 6 years, 8 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
Index: ui/views/corewm/tooltip_win.cc
diff --git a/ui/views/corewm/tooltip_win.cc b/ui/views/corewm/tooltip_win.cc
index 34ea1711c342862199152e5bed9cd4a12c2f3e1e..0bad2579b06bead55dc070d91657fc2201e39243 100644
--- a/ui/views/corewm/tooltip_win.cc
+++ b/ui/views/corewm/tooltip_win.cc
@@ -14,7 +14,6 @@
#include "ui/gfx/screen.h"
#include "ui/gfx/win/dpi.h"
-
namespace views {
namespace corewm {
@@ -78,24 +77,19 @@ bool TooltipWin::EnsureTooltipWindow() {
void TooltipWin::PositionTooltip() {
// This code only runs for non-metro, so GetNativeScreen() is fine.
+ gfx::Point screen_point = gfx::win::DIPToScreenPoint(location_);
gfx::Display display(
- gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(location_));
+ gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(screen_point));
DWORD tooltip_size = SendMessage(tooltip_hwnd_, TTM_GETBUBBLESIZE, 0,
reinterpret_cast<LPARAM>(&toolinfo_));
- // 20 accounts for visible cursor size. I tried using SM_CYCURSOR but that's
- // way too big (32 on win7 default).
- // TODO(sky): figure out the right way to determine offset.
- const int initial_y = location_.y();
- gfx::Rect tooltip_bounds(location_.x(), initial_y + 20,
- LOWORD(tooltip_size), HIWORD(tooltip_size));
- tooltip_bounds.AdjustToFit(display.work_area());
- if (tooltip_bounds.y() < initial_y)
- tooltip_bounds.set_y(initial_y - tooltip_bounds.height() - 2);
-
- // Convert the tooltip bounds to pixel coordinates. SetWindowPos works in
- // pixel coordinates.
- tooltip_bounds = gfx::win::DIPToScreenRect(tooltip_bounds);
+ gfx::Size size(LOWORD(tooltip_size), HIWORD(tooltip_size));
+ size = gfx::win::DIPToScreenSize(size);
+
+ const int cursoroffset = cursor_height_provider_.GetCursorHeight();
+ screen_point.Offset(0, cursoroffset);
+ gfx::Rect tooltip_bounds(screen_point, size);
+ tooltip_bounds.AdjustToFit(gfx::win::DIPToScreenRect(display.work_area()));
SetWindowPos(tooltip_hwnd_, NULL, tooltip_bounds.x(), tooltip_bounds.y(), 0,
0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
@@ -122,8 +116,9 @@ void TooltipWin::SetText(aura::Window* window,
reinterpret_cast<LPARAM>(&toolinfo_));
// This code only runs for non-metro, so GetNativeScreen() is fine.
+ const gfx::Point screen_point = gfx::win::DIPToScreenPoint(location_);
gfx::Display display(
- gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(location_));
+ gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(screen_point));
const gfx::Rect monitor_bounds = display.bounds();
int max_width = (monitor_bounds.width() + 1) / 2;
SendMessage(tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0, max_width);

Powered by Google App Engine
This is Rietveld 408576698