Commit 42de8ba1 authored by oshima's avatar oshima Committed by Commit bot

Use org.gnome.desktop.interface text-scaling-factor directly

gtk-xft-dpi is updated based on this value, so using this directly makes more sense.

BUG=511580
TEST=manual.

Review URL: https://codereview.chromium.org/1242753005

Cr-Commit-Position: refs/heads/master@{#339957}
parent f6215431
...@@ -61,7 +61,14 @@ component("libgtk2ui") { ...@@ -61,7 +61,14 @@ component("libgtk2ui") {
"gconf_listener.h", "gconf_listener.h",
] ]
} }
defines = [ "LIBGTK2UI_IMPLEMENTATION" ] defines = [
"LIBGTK2UI_IMPLEMENTATION",
# g_settings_list_schemas is deprecated, but this function is not
# available on earlier version that we still need to support.
# See build/config/linux/BUILD.gn:gio_config for details.
"GLIB_DISABLE_DEPRECATION_WARNINGS",
]
configs += [ configs += [
"//build/config/linux:gconf", "//build/config/linux:gconf",
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <pango/pango.h> #include <pango/pango.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <gio/gio.h>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/leak_annotations.h" #include "base/debug/leak_annotations.h"
...@@ -426,6 +427,21 @@ views::LinuxUI::NonClientMiddleClickAction GetDefaultMiddleClickAction() { ...@@ -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 } // namespace
Gtk2UI::Gtk2UI() Gtk2UI::Gtk2UI()
...@@ -1438,9 +1454,12 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { ...@@ -1438,9 +1454,12 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) {
float Gtk2UI::GetDeviceScaleFactor() const { float Gtk2UI::GetDeviceScaleFactor() const {
if (gfx::Display::HasForceDeviceScaleFactor()) if (gfx::Display::HasForceDeviceScaleFactor())
return gfx::Display::GetForcedDeviceScaleFactor(); return gfx::Display::GetForcedDeviceScaleFactor();
float scale = GetFontDPI() / GetBaseDPI(); // Linux chrome does not support dynamnic scale factor change. Use the
// Round to 1 decimal, e.g. to 1.4. // value obtanied during startup. The value is rounded to 1 decimal, e.g.
return roundf(scale * 10) / 10; // to 1.4, for safety.
static float device_scale_factor =
roundf(GetGnomeTextScalingFactor() * 10) / 10;
return device_scale_factor;
} }
} // namespace libgtk2ui } // namespace libgtk2ui
......
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
], ],
'defines': [ 'defines': [
'LIBGTK2UI_IMPLEMENTATION', 'LIBGTK2UI_IMPLEMENTATION',
# g_settings_list_schemas is deprecated, but this function is not
# available on earlier version that we still need to support.
# See build/linux/system.gyp:gio for details.
'GLIB_DISABLE_DEPRECATION_WARNINGS'
], ],
# Several of our source files are named _gtk2.cc. This isn't to # Several of our source files are named _gtk2.cc. This isn't to
# differentiate them from their source files (ninja and make are sane # differentiate them from their source files (ninja and make are sane
......
...@@ -11,4 +11,10 @@ class PixelExpectations(GpuTestExpectations): ...@@ -11,4 +11,10 @@ class PixelExpectations(GpuTestExpectations):
# Sample Usage: # Sample Usage:
# self.Fail('Pixel.Canvas2DRedBox', # self.Fail('Pixel.Canvas2DRedBox',
# ['mac', 'amd', ('nvidia', 0x1234)], bug=123) # ['mac', 'amd', ('nvidia', 0x1234)], bug=123)
self.Fail('Pixel.Canvas2DRedBox',
[ 'linux', ('nvidia', 0x104a)], bug=511580)
self.Fail('Pixel.CSS3DBlueBox',
[ 'linux', ('nvidia', 0x104a)], bug=511580)
self.Fail('Pixel.WebGLGreenTriangle',
[ 'linux', ('nvidia', 0x104a)], bug=511580)
pass pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment