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

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

Issue 2022383002: Keep using the same DPI scale (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | 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 6dd25ffa99761ba91a47f4edbe6934fa853a13af..19da7c8a0bec85964bf02a79764611f340b56413 100644
--- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
+++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
@@ -431,13 +431,25 @@ gfx::FontRenderParams GetGtkFontRenderParams() {
}
double GetDPI() {
- GtkSettings* gtk_settings = gtk_settings_get_default();
- CHECK(gtk_settings);
- gint gtk_dpi = -1;
- g_object_get(gtk_settings, "gtk-xft-dpi", &gtk_dpi, NULL);
-
- // GTK multiplies the DPI by 1024 before storing it.
- return (gtk_dpi > 0) ? gtk_dpi / 1024.0 : 96.0;
+ // Linux chrome currently does not support dynamic DPI changes.
+ // Keep using the first value detected.
Elliot Glaysher 2016/06/01 17:22:43 I has a sad.
+ static double dpi = -1.f;
+ if (dpi < 0) {
+ const double kDefaultDPI = 96;
+
+ GtkSettings* gtk_settings = gtk_settings_get_default();
+ CHECK(gtk_settings);
+ gint gtk_dpi = -1;
+ g_object_get(gtk_settings, "gtk-xft-dpi", &gtk_dpi, NULL);
+
+ // GTK multiplies the DPI by 1024 before storing it.
+ dpi = (gtk_dpi > 0) ? gtk_dpi / 1024.0 : kDefaultDPI;
+
+ // DSF is always >=1.0 on win/cros and lower DSF has never been considered
+ // nor tested.
+ dpi = std::max(kDefaultDPI, dpi);
+ }
+ return dpi;
}
// Queries GTK for its font DPI setting and returns the number of pixels in a
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698