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 b70623b56267fb7df71519a2c19a04a658f766e2..0bae000a3491e03196bbba033621d389c6150225 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -840,6 +840,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 636f09a8ac86e7c3f7b8dcdc285792f18f5c5989..276852573eade86f1bc9690e3c78a6279e9ff5af 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -1031,6 +1031,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 b8f74e321a8bd8bd65e89cf9d794651c9f6f8705..e8a0554c4d84a16fc2122cb3e48199b4f43ecf88 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -642,7 +642,7 @@ void RenderWidgetHostViewAura::HideImpl() { CHECK(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();