diff options
author | scottmg <scottmg@chromium.org> | 2015-02-03 16:48:52 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-04 00:51:31 +0000 |
commit | e027f6829a0644ab140bef89125307db2b93dd29 (patch) | |
tree | a0c0d3b6b74293b752f021e29e53ca41a802ad2f /ui | |
parent | 7ccf4fab5d4473e431f1a289056033eea0b3dd43 (diff) | |
download | chromium_src-e027f6829a0644ab140bef89125307db2b93dd29.zip chromium_src-e027f6829a0644ab140bef89125307db2b93dd29.tar.gz chromium_src-e027f6829a0644ab140bef89125307db2b93dd29.tar.bz2 |
win: fix ScreenWin::GetDisplayNearestPoint implementation
MenuController::CalculateMenuBounds adjusts the location of popup menus
based on the monitor it thinks the menu is on. Because
MenuController::State is filled via GetDisplayNearestPoint when on
hidpi, on a second monitor to the right of the first monitor, this
would return the first monitor (because of lack of adjustment for dpi)
and so the menu would be incorrectly adjusted and shown on the first
monitor, instead of at the correct location. This does fix the popup
menu.
There are a non-zero number of other calls to GetDisplayNearestPoint.
Looking through the windows ones I don't see any horrible behaviour.
This also fixes, e.g. the wrench menu showing up at the wrong location.
The most suspicious looking is
https://code.google.com/p/chromium/codesearch#chromium/src/ui/views/corewm/tooltip_win.cc&l=122
but I cannot reproduce any problem with tooltips with this patch. And
all the tests pass, so I guess I'll try it and see how it goes.
R=sky@chromium.org,ananta@chromium.org
BUG=378945
Review URL: https://codereview.chromium.org/759853003
Cr-Commit-Position: refs/heads/master@{#314452}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/screen.h | 2 | ||||
-rw-r--r-- | ui/gfx/screen_win.cc | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index 65d78fe..2865274 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -76,7 +76,7 @@ class GFX_EXPORT Screen { // return the primary display. virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0; - // Returns the display nearest the specified point. + // Returns the display nearest the specified point. |point| should be in DIPs. virtual gfx::Display GetDisplayNearestPoint( const gfx::Point& point) const = 0; diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc index d5ad22b..9210971 100644 --- a/ui/gfx/screen_win.cc +++ b/ui/gfx/screen_win.cc @@ -136,7 +136,8 @@ gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const { } gfx::Display ScreenWin::GetDisplayNearestPoint(const gfx::Point& point) const { - POINT initial_loc = { point.x(), point.y() }; + gfx::Point point_in_pixels = gfx::win::DIPToScreenPoint(point); + POINT initial_loc = { point_in_pixels.x(), point_in_pixels.y() }; HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); MONITORINFOEX mi; ZeroMemory(&mi, sizeof(MONITORINFOEX)); |