Merge pull request #2980 from atom/linux-fix-dpi

Do not manually read DPI settings on Linux
This commit is contained in:
Cheng Zhao 2015-10-04 17:18:35 +08:00
commit eb7ed5b456
7 changed files with 6 additions and 86 deletions

View file

@ -55,10 +55,6 @@ void AtomBrowserMainParts::RegisterDestructionCallback(
void AtomBrowserMainParts::PostEarlyInitialization() {
brightray::BrowserMainParts::PostEarlyInitialization();
#if defined(USE_X11)
SetDPIFromGSettings();
#endif
{
// 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

View file

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

@ -905,9 +905,6 @@ void NativeWindowViews::HandleKeyboardEvent(
// When a single Alt is pressed:
menu_bar_alt_pressed_ = true;
} else if (event.type == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
#if defined(USE_X11)
event.modifiers == 0 &&
#endif
menu_bar_alt_pressed_) {
// When a single Alt is released right after a Alt is pressed:
menu_bar_alt_pressed_ = false;

View file

@ -6,6 +6,7 @@
#include <X11/Xatom.h>
#include "base/environment.h"
#include "base/strings/string_util.h"
#include "dbus/bus.h"
#include "dbus/object_proxy.h"
@ -50,6 +51,10 @@ void SetWindowType(::Window xwindow, const std::string& type) {
}
bool ShouldUseGlobalMenuBar() {
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasVar("ELECTRON_FORCE_WINDOW_MENU_BAR"))
return false;
dbus::Bus::Options options;
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));

View file

@ -124,7 +124,6 @@
'atom/browser/atom_download_manager_delegate.h',
'atom/browser/atom_browser_main_parts.cc',
'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_javascript_dialog_manager.cc',
'atom/browser/atom_javascript_dialog_manager.h',

2
vendor/brightray vendored

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