From fda291baec03fc9509ed303bea57fe818a02c592 Mon Sep 17 00:00:00 2001 From: amaitland Date: Mon, 25 Jun 2018 11:51:37 +1000 Subject: [PATCH] WPF - DisableTouchpadAndWheelScrollLatching In ChromiumWebBrowser disable by default when default call to Cef.Initialize Issue #2408 --- CefSharp.Core/CefSettings.h | 13 +++++++++++++ CefSharp.Example/CefExample.cs | 4 +++- CefSharp.Wpf/ChromiumWebBrowser.cs | 12 ++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CefSharp.Core/CefSettings.h b/CefSharp.Core/CefSettings.h index 4e62ae525..7d33aaff1 100644 --- a/CefSharp.Core/CefSettings.h +++ b/CefSharp.Core/CefSettings.h @@ -430,5 +430,18 @@ namespace CefSharp _cefCommandLineArgs->Add("enable-begin-frame-scheduling", "1"); } } + + /// + /// Disable TouchpadAndWheelScrollLatching, Mouse Wheel becomes unreponsive after reload when + /// enabled. This is only required for WPF/OffScreen versions, see issue #2408 + /// This is a short term workaround until the CEF issue is fixed. + /// + void DisableTouchpadAndWheelScrollLatching() + { + if (!_cefCommandLineArgs->ContainsKey("disable-features")) + { + _cefCommandLineArgs->Add("disable-features", "TouchpadAndWheelScrollLatching,AsyncWheelEvents"); + } + } }; } diff --git a/CefSharp.Example/CefExample.cs b/CefSharp.Example/CefExample.cs index c521005e4..51845c643 100644 --- a/CefSharp.Example/CefExample.cs +++ b/CefSharp.Example/CefExample.cs @@ -108,7 +108,9 @@ namespace CefSharp.Example settings.WindowlessRenderingEnabled = true; //https://github.com/cefsharp/CefSharp/issues/2408 - settings.CefCommandLineArgs.Add("disable-features", "TouchpadAndWheelScrollLatching,AsyncWheelEvents"); + settings.DisableTouchpadAndWheelScrollLatching(); + //This maybe required for scrolling overflow views in iframes + //see https://bitbucket.org/chromiumembedded/cef/issues/2400/scroll-wheel-becomes-non-functional-with#comment-44369181 settings.CefCommandLineArgs.Add("disable-blink-features", "RootLayerScrolling"); //Disable Direct Composition to test https://github.com/cefsharp/CefSharp/issues/1634 diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index e9141f479..66093e005 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -433,9 +433,17 @@ namespace CefSharp.Wpf private void NoInliningConstructor() { //Initialize CEF if it hasn't already been initialized - if (!Cef.IsInitialized && !Cef.Initialize()) + if (!Cef.IsInitialized) { - throw new InvalidOperationException("Cef::Initialize() failed"); + //Disable TouchpadAndWheelScrollLatching + //Workaround for #2408 + var settings = new CefSettings(); + settings.DisableTouchpadAndWheelScrollLatching(); + + if (!Cef.Initialize(settings)) + { + throw new InvalidOperationException("Cef::Initialize() failed"); + } } //Add this ChromiumWebBrowser instance to a list of IDisposable objects