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

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

Issue 1171693008: device scale factor detection: use gtk-xft-dpi consistently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: Created 5 years, 6 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/gtk2_ui.h ('k') | ui/views/linux_ui/linux_ui.h » ('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 5e16ba7dd2028d901420160102e503c09a16250e..d851e6d427b61370a3609f2996318ab230f4e2a0 100644
--- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
+++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
@@ -380,16 +380,20 @@ gfx::FontRenderParams GetGtkFontRenderParams() {
return params;
}
-// Queries GTK for its font DPI setting and returns the number of pixels in a
-// point.
-double GetPixelsInPoint(float device_scale_factor) {
+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.
- double dpi = (gtk_dpi > 0) ? gtk_dpi / 1024.0 : 96.0;
+ 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 = GetDPI();
// Take device_scale_factor into account — if Chrome already scales the
// entire UI up by 2x, we should not also scale up.
@@ -1420,6 +1424,12 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) {
UpdateDefaultFont(label_style->font_desc);
}
+float Gtk2UI::GetDeviceScaleFactor() const {
+ const int kCSSDefaultDPI = 96;
+ const float scale = GetDPI() / kCSSDefaultDPI;
+ return ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(scale));
+}
+
} // namespace libgtk2ui
views::LinuxUI* BuildGtk2UI() {
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_ui.h ('k') | ui/views/linux_ui/linux_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698