diff --git a/src/Avalonia.Windowing/Bindings/GlWindow.cs b/src/Avalonia.Windowing/Bindings/GlWindow.cs index 4b1ac3230e..82cbc978e0 100644 --- a/src/Avalonia.Windowing/Bindings/GlWindow.cs +++ b/src/Avalonia.Windowing/Bindings/GlWindow.cs @@ -25,9 +25,15 @@ namespace Avalonia.Windowing.Bindings [DllImport("winit_wrapper")] private static extern LogicalSize winit_gl_window_get_size(IntPtr handle); + [DllImport("winit_wrapper")] + private static extern LogicalPosition winit_gl_window_get_position(IntPtr handle); + [DllImport("winit_wrapper")] private static extern void winit_gl_window_present(IntPtr handle); + [DllImport("winit_wrapper")] + private static extern void winit_gl_window_show(IntPtr handle); + [DllImport("winit_wrapper")] private static extern IntPtr winit_gl_window_get_proc_addr(IntPtr handle, string symbol); @@ -64,15 +70,23 @@ namespace Avalonia.Windowing.Bindings public (double, double) GetSize() { var size = winit_gl_window_get_size(_handle); - return (size.Width, size.Height); } public (double, double) GetFramebufferSize() { - var size = winit_gl_window_get_size(_handle); + return GetSize(); + } - return (size.Width, size.Height); + public (double, double) GetPosition() + { + var position = winit_gl_window_get_position(_handle); + return (position.X, position.Y); + } + + public void Show() + { + winit_gl_window_show(_handle); } } } diff --git a/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs b/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs index 141a6cef25..53181ad2fa 100644 --- a/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs +++ b/src/Avalonia.Windowing/Bindings/IWindowWrapper.cs @@ -9,5 +9,7 @@ namespace Avalonia.Windowing.Bindings void SetTitle(string title); void SetSize(double width, double height); (double, double) GetSize(); + (double, double) GetPosition(); + void Show(); } } diff --git a/src/Avalonia.Windowing/Bindings/Window.cs b/src/Avalonia.Windowing/Bindings/Window.cs index 36da41012e..a7a45c6696 100644 --- a/src/Avalonia.Windowing/Bindings/Window.cs +++ b/src/Avalonia.Windowing/Bindings/Window.cs @@ -36,5 +36,15 @@ namespace Avalonia.Windowing.Bindings { return (0, 0); } + + public (double, double) GetPosition() + { + return (0, 0); + } + + public void Show() + { + + } } } diff --git a/src/Avalonia.Windowing/WIndowingPlatform.cs b/src/Avalonia.Windowing/WIndowingPlatform.cs index 696171dda7..6b85713c50 100644 --- a/src/Avalonia.Windowing/WIndowingPlatform.cs +++ b/src/Avalonia.Windowing/WIndowingPlatform.cs @@ -82,6 +82,7 @@ namespace Avalonia.Windowing public void Signal(DispatcherPriority priority) { + // We need to run some sort of callback on wakeup don't we? _eventsLoop.Wakeup(); } diff --git a/src/Avalonia.Windowing/WindowImpl.cs b/src/Avalonia.Windowing/WindowImpl.cs index 0060b33c61..8434609f3c 100644 --- a/src/Avalonia.Windowing/WindowImpl.cs +++ b/src/Avalonia.Windowing/WindowImpl.cs @@ -21,7 +21,19 @@ namespace Avalonia.Windowing public WindowState WindowState { get; set; } public Action WindowStateChanged { get; set; } public Func Closing { get; set; } - public Point Position { get; set; } + public Point Position + { + get + { + var (x, y) = _windowWrapper.GetPosition(); + return new Point(x, y); + } + set + { + var x = value; + } + } + public Action PositionChanged { get; set; } public Action Deactivated { get; set; } public Action Activated { get; set; } @@ -36,11 +48,11 @@ namespace Avalonia.Windowing get { var (width, height) = _windowWrapper.GetSize(); - return new Size(width, height); + return new Size(width * 2, height * 2); } } - public double Scaling => 1.0; + public double Scaling => 192 / 96; public IEnumerable Surfaces => new List() { _windowWrapper }; @@ -89,18 +101,24 @@ namespace Avalonia.Windowing public Point PointToClient(Point point) { - return point; + point = point.WithY(ClientSize.Height - point.Y); + var (x, y) = _windowWrapper.GetPosition(); + return new Point(point.X + x, point.Y + y); } public Point PointToScreen(Point point) { - return point; + point = point.WithY(ClientSize.Height - point.Y); + var (x, y) = _windowWrapper.GetPosition(); + return new Point(point.X - x, point.Y - y);; } public void Resize(Size clientSize) { // This is where we size the window accordingly.. - _windowWrapper.SetSize(clientSize.Width, clientSize.Height); + _windowWrapper.SetSize(clientSize.Width / Scaling, clientSize.Height / Scaling); + + // TODO: Move this to when we receive the Resized message. Resized(clientSize); } @@ -135,6 +153,7 @@ namespace Avalonia.Windowing public void Show() { + _windowWrapper.Show(); } public IDisposable ShowDialog() diff --git a/src/Skia/Avalonia.Skia/GlRenderTarget.cs b/src/Skia/Avalonia.Skia/GlRenderTarget.cs index 36d942430c..7561c98e0f 100644 --- a/src/Skia/Avalonia.Skia/GlRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/GlRenderTarget.cs @@ -31,14 +31,14 @@ namespace Avalonia.Skia { // TODO: These are hard coded for now. Don't do that. // TODO: Recreate the surface when the size changes. - // if (_surface == null) - // { + if (_surface == null) + { var (width, height) = _context.GetFramebufferSize(); _surface = SKSurface.Create(_grContext, new GRBackendRenderTargetDesc { - Height = (int)height, - Width = (int)width, + Height = (int)height * 2, + Width = (int)width * 2, SampleCount = 1, StencilBits = 8, Config = GRPixelConfig.Bgra8888, @@ -47,12 +47,15 @@ namespace Avalonia.Skia }); _canvas = _surface.Canvas; - // } + } + + _canvas.RestoreToCount(-1); + _canvas.ResetMatrix(); var createInfo = new DrawingContextImpl.CreateInfo { Canvas = _canvas, - Dpi = new Vector(96, 96), + Dpi = new Vector(192, 192), VisualBrushRenderer = visualBrushRenderer, DisableTextLcdRendering = true };