disable-redraw-lock.patch 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Heilig Benedek <[email protected]>
  3. Date: Thu, 20 Sep 2018 17:47:54 -0700
  4. Subject: disable-redraw-lock.patch
  5. Chromium uses a custom window titlebar implementation on Windows when DWM
  6. is disabled (Windows 7 and earlier, non Aero theme). The native titlebar
  7. sometimes painted over this custom titlebar, so a workaround was put in
  8. place to lock redraws in reaction to certain events if DWM is disabled,
  9. since the code assumes that in that case, the custom titlebar is painted.
  10. Electron forces the use of the native titlebar, which the workaround doesn't
  11. take into account, and still locks redraws, causing weird repainting issues
  12. in electron (and other applications). This patch provides a way to disable
  13. the redraw locking mechanism, which fixes these issues. The electron issue
  14. can be found at https://github.com/electron/electron/issues/1821
  15. diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
  16. index bb79a55d46730a4a127ee6483a7a25ecdc2aea5b..b14fa0f41166a904991ec920cec2f45c3b71c953 100644
  17. --- a/ui/views/win/hwnd_message_handler.cc
  18. +++ b/ui/views/win/hwnd_message_handler.cc
  19. @@ -308,6 +308,10 @@ constexpr int kSynthesizedMouseMessagesTimeDifference = 500;
  20. } // namespace
  21. +bool HWNDMessageHandlerDelegate::HasNativeFrame() const {
  22. + return false;
  23. +}
  24. +
  25. // A scoping class that prevents a window from being able to redraw in response
  26. // to invalidations that may occur within it for the lifetime of the object.
  27. //
  28. @@ -359,6 +363,7 @@ class HWNDMessageHandler::ScopedRedrawLock {
  29. cancel_unlock_(false),
  30. should_lock_(owner_->IsVisible() && !owner->HasChildRenderingWindow() &&
  31. ::IsWindow(hwnd_) &&
  32. + !owner_->HasNativeFrame() &&
  33. (!(GetWindowLong(hwnd_, GWL_STYLE) & WS_CAPTION) ||
  34. !ui::win::IsAeroGlassEnabled())) {
  35. if (should_lock_)
  36. @@ -986,6 +991,10 @@ HWNDMessageHandler::RegisterUnadjustedMouseEvent() {
  37. return scoped_enable;
  38. }
  39. +bool HWNDMessageHandler::HasNativeFrame() {
  40. + return delegate_->HasNativeFrame();
  41. +}
  42. +
  43. ////////////////////////////////////////////////////////////////////////////////
  44. // HWNDMessageHandler, gfx::WindowImpl overrides:
  45. diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h
  46. index f4efdc7174b90e57fb332f031530545e493a2e0d..9d45f97b930831a703efab2bbdf10afb61140c7f 100644
  47. --- a/ui/views/win/hwnd_message_handler.h
  48. +++ b/ui/views/win/hwnd_message_handler.h
  49. @@ -205,6 +205,8 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
  50. using TouchIDs = std::set<DWORD>;
  51. enum class DwmFrameState { kOff, kOn };
  52. + bool HasNativeFrame();
  53. +
  54. // Overridden from WindowImpl:
  55. HICON GetDefaultWindowIcon() const override;
  56. HICON GetSmallWindowIcon() const override;
  57. diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h
  58. index d8e0f1d3131aef80c9fcb6069df7d7f986af6605..5dbb192d0840ca0ded61397c399b774a8cb05cce 100644
  59. --- a/ui/views/win/hwnd_message_handler_delegate.h
  60. +++ b/ui/views/win/hwnd_message_handler_delegate.h
  61. @@ -46,6 +46,8 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate {
  62. // True if the widget associated with this window has a non-client view.
  63. virtual bool HasNonClientView() const = 0;
  64. + virtual bool HasNativeFrame() const;
  65. +
  66. // Returns who we want to be drawing the frame. Either the system (Windows)
  67. // will handle it or Chrome will custom draw it.
  68. virtual FrameMode GetFrameMode() const = 0;