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 fb8f39aa55ffd192f5d7fc9c49408dcf3c5c4cd4..16f88856c10df7af52356ea5648c5062804fd769 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -749,6 +749,9 @@ void RenderWidgetHostImpl::WasHidden() { return; } + if (disable_hidden_) + return; + RejectPointerLockOrUnlockIfNecessary( blink::mojom::PointerLockResult::kWrongDocument); diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 220f8998b0499128396d868d1a80e402ddcff5fc..c51e6f684a58458ce487baaa970c438222a9f299 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -919,6 +919,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl void UpdateBrowserControlsState(cc::BrowserControlsState constraints, cc::BrowserControlsState current, bool animate); + // Electron: Prevents the widget from getting hidden. + bool disable_hidden_ = false; void StartDragging(blink::mojom::DragDataPtr drag_data, const url::Origin& source_origin, 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 bb65375eb77e0bc56ef6a6d0cb537ce59b14f9f2..95fb2a4b401ec57ed4492413a2607dba5ece1fa6 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -614,7 +614,7 @@ void RenderWidgetHostViewAura::HideImpl() { DCHECK(visibility_ == Visibility::HIDDEN || visibility_ == Visibility::OCCLUDED); - if (!host()->is_hidden()) { + if (!host()->is_hidden() && !host()->disable_hidden_) { host()->WasHidden(); aura::WindowTreeHost* host = window_->GetHost(); aura::Window* parent = window_->parent();