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

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: More review fixes. Created 6 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 | « ui/views/corewm/cursor_height_provider_win.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6c2f5fac55eac36dd0eee3c9eeabeb346ba4dc10 100644
--- a/ui/views/corewm/tooltip_win.cc
+++ b/ui/views/corewm/tooltip_win.cc
@@ -13,7 +13,7 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/win/dpi.h"
-
+#include "ui/views/corewm/cursor_height_provider_win.h"
namespace views {
namespace corewm {
@@ -78,24 +78,19 @@ bool TooltipWin::EnsureTooltipWindow() {
void TooltipWin::PositionTooltip() {
// This code only runs for non-metro, so GetNativeScreen() is fine.
- gfx::Display display(
- gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(location_));
+ gfx::Point screen_point = gfx::win::DIPToScreenPoint(location_);
+ const int cursoroffset = GetCurrentCursorVisibleHeight();
+ screen_point.Offset(0, cursoroffset);
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);
+ const gfx::Size size(LOWORD(tooltip_size), HIWORD(tooltip_size));
+
+ const gfx::Display display(
+ gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(screen_point));
+
+ 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 +117,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);
« no previous file with comments | « ui/views/corewm/cursor_height_provider_win.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698