Chromium Code Reviews| 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 2f7f2cd93cfb7e6629ebaa96c8f8b5012a4cea20..a57b59fb7905762f861446e6587b52f536adf2dc 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", >k_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)); |
|
oshima
2015/04/08 23:57:41
you may want to add more scales for linux (133 150
stapelberg
2015/04/09 06:49:34
Yeah, I’ll investigate that in a separate CL so th
oshima
2015/04/09 17:22:23
I think my comment was a bit confusing. Technicall
|
| +} |
| + |
| } // namespace libgtk2ui |
| views::LinuxUI* BuildGtk2UI() { |