Skip to content

Commit fda291b

Browse files
committed
WPF - DisableTouchpadAndWheelScrollLatching
In ChromiumWebBrowser disable by default when default call to Cef.Initialize Issue #2408
1 parent 97eb6cf commit fda291b

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CefSharp.Core/CefSettings.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,5 +430,18 @@ namespace CefSharp
430430
_cefCommandLineArgs->Add("enable-begin-frame-scheduling", "1");
431431
}
432432
}
433+
434+
/// <summary>
435+
/// Disable TouchpadAndWheelScrollLatching, Mouse Wheel becomes unreponsive after reload when
436+
/// enabled. This is only required for WPF/OffScreen versions, see issue #2408
437+
/// This is a short term workaround until the CEF issue is fixed.
438+
/// </summary>
439+
void DisableTouchpadAndWheelScrollLatching()
440+
{
441+
if (!_cefCommandLineArgs->ContainsKey("disable-features"))
442+
{
443+
_cefCommandLineArgs->Add("disable-features", "TouchpadAndWheelScrollLatching,AsyncWheelEvents");
444+
}
445+
}
433446
};
434447
}

CefSharp.Example/CefExample.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ public static void Init(bool osr, bool multiThreadedMessageLoop, IBrowserProcess
108108
settings.WindowlessRenderingEnabled = true;
109109

110110
//https://github.com/cefsharp/CefSharp/issues/2408
111-
settings.CefCommandLineArgs.Add("disable-features", "TouchpadAndWheelScrollLatching,AsyncWheelEvents");
111+
settings.DisableTouchpadAndWheelScrollLatching();
112+
//This maybe required for scrolling overflow views in iframes
113+
//see https://bitbucket.org/chromiumembedded/cef/issues/2400/scroll-wheel-becomes-non-functional-with#comment-44369181
112114
settings.CefCommandLineArgs.Add("disable-blink-features", "RootLayerScrolling");
113115

114116
//Disable Direct Composition to test https://github.com/cefsharp/CefSharp/issues/1634

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,17 @@ public ChromiumWebBrowser()
433433
private void NoInliningConstructor()
434434
{
435435
//Initialize CEF if it hasn't already been initialized
436-
if (!Cef.IsInitialized && !Cef.Initialize())
436+
if (!Cef.IsInitialized)
437437
{
438-
throw new InvalidOperationException("Cef::Initialize() failed");
438+
//Disable TouchpadAndWheelScrollLatching
439+
//Workaround for #2408
440+
var settings = new CefSettings();
441+
settings.DisableTouchpadAndWheelScrollLatching();
442+
443+
if (!Cef.Initialize(settings))
444+
{
445+
throw new InvalidOperationException("Cef::Initialize() failed");
446+
}
439447
}
440448

441449
//Add this ChromiumWebBrowser instance to a list of IDisposable objects

0 commit comments

Comments
 (0)