commit
c22ffd863b
34 changed files with 492 additions and 172 deletions
2
atom.gyp
2
atom.gyp
|
@ -4,7 +4,7 @@
|
|||
'product_name%': 'Electron',
|
||||
'company_name%': 'GitHub, Inc',
|
||||
'company_abbr%': 'github',
|
||||
'version%': '0.33.4',
|
||||
'version%': '0.33.6',
|
||||
},
|
||||
'includes': [
|
||||
'filenames.gypi',
|
||||
|
|
|
@ -27,10 +27,10 @@ AtomMainDelegate::~AtomMainDelegate() {
|
|||
}
|
||||
|
||||
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
// Disable logging out to debug.log on Windows
|
||||
logging::LoggingSettings settings;
|
||||
#if defined(OS_WIN)
|
||||
#if defined(DEBUG)
|
||||
// Print logging to debug.log on Windows
|
||||
settings.logging_dest = logging::LOG_TO_ALL;
|
||||
settings.log_file = L"debug.log";
|
||||
settings.lock_log = logging::LOCK_LOG_FILE;
|
||||
|
@ -41,6 +41,12 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||
#else // defined(OS_WIN)
|
||||
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
||||
#endif // !defined(OS_WIN)
|
||||
|
||||
// Only enable logging when --enable-logging is specified.
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (!command_line->HasSwitch(switches::kEnableLogging))
|
||||
settings.logging_dest = logging::LOG_NONE;
|
||||
|
||||
logging::InitLogging(settings);
|
||||
|
||||
// Logging with pid and timestamp.
|
||||
|
|
|
@ -52,13 +52,16 @@ void AtomBrowserMainParts::RegisterDestructionCallback(
|
|||
destruction_callbacks_.push_back(callback);
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PreEarlyInitialization() {
|
||||
brightray::BrowserMainParts::PreEarlyInitialization();
|
||||
#if defined(OS_POSIX)
|
||||
HandleSIGCHLD();
|
||||
#endif
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -116,6 +119,13 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
||||
brightray::BrowserMainParts::PostMainMessageLoopStart();
|
||||
#if defined(OS_POSIX)
|
||||
HandleShutdownSignals();
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
||||
brightray::BrowserMainParts::PostMainMessageLoopRun();
|
||||
|
||||
|
|
|
@ -39,8 +39,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
|||
|
||||
protected:
|
||||
// content::BrowserMainParts:
|
||||
void PreEarlyInitialization() override;
|
||||
void PostEarlyInitialization() override;
|
||||
void PreMainMessageLoopRun() override;
|
||||
void PostMainMessageLoopStart() override;
|
||||
void PostMainMessageLoopRun() override;
|
||||
#if defined(OS_MACOSX)
|
||||
void PreMainMessageLoopStart() override;
|
||||
|
@ -48,8 +50,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
|||
#endif
|
||||
|
||||
private:
|
||||
#if defined(USE_X11)
|
||||
void SetDPIFromGSettings();
|
||||
#if defined(OS_POSIX)
|
||||
// Set signal handlers.
|
||||
void HandleSIGCHLD();
|
||||
void HandleShutdownSignals();
|
||||
#endif
|
||||
|
||||
// A fake BrowserProcess object that used to feed the source code from chrome.
|
||||
|
|
|
@ -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
|
225
atom/browser/atom_browser_main_parts_posix.cc
Normal file
225
atom/browser/atom_browser_main_parts_posix.cc
Normal file
|
@ -0,0 +1,225 @@
|
|||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Most code came from: chrome/browser/chrome_browser_main_posix.cc.
|
||||
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// See comment in |PreEarlyInitialization()|, where sigaction is called.
|
||||
void SIGCHLDHandler(int signal) {
|
||||
}
|
||||
|
||||
// The OSX fork() implementation can crash in the child process before
|
||||
// fork() returns. In that case, the shutdown pipe will still be
|
||||
// shared with the parent process. To prevent child crashes from
|
||||
// causing parent shutdowns, |g_pipe_pid| is the pid for the process
|
||||
// which registered |g_shutdown_pipe_write_fd|.
|
||||
// See <http://crbug.com/175341>.
|
||||
pid_t g_pipe_pid = -1;
|
||||
int g_shutdown_pipe_write_fd = -1;
|
||||
int g_shutdown_pipe_read_fd = -1;
|
||||
|
||||
// Common code between SIG{HUP, INT, TERM}Handler.
|
||||
void GracefulShutdownHandler(int signal) {
|
||||
// Reinstall the default handler. We had one shot at graceful shutdown.
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = SIG_DFL;
|
||||
RAW_CHECK(sigaction(signal, &action, NULL) == 0);
|
||||
|
||||
RAW_CHECK(g_pipe_pid == getpid());
|
||||
RAW_CHECK(g_shutdown_pipe_write_fd != -1);
|
||||
RAW_CHECK(g_shutdown_pipe_read_fd != -1);
|
||||
size_t bytes_written = 0;
|
||||
do {
|
||||
int rv = HANDLE_EINTR(
|
||||
write(g_shutdown_pipe_write_fd,
|
||||
reinterpret_cast<const char*>(&signal) + bytes_written,
|
||||
sizeof(signal) - bytes_written));
|
||||
RAW_CHECK(rv >= 0);
|
||||
bytes_written += rv;
|
||||
} while (bytes_written < sizeof(signal));
|
||||
}
|
||||
|
||||
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
|
||||
void SIGHUPHandler(int signal) {
|
||||
RAW_CHECK(signal == SIGHUP);
|
||||
GracefulShutdownHandler(signal);
|
||||
}
|
||||
|
||||
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
|
||||
void SIGINTHandler(int signal) {
|
||||
RAW_CHECK(signal == SIGINT);
|
||||
GracefulShutdownHandler(signal);
|
||||
}
|
||||
|
||||
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
|
||||
void SIGTERMHandler(int signal) {
|
||||
RAW_CHECK(signal == SIGTERM);
|
||||
GracefulShutdownHandler(signal);
|
||||
}
|
||||
|
||||
class ShutdownDetector : public base::PlatformThread::Delegate {
|
||||
public:
|
||||
explicit ShutdownDetector(int shutdown_fd);
|
||||
|
||||
void ThreadMain() override;
|
||||
|
||||
private:
|
||||
const int shutdown_fd_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ShutdownDetector);
|
||||
};
|
||||
|
||||
ShutdownDetector::ShutdownDetector(int shutdown_fd)
|
||||
: shutdown_fd_(shutdown_fd) {
|
||||
CHECK_NE(shutdown_fd_, -1);
|
||||
}
|
||||
|
||||
// These functions are used to help us diagnose crash dumps that happen
|
||||
// during the shutdown process.
|
||||
NOINLINE void ShutdownFDReadError() {
|
||||
// Ensure function isn't optimized away.
|
||||
asm("");
|
||||
sleep(UINT_MAX);
|
||||
}
|
||||
|
||||
NOINLINE void ShutdownFDClosedError() {
|
||||
// Ensure function isn't optimized away.
|
||||
asm("");
|
||||
sleep(UINT_MAX);
|
||||
}
|
||||
|
||||
NOINLINE void ExitPosted() {
|
||||
// Ensure function isn't optimized away.
|
||||
asm("");
|
||||
sleep(UINT_MAX);
|
||||
}
|
||||
|
||||
void ShutdownDetector::ThreadMain() {
|
||||
base::PlatformThread::SetName("CrShutdownDetector");
|
||||
|
||||
int signal;
|
||||
size_t bytes_read = 0;
|
||||
ssize_t ret;
|
||||
do {
|
||||
ret = HANDLE_EINTR(
|
||||
read(shutdown_fd_,
|
||||
reinterpret_cast<char*>(&signal) + bytes_read,
|
||||
sizeof(signal) - bytes_read));
|
||||
if (ret < 0) {
|
||||
NOTREACHED() << "Unexpected error: " << strerror(errno);
|
||||
ShutdownFDReadError();
|
||||
break;
|
||||
} else if (ret == 0) {
|
||||
NOTREACHED() << "Unexpected closure of shutdown pipe.";
|
||||
ShutdownFDClosedError();
|
||||
break;
|
||||
}
|
||||
bytes_read += ret;
|
||||
} while (bytes_read < sizeof(signal));
|
||||
VLOG(1) << "Handling shutdown for signal " << signal << ".";
|
||||
base::Closure task =
|
||||
base::Bind(&Browser::Quit, base::Unretained(Browser::Get()));
|
||||
|
||||
if (!BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task)) {
|
||||
// Without a UI thread to post the exit task to, there aren't many
|
||||
// options. Raise the signal again. The default handler will pick it up
|
||||
// and cause an ungraceful exit.
|
||||
RAW_LOG(WARNING, "No UI thread, exiting ungracefully.");
|
||||
kill(getpid(), signal);
|
||||
|
||||
// The signal may be handled on another thread. Give that a chance to
|
||||
// happen.
|
||||
sleep(3);
|
||||
|
||||
// We really should be dead by now. For whatever reason, we're not. Exit
|
||||
// immediately, with the exit status set to the signal number with bit 8
|
||||
// set. On the systems that we care about, this exit status is what is
|
||||
// normally used to indicate an exit by this signal's default handler.
|
||||
// This mechanism isn't a de jure standard, but even in the worst case, it
|
||||
// should at least result in an immediate exit.
|
||||
RAW_LOG(WARNING, "Still here, exiting really ungracefully.");
|
||||
_exit(signal | (1 << 7));
|
||||
}
|
||||
ExitPosted();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AtomBrowserMainParts::HandleSIGCHLD() {
|
||||
// We need to accept SIGCHLD, even though our handler is a no-op because
|
||||
// otherwise we cannot wait on children. (According to POSIX 2001.)
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = SIGCHLDHandler;
|
||||
CHECK_EQ(sigaction(SIGCHLD, &action, NULL), 0);
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::HandleShutdownSignals() {
|
||||
int pipefd[2];
|
||||
int ret = pipe(pipefd);
|
||||
if (ret < 0) {
|
||||
PLOG(DFATAL) << "Failed to create pipe";
|
||||
} else {
|
||||
g_pipe_pid = getpid();
|
||||
g_shutdown_pipe_read_fd = pipefd[0];
|
||||
g_shutdown_pipe_write_fd = pipefd[1];
|
||||
#if !defined(ADDRESS_SANITIZER) && !defined(KEEP_SHADOW_STACKS)
|
||||
const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 2;
|
||||
#else
|
||||
// ASan instrumentation and -finstrument-functions (used for keeping the
|
||||
// shadow stacks) bloat the stack frames, so we need to increase the stack
|
||||
// size to avoid hitting the guard page.
|
||||
const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN * 4;
|
||||
#endif
|
||||
// TODO(viettrungluu,willchan): crbug.com/29675 - This currently leaks, so
|
||||
// if you change this, you'll probably need to change the suppression.
|
||||
if (!base::PlatformThread::CreateNonJoinable(
|
||||
kShutdownDetectorThreadStackSize,
|
||||
new ShutdownDetector(g_shutdown_pipe_read_fd))) {
|
||||
LOG(DFATAL) << "Failed to create shutdown detector task.";
|
||||
}
|
||||
}
|
||||
// Setup signal handlers for shutdown AFTER shutdown pipe is setup because
|
||||
// it may be called right away after handler is set.
|
||||
|
||||
// If adding to this list of signal handlers, note the new signal probably
|
||||
// needs to be reset in child processes. See
|
||||
// base/process_util_posix.cc:LaunchProcess.
|
||||
|
||||
// We need to handle SIGTERM, because that is how many POSIX-based distros ask
|
||||
// processes to quit gracefully at shutdown time.
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = SIGTERMHandler;
|
||||
CHECK_EQ(sigaction(SIGTERM, &action, NULL), 0);
|
||||
// Also handle SIGINT - when the user terminates the browser via Ctrl+C. If
|
||||
// the browser process is being debugged, GDB will catch the SIGINT first.
|
||||
action.sa_handler = SIGINTHandler;
|
||||
CHECK_EQ(sigaction(SIGINT, &action, NULL), 0);
|
||||
// And SIGHUP, for when the terminal disappears. On shutdown, many Linux
|
||||
// distros send SIGHUP, SIGTERM, and then SIGKILL.
|
||||
action.sa_handler = SIGHUPHandler;
|
||||
CHECK_EQ(sigaction(SIGHUP, &action, NULL), 0);
|
||||
}
|
||||
|
||||
} // namespace atom
|
|
@ -16,7 +16,8 @@ namespace atom {
|
|||
|
||||
Browser::Browser()
|
||||
: is_quiting_(false),
|
||||
is_ready_(false) {
|
||||
is_ready_(false),
|
||||
is_shutdown_(false) {
|
||||
WindowList::AddObserver(this);
|
||||
}
|
||||
|
||||
|
@ -30,6 +31,9 @@ Browser* Browser::Get() {
|
|||
}
|
||||
|
||||
void Browser::Quit() {
|
||||
if (is_quiting_)
|
||||
return;
|
||||
|
||||
is_quiting_ = HandleBeforeQuit();
|
||||
if (!is_quiting_)
|
||||
return;
|
||||
|
@ -42,9 +46,13 @@ void Browser::Quit() {
|
|||
}
|
||||
|
||||
void Browser::Shutdown() {
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
|
||||
if (is_shutdown_)
|
||||
return;
|
||||
|
||||
is_shutdown_ = true;
|
||||
is_quiting_ = true;
|
||||
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
|
||||
base::MessageLoop::current()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
}
|
||||
|
@ -121,6 +129,9 @@ void Browser::ClientCertificateSelector(
|
|||
}
|
||||
|
||||
void Browser::NotifyAndShutdown() {
|
||||
if (is_shutdown_)
|
||||
return;
|
||||
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default));
|
||||
|
||||
|
|
|
@ -159,6 +159,9 @@ class Browser : public WindowListObserver {
|
|||
// Whether "ready" event has been emitted.
|
||||
bool is_ready_;
|
||||
|
||||
// The browse is being shutdown.
|
||||
bool is_shutdown_;
|
||||
|
||||
std::string version_override_;
|
||||
std::string name_override_;
|
||||
|
||||
|
|
|
@ -7,14 +7,17 @@ Module = require 'module'
|
|||
# we need to restore it here.
|
||||
process.argv.splice 1, 1
|
||||
|
||||
# Clear search paths.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
# Add browser/api/lib to module search paths, which contains javascript part of
|
||||
# Electron's built-in libraries.
|
||||
globalPaths = Module.globalPaths
|
||||
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
if process.platform is 'win32'
|
||||
# Redirect node's console to use our own implementations, since node can not
|
||||
# handle console output when running as GUI program.
|
||||
|
|
|
@ -283,6 +283,8 @@ NativeWindowViews::NativeWindowViews(
|
|||
else
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
|
||||
last_normal_size_ = gfx::Size(widget_size_);
|
||||
|
||||
if (!has_frame()) {
|
||||
// Set Window style so that we get a minimize and maximize animation when
|
||||
// frameless.
|
||||
|
@ -351,7 +353,7 @@ void NativeWindowViews::ShowInactive() {
|
|||
}
|
||||
|
||||
void NativeWindowViews::Hide() {
|
||||
web_contents()->WasHidden();
|
||||
window_->Hide();
|
||||
}
|
||||
|
||||
bool NativeWindowViews::IsVisible() {
|
||||
|
@ -818,9 +820,7 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
|||
NotifyWindowExecuteWindowsCommand(command);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool NativeWindowViews::PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
|
||||
switch (message) {
|
||||
|
@ -851,12 +851,18 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
|||
NotifyWindowMinimize();
|
||||
break;
|
||||
case SIZE_RESTORED:
|
||||
if (last_window_state_ == ui::SHOW_STATE_NORMAL)
|
||||
return;
|
||||
|
||||
if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
|
||||
// Window was resized so we save it's new size.
|
||||
last_normal_size_ = GetSize();
|
||||
} else {
|
||||
switch (last_window_state_) {
|
||||
case ui::SHOW_STATE_MAXIMIZED:
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
|
||||
// When the window is restored we resize it to the previous known
|
||||
// normal size.
|
||||
NativeWindow::SetSize(last_normal_size_);
|
||||
|
||||
NotifyWindowUnmaximize();
|
||||
break;
|
||||
case ui::SHOW_STATE_MINIMIZED:
|
||||
|
@ -865,15 +871,48 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
|||
NotifyWindowEnterFullScreen();
|
||||
} else {
|
||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||
|
||||
// When the window is restored we resize it to the previous known
|
||||
// normal size.
|
||||
NativeWindow::SetSize(last_normal_size_);
|
||||
|
||||
NotifyWindowRestore();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
gfx::Size NativeWindowViews::WindowSizeToFramelessSize(
|
||||
const gfx::Size& size) {
|
||||
if (size.width() == 0 && size.height() == 0)
|
||||
return size;
|
||||
|
||||
gfx::Rect window_bounds = gfx::Rect(size);
|
||||
if (use_content_size_) {
|
||||
if (menu_bar_ && menu_bar_visible_) {
|
||||
window_bounds.set_height(window_bounds.height() + kMenuBarHeight);
|
||||
}
|
||||
} else if (has_frame()) {
|
||||
#if defined(OS_WIN)
|
||||
gfx::Size frame_size = gfx::win::ScreenToDIPRect(
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(
|
||||
gfx::Rect())).size();
|
||||
#else
|
||||
gfx::Size frame_size =
|
||||
window_->non_client_view()->GetWindowBoundsForClientBounds(
|
||||
gfx::Rect()).size();
|
||||
#endif
|
||||
window_bounds.set_height(window_bounds.height() - frame_size.height());
|
||||
window_bounds.set_width(window_bounds.width() - frame_size.width());
|
||||
}
|
||||
|
||||
return window_bounds.size();
|
||||
}
|
||||
|
||||
void NativeWindowViews::HandleKeyboardEvent(
|
||||
content::WebContents*,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
|
@ -905,9 +944,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;
|
||||
|
|
|
@ -94,6 +94,8 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget();
|
||||
|
||||
gfx::Size WindowSizeToFramelessSize(const gfx::Size& size);
|
||||
|
||||
views::Widget* widget() const { return window_.get(); }
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -176,6 +178,12 @@ class NativeWindowViews : public NativeWindow,
|
|||
|
||||
ui::WindowShowState last_window_state_;
|
||||
|
||||
// There's an issue with restore on Windows, that sometimes causes the Window
|
||||
// to receive the wrong size (#2498). To circumvent that, we keep tabs on the
|
||||
// size of the window while in the normal state (not maximized, minimized or
|
||||
// fullscreen), so we restore it correctly.
|
||||
gfx::Size last_normal_size_;
|
||||
|
||||
// In charge of running taskbar related APIs.
|
||||
TaskbarHost taskbar_host_;
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<key>CFBundleIconFile</key>
|
||||
<string>atom.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.33.4</string>
|
||||
<string>0.33.6</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.8.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
|
|
|
@ -56,8 +56,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,33,4,0
|
||||
PRODUCTVERSION 0,33,4,0
|
||||
FILEVERSION 0,33,6,0
|
||||
PRODUCTVERSION 0,33,6,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -74,12 +74,12 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "0.33.4"
|
||||
VALUE "FileVersion", "0.33.6"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "0.33.4"
|
||||
VALUE "ProductVersion", "0.33.6"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -40,12 +40,14 @@ int WinFrameView::NonClientHitTest(const gfx::Point& point) {
|
|||
}
|
||||
|
||||
gfx::Size WinFrameView::GetMinimumSize() const {
|
||||
gfx::Size size = FramelessView::GetMinimumSize();
|
||||
gfx::Size size = window_->WindowSizeToFramelessSize(
|
||||
window_->GetMinimumSize());
|
||||
return gfx::win::DIPToScreenSize(size);
|
||||
}
|
||||
|
||||
gfx::Size WinFrameView::GetMaximumSize() const {
|
||||
gfx::Size size = FramelessView::GetMaximumSize();
|
||||
gfx::Size size = window_->WindowSizeToFramelessSize(
|
||||
window_->GetMaximumSize());
|
||||
return gfx::win::DIPToScreenSize(size);
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#define ATOM_MAJOR_VERSION 0
|
||||
#define ATOM_MINOR_VERSION 33
|
||||
#define ATOM_PATCH_VERSION 4
|
||||
#define ATOM_PATCH_VERSION 6
|
||||
|
||||
#define ATOM_VERSION_IS_RELEASE 1
|
||||
|
||||
|
|
|
@ -9,21 +9,8 @@ process.atomBinding = (name) ->
|
|||
catch e
|
||||
process.binding "atom_common_#{name}" if /No such module/.test e.message
|
||||
|
||||
# Global module search paths.
|
||||
globalPaths = Module.globalPaths
|
||||
|
||||
# Don't lookup modules in user-defined search paths, see http://git.io/vf8sF.
|
||||
homeDir =
|
||||
if process.platform is 'win32'
|
||||
process.env.USERPROFILE
|
||||
else
|
||||
process.env.HOME
|
||||
if homeDir # Node only add user-defined search paths when $HOME is defined.
|
||||
userModulePath = path.resolve homeDir, '.node_modules'
|
||||
globalPaths.splice globalPaths.indexOf(userModulePath), 2
|
||||
|
||||
# Add common/api/lib to module search paths.
|
||||
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
Module.globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
|
||||
# setImmediate and process.nextTick makes use of uv_check and uv_prepare to
|
||||
# run the callbacks, however since we only run uv loop on requests, the
|
||||
|
|
29
atom/common/lib/reset-search-paths.coffee
Normal file
29
atom/common/lib/reset-search-paths.coffee
Normal file
|
@ -0,0 +1,29 @@
|
|||
path = require 'path'
|
||||
Module = require 'module'
|
||||
|
||||
# Clear Node's global search paths.
|
||||
Module.globalPaths.length = 0
|
||||
|
||||
# Clear current and parent(init.coffee)'s search paths.
|
||||
module.paths = []
|
||||
module.parent.paths = []
|
||||
|
||||
# Prevent Node from adding paths outside this app to search paths.
|
||||
Module._nodeModulePaths = (from) ->
|
||||
from = path.resolve from
|
||||
|
||||
# If "from" is outside the app then we do nothing.
|
||||
skipOutsidePaths = from.startsWith process.resourcesPath
|
||||
|
||||
# Following logoic is copied from module.js.
|
||||
splitRe = if process.platform is 'win32' then /[\/\\]/ else /\//
|
||||
paths = []
|
||||
|
||||
parts = from.split splitRe
|
||||
for part, tip in parts by -1
|
||||
continue if part is 'node_modules'
|
||||
dir = parts.slice(0, tip + 1).join path.sep
|
||||
break if skipOutsidePaths and not dir.startsWith process.resourcesPath
|
||||
paths.push path.join(dir, 'node_modules')
|
||||
|
||||
paths
|
|
@ -7,16 +7,16 @@ Module = require 'module'
|
|||
# atom-renderer.js, we need to restore it here.
|
||||
process.argv.splice 1, 1
|
||||
|
||||
# Clear search paths.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
# Add renderer/api/lib to require's search paths, which contains javascript part
|
||||
# of Atom's built-in libraries.
|
||||
globalPaths = Module.globalPaths
|
||||
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||
# And also app.
|
||||
globalPaths.push path.join(process.resourcesPath, 'app')
|
||||
globalPaths.push path.join(process.resourcesPath, 'app.asar')
|
||||
|
||||
# Import common settings.
|
||||
require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')
|
||||
|
||||
# The global variable will be used by ipc for event dispatching
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
## 개발 가이드
|
||||
|
||||
* [지원하는 플랫폼](tutorial/supported-platforms.md)
|
||||
* [어플리케이션 배포](tutorial/application-distribution.md)
|
||||
* [어플리케이션 패키징](tutorial/application-packaging.md)
|
||||
* [네이티브 Node 모듈 사용하기](tutorial/using-native-node-modules.md)
|
||||
|
|
|
@ -84,13 +84,19 @@ Net log 이벤트를 활성화하고 `path`에 로그를 기록합니다.
|
|||
|
||||
## --ssl-version-fallback-min=`version`
|
||||
|
||||
Fallback SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2")
|
||||
TLS fallback에서 사용할 SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2")
|
||||
|
||||
## --enable-logging
|
||||
|
||||
Chromium의 로그를 콘솔에 출력합니다.
|
||||
|
||||
이 스위치는 어플리케이션이 로드되기 전에 파싱 되므로 `app.commandLine.appendSwitch`에서 사용할 수 없습니다.
|
||||
|
||||
## --v=`log_level`
|
||||
|
||||
기본 V-logging 최대 활성화 레벨을 지정합니다. 기본값은 0입니다. 기본적으로 양수를 레벨로 사용합니다.
|
||||
|
||||
`--v=-1`를 사용하면 로깅이 비활성화 됩니다.
|
||||
이 스위치는 `--enable-logging` 스위치를 같이 지정해야 작동합니다.
|
||||
|
||||
## --vmodule=`pattern`
|
||||
|
||||
|
@ -100,10 +106,4 @@ Fallback SSL/TLS 최소 버전을 지정합니다. ("tls1", "tls1.1", "tls1.2")
|
|||
또한 슬래시(`/`) 또는 백슬래시(`\`)를 포함하는 패턴은 지정한 경로에 대해 패턴을 테스트 합니다.
|
||||
예를 들어 `*/foo/bar/*=2` 표현식은 `foo/bar` 디렉터리 안의 모든 소스 코드의 로깅 레벨을 2로 지정합니다.
|
||||
|
||||
모든 크로미움과 관련된 로그를 비활성화하고 어플리케이션의 로그만 활성화 하려면 다음과 같이 코드를 작성하면 됩니다:
|
||||
|
||||
|
||||
```javascript
|
||||
app.commandLine.appendSwitch('v', -1);
|
||||
app.commandLine.appendSwitch('vmodule', 'console=0');
|
||||
```
|
||||
이 스위치는 `--enable-logging` 스위치를 같이 지정해야 작동합니다.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# MenuItem
|
||||
|
||||
`menu-item` 모듈은 어플리케이션 또는 컨텐츠 [`menu`](menu.md)에 아이템을 추가할 수 있도록 관련 클래스를 제공합니다.
|
||||
`menu-item` 모듈은 어플리케이션 또는 컨텍스트 [`menu`](menu.md)에 아이템을 추가할 수 있도록 관련 클래스를 제공합니다.
|
||||
|
||||
[`menu`](menu.md)에서 예제를 확인할 수 있습니다.
|
||||
|
||||
|
|
26
docs-translations/ko-KR/tutorial/supported-platforms.md
Normal file
26
docs-translations/ko-KR/tutorial/supported-platforms.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
# 지원하는 플랫폼
|
||||
|
||||
Electron에선 다음과 같은 플랫폼을 지원합니다:
|
||||
|
||||
### OS X
|
||||
|
||||
OS X는 64비트 바이너리만 제공됩니다. 그리고 최소 OS X 지원 버전은 10.8입니다.
|
||||
|
||||
### Windows
|
||||
|
||||
Windows 7 이후 버전만 지원됩니다. Windows Vista에서도 작동할 수 있지만 아직 모든 작동 테스트가 완료되지 않았습니다.
|
||||
|
||||
윈도우용 바이너리는 `x86`과 `x64` 모두 제공됩니다. 그리고 `ARM` 버전 윈도우는 아직 지원하지 않습니다. (역주: 추후 지원할 가능성이 있습니다)
|
||||
|
||||
### Linux
|
||||
|
||||
Ubuntu 12.04 버전에서 빌드된 `ia32`(`i686`), `x64`(`amd64`) 바이너리가 제공됩니다.
|
||||
그리고 `arm` 버전 바이너리는 ARM v7 hard-float ABI와 Debian Wheezy용 NEON에 맞춰 제공됩니다.
|
||||
|
||||
미리 빌드된 바이너리가 배포판에서 작동할 수 있는지 여부는 Electron이 빌드된 플랫폼에서 링크된 라이브러리에 따라 달라집니다.
|
||||
그래서 현재 Linux 바이너리는 Ubuntu 12.04 버전만 정상적인 작동이 보장됩니다.
|
||||
하지만 다음 플랫폼들은 미리 빌드된 Electron 바이너리가 정상적으로 작동하는 것을 확인했습니다:
|
||||
|
||||
* Ubuntu 12.04 이후 버전
|
||||
* Fedora 21
|
||||
* Debian 8
|
|
@ -71,7 +71,7 @@ driver.quit();
|
|||
먼저, `chromedriver` 바이너리를 다운로드 받고 실행합니다:
|
||||
|
||||
```bash
|
||||
$ chromedriver --url-base=/wd/hub --port=9515
|
||||
$ chromedriver --url-base=wd/hub --port=9515
|
||||
Starting ChromeDriver (v2.10.291558) on port 9515
|
||||
Only local connections are allowed.
|
||||
```
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
## Guides
|
||||
|
||||
* [Supported Platforms](tutorial/supported-platforms.md)
|
||||
* [Application Distribution](tutorial/application-distribution.md)
|
||||
* [Application Packaging](tutorial/application-packaging.md)
|
||||
* [Using Native Node Modules](tutorial/using-native-node-modules.md)
|
||||
|
|
|
@ -197,12 +197,6 @@ You can request the following paths by the name:
|
|||
* `~/Library/Application Support` on OS X
|
||||
* `userData` The directory for storing your app's configuration files, which by
|
||||
default it is the `appData` directory appended with your app's name.
|
||||
* `cache` Per-user application cache directory, which by default points to:
|
||||
* `%APPDATA%` on Windows (which doesn't have a universal cache location)
|
||||
* `$XDG_CACHE_HOME` or `~/.cache` on Linux
|
||||
* `~/Library/Caches` on OS X
|
||||
* `userCache` The directory for placing your app's caches, by default it is the
|
||||
`cache` directory appended with your app's name.
|
||||
* `temp` Temporary directory.
|
||||
* `userDesktop` The current user's Desktop directory.
|
||||
* `exe` The current executable file.
|
||||
|
|
|
@ -89,15 +89,21 @@ Enables net log events to be saved and writes them to `path`.
|
|||
|
||||
## --ssl-version-fallback-min=`version`
|
||||
|
||||
Set the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS
|
||||
Sets the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS
|
||||
fallback will accept.
|
||||
|
||||
## --enable-logging
|
||||
|
||||
Prints Chromium's logging into console.
|
||||
|
||||
This switch can not be used in `app.commandLine.appendSwitch` since it is parsed earlier than user's app is loaded.
|
||||
|
||||
## --v=`log_level`
|
||||
|
||||
Gives the default maximal active V-logging level; 0 is the default. Normally
|
||||
positive values are used for V-logging levels.
|
||||
|
||||
Passing `--v=-1` will disable logging.
|
||||
This switch only works when `--enable-logging` is also passed.
|
||||
|
||||
## --vmodule=`pattern`
|
||||
|
||||
|
@ -109,10 +115,4 @@ Any pattern containing a forward or backward slash will be tested against the
|
|||
whole pathname and not just the module. E.g. `*/foo/bar/*=2` would change the
|
||||
logging level for all code in the source files under a `foo/bar` directory.
|
||||
|
||||
To disable all chromium related logs and only enable your application logs you
|
||||
can do:
|
||||
|
||||
```javascript
|
||||
app.commandLine.appendSwitch('v', -1);
|
||||
app.commandLine.appendSwitch('vmodule', 'console=0');
|
||||
```
|
||||
This switch only works when `--enable-logging` is also passed.
|
||||
|
|
|
@ -9,7 +9,25 @@ upstream node:
|
|||
* `process.versions['chrome']` String - Version of Chromium.
|
||||
* `process.resourcesPath` String - Path to JavaScript source code.
|
||||
|
||||
# Methods
|
||||
## Events
|
||||
|
||||
### Event: 'loaded'
|
||||
|
||||
Emitted when Electron has loaded its internal initialization script and is
|
||||
beginning to load the web page or the main script.
|
||||
|
||||
It can be used by the preload script to add removed Node global symbols back to
|
||||
the global scope when node integration is turned off:
|
||||
|
||||
```js
|
||||
// preload.js
|
||||
process.once('loaded', function() {
|
||||
global.setImmediate = setImmediate;
|
||||
global.clearImmediate = clearImmediate;
|
||||
});
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
The `process` object has the following method:
|
||||
|
||||
|
@ -17,7 +35,7 @@ The `process` object has the following method:
|
|||
|
||||
Causes the main thread of the current process hang.
|
||||
|
||||
## process.setFdLimit(maxDescriptors) _OS X_ _Linux_
|
||||
### process.setFdLimit(maxDescriptors) _OS X_ _Linux_
|
||||
|
||||
* `maxDescriptors` Integer
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ app.on('ready', function() {
|
|||
var displays = electronScreen.getAllDisplays();
|
||||
var externalDisplay = null;
|
||||
for (var i in displays) {
|
||||
if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) {
|
||||
if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) {
|
||||
externalDisplay = displays[i];
|
||||
break;
|
||||
}
|
||||
|
|
23
docs/tutorial/supported-platforms.md
Normal file
23
docs/tutorial/supported-platforms.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Supported Platforms
|
||||
|
||||
Following platforms are supported by Electron:
|
||||
|
||||
### OS X
|
||||
|
||||
Only 64bit binaries are provided for OS X, and the minimum OS X version supported is OS X 10.8.
|
||||
|
||||
### Windows
|
||||
|
||||
Windows 7 and later are supported, Electron should be able to run on Windows Vista, but there is no testing done on it.
|
||||
|
||||
Both `x86` and `x64` binaries are provided for Windows. Please note, the `ARM` version of Windows is not supported for now.
|
||||
|
||||
### Linux
|
||||
|
||||
The prebuilt `ia32`(`i686`) and `x64`(`amd64`) binaries of Electron are built on Ubuntu 12.04, the `arm` binary is built against ARM v7 with hard-float ABI and NEON for Debian Wheezy.
|
||||
|
||||
Whether the prebuilt binary can run on a distribution depends on whether the distribution includes the libraries that Electron is linked to on the building platform, so only Ubuntu 12.04 is guaranteed to work, but following platforms are also verified to be able to run the prebuilt binaries of Electron:
|
||||
|
||||
* Ubuntu 12.04 and later
|
||||
* Fedora 21
|
||||
* Debian 8
|
|
@ -74,7 +74,7 @@ driver.
|
|||
First you need to download the `chromedriver` binary, and run it:
|
||||
|
||||
```bash
|
||||
$ chromedriver --url-base=/wd/hub --port=9515
|
||||
$ chromedriver --url-base=wd/hub --port=9515
|
||||
Starting ChromeDriver (v2.10.291558) on port 9515
|
||||
Only local connections are allowed.
|
||||
```
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
'atom/common/api/lib/native-image.coffee',
|
||||
'atom/common/api/lib/shell.coffee',
|
||||
'atom/common/lib/init.coffee',
|
||||
'atom/common/lib/reset-search-paths.coffee',
|
||||
'atom/renderer/lib/chrome-api.coffee',
|
||||
'atom/renderer/lib/init.coffee',
|
||||
'atom/renderer/lib/inspector.coffee',
|
||||
|
@ -123,8 +124,8 @@
|
|||
'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_browser_main_parts_posix.cc',
|
||||
'atom/browser/atom_javascript_dialog_manager.cc',
|
||||
'atom/browser/atom_javascript_dialog_manager.h',
|
||||
'atom/browser/atom_quota_permission_context.cc',
|
||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 6cbb4ad4d173d25b66eecf675c2b25ee64196429
|
||||
Subproject commit c44f99278bc4f6823f81b6f3a8d75881d697fd01
|
Loading…
Reference in a new issue