OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
6 | 6 |
| 7 #include <math.h> |
7 #include <set> | 8 #include <set> |
8 | 9 |
9 #include <pango/pango.h> | 10 #include <pango/pango.h> |
10 | 11 |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/debug/leak_annotations.h" | 13 #include "base/debug/leak_annotations.h" |
13 #include "base/environment.h" | 14 #include "base/environment.h" |
14 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/nix/mime_util_xdg.h" | 17 #include "base/nix/mime_util_xdg.h" |
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 } | 1421 } |
1421 | 1422 |
1422 void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { | 1423 void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) { |
1423 device_scale_factor_ = device_scale_factor; | 1424 device_scale_factor_ = device_scale_factor; |
1424 GtkStyle* label_style = gtk_rc_get_style(fake_label_.get()); | 1425 GtkStyle* label_style = gtk_rc_get_style(fake_label_.get()); |
1425 UpdateDefaultFont(label_style->font_desc); | 1426 UpdateDefaultFont(label_style->font_desc); |
1426 } | 1427 } |
1427 | 1428 |
1428 float Gtk2UI::GetDeviceScaleFactor() const { | 1429 float Gtk2UI::GetDeviceScaleFactor() const { |
1429 const int kCSSDefaultDPI = 96; | 1430 const int kCSSDefaultDPI = 96; |
1430 const float scale = GetDPI() / kCSSDefaultDPI; | 1431 float scale = GetDPI() / kCSSDefaultDPI; |
1431 return ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(scale)); | 1432 // Round to 2 decimals, e.g. to 1.33. |
| 1433 return roundf(scale * 100) / 100; |
1432 } | 1434 } |
1433 | 1435 |
1434 } // namespace libgtk2ui | 1436 } // namespace libgtk2ui |
1435 | 1437 |
1436 views::LinuxUI* BuildGtk2UI() { | 1438 views::LinuxUI* BuildGtk2UI() { |
1437 return new libgtk2ui::Gtk2UI; | 1439 return new libgtk2ui::Gtk2UI; |
1438 } | 1440 } |
OLD | NEW |