linux: No longer needs to manually read DPI settings

It is now done in brightray by reading the value from GTK+.
This commit is contained in:
Cheng Zhao 2015-10-04 16:53:20 +08:00
parent add9c38023
commit 74b76102a8
5 changed files with 1 additions and 83 deletions

View file

@ -55,10 +55,6 @@ void AtomBrowserMainParts::RegisterDestructionCallback(
void AtomBrowserMainParts::PostEarlyInitialization() { void AtomBrowserMainParts::PostEarlyInitialization() {
brightray::BrowserMainParts::PostEarlyInitialization(); brightray::BrowserMainParts::PostEarlyInitialization();
#if defined(USE_X11)
SetDPIFromGSettings();
#endif
{ {
// Temporary set the bridge_task_runner_ as current thread's task runner, // Temporary set the bridge_task_runner_ as current thread's task runner,
// so we can fool gin::PerIsolateData to use it as its task runner, instead // so we can fool gin::PerIsolateData to use it as its task runner, instead

View file

@ -48,10 +48,6 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
#endif #endif
private: private:
#if defined(USE_X11)
void SetDPIFromGSettings();
#endif
// A fake BrowserProcess object that used to feed the source code from chrome. // A fake BrowserProcess object that used to feed the source code from chrome.
scoped_ptr<BrowserProcess> fake_browser_process_; scoped_ptr<BrowserProcess> fake_browser_process_;

View file

@ -1,73 +0,0 @@
// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/atom_browser_main_parts.h"
#include <gio/gio.h>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "ui/gfx/switches.h"
namespace atom {
namespace {
const char* kInterfaceSchema = "org.gnome.desktop.interface";
const char* kScaleFactor = "scaling-factor";
bool SchemaExists(const char* schema_name) {
const gchar* const* schemas = g_settings_list_schemas();
while (*schemas) {
if (strcmp(schema_name, static_cast<const char*>(*schemas)) == 0)
return true;
schemas++;
}
return false;
}
bool KeyExists(GSettings* client, const char* key) {
gchar** keys = g_settings_list_keys(client);
if (!keys)
return false;
gchar** iter = keys;
while (*iter) {
if (strcmp(*iter, key) == 0)
break;
iter++;
}
bool exists = *iter != NULL;
g_strfreev(keys);
return exists;
}
void GetDPIFromGSettings(guint* scale_factor) {
GSettings* client = nullptr;
if (!SchemaExists(kInterfaceSchema) ||
!(client = g_settings_new(kInterfaceSchema))) {
VLOG(1) << "Cannot create gsettings client.";
return;
}
if (KeyExists(client, kScaleFactor))
*scale_factor = g_settings_get_uint(client, kScaleFactor);
g_object_unref(client);
}
} // namespace
void AtomBrowserMainParts::SetDPIFromGSettings() {
guint scale_factor = 1;
GetDPIFromGSettings(&scale_factor);
if (scale_factor == 0)
scale_factor = 1;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kForceDeviceScaleFactor, base::UintToString(scale_factor));
}
} // namespace atom

View file

@ -124,7 +124,6 @@
'atom/browser/atom_download_manager_delegate.h', 'atom/browser/atom_download_manager_delegate.h',
'atom/browser/atom_browser_main_parts.cc', 'atom/browser/atom_browser_main_parts.cc',
'atom/browser/atom_browser_main_parts.h', 'atom/browser/atom_browser_main_parts.h',
'atom/browser/atom_browser_main_parts_linux.cc',
'atom/browser/atom_browser_main_parts_mac.mm', 'atom/browser/atom_browser_main_parts_mac.mm',
'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.cc',
'atom/browser/atom_javascript_dialog_manager.h', 'atom/browser/atom_javascript_dialog_manager.h',

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit 361d99dd05a8368faee20bc39a6ffaedbc67c383 Subproject commit bbb9287337f8b7958b001be35b993c21cd573109