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

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

Issue 1070433002: device scale factor detection: use gtk-xft-dpi consistently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: device scale factor detection: always use X11 root window’s dpi Created 5 years, 8 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
« chrome/browser/ui/libgtk2ui/gtk2_ui.cc ('K') | « ui/views/linux_ui/linux_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 019688fb9463fb518681202d611a0fc90160a6b2..6f9e4ba0deefbae4a4fd5a9dca7e0aa864034795 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -25,6 +25,7 @@
#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"
@@ -35,29 +36,14 @@ namespace {
// in |Dispatch()|.
const int64 kConfigureDelayMs = 500;
-// 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) {
- return ToFlooredPoint(ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactor()));
+ return ToFlooredPoint(ScalePoint(pixel_point,
+ 1.0f / views::LinuxUI::instance()->GetDeviceScaleFactor()));
}
gfx::Point DIPToPixelPoint(const gfx::Point& dip_point) {
- return ToFlooredPoint(gfx::ScalePoint(dip_point, GetDeviceScaleFactor()));
+ return ToFlooredPoint(gfx::ScalePoint(dip_point,
+ views::LinuxUI::instance()->GetDeviceScaleFactor()));
}
std::vector<gfx::Display> GetFallbackDisplayList() {
@@ -71,8 +57,8 @@ std::vector<gfx::Display> GetFallbackDisplayList() {
gfx::Display gfx_display(0, bounds_in_pixels);
if (!gfx::Display::HasForceDeviceScaleFactor() &&
!ui::IsDisplaySizeBlackListed(physical_size)) {
- float device_scale_factor = GetDeviceScaleFactor(
- width, physical_size.width());
+ float device_scale_factor =
+ views::LinuxUI::instance()->GetDeviceScaleFactor();
DCHECK_LE(1.0f, device_scale_factor);
gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels);
}
@@ -295,6 +281,12 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
}
float device_scale_factor = 1.0f;
+ {
+ // As per-display scale factor is not supported right now,
+ // the X11 root window's scale factor is always used.
+ std::vector<gfx::Display> fallback_displays = GetFallbackDisplayList();
+ device_scale_factor = fallback_displays[0].device_scale_factor();
oshima 2015/04/08 23:57:41 nit: you can get device scale factor from LinuxUI
stapelberg 2015/04/09 06:49:34 Done.
+ }
for (int i = 0; i < resources->noutput; ++i) {
RROutput output_id = resources->outputs[i];
gfx::XScopedPtr<XRROutputInfo,
@@ -321,14 +313,6 @@ 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);
}
« chrome/browser/ui/libgtk2ui/gtk2_ui.cc ('K') | « ui/views/linux_ui/linux_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698