diff --git a/src/Avalonia.Windowing/Bindings/GlWindow.cs b/src/Avalonia.Windowing/Bindings/GlWindow.cs index 864cf76dcf..334453e74a 100644 --- a/src/Avalonia.Windowing/Bindings/GlWindow.cs +++ b/src/Avalonia.Windowing/Bindings/GlWindow.cs @@ -25,6 +25,9 @@ namespace Avalonia.Windowing.Bindings [DllImport("winit_wrapper")] private static extern LogicalSize winit_gl_window_get_size(IntPtr handle); + [DllImport("winit_wrapper")] + private static extern double winit_gl_window_get_dpi_scale_factor(IntPtr handle); + [DllImport("winit_wrapper")] private static extern LogicalPosition winit_gl_window_get_position(IntPtr handle); @@ -89,6 +92,11 @@ namespace Avalonia.Windowing.Bindings return (size.Width, size.Height); } + public double GetScaleFactor () + { + return winit_gl_window_get_dpi_scale_factor(_handle); + } + public (double, double) GetFramebufferSize() { return GetSize(); diff --git a/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs b/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs index 76227cdf86..09319c9bb0 100644 --- a/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs +++ b/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs @@ -12,6 +12,7 @@ namespace Avalonia.Windowing.Bindings void SetTitle(string title); void SetSize(double width, double height); + double GetScaleFactor(); (double, double) GetSize(); (double, double) GetPosition(); diff --git a/src/Avalonia.Windowing/PlatformSettings.cs b/src/Avalonia.Windowing/PlatformSettings.cs new file mode 100644 index 0000000000..1628fb95a7 --- /dev/null +++ b/src/Avalonia.Windowing/PlatformSettings.cs @@ -0,0 +1,11 @@ +using System; +using Avalonia.Platform; + +namespace Avalonia.Windowing +{ + public class PlatformSettings : IPlatformSettings + { + public Size DoubleClickSize => new Size(4, 4); + public TimeSpan DoubleClickTime => TimeSpan.FromMilliseconds(200); + } +} diff --git a/src/Avalonia.Windowing/WIndowingPlatform.cs b/src/Avalonia.Windowing/WIndowingPlatform.cs index 522540cabe..578cbc9c54 100644 --- a/src/Avalonia.Windowing/WIndowingPlatform.cs +++ b/src/Avalonia.Windowing/WIndowingPlatform.cs @@ -11,12 +11,6 @@ using static Avalonia.Windowing.Bindings.EventsLoop; namespace Avalonia.Windowing { - public class PlatformSettings : IPlatformSettings - { - public Size DoubleClickSize => new Size(4, 4); - public TimeSpan DoubleClickTime => TimeSpan.FromMilliseconds(200); - } - public class DummyPlatformHandle : IPlatformHandle { public IntPtr Handle => IntPtr.Zero; diff --git a/src/Avalonia.Windowing/WindowImpl.cs b/src/Avalonia.Windowing/WindowImpl.cs index 3120193f8e..516c21598f 100644 --- a/src/Avalonia.Windowing/WindowImpl.cs +++ b/src/Avalonia.Windowing/WindowImpl.cs @@ -55,7 +55,7 @@ namespace Avalonia.Windowing } } - public double Scaling => 192 / 96; + public double Scaling => _windowWrapper.GetScaleFactor(); public IEnumerable Surfaces => new List() { _windowWrapper }; @@ -105,14 +105,12 @@ namespace Avalonia.Windowing public Point PointToClient(Point point) { - // point = point.WithY(ClientSize.Height - point.Y); var position = Position; return new Point(point.X + position.X, point.Y + position.Y); } public Point PointToScreen(Point point) { - //point = point.WithY(ClientSize.Height - point.Y); var position = Position; return new Point(point.X - position.X, point.Y - position.Y); ; } @@ -174,9 +172,15 @@ namespace Avalonia.Windowing { Dispatcher.UIThread.RunJobs(DispatcherPriority.Input); - if (evt.EventType == MouseEventType.Move) + switch(evt.EventType) { - _lastPosition = evt.Position; + case MouseEventType.Move: + _lastPosition = evt.Position; + break; + + case MouseEventType.Wheel: + Input(new RawMouseWheelEventArgs(MouseDevice, (uint)Environment.TickCount, _inputRoot, new Point(_lastPosition.X, _lastPosition.Y), new Point(evt.Position.X, evt.Position.Y), InputModifiers.None)); + return; } Input(new RawMouseEventArgs(MouseDevice, (uint)Environment.TickCount, _inputRoot, (RawMouseEventType)evt.EventType, new Point(_lastPosition.X, _lastPosition.Y), InputModifiers.None));