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 9358875895ac0bd2f1aadb30c27df4f1fd018773..1aa1328e729320d88aff3c799612e4f19e5edd77 100644 |
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc |
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc |
@@ -14,6 +14,7 @@ |
#include "base/x11/edid_parser_x11.h" |
#include "ui/aura/root_window.h" |
#include "ui/aura/root_window_host.h" |
+#include "ui/base/layout.h" |
#include "ui/base/x/x11_util.h" |
#include "ui/gfx/display.h" |
#include "ui/gfx/display_observer.h" |
@@ -29,14 +30,32 @@ namespace { |
// in |Dispatch()|. |
const int64 kConfigureDelayMs = 500; |
+float GetDeviceScaleFactor(int screen_dim, int screen_dim_mm) { |
+ const int kCSSPixelsPerInch = 96; |
kenneth.r.christiansen
2013/10/14 08:20:54
kDefaultCSSPixelsPerInch ?
Mikhail
2013/10/14 09:15:52
Yeah, I would even say kDefaultDIPPerInch to be mo
|
+ const float kMillimetersPerInch = 25.4f; |
+ float screen_DPI = (screen_dim * kMillimetersPerInch) |
+ / screen_dim_mm; |
+ |
+ float scale = screen_DPI / kCSSPixelsPerInch; |
+ |
+ return ui::GetImageScale(ui::GetSupportedScaleFactor(scale)); |
+} |
+ |
std::vector<gfx::Display> GetFallbackDisplayList() { |
::XDisplay* display = gfx::GetXDisplay(); |
::Screen* screen = DefaultScreenOfDisplay(display); |
int width = WidthOfScreen(screen); |
int height = HeightOfScreen(screen); |
- return std::vector<gfx::Display>( |
- 1, gfx::Display(0, gfx::Rect(0, 0, width, height))); |
+ gfx::Rect bounds_in_pixels(0, 0, width, height); |
kenneth.r.christiansen
2013/10/14 08:20:54
device pixels? or css pixels? not obvious
Mikhail
2013/10/14 09:15:52
Device pixels. From what I saw postfix "_in_pixels
|
+ gfx::Display gfx_display(0, bounds_in_pixels); |
kenneth.r.christiansen
2013/10/14 08:20:54
Why are we assuming screen 0 here?
Mikhail
2013/10/14 09:15:52
Guess, this is just a fallback display number. Any
|
+ if (!gfx::Display::HasForceDeviceScaleFactor()) { |
+ float device_scale_factor = GetDeviceScaleFactor(width, |
+ WidthMMOfScreen(screen)); |
+ gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels); |
+ } |
+ |
+ return std::vector<gfx::Display>(1, gfx_display); |
} |
} // namespace |
@@ -128,7 +147,7 @@ void DesktopScreenX11::ProcessDisplayChange( |
// DesktopScreenX11, gfx::Screen implementation: |
bool DesktopScreenX11::IsDIPEnabled() { |
- return false; |
+ return true; |
} |
gfx::Point DesktopScreenX11::GetCursorScreenPoint() { |
@@ -317,6 +336,13 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() { |
gfx::Rect crtc_bounds(crtc->x, crtc->y, crtc->width, crtc->height); |
gfx::Display display(display_id, crtc_bounds); |
+ |
+ if (!gfx::Display::HasForceDeviceScaleFactor()) { |
+ float device_scale_factor = GetDeviceScaleFactor(crtc->width, |
+ output_info->mm_width); |
+ display.SetScaleAndBounds(device_scale_factor, crtc_bounds); |
+ } |
+ |
if (has_work_area) { |
gfx::Rect intersection = crtc_bounds; |
intersection.Intersect(work_area); |