mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
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
This commit is contained in:
@@ -1684,7 +1684,7 @@ namespace CefSharp.Wpf
|
||||
|
||||
var matrix = source.CompositionTarget.TransformToDevice;
|
||||
|
||||
NotifyDpiChange(matrix.M11);
|
||||
NotifyDpiChange((float)matrix.M11);
|
||||
|
||||
var window = source.RootVisual as Window;
|
||||
if (window != null)
|
||||
@@ -2431,11 +2431,17 @@ namespace CefSharp.Wpf
|
||||
/// <param name="newDpi">new DPI</param>
|
||||
/// <remarks>.Net 4.6.2 adds HwndSource.DpiChanged which could be used to automatically
|
||||
/// handle DPI change, unforunately we still target .Net 4.5.2</remarks>
|
||||
public virtual void NotifyDpiChange(double newDpi)
|
||||
public virtual void NotifyDpiChange(float newDpi)
|
||||
{
|
||||
//Do nothing
|
||||
if (DpiScaleFactor.Equals(newDpi))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var notifyDpiChanged = DpiScaleFactor > 0 && !DpiScaleFactor.Equals(newDpi);
|
||||
|
||||
DpiScaleFactor = (float)newDpi;
|
||||
DpiScaleFactor = newDpi;
|
||||
|
||||
if (notifyDpiChanged && browser != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user