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

Unified Diff: chrome/browser/ui/libgtk2ui/gtk2_ui.cc

Issue 1242753005: Use org.gnome.desktop.interface text-scaling-factor directly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « chrome/browser/ui/libgtk2ui/BUILD.gn ('k') | chrome/browser/ui/libgtk2ui/libgtk2ui.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/ui/libgtk2ui/BUILD.gn ('k') | chrome/browser/ui/libgtk2ui/libgtk2ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698