| 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 fc477e61d5d2d745dc4a8416cfe361196d4c04fc..019688fb9463fb518681202d611a0fc90160a6b2 100644
|
| --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
|
| +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
|
| @@ -25,7 +25,6 @@
|
| #include "ui/gfx/native_widget_types.h"
|
| #include "ui/gfx/screen.h"
|
| #include "ui/gfx/x/x11_types.h"
|
| -#include "ui/views/linux_ui/linux_ui.h"
|
| #include "ui/views/widget/desktop_aura/desktop_screen.h"
|
| #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
|
| #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
|
| @@ -36,12 +35,21 @@ namespace {
|
| // in |Dispatch()|.
|
| const int64 kConfigureDelayMs = 500;
|
|
|
| -double GetDeviceScaleFactor() {
|
| - float device_scale_factor = 1.0f;
|
| - if (views::LinuxUI::instance())
|
| - device_scale_factor =
|
| - views::LinuxUI::instance()->GetDeviceScaleFactor();
|
| - return device_scale_factor;
|
| +// TODO(oshima): Consider using gtk-xft-dpi instead.
|
| +float GetDeviceScaleFactor(int screen_pixels, int screen_mm) {
|
| + const int kCSSDefaultDPI = 96;
|
| + const float kInchInMm = 25.4f;
|
| +
|
| + float screen_inches = screen_mm / kInchInMm;
|
| + float screen_dpi = screen_pixels / screen_inches;
|
| + float scale = screen_dpi / kCSSDefaultDPI;
|
| +
|
| + 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) {
|
| @@ -63,7 +71,8 @@ std::vector<gfx::Display> GetFallbackDisplayList() {
|
| gfx::Display gfx_display(0, bounds_in_pixels);
|
| if (!gfx::Display::HasForceDeviceScaleFactor() &&
|
| !ui::IsDisplaySizeBlackListed(physical_size)) {
|
| - const float device_scale_factor = GetDeviceScaleFactor();
|
| + float device_scale_factor = GetDeviceScaleFactor(
|
| + width, physical_size.width());
|
| DCHECK_LE(1.0f, device_scale_factor);
|
| gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels);
|
| }
|
| @@ -285,9 +294,7 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
|
| has_work_area = true;
|
| }
|
|
|
| - // As per-display scale factor is not supported right now,
|
| - // the X11 root window's scale factor is always used.
|
| - const float device_scale_factor = GetDeviceScaleFactor();
|
| + float device_scale_factor = 1.0f;
|
| for (int i = 0; i < resources->noutput; ++i) {
|
| RROutput output_id = resources->outputs[i];
|
| gfx::XScopedPtr<XRROutputInfo,
|
| @@ -314,6 +321,14 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
|
| gfx::Display display(display_id, crtc_bounds);
|
|
|
| if (!gfx::Display::HasForceDeviceScaleFactor()) {
|
| + if (i == 0 && !ui::IsDisplaySizeBlackListed(
|
| + gfx::Size(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);
|
| }
|
|
|
|
|