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 8d8bd02ee8311ee6be0c50efcaf369ed7d1c4651..40e49c4b01b805fe689069eb5469ee7371a219fa 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,34 @@ namespace { |
| // in |Dispatch()|. |
| const int64 kConfigureDelayMs = 500; |
| +float GetDeviceScaleFactor(int screen_dimention, int mm_screen_dimention) { |
|
Daniel Erat
2013/10/29 16:27:03
s/dimention/dimension/g
the units of the first ar
|
| + const int kCSSDefaultDIPCountPerInch = 96; |
|
Daniel Erat
2013/10/29 16:27:03
is something shorter like kCSSDefaultDPI still acc
|
| + const float kInchInMm = 25.4f; |
| + |
| + float screen_dpi = (screen_dimention * kInchInMm) / mm_screen_dimention; |
|
Daniel Erat
2013/10/29 16:27:03
maybe a bit clearer:
float screen_inches = scre
|
| + float scale = screen_dpi / kCSSDefaultDIPCountPerInch; |
| + |
| + 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); |
| + int mm_width = WidthMMOfScreen(screen); |
| + int mm_height = HeightMMOfScreen(screen); |
| + |
| + gfx::Rect bounds_in_pixels(0, 0, width, height); |
| + gfx::Display gfx_display(0, bounds_in_pixels); |
| + if (!gfx::Display::HasForceDeviceScaleFactor() && |
| + !ui::IsXDisplaySizeBlackListed(mm_width, mm_height)) { |
| + float device_scale_factor = GetDeviceScaleFactor(width, mm_width); |
| + DCHECK_LE(1.0f, device_scale_factor); |
| + gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels); |
| + } |
| - return std::vector<gfx::Display>( |
| - 1, gfx::Display(0, gfx::Rect(0, 0, width, height))); |
| + return std::vector<gfx::Display>(1, gfx_display); |
| } |
| } // namespace |
| @@ -128,7 +149,7 @@ void DesktopScreenX11::ProcessDisplayChange( |
| // DesktopScreenX11, gfx::Screen implementation: |
| bool DesktopScreenX11::IsDIPEnabled() { |
| - return false; |
| + return true; |
| } |
| gfx::Point DesktopScreenX11::GetCursorScreenPoint() { |
| @@ -292,6 +313,7 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() { |
| has_work_area = true; |
| } |
| + float device_scale_factor = 1.0f; |
| for (int i = 0; i < resources->noutput; ++i) { |
| RROutput output_id = resources->outputs[i]; |
| XRROutputInfo* output_info = |
| @@ -317,6 +339,19 @@ 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()) { |
| + if (i == 0 && !ui::IsXDisplaySizeBlackListed(output_info->mm_width, |
| + output_info->mm_height)) { |
| + // As per display scale factor is not supported right now, |
| + // the primary display's scale factor is always used. |
| + device_scale_factor = GetDeviceScaleFactor(crtc->width, |
| + output_info->mm_width); |
| + DCHECK_LE(1.0f, device_scale_factor); |
| + } |
| + display.SetScaleAndBounds(device_scale_factor, crtc_bounds); |
| + } |
| + |
| if (has_work_area) { |
| gfx::Rect intersection = crtc_bounds; |
| intersection.Intersect(work_area); |