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

Unified Diff: ui/views/widget/desktop_aura/desktop_screen_x11.cc

Issue 1003863005: Fix tab drag and drop with hi-dpi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tab drag and drop with hi-dpi. Created 5 years, 9 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/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..7cd8bd71050722e51e8f8dbcc4f7f7ac2a2fe8f2 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 PixelToDIPPoint(const gfx::Point& pixel_point) {
+ return ToFlooredPoint(ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor()));
+}
+
+gfx::Point DIPToPixelPoint(const gfx::Point& dip_point) {
+ return ToFlooredPoint(gfx::ScalePoint(dip_point, GetDeviceScaleFactor()));
+}
+
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 PixelToDIPPoint(gfx::Point(root_x, root_y));
}
gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() {
@@ -140,7 +153,8 @@ gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() {
gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint(
const gfx::Point& point) {
X11TopmostWindowFinder finder;
- return finder.FindLocalProcessWindowAt(point, std::set<aura::Window*>());
+ return finder.FindLocalProcessWindowAt(
+ DIPToPixelPoint(point), std::set<aura::Window*>());
}
int DesktopScreenX11::GetNumDisplays() const {
@@ -177,10 +191,11 @@ gfx::Display DesktopScreenX11::GetDisplayNearestWindow(
}
gfx::Display DesktopScreenX11::GetDisplayNearestPoint(
- const gfx::Point& point) const {
+ const gfx::Point& requested_point) const {
+ const gfx::Point point_in_pixel = DIPToPixelPoint(requested_point);
for (std::vector<gfx::Display>::const_iterator it = displays_.begin();
it != displays_.end(); ++it) {
- if (it->bounds().Contains(point))
+ if (it->bounds().Contains(point_in_pixel))
return *it;
}
« no previous file with comments | « chrome/browser/ui/views/tabs/window_finder_x11.cc ('k') | ui/views/widget/desktop_aura/x11_topmost_window_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698