| 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 698af9819a8de1db4d89a8be0235847e40b5b6f4..2eced15cfbef71e528969ab7aece957dc5622a2f 100644
|
| --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
|
| +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
|
| @@ -9,6 +9,7 @@
|
|
|
| #include <pango/pango.h>
|
| #include <X11/Xlib.h>
|
| +#include <gio/gio.h>
|
|
|
| #include "base/command_line.h"
|
| #include "base/debug/leak_annotations.h"
|
| @@ -426,6 +427,21 @@ 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()
|
| @@ -1437,9 +1453,12 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) {
|
| float Gtk2UI::GetDeviceScaleFactor() const {
|
| if (gfx::Display::HasForceDeviceScaleFactor())
|
| return gfx::Display::GetForcedDeviceScaleFactor();
|
| - float scale = GetFontDPI() / GetBaseDPI();
|
| - // Round to 1 decimal, e.g. to 1.4.
|
| - return roundf(scale * 10) / 10;
|
| + // 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;
|
| }
|
|
|
| } // namespace libgtk2ui
|
|
|