From 021ee20400ea4636090fb41213f3dcfd1770edf6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 17:52:46 +0800 Subject: [PATCH 01/23] No need to add "app" to search paths --- atom/renderer/lib/init.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index 274c50ec5f39..ff9b12ecbf3c 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -11,9 +11,6 @@ process.argv.splice 1, 1 # 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') From 9fe326ebeb43ffb2c955945ca8b4a2135efb08c2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 19:55:59 +0800 Subject: [PATCH 02/23] Clear node's global search paths --- atom/browser/lib/init.coffee | 6 +++--- atom/common/lib/init.coffee | 13 ++----------- atom/renderer/lib/init.coffee | 6 +++--- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 454baf0b8ac5..44ae29522ebf 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -7,14 +7,14 @@ Module = require 'module' # we need to restore it here. process.argv.splice 1, 1 +# 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. diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index acb635edeaa4..2bfea3d72afa 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -9,18 +9,9 @@ process.atomBinding = (name) -> catch e process.binding "atom_common_#{name}" if /No such module/.test e.message -# Global module search paths. +# Clear node's global 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 +globalPaths.length = 0 # Add common/api/lib to module search paths. globalPaths.push path.resolve(__dirname, '..', 'api', 'lib') diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index ff9b12ecbf3c..e5173fcd1ec8 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -7,14 +7,14 @@ Module = require 'module' # atom-renderer.js, we need to restore it here. process.argv.splice 1, 1 +# 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') -# 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' v8Util.setHiddenValue global, 'ipc', new events.EventEmitter From 01d2765e4b566df853cd583006ebc7993d48cd38 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 3 Oct 2015 20:38:39 +0800 Subject: [PATCH 03/23] Prevent Node from adding paths outside this app to search paths --- atom/browser/lib/init.coffee | 3 +++ atom/common/lib/init.coffee | 6 +---- atom/common/lib/reset-search-paths.coffee | 29 +++++++++++++++++++++++ atom/renderer/lib/init.coffee | 3 +++ filenames.gypi | 1 + 5 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 atom/common/lib/reset-search-paths.coffee diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 44ae29522ebf..b394c0fecc28 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -7,6 +7,9 @@ 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') diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 2bfea3d72afa..1c80e6171a4d 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -9,12 +9,8 @@ process.atomBinding = (name) -> catch e process.binding "atom_common_#{name}" if /No such module/.test e.message -# Clear node's global search paths. -globalPaths = Module.globalPaths -globalPaths.length = 0 - # 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 diff --git a/atom/common/lib/reset-search-paths.coffee b/atom/common/lib/reset-search-paths.coffee new file mode 100644 index 000000000000..7061103306aa --- /dev/null +++ b/atom/common/lib/reset-search-paths.coffee @@ -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 diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index e5173fcd1ec8..b7224b39aeed 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -7,6 +7,9 @@ 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') diff --git a/filenames.gypi b/filenames.gypi index 0e7010d7a4cf..000633fb96b1 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -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', From b4ec7c5aaf09d7125124658f269954cacc1765c0 Mon Sep 17 00:00:00 2001 From: chriswmercer Date: Sat, 3 Oct 2015 18:03:49 +0100 Subject: [PATCH 04/23] Minor grammar correction --- docs/tutorial/supported-platforms.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/supported-platforms.md b/docs/tutorial/supported-platforms.md index 8b795769a878..ec0f3ef6a11c 100644 --- a/docs/tutorial/supported-platforms.md +++ b/docs/tutorial/supported-platforms.md @@ -10,7 +10,7 @@ Only 64bit binaries are provided for OS X, and the minimum OS X version supporte 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, and `ARM` version of Windows is not supported for now. +Both `x86` and `x64` binaries are provided for Windows. Please note, the `ARM` version of Windows is not supported for now. ### Linux From aea1f8aebb8faf71c2c54c815b72ad9a8c21a88e Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 3 Oct 2015 22:09:57 +0300 Subject: [PATCH 05/23] Fix calculating min/max size in frameless views The minimum and maximum size that frameless windows had used, was incorrect. It included the border, so when it was called it actually added that to the size, so window increased in size. The fix makes sure that the view will use the frameless size. This fixes #2945 and partially fixes #1806 (it also refers to some other issues with hidpi which might still exist). --- atom/browser/native_window_views.cc | 29 +++++++++++++++++++++++-- atom/browser/native_window_views.h | 2 ++ atom/browser/ui/views/frameless_view.cc | 8 +++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index e9db97e195d1..40d702e35aa4 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -818,9 +818,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) { @@ -874,6 +872,33 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { } #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) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 71e122d3814f..790e532f84a0 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -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) diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index 03a31e082874..e8d351ec8281 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -104,11 +104,15 @@ gfx::Size FramelessView::GetPreferredSize() const { } gfx::Size FramelessView::GetMinimumSize() const { - return window_->GetMinimumSize(); + gfx::Size size = window_->WindowSizeToFramelessSize( + window_->GetMinimumSize()); + return size; } gfx::Size FramelessView::GetMaximumSize() const { - return window_->GetMaximumSize(); + gfx::Size size = window_->WindowSizeToFramelessSize( + window_->GetMaximumSize()); + return size; } const char* FramelessView::GetClassName() const { From 5d7cfa1b3ac5b3f578ceca6ceb94dcbddedd4dcf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 15:53:09 +0800 Subject: [PATCH 06/23] Update brightray for atom/brightray#149 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 6cbb4ad4d173..361d99dd05a8 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 6cbb4ad4d173d25b66eecf675c2b25ee64196429 +Subproject commit 361d99dd05a8368faee20bc39a6ffaedbc67c383 From 791f988aba568921c940713231da1811b6a1cdd3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 16:32:08 +0800 Subject: [PATCH 07/23] linux: Fix pressing Alt not showing menubar --- atom/browser/native_window_views.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index e9db97e195d1..4282b0eda96f 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -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; From add9c380230ae61316156025ef8c9fec85d23f84 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 16:33:03 +0800 Subject: [PATCH 08/23] linux: Enable force showing menubar This is for debugging purpose. --- atom/browser/ui/x/x_window_utils.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atom/browser/ui/x/x_window_utils.cc b/atom/browser/ui/x/x_window_utils.cc index e57122839cd8..f5c3f54ec123 100644 --- a/atom/browser/ui/x/x_window_utils.cc +++ b/atom/browser/ui/x/x_window_utils.cc @@ -6,6 +6,7 @@ #include +#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 env(base::Environment::Create()); + if (env->HasVar("ELECTRON_FORCE_WINDOW_MENU_BAR")) + return false; + dbus::Bus::Options options; scoped_refptr bus(new dbus::Bus(options)); From 74b76102a84740a618ff3288f27dfad1197d32a2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 16:53:20 +0800 Subject: [PATCH 09/23] linux: No longer needs to manually read DPI settings It is now done in brightray by reading the value from GTK+. --- atom/browser/atom_browser_main_parts.cc | 4 - atom/browser/atom_browser_main_parts.h | 4 - atom/browser/atom_browser_main_parts_linux.cc | 73 ------------------- filenames.gypi | 1 - vendor/brightray | 2 +- 5 files changed, 1 insertion(+), 83 deletions(-) delete mode 100644 atom/browser/atom_browser_main_parts_linux.cc diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index a1a1192b2768..1b46247c4918 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -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 diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index bcebc86f16ca..9fefa486a1dc 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -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 fake_browser_process_; diff --git a/atom/browser/atom_browser_main_parts_linux.cc b/atom/browser/atom_browser_main_parts_linux.cc deleted file mode 100644 index 278e49ac1f1e..000000000000 --- a/atom/browser/atom_browser_main_parts_linux.cc +++ /dev/null @@ -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 - -#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(*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 diff --git a/filenames.gypi b/filenames.gypi index 000633fb96b1..eb94973e018c 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -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', diff --git a/vendor/brightray b/vendor/brightray index 361d99dd05a8..bbb9287337f8 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 361d99dd05a8368faee20bc39a6ffaedbc67c383 +Subproject commit bbb9287337f8b7958b001be35b993c21cd573109 From bdd2f919137546a560ce808fd386994823628c57 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 19:20:52 +0800 Subject: [PATCH 10/23] Make Browser::Quit more robust --- atom/browser/browser.cc | 15 +++++++++++++-- atom/browser/browser.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 9d2a9fc1effb..d8bb94103cd9 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -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)); diff --git a/atom/browser/browser.h b/atom/browser/browser.h index d135556b8760..3c5abd2f0405 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -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_; From 0e131f760b63ad199c5fffa13b2d422cf3bb5e26 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 19:21:36 +0800 Subject: [PATCH 11/23] Quit gracefully when Ctrl-C is pressed --- atom/browser/atom_browser_main_parts.cc | 12 + atom/browser/atom_browser_main_parts.h | 8 + atom/browser/atom_browser_main_parts_posix.cc | 225 ++++++++++++++++++ filenames.gypi | 1 + 4 files changed, 246 insertions(+) create mode 100644 atom/browser/atom_browser_main_parts_posix.cc diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 1b46247c4918..e70d42fc768a 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -52,6 +52,12 @@ void AtomBrowserMainParts::RegisterDestructionCallback( destruction_callbacks_.push_back(callback); } +void AtomBrowserMainParts::PreEarlyInitialization() { +#if defined(OS_POSIX) + HandleSIGCHLD(); +#endif +} + void AtomBrowserMainParts::PostEarlyInitialization() { brightray::BrowserMainParts::PostEarlyInitialization(); @@ -112,6 +118,12 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { #endif } +void AtomBrowserMainParts::PostMainMessageLoopStart() { +#if defined(OS_POSIX) + HandleShutdownSignals(); +#endif +} + void AtomBrowserMainParts::PostMainMessageLoopRun() { brightray::BrowserMainParts::PostMainMessageLoopRun(); diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index 9fefa486a1dc..65b142157dc1 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -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,6 +50,12 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { #endif private: +#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. scoped_ptr fake_browser_process_; diff --git a/atom/browser/atom_browser_main_parts_posix.cc b/atom/browser/atom_browser_main_parts_posix.cc new file mode 100644 index 000000000000..ea0f87b171d4 --- /dev/null +++ b/atom/browser/atom_browser_main_parts_posix.cc @@ -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 +#include +#include +#include +#include +#include + +#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 . +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(&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(&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(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(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(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(sigaction(SIGHUP, &action, NULL) == 0); +} + +} // namespace atom diff --git a/filenames.gypi b/filenames.gypi index eb94973e018c..04b82992bc33 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -125,6 +125,7 @@ 'atom/browser/atom_browser_main_parts.cc', 'atom/browser/atom_browser_main_parts.h', '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', From a2a4970f5f6601c6e8b713e6fe342ea63d78b022 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 19:36:41 +0800 Subject: [PATCH 12/23] Fix cpplint warnings --- atom/browser/atom_browser_main_parts_posix.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/atom/browser/atom_browser_main_parts_posix.cc b/atom/browser/atom_browser_main_parts_posix.cc index ea0f87b171d4..2a0dddc47483 100644 --- a/atom/browser/atom_browser_main_parts_posix.cc +++ b/atom/browser/atom_browser_main_parts_posix.cc @@ -171,7 +171,7 @@ void AtomBrowserMainParts::HandleSIGCHLD() { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = SIGCHLDHandler; - CHECK(sigaction(SIGCHLD, &action, NULL) == 0); + CHECK_EQ(sigaction(SIGCHLD, &action, NULL), 0); } void AtomBrowserMainParts::HandleShutdownSignals() { @@ -211,15 +211,15 @@ void AtomBrowserMainParts::HandleShutdownSignals() { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = SIGTERMHandler; - CHECK(sigaction(SIGTERM, &action, NULL) == 0); + 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(sigaction(SIGINT, &action, NULL) == 0); + 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(sigaction(SIGHUP, &action, NULL) == 0); + CHECK_EQ(sigaction(SIGHUP, &action, NULL), 0); } } // namespace atom From d4bfeff6ad1686feb4a815096bb7890230a73a01 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 20:08:19 +0800 Subject: [PATCH 13/23] Fix crashing on Linux --- atom/browser/atom_browser_main_parts.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index e70d42fc768a..4c11176997ca 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -53,6 +53,7 @@ void AtomBrowserMainParts::RegisterDestructionCallback( } void AtomBrowserMainParts::PreEarlyInitialization() { + brightray::BrowserMainParts::PreEarlyInitialization(); #if defined(OS_POSIX) HandleSIGCHLD(); #endif @@ -119,6 +120,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { } void AtomBrowserMainParts::PostMainMessageLoopStart() { + brightray::BrowserMainParts::PostMainMessageLoopStart(); #if defined(OS_POSIX) HandleShutdownSignals(); #endif From 3d4318e15e757cf26377637ee1240d5b87cde39c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 21:19:44 +0800 Subject: [PATCH 14/23] docs: Remove `cache` and `userCache` dir Closes #1404. --- docs/api/app.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index e4a8d561e2f5..0b5780aab7bf 100644 --- a/docs/api/app.md +++ b/docs/api/app.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. From ca6f6880139670e560157ebaa812cdf73afdeb0a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 4 Oct 2015 22:19:05 +0800 Subject: [PATCH 15/23] Update brightray for #877 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index bbb9287337f8..c44f99278bc4 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit bbb9287337f8b7958b001be35b993c21cd573109 +Subproject commit c44f99278bc4f6823f81b6f3a8d75881d697fd01 From 4d02fc58fa183c13273888cc30a874abaee52238 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 03:29:02 +0300 Subject: [PATCH 16/23] Fix restore/unmaximize wrong window size This resolves #2498. --- atom/browser/native_window_views.cc | 46 +++++++++++++++++++---------- atom/browser/native_window_views.h | 6 ++++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index e9db97e195d1..7117142cf006 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -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. @@ -851,23 +853,35 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) { NotifyWindowMinimize(); break; case SIZE_RESTORED: - if (last_window_state_ == ui::SHOW_STATE_NORMAL) - return; - - switch (last_window_state_) { - case ui::SHOW_STATE_MAXIMIZED: - last_window_state_ = ui::SHOW_STATE_NORMAL; - NotifyWindowUnmaximize(); - break; - case ui::SHOW_STATE_MINIMIZED: - if (IsFullscreen()) { - last_window_state_ = ui::SHOW_STATE_FULLSCREEN; - NotifyWindowEnterFullScreen(); - } else { + 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; - NotifyWindowRestore(); - } - break; + + // 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: + if (IsFullscreen()) { + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; + 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; } diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 71e122d3814f..f93a9e2f7f9a 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -176,6 +176,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 From c34c123b338df7a8a72cc14f0b032eae223800ac Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 5 Oct 2015 04:01:25 +0300 Subject: [PATCH 17/23] Make it work only on Windows Limiting the solution to Windows only. --- atom/browser/ui/views/frameless_view.cc | 8 ++------ atom/browser/ui/views/win_frame_view.cc | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/atom/browser/ui/views/frameless_view.cc b/atom/browser/ui/views/frameless_view.cc index e8d351ec8281..03a31e082874 100644 --- a/atom/browser/ui/views/frameless_view.cc +++ b/atom/browser/ui/views/frameless_view.cc @@ -104,15 +104,11 @@ gfx::Size FramelessView::GetPreferredSize() const { } gfx::Size FramelessView::GetMinimumSize() const { - gfx::Size size = window_->WindowSizeToFramelessSize( - window_->GetMinimumSize()); - return size; + return window_->GetMinimumSize(); } gfx::Size FramelessView::GetMaximumSize() const { - gfx::Size size = window_->WindowSizeToFramelessSize( - window_->GetMaximumSize()); - return size; + return window_->GetMaximumSize(); } const char* FramelessView::GetClassName() const { diff --git a/atom/browser/ui/views/win_frame_view.cc b/atom/browser/ui/views/win_frame_view.cc index db74661932b7..d0338af19d9a 100644 --- a/atom/browser/ui/views/win_frame_view.cc +++ b/atom/browser/ui/views/win_frame_view.cc @@ -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); } From 69140af0835d2d7aea8bbce632ae7fe9faa70bad Mon Sep 17 00:00:00 2001 From: hansrwindhoff Date: Sun, 4 Oct 2015 20:14:52 -0600 Subject: [PATCH 18/23] example code didn't run --- docs/api/screen.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/api/screen.md b/docs/api/screen.md index da15c7326f17..9afbf02170e1 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -37,8 +37,8 @@ app.on('ready', function() { var electronScreen = require('screen'); var displays = electronScreen.getAllDisplays(); var externalDisplay = null; - for (var i in displays) { - if (displays[i].bounds.x > 0 || displays[i].bounds.y > 0) { + for (var i =0; i< displays.length; i++) { + if (displays[i].bounds.x !==0 || displays[i].bounds.y !== 0) { externalDisplay = displays[i]; break; } @@ -48,6 +48,8 @@ app.on('ready', function() { mainWindow = new BrowserWindow({ x: externalDisplay.bounds.x + 50, y: externalDisplay.bounds.y + 50, + width: 900, + height:600 }); } }); From 46c69cc3e5f76aee329a1b79847ac0f65818e5ee Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 11:41:06 +0800 Subject: [PATCH 19/23] docs: Removed unneeded changes from PR --- docs/api/screen.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/api/screen.md b/docs/api/screen.md index 9afbf02170e1..3b6c276daf34 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -37,8 +37,8 @@ app.on('ready', function() { var electronScreen = require('screen'); var displays = electronScreen.getAllDisplays(); var externalDisplay = null; - for (var i =0; i< displays.length; i++) { - if (displays[i].bounds.x !==0 || displays[i].bounds.y !== 0) { + for (var i in displays) { + if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) { externalDisplay = displays[i]; break; } @@ -48,8 +48,6 @@ app.on('ready', function() { mainWindow = new BrowserWindow({ x: externalDisplay.bounds.x + 50, y: externalDisplay.bounds.y + 50, - width: 900, - height:600 }); } }); From ad8e727ba251b559e48625680a50cc014f26b0e5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 11:41:36 +0800 Subject: [PATCH 20/23] docs: "loaded" event of "process" --- docs/api/process.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/api/process.md b/docs/api/process.md index abd3c4fe574c..4e0fa4d602ef 100644 --- a/docs/api/process.md +++ b/docs/api/process.md @@ -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 From ec0a8a13219a18989623878ed063449742a42bd6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 11:42:43 +0800 Subject: [PATCH 21/23] Bump v0.33.5 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index b3c9e117a505..637e1c4795cf 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.4', + 'version%': '0.33.5', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index b1b905a43332..12934e6ef855 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.4 + 0.33.5 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 6d900b0ea017..7a36dcdf35e5 100644 --- a/atom/browser/resources/win/atom.rc +++ b/atom/browser/resources/win/atom.rc @@ -56,8 +56,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,33,4,0 - PRODUCTVERSION 0,33,4,0 + FILEVERSION 0,33,5,0 + PRODUCTVERSION 0,33,5,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.5" 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.5" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 998e43088122..42610f196e12 100644 --- a/atom/common/atom_version.h +++ b/atom/common/atom_version.h @@ -7,7 +7,7 @@ #define ATOM_MAJOR_VERSION 0 #define ATOM_MINOR_VERSION 33 -#define ATOM_PATCH_VERSION 4 +#define ATOM_PATCH_VERSION 5 #define ATOM_VERSION_IS_RELEASE 1 From 7de3aa3cc1eef66a84df8d474954d4e2d81a1adb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 19:57:14 +0800 Subject: [PATCH 22/23] Fix typo, closes #2990 --- atom/browser/native_window_views.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 4282b0eda96f..689626fc5f48 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -351,7 +351,7 @@ void NativeWindowViews::ShowInactive() { } void NativeWindowViews::Hide() { - web_contents()->WasHidden(); + window_->Hide(); } bool NativeWindowViews::IsVisible() { From 2d676770b12975daf1bbf67d0c758be04e03844f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 5 Oct 2015 19:57:30 +0800 Subject: [PATCH 23/23] Bump v0.33.6 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 2 +- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/atom.gyp b/atom.gyp index 637e1c4795cf..f06a0c8251be 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.33.5', + 'version%': '0.33.6', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index 12934e6ef855..50e019c1c77e 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,7 +17,7 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.33.5 + 0.33.6 LSMinimumSystemVersion 10.8.0 NSMainNibFile diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 7a36dcdf35e5..b1aba451dcf6 100644 --- a/atom/browser/resources/win/atom.rc +++ b/atom/browser/resources/win/atom.rc @@ -56,8 +56,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,33,5,0 - PRODUCTVERSION 0,33,5,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.5" + 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.5" + VALUE "ProductVersion", "0.33.6" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 42610f196e12..8078551b90ed 100644 --- a/atom/common/atom_version.h +++ b/atom/common/atom_version.h @@ -7,7 +7,7 @@ #define ATOM_MAJOR_VERSION 0 #define ATOM_MINOR_VERSION 33 -#define ATOM_PATCH_VERSION 5 +#define ATOM_PATCH_VERSION 6 #define ATOM_VERSION_IS_RELEASE 1