|
|
@ -22,16 +22,15 @@ namespace Perspex.Win32 |
|
|
{ |
|
|
{ |
|
|
private static readonly Win32Platform s_instance = new Win32Platform(); |
|
|
private static readonly Win32Platform s_instance = new Win32Platform(); |
|
|
private static Thread _uiThread; |
|
|
private static Thread _uiThread; |
|
|
|
|
|
|
|
|
private UnmanagedMethods.WndProc _wndProcDelegate; |
|
|
private UnmanagedMethods.WndProc _wndProcDelegate; |
|
|
|
|
|
|
|
|
private IntPtr _hwnd; |
|
|
private IntPtr _hwnd; |
|
|
private double _scale = 1.0; |
|
|
|
|
|
private readonly List<Delegate> _delegates = new List<Delegate>(); |
|
|
private readonly List<Delegate> _delegates = new List<Delegate>(); |
|
|
|
|
|
|
|
|
public Win32Platform() |
|
|
public Win32Platform() |
|
|
{ |
|
|
{ |
|
|
HandleDpi(); |
|
|
// Declare that this process is aware of per monitor DPI
|
|
|
|
|
|
UnmanagedMethods.SetProcessDpiAwareness(UnmanagedMethods.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE); |
|
|
|
|
|
|
|
|
CreateMessageWindow(); |
|
|
CreateMessageWindow(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -40,8 +39,6 @@ namespace Perspex.Win32 |
|
|
UnmanagedMethods.GetSystemMetrics(UnmanagedMethods.SystemMetric.SM_CYDOUBLECLK)); |
|
|
UnmanagedMethods.GetSystemMetrics(UnmanagedMethods.SystemMetric.SM_CYDOUBLECLK)); |
|
|
|
|
|
|
|
|
public TimeSpan DoubleClickTime => TimeSpan.FromMilliseconds(UnmanagedMethods.GetDoubleClickTime()); |
|
|
public TimeSpan DoubleClickTime => TimeSpan.FromMilliseconds(UnmanagedMethods.GetDoubleClickTime()); |
|
|
public double RenderScalingFactor => _scale; |
|
|
|
|
|
public double LayoutScalingFactor => _scale; |
|
|
|
|
|
|
|
|
|
|
|
public static void Initialize() |
|
|
public static void Initialize() |
|
|
{ |
|
|
{ |
|
|
@ -173,22 +170,5 @@ namespace Perspex.Win32 |
|
|
{ |
|
|
{ |
|
|
return new PopupImpl(); |
|
|
return new PopupImpl(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void HandleDpi() |
|
|
|
|
|
{ |
|
|
|
|
|
// Declare that this process is aware of per monitor DPI
|
|
|
|
|
|
UnmanagedMethods.SetProcessDpiAwareness(UnmanagedMethods.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE); |
|
|
|
|
|
|
|
|
|
|
|
// Get the DPI for the main monitor, and set the scaling factor
|
|
|
|
|
|
UnmanagedMethods.POINT pt = new UnmanagedMethods.POINT() { X = 1, Y = 1 }; |
|
|
|
|
|
var hMonitor = UnmanagedMethods.MonitorFromPoint(pt, UnmanagedMethods.MONITOR_DEFAULTTONEAREST); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Check for failure
|
|
|
|
|
|
uint dpix, dpiy; |
|
|
|
|
|
UnmanagedMethods.GetDpiForMonitor(hMonitor, UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out dpix, out dpiy); |
|
|
|
|
|
|
|
|
|
|
|
// Set scale based on x DPI
|
|
|
|
|
|
_scale = dpix / 96.0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|