From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Sep 2018 17:45:47 -0700 Subject: disable_hidden.patch Electron uses this to disable background throttling for hidden windows. diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index b54fb62c9f1071f9819240679e4a8fa0e2d71055..b2ae1fd2dcc348e656e69db335701aa90d4cea8a 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -841,6 +841,10 @@ void RenderWidgetHostImpl::WasHidden() { return; } + if (disable_hidden_) { + return; + } + // Cancel pending pointer lock requests, unless there's an open user prompt. // Prompts should remain open and functional across tab switches. if (!delegate_ || !delegate_->IsWaitingForPointerLockPrompt(this)) { diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 848a6661dabb64c4eed3bf1d23e1de730918e05f..437e1aadf8d2583050a622b28c391715c131d32a 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -1032,6 +1032,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl return synthetic_gesture_controller_.get(); } + // Electron: Prevents the widget from getting hidden. + bool disable_hidden_ = false; protected: // |routing_id| must not be IPC::mojom::kRoutingIdNone. // If this object outlives |delegate|, DetachDelegate() must be called when diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 63a7dc99a9596f22379436c32325936ebd8d14e6..b4f1a82dc4294313c4439cb132ae05ea8cd19a99 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -697,7 +697,7 @@ void RenderWidgetHostViewAura::HideImpl() { CHECK(visibility_ == Visibility::HIDDEN || visibility_ == Visibility::OCCLUDED); - if (!host()->IsHidden()) { + if (!host()->IsHidden() && !host()->disable_hidden_) { host()->WasHidden(); aura::WindowTreeHost* host = window_->GetHost(); aura::Window* parent = window_->parent();