disable_hidden.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 55364bf0f6313eb57a96b46ad0a28051ab33fd62..3e0ed454b09a3d23570479a390e3dff92cbf83bc 100644
  8. --- a/content/browser/renderer_host/render_widget_host_impl.cc
  9. +++ b/content/browser/renderer_host/render_widget_host_impl.cc
  10. @@ -800,6 +800,9 @@ void RenderWidgetHostImpl::WasHidden() {
  11. return;
  12. }
  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 401123216fccc830a240b0b473e0426a65e630e6..2c205dd684340ddbed4fd301d5928ce6dad559fe 100644
  20. --- a/content/browser/renderer_host/render_widget_host_impl.h
  21. +++ b/content/browser/renderer_host/render_widget_host_impl.h
  22. @@ -902,6 +902,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl
  23. void UpdateBrowserControlsState(cc::BrowserControlsState constraints,
  24. cc::BrowserControlsState current,
  25. bool animate);
  26. + // Electron: Prevents the widget from getting hidden.
  27. + bool disable_hidden_ = false;
  28. protected:
  29. // |routing_id| must not be MSG_ROUTING_NONE.
  30. diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
  31. index 628724f3cc5c970402479a5c4a0c23af0d1f906d..8fa040071ba1e70890f7dcf8193e83e147679ed7 100644
  32. --- a/content/browser/renderer_host/render_widget_host_view_aura.cc
  33. +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
  34. @@ -617,7 +617,7 @@ void RenderWidgetHostViewAura::HideImpl() {
  35. DCHECK(visibility_ == Visibility::HIDDEN ||
  36. visibility_ == Visibility::OCCLUDED);
  37. - if (!host()->is_hidden()) {
  38. + if (!host()->is_hidden() && !host()->disable_hidden_) {
  39. host()->WasHidden();
  40. aura::WindowTreeHost* host = window_->GetHost();
  41. aura::Window* parent = window_->parent();