Browse Source

Merge branch 'windowing-prototype' of https://github.com/nc4rrillo/Avalonia into windowing-prototype

repro-window-close
Nelson Carrillo 8 years ago
parent
commit
97a9e00860
  1. 8
      src/Avalonia.Windowing/Bindings/GlWindow.cs
  2. 1
      src/Avalonia.Windowing/Bindings/IWindowWrapper.cs
  3. 11
      src/Avalonia.Windowing/PlatformSettings.cs
  4. 6
      src/Avalonia.Windowing/WIndowingPlatform.cs
  5. 14
      src/Avalonia.Windowing/WindowImpl.cs

8
src/Avalonia.Windowing/Bindings/GlWindow.cs

@ -25,6 +25,9 @@ namespace Avalonia.Windowing.Bindings
[DllImport("winit_wrapper")] [DllImport("winit_wrapper")]
private static extern LogicalSize winit_gl_window_get_size(IntPtr handle); 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")] [DllImport("winit_wrapper")]
private static extern LogicalPosition winit_gl_window_get_position(IntPtr handle); private static extern LogicalPosition winit_gl_window_get_position(IntPtr handle);
@ -89,6 +92,11 @@ namespace Avalonia.Windowing.Bindings
return (size.Width, size.Height); return (size.Width, size.Height);
} }
public double GetScaleFactor ()
{
return winit_gl_window_get_dpi_scale_factor(_handle);
}
public (double, double) GetFramebufferSize() public (double, double) GetFramebufferSize()
{ {
return GetSize(); return GetSize();

1
src/Avalonia.Windowing/Bindings/IWindowWrapper.cs

@ -12,6 +12,7 @@ namespace Avalonia.Windowing.Bindings
void SetTitle(string title); void SetTitle(string title);
void SetSize(double width, double height); void SetSize(double width, double height);
double GetScaleFactor();
(double, double) GetSize(); (double, double) GetSize();
(double, double) GetPosition(); (double, double) GetPosition();

11
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);
}
}

6
src/Avalonia.Windowing/WIndowingPlatform.cs

@ -11,12 +11,6 @@ using static Avalonia.Windowing.Bindings.EventsLoop;
namespace Avalonia.Windowing 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 class DummyPlatformHandle : IPlatformHandle
{ {
public IntPtr Handle => IntPtr.Zero; public IntPtr Handle => IntPtr.Zero;

14
src/Avalonia.Windowing/WindowImpl.cs

@ -55,7 +55,7 @@ namespace Avalonia.Windowing
} }
} }
public double Scaling => 192 / 96; public double Scaling => _windowWrapper.GetScaleFactor();
public IEnumerable<object> Surfaces => new List<object>() { _windowWrapper }; public IEnumerable<object> Surfaces => new List<object>() { _windowWrapper };
@ -105,14 +105,12 @@ namespace Avalonia.Windowing
public Point PointToClient(Point point) public Point PointToClient(Point point)
{ {
// point = point.WithY(ClientSize.Height - point.Y);
var position = Position; var position = Position;
return new Point(point.X + position.X, point.Y + position.Y); return new Point(point.X + position.X, point.Y + position.Y);
} }
public Point PointToScreen(Point point) public Point PointToScreen(Point point)
{ {
//point = point.WithY(ClientSize.Height - point.Y);
var position = Position; var position = Position;
return new Point(point.X - position.X, point.Y - position.Y); ; return new Point(point.X - position.X, point.Y - position.Y); ;
} }
@ -174,9 +172,15 @@ namespace Avalonia.Windowing
{ {
Dispatcher.UIThread.RunJobs(DispatcherPriority.Input); 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)); Input(new RawMouseEventArgs(MouseDevice, (uint)Environment.TickCount, _inputRoot, (RawMouseEventType)evt.EventType, new Point(_lastPosition.X, _lastPosition.Y), InputModifiers.None));

Loading…
Cancel
Save