Browse Source

Merge branch 'master' into pointerover-fixes

pull/8918/head
Max Katz 4 years ago
committed by GitHub
parent
commit
4abf910278
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.MicroCom/MicroComProxyBase.cs
  2. 6
      src/Linux/Avalonia.LinuxFramebuffer/Input/LibInput/LibInputBackend.cs
  3. 16
      src/Linux/Avalonia.LinuxFramebuffer/Input/NullInput/NullInputBackend.cs
  4. 40
      src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs

2
src/Avalonia.MicroCom/MicroComProxyBase.cs

@ -65,7 +65,7 @@ namespace Avalonia.MicroCom
protected virtual void Dispose(bool disposing)
{
if(_nativePointer == null)
if(_nativePointer == IntPtr.Zero)
return;
if (_ownsHandle)
{

6
src/Linux/Avalonia.LinuxFramebuffer/Input/LibInput/LibInputBackend.cs

@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Threading;
using Avalonia.Input;
using Avalonia.Input.Raw;
using Avalonia.Threading;
using static Avalonia.LinuxFramebuffer.Input.LibInput.LibInputNativeUnsafeMethods;
namespace Avalonia.LinuxFramebuffer.Input.LibInput
{
@ -29,8 +27,6 @@ namespace Avalonia.LinuxFramebuffer.Input.LibInput
new Thread(()=>InputThread(ctx)).Start();
}
private unsafe void InputThread(IntPtr ctx)
{
var fd = libinput_get_fd(ctx);
@ -143,8 +139,6 @@ namespace Avalonia.LinuxFramebuffer.Input.LibInput
}
}
public void Initialize(IScreenInfoProvider screen, Action<RawInputEventArgs> onInput)
{

16
src/Linux/Avalonia.LinuxFramebuffer/Input/NullInput/NullInputBackend.cs

@ -0,0 +1,16 @@
using System;
using Avalonia.Input;
using Avalonia.Input.Raw;
namespace Avalonia.LinuxFramebuffer.Input.NullInput;
public class NullInputBackend : IInputBackend
{
public void Initialize(IScreenInfoProvider screen, Action<RawInputEventArgs> onInput)
{
}
public void SetInputRoot(IInputRoot root)
{
}
}

40
src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs

@ -42,9 +42,9 @@ namespace Avalonia.LinuxFramebuffer
Threading = new InternalPlatformThreadingInterface();
if (_fb is IGlOutputBackend gl)
AvaloniaLocator.CurrentMutable.Bind<IPlatformOpenGlInterface>().ToConstant(gl.PlatformOpenGlInterface);
var opts = AvaloniaLocator.Current.GetService<LinuxFramebufferPlatformOptions>() ?? new LinuxFramebufferPlatformOptions();
AvaloniaLocator.CurrentMutable
.Bind<IPlatformThreadingInterface>().ToConstant(Threading)
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(opts.Fps))
@ -59,12 +59,12 @@ namespace Avalonia.LinuxFramebuffer
AvaloniaLocator.Current.GetService<IPlatformOpenGlInterface>());
}
internal static LinuxFramebufferLifetime Initialize<T>(T builder, IOutputBackend outputBackend) where T : AppBuilderBase<T>, new()
internal static LinuxFramebufferLifetime Initialize<T>(T builder, IOutputBackend outputBackend, IInputBackend inputBackend) where T : AppBuilderBase<T>, new()
{
var platform = new LinuxFramebufferPlatform(outputBackend);
builder.UseSkia().UseWindowingSubsystem(platform.Initialize, "fbdev");
return new LinuxFramebufferLifetime(platform._fb);
return new LinuxFramebufferLifetime(platform._fb, inputBackend);
}
}
@ -80,13 +80,13 @@ namespace Avalonia.LinuxFramebuffer
{
_fb = fb;
}
public LinuxFramebufferLifetime(IOutputBackend fb, IInputBackend input)
{
_fb = fb;
_inputBackend = input;
}
public Control MainView
{
get => (Control)_topLevel?.Content;
@ -126,7 +126,7 @@ namespace Avalonia.LinuxFramebuffer
{
Startup?.Invoke(this, new ControlledApplicationLifetimeStartupEventArgs(args));
}
public void Shutdown(int exitCode)
{
ExitCode = exitCode;
@ -140,22 +140,22 @@ namespace Avalonia.LinuxFramebuffer
public static class LinuxFramebufferPlatformExtensions
{
public static int StartLinuxFbDev<T>(this T builder, string[] args, string fbdev = null, double scaling = 1)
public static int StartLinuxFbDev<T>(this T builder, string[] args, string fbdev = null, double scaling = 1, IInputBackend inputBackend = default)
where T : AppBuilderBase<T>, new() =>
StartLinuxDirect(builder, args, new FbdevOutput(fileName: fbdev, format: null) { Scaling = scaling });
public static int StartLinuxFbDev<T>(this T builder, string[] args, string fbdev, PixelFormat? format, double scaling)
StartLinuxDirect(builder, args, new FbdevOutput(fileName: fbdev, format: null) { Scaling = scaling }, inputBackend);
public static int StartLinuxFbDev<T>(this T builder, string[] args, string fbdev, PixelFormat? format, double scaling, IInputBackend inputBackend = default)
where T : AppBuilderBase<T>, new() =>
StartLinuxDirect(builder, args, new FbdevOutput(fileName: fbdev, format: format) { Scaling = scaling });
public static int StartLinuxDrm<T>(this T builder, string[] args, string card = null, double scaling = 1)
where T : AppBuilderBase<T>, new() => StartLinuxDirect(builder, args, new DrmOutput(card) {Scaling = scaling});
public static int StartLinuxDrm<T>(this T builder, string[] args, string card = null, bool connectorsForceProbe = false, [CanBeNull] DrmOutputOptions options = null)
where T : AppBuilderBase<T>, new() => StartLinuxDirect(builder, args, new DrmOutput(card, connectorsForceProbe, options));
public static int StartLinuxDirect<T>(this T builder, string[] args, IOutputBackend backend)
StartLinuxDirect(builder, args, new FbdevOutput(fileName: fbdev, format: format) { Scaling = scaling }, inputBackend);
public static int StartLinuxDrm<T>(this T builder, string[] args, string card = null, double scaling = 1, IInputBackend inputBackend = default)
where T : AppBuilderBase<T>, new() => StartLinuxDirect(builder, args, new DrmOutput(card) { Scaling = scaling }, inputBackend);
public static int StartLinuxDrm<T>(this T builder, string[] args, string card = null, bool connectorsForceProbe = false, [CanBeNull] DrmOutputOptions options = null, IInputBackend inputBackend = default)
where T : AppBuilderBase<T>, new() => StartLinuxDirect(builder, args, new DrmOutput(card, connectorsForceProbe, options), inputBackend);
public static int StartLinuxDirect<T>(this T builder, string[] args, IOutputBackend outputBackend, IInputBackend inputBackend = default)
where T : AppBuilderBase<T>, new()
{
var lifetime = LinuxFramebufferPlatform.Initialize(builder, backend);
var lifetime = LinuxFramebufferPlatform.Initialize(builder, outputBackend, inputBackend);
builder.SetupWithLifetime(lifetime);
lifetime.Start(args);
builder.Instance.Run(lifetime.Token);

Loading…
Cancel
Save