Chromium Code Reviews| Index: ui/views/widget/desktop_aura/desktop_screen_x11.cc |
| diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc |
| index ed8a0f4844cd7f002c6d1c492eff05575ebedf81..a7ea43af543a4e54d926d12d444184b58dd253f8 100644 |
| --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc |
| +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc |
| @@ -45,6 +45,19 @@ float GetDeviceScaleFactor(int screen_pixels, int screen_mm) { |
| return ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(scale)); |
| } |
| +float GetDeviceScaleFactor() { |
| + gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| + return display.device_scale_factor(); |
| +} |
| + |
| +gfx::Point ScreenToDIPPoint(const gfx::Point& pixel_point) { |
|
sadrul
2015/03/17 15:56:06
Let's call this ToDIPPoint, or PixelToDIPPoint.
I
stapelberg
2015/03/19 08:25:44
Done.
|
| + return ToFlooredPoint(ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor())); |
| +} |
| + |
| +gfx::Point DIPToScreenPoint(const gfx::Point& dip_point) { |
| + return ToFlooredPoint(gfx::ScalePoint(dip_point, GetDeviceScaleFactor())); |
| +} |
| + |
|
sadrul
2015/03/17 15:56:06
Is there any way we can avoid dup'ing this block o
stapelberg
2015/03/19 08:25:44
I wouldn’t know how, if not by introducing yet ano
|
| std::vector<gfx::Display> GetFallbackDisplayList() { |
| ::XDisplay* display = gfx::GetXDisplay(); |
| ::Screen* screen = DefaultScreenOfDisplay(display); |
| @@ -130,7 +143,7 @@ gfx::Point DesktopScreenX11::GetCursorScreenPoint() { |
| &win_y, |
| &mask); |
| - return gfx::Point(root_x, root_y); |
| + return ScreenToDIPPoint(gfx::Point(root_x, root_y)); |
| } |
| gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() { |
| @@ -177,7 +190,8 @@ gfx::Display DesktopScreenX11::GetDisplayNearestWindow( |
| } |
| gfx::Display DesktopScreenX11::GetDisplayNearestPoint( |
| - const gfx::Point& point) const { |
| + const gfx::Point& requested_point) const { |
| + const gfx::Point point = DIPToScreenPoint(requested_point); |
|
sadrul
2015/03/17 15:56:06
point_in_pixel
stapelberg
2015/03/19 08:25:44
Done.
|
| for (std::vector<gfx::Display>::const_iterator it = displays_.begin(); |
| it != displays_.end(); ++it) { |
| if (it->bounds().Contains(point)) |