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

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

Issue 1276553007: Revert broken Linux hidpi changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fixes Created 5 years, 4 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 f9ce890766ce94e9069bcf1ad20e63e448979600..ca74730bcb5f7e1e3944e145ee472f128f7eb7a3 100644
--- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
+++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc
@@ -8,8 +8,6 @@
#include <set>
#include <pango/pango.h>
-#include <X11/Xlib.h>
-#include <gio/gio.h>
#include "base/command_line.h"
#include "base/debug/leak_annotations.h"
@@ -52,7 +50,6 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/skbitmap_operations.h"
#include "ui/gfx/skia_util.h"
-#include "ui/gfx/x/x11_types.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/controls/button/label_button.h"
@@ -384,27 +381,20 @@ gfx::FontRenderParams GetGtkFontRenderParams() {
return params;
}
-double GetBaseDPI() {
- XDisplay* xdisplay = gfx::GetXDisplay();
- int xscreen = DefaultScreen(xdisplay);
- return (DisplayHeight(xdisplay, xscreen) * 25.4) /
- DisplayHeightMM(xdisplay, xscreen);
-}
-
-double GetFontDPI() {
+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 : GetBaseDPI();
+ 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 = GetFontDPI();
+ 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.
@@ -428,21 +418,6 @@ 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()
@@ -1462,12 +1437,10 @@ void Gtk2UI::UpdateDeviceScaleFactor(float device_scale_factor) {
float Gtk2UI::GetDeviceScaleFactor() const {
if (gfx::Display::HasForceDeviceScaleFactor())
return gfx::Display::GetForcedDeviceScaleFactor();
- // 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;
+ const int kCSSDefaultDPI = 96;
+ float scale = GetDPI() / kCSSDefaultDPI;
+ // Round to 1 decimal, e.g. to 1.4.
+ return roundf(scale * 10) / 10;
}
} // 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