Browse Source

Patch DPI check for Win7 (#16148)

https://github.com/AvaloniaUI/Avalonia/issues/16146

Co-authored-by: evgeniy <441349+evgeniylevakhin@users.noreply.github.com>
Co-authored-by: Max Katz <maxkatz6@outlook.com>
pull/16159/head
elevakhin 2 years ago
committed by GitHub
parent
commit
818495ebe6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 28
      src/Windows/Avalonia.Win32/TrayIconImpl.cs

28
src/Windows/Avalonia.Win32/TrayIconImpl.cs

@ -126,13 +126,7 @@ namespace Avalonia.Win32
Win32Icon? newIcon = null;
if (_iconStale && _iconImpl is not null)
{
var scaling = 1.0;
if ((HRESULT)GetDpiForMonitor(s_taskBarMonitor, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out var dpiX, out var dpiY) == HRESULT.S_OK)
{
Debug.Assert(dpiX == dpiY);
scaling = dpiX / 96.0;
}
var scaling = GetTaskBarMonScalingOrDefault();
newIcon = _iconImpl.LoadSmallIcon(scaling);
}
@ -173,6 +167,26 @@ namespace Avalonia.Win32
_iconStale = false;
}
}
private double GetTaskBarMonScalingOrDefault()
{
if (ShCoreAvailable && Win32Platform.WindowsVersion > PlatformConstants.Windows8_1)
{
uint dpiX, dpiY;
if ((HRESULT)GetDpiForMonitor(
s_taskBarMonitor,
MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI,
out dpiX,
out dpiY) == HRESULT.S_OK)
{
Debug.Assert(dpiX == dpiY);
return dpiX / 96.0;
}
}
return 1.0;
}
private IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
{

Loading…
Cancel
Save