disable_hidden.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 ff4e181fae1849772b699bf83e0f7e9556dbd71e..84b3bcbfb4f52098efad6f2b8ab8e8445d8fe13a 100644
  8. --- a/content/browser/renderer_host/render_widget_host_impl.cc
  9. +++ b/content/browser/renderer_host/render_widget_host_impl.cc
  10. @@ -824,6 +824,9 @@ void RenderWidgetHostImpl::WasHidden() {
  11. if (is_hidden_)
  12. return;
  13. + if (disable_hidden_)
  14. + return;
  15. +
  16. RejectMouseLockOrUnlockIfNecessary(
  17. blink::mojom::PointerLockResult::kWrongDocument);
  18. diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
  19. index 6ea55a22496a5186513963d06fa700cb82758177..bbcff3ff49234e2f6b9fcdaa1409678189d91b67 100644
  20. --- a/content/browser/renderer_host/render_widget_host_impl.h
  21. +++ b/content/browser/renderer_host/render_widget_host_impl.h
  22. @@ -894,6 +894,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl
  23. cc::BrowserControlsState current,
  24. bool animate);
  25. + // Electron: Prevents the widget from getting hidden.
  26. + bool disable_hidden_ = false;
  27. +
  28. protected:
  29. // |routing_id| must not be MSG_ROUTING_NONE.
  30. // If this object outlives |delegate|, DetachDelegate() must be called when
  31. diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
  32. index 8b712a21e7ee1d2375c28af6a2f8d7279220138c..96c24edf6e4044a3ced0a87ecbd7a56f36f5d3d3 100644
  33. --- a/content/browser/renderer_host/render_widget_host_view_aura.cc
  34. +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
  35. @@ -604,7 +604,7 @@ void RenderWidgetHostViewAura::HideImpl() {
  36. DCHECK(visibility_ == Visibility::HIDDEN ||
  37. visibility_ == Visibility::OCCLUDED);
  38. - if (!host()->is_hidden()) {
  39. + if (!host()->is_hidden() && !host()->disable_hidden_) {
  40. host()->WasHidden();
  41. aura::WindowTreeHost* host = window_->GetHost();
  42. aura::Window* parent = window_->parent();