Skip to content

Commit 4163c8c

Browse files
committed
WPF - Change NotifyDpiChange to accept float instead of double
- Double was being cast to float - If newDpi is same as old DPI do nothing, no extra floating point comparison is being used, so in some cases it's possible the DPI change will be triggered when the DPI's are actually the same
1 parent 06b7549 commit 4163c8c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ private void PresentationSourceChangedHandler(object sender, SourceChangedEventA
17081708

17091709
var matrix = source.CompositionTarget.TransformToDevice;
17101710

1711-
NotifyDpiChange(matrix.M11);
1711+
NotifyDpiChange((float)matrix.M11);
17121712

17131713
var window = source.RootVisual as Window;
17141714
if (window != null)
@@ -2436,11 +2436,17 @@ private void ZoomReset()
24362436
/// <param name="newDpi">new DPI</param>
24372437
/// <remarks>.Net 4.6.2 adds HwndSource.DpiChanged which could be used to automatically
24382438
/// handle DPI change, unforunately we still target .Net 4.5.2</remarks>
2439-
public void NotifyDpiChange(double newDpi)
2439+
public virtual void NotifyDpiChange(float newDpi)
24402440
{
2441+
//Do nothing
2442+
if (DpiScaleFactor.Equals(newDpi))
2443+
{
2444+
return;
2445+
}
2446+
24412447
var notifyDpiChanged = DpiScaleFactor > 0 && !DpiScaleFactor.Equals(newDpi);
24422448

2443-
DpiScaleFactor = (float)newDpi;
2449+
DpiScaleFactor = newDpi;
24442450

24452451
if (notifyDpiChanged && browser != null)
24462452
{

0 commit comments

Comments
 (0)