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 213b7ec788f59b649f19a702063307ad622ef462..69cce8cadec4ca2e5e5a6a17043df70846aa37bb 100644
  8. --- a/content/browser/renderer_host/render_widget_host_impl.cc
  9. +++ b/content/browser/renderer_host/render_widget_host_impl.cc
  10. @@ -814,6 +814,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_->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 ba199dfd6445ebb696a8c2fdda17000ac672b5bf..2d0f23b2347f5d420a31c325002fb0f2d830e42f 100644
  22. --- a/content/browser/renderer_host/render_widget_host_impl.h
  23. +++ b/content/browser/renderer_host/render_widget_host_impl.h
  24. @@ -1013,6 +1013,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 eaf23665d72fccbf3cfb368d88418181aaa07285..e2d7bfcc45c6450de38a1dd1a743ac3de61f3d35 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();