Chromium Code Reviews| Index: chrome/browser/ui/libgtk2ui/gtk2_ui.cc |
| diff --git a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc |
| index f9ce890766ce94e9069bcf1ad20e63e448979600..3dbb4d00b36afae33c93c19c7e0810a8a36399e6 100644 |
| --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc |
| +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc |
| @@ -8,8 +8,6 @@ |
| #include <set> |
| #include <pango/pango.h> |
| -#include <X11/Xlib.h> |
| -#include <gio/gio.h> |
| #include "base/command_line.h" |
| #include "base/debug/leak_annotations.h" |
| @@ -384,27 +382,20 @@ gfx::FontRenderParams GetGtkFontRenderParams() { |
| return params; |
| } |
| -double GetBaseDPI() { |
| - XDisplay* xdisplay = gfx::GetXDisplay(); |
| - int xscreen = DefaultScreen(xdisplay); |
| - return (DisplayHeight(xdisplay, xscreen) * 25.4) / |
| - DisplayHeightMM(xdisplay, xscreen); |
| -} |
| - |
| -double GetFontDPI() { |
| +double GetDPI() { |
| GtkSettings* gtk_settings = gtk_settings_get_default(); |
| CHECK(gtk_settings); |
| gint gtk_dpi = -1; |
| g_object_get(gtk_settings, "gtk-xft-dpi", >k_dpi, NULL); |
| // GTK multiplies the DPI by 1024 before storing it. |
| - return (gtk_dpi > 0) ? gtk_dpi / 1024.0 : GetBaseDPI(); |
| + return (gtk_dpi > 0) ? gtk_dpi / 1024.0 : 96.0; |
| } |
| // Queries GTK for its font DPI setting and returns the number of pixels in a |
| // point. |
| double GetPixelsInPoint(float device_scale_factor) { |
| - double dpi = GetFontDPI(); |
| + double dpi = GetDPI(); |
| // Take device_scale_factor into account — if Chrome already scales the |
| // entire UI up by 2x, we should not also scale up. |
| @@ -428,21 +419,6 @@ views::LinuxUI::NonClientMiddleClickAction GetDefaultMiddleClickAction() { |
| } |
| } |
| -double GetGnomeTextScalingFactor() { |
| - const char kDesktopInterfaceSchema[] = "org.gnome.desktop.interface"; |
| - for (const gchar* const* schemas = g_settings_list_schemas(); *schemas; |
| - schemas++) { |
| - if (!strcmp(kDesktopInterfaceSchema, static_cast<const char*>(*schemas))) { |
| - GSettings* settings = g_settings_new(kDesktopInterfaceSchema); |
| - double scale = g_settings_get_double(settings, "text-scaling-factor"); |
| - g_object_unref(settings); |
| - return scale; |
| - } |
| - } |
| - // Fallback if the schema does not exist. |
| - return GetFontDPI() / GetBaseDPI(); |
| -} |
| - |
| } // namespace |
| Gtk2UI::Gtk2UI() |
| @@ -1462,12 +1438,10 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { |
| float Gtk2UI::GetDeviceScaleFactor() const { |
| if (gfx::Display::HasForceDeviceScaleFactor()) |
| return gfx::Display::GetForcedDeviceScaleFactor(); |
| - // Linux chrome does not support dynamnic scale factor change. Use the |
| - // value obtanied during startup. The value is rounded to 1 decimal, e.g. |
| - // to 1.4, for safety. |
| - static float device_scale_factor = |
| - roundf(GetGnomeTextScalingFactor() * 10) / 10; |
| - return device_scale_factor; |
| + const int kCSSDefaultDPI = 96; |
| + float scale = GetDPI() / kCSSDefaultDPI; |
| + // Round to 2 decimals, e.g. to 1.33. |
| + return roundf(scale * 100) / 100; |
|
stapelberg
2015/08/07 10:38:22
I think we should keep the rounding to 1 decimal,
Michael Moss
2015/08/07 16:45:40
Done.
|
| } |
| } // namespace libgtk2ui |