disable_hidden.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Cheng Zhao <[email protected]>
  3. Date: Thu, 20 Sep 2018 17:45:47 -0700
  4. Subject: disable_hidden.patch
  5. Electron uses this to disable background throttling for hidden windows.
  6. diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
  7. index 22ffafd8f5e0f49d5c9df7ecd3f61dad3dfd2814..a409c64768968c81be3b6c7e7646f8df26e2afe6 100644
  8. --- a/content/browser/renderer_host/render_widget_host_impl.cc
  9. +++ b/content/browser/renderer_host/render_widget_host_impl.cc
  10. @@ -832,6 +832,10 @@ void RenderWidgetHostImpl::WasHidden() {
  11. return;
  12. }
  13. + if (disable_hidden_) {
  14. + return;
  15. + }
  16. +
  17. // Cancel pending pointer lock requests, unless there's an open user prompt.
  18. // Prompts should remain open and functional across tab switches.
  19. if (!delegate_ || !delegate_->IsWaitingForPointerLockPrompt(this)) {
  20. diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
  21. index c201cff9e5c3b286389a5eb74e1a9ebd86edfef9..949f6a7867758e35c24897add9a4d47a641357b2 100644
  22. --- a/content/browser/renderer_host/render_widget_host_impl.h
  23. +++ b/content/browser/renderer_host/render_widget_host_impl.h
  24. @@ -1012,6 +1012,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl
  25. // Requests a commit and forced redraw in the renderer compositor.
  26. void ForceRedrawForTesting();
  27. + // Electron: Prevents the widget from getting hidden.
  28. + bool disable_hidden_ = false;
  29. +
  30. protected:
  31. // |routing_id| must not be MSG_ROUTING_NONE.
  32. // If this object outlives |delegate|, DetachDelegate() must be called when
  33. diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
  34. index 70f368ab0c59e7f495cb13094160d72f601e0938..19d2df47b0c929558ac8cfc208742dfef463a68b 100644
  35. --- a/content/browser/renderer_host/render_widget_host_view_aura.cc
  36. +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
  37. @@ -643,7 +643,7 @@ void RenderWidgetHostViewAura::HideImpl() {
  38. CHECK(visibility_ == Visibility::HIDDEN ||
  39. visibility_ == Visibility::OCCLUDED);
  40. - if (!host()->is_hidden()) {
  41. + if (!host()->is_hidden() && !host()->disable_hidden_) {
  42. host()->WasHidden();
  43. aura::WindowTreeHost* host = window_->GetHost();
  44. aura::Window* parent = window_->parent();