Browse Source

Fix EntryPointNotFound on Windows 8 due to missing version check (#6471)

* Prevent calls to unavailable entrypoint 'GetDpiForMonitor' on Win8 (#5357)

* Introduce Windows8 platform constant

* wip

Co-authored-by: Tim Schneeberger <tim.schneeberger@outlook.de>
Co-authored-by: Tim Schneeberger <thebone.main@gmail.com>
Co-authored-by: Dan Walmsley <dan@walms.co.uk>
pull/6476/head
Tako 5 years ago
committed by GitHub
parent
commit
3867a68ade
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj
  2. 3
      src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs
  3. 2
      src/Windows/Avalonia.Win32/FramebufferManager.cs
  4. 7
      src/Windows/Avalonia.Win32/PlatformConstants.cs
  5. 4
      src/Windows/Avalonia.Win32/Win32GlManager.cs
  6. 2
      src/Windows/Avalonia.Win32/Win32Platform.cs
  7. 4
      src/Windows/Avalonia.Win32/WindowImpl.cs

1
src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj

@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" />
<ProjectReference Include="..\Avalonia.Win32\Avalonia.Win32.csproj" />
</ItemGroup>
<Import Project="..\..\..\build\Rx.props" />
<Import Project="..\..\..\build\SharpDX.props" />

3
src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs

@ -1,4 +1,5 @@
using Avalonia.Platform;
using Avalonia.Win32;
using Avalonia.Win32.Interop;
using SharpDX;
using SharpDX.DXGI;
@ -21,7 +22,7 @@ namespace Avalonia.Direct2D1
protected override Size2F GetWindowDpi()
{
if (UnmanagedMethods.ShCoreAvailable)
if (UnmanagedMethods.ShCoreAvailable && Win32Platform.WindowsVersion > PlatformConstants.Windows8)
{
uint dpix, dpiy;

2
src/Windows/Avalonia.Win32/FramebufferManager.cs

@ -87,7 +87,7 @@ namespace Avalonia.Win32
private Vector GetCurrentDpi()
{
if (UnmanagedMethods.ShCoreAvailable)
if (UnmanagedMethods.ShCoreAvailable && Win32Platform.WindowsVersion > PlatformConstants.Windows8)
{
var monitor =
UnmanagedMethods.MonitorFromWindow(_hwnd, UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST);

7
src/Windows/Avalonia.Win32/PlatformConstants.cs

@ -1,8 +1,13 @@
using System;
namespace Avalonia.Win32
{
static class PlatformConstants
public static class PlatformConstants
{
public const string WindowHandleType = "HWND";
public const string CursorHandleType = "HCURSOR";
public static readonly Version Windows8 = new Version(6, 2);
public static readonly Version Windows7 = new Version(6, 1);
}
}

4
src/Windows/Avalonia.Win32/Win32GlManager.cs

@ -1,4 +1,3 @@
using System;
using Avalonia.OpenGL;
using Avalonia.OpenGL.Angle;
using Avalonia.OpenGL.Egl;
@ -9,7 +8,6 @@ namespace Avalonia.Win32
{
static class Win32GlManager
{
private static readonly Version Windows7 = new Version(6, 1);
public static void Initialize()
{
@ -22,7 +20,7 @@ namespace Avalonia.Win32
return wgl;
}
if (opts?.AllowEglInitialization ?? Win32Platform.WindowsVersion > Windows7)
if (opts?.AllowEglInitialization ?? Win32Platform.WindowsVersion > PlatformConstants.Windows7)
{
var egl = EglPlatformOpenGlInterface.TryCreate(() => new AngleWin32EglDisplay());

2
src/Windows/Avalonia.Win32/Win32Platform.cs

@ -94,7 +94,7 @@ namespace Avalonia
namespace Avalonia.Win32
{
class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader, IPlatformLifetimeEventsImpl
public class Win32Platform : IPlatformThreadingInterface, IPlatformSettings, IWindowingPlatform, IPlatformIconLoader, IPlatformLifetimeEventsImpl
{
private static readonly Win32Platform s_instance = new Win32Platform();
private static Thread _uiThread;

4
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -764,8 +764,8 @@ namespace Avalonia.Win32
RegisterTouchWindow(_hwnd, 0);
}
if (ShCoreAvailable)
{
if (ShCoreAvailable && Win32Platform.WindowsVersion > PlatformConstants.Windows8)
{
var monitor = MonitorFromWindow(
_hwnd,
MONITOR.MONITOR_DEFAULTTONEAREST);

Loading…
Cancel
Save