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 31c6ca8c223180086736a1677febc0d4247f5a23..9501ae821c3cd16e53e63e28d717856c9f66efd3 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -804,6 +804,9 @@ void RenderWidgetHostImpl::WasHidden() { if (is_hidden_) return; + if (disable_hidden_) + return; + RejectMouseLockOrUnlockIfNecessary( 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 170e0755756f26c3291ef7269caadfe3ed5dae05..e288fe0ba76dee05ccc6f2339477d7c78ce46540 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -873,6 +873,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl void OnLocalSurfaceIdChanged( const cc::RenderFrameMetadata& metadata) override; + // Electron: Prevents the widget from getting hidden. + bool disable_hidden_ = false; + protected: // |routing_id| must not be MSG_ROUTING_NONE. // 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 a2c22345475c424bd23af4e8e1e8c087a780fc68..b3f02329ae0398978f8a87299181cb07a4799af4 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -626,7 +626,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();