Skip to content

Commit

Permalink
fix: Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
workgroupengineering committed Mar 25, 2024
1 parent d697a72 commit 0d09ca8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class LibInputBackend : IInputBackend
{
private IScreenInfoProvider? _screen;
private IInputRoot? _inputRoot;
private const string LibInput = nameof(Avalonia.LinuxFramebuffer) + "/" + nameof(Avalonia.LinuxFramebuffer.Input) + "/" + nameof(LibInput);
private const string LibInput = nameof(LinuxFramebuffer) + "/" + nameof(Input) + "/" + nameof(LibInput);
private Action<RawInputEventArgs>? _onInput;
private readonly LibInputBackendOptions? _options;

Expand All @@ -25,10 +25,8 @@ public LibInputBackend(LibInputBackendOptions options)
_options = options;
}

private unsafe void InputThread(object? state)
private unsafe void InputThread(IntPtr ctx, LibInputBackendOptions options)
{
var options = (LibInputBackendOptions)state!;
var ctx = options.LibInputContext;
var fd = libinput_get_fd(ctx);

foreach (var f in options.Events)
Expand Down Expand Up @@ -67,16 +65,15 @@ public void Initialize(IScreenInfoProvider screen, Action<RawInputEventArgs> onI
var ctx = libinput_path_create_context();
var options = new LibInputBackendOptions()
{
LibInputContext = ctx,
Events = _options?.Events is null
? Directory.GetFiles("/dev/input", "event*")
: _options.Events,
};
new Thread(InputThread)
new Thread(() => InputThread(ctx, options))
{
Name = "Input Manager Worker",
IsBackground = true
}.Start(options);
}.Start();
}

public void SetInputRoot(IInputRoot root)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
#nullable enable
using System.Collections.Generic;

namespace Avalonia.LinuxFramebuffer.Input.LibInput;
Expand All @@ -8,13 +8,8 @@ namespace Avalonia.LinuxFramebuffer.Input.LibInput;
/// </summary>
public sealed record class LibInputBackendOptions
{
/// <summary>
/// Used internally to pass libinput context to <see cref="LibInputBackend.InputThread(object?)"/>.
/// </summary>
internal IntPtr LibInputContext { get; init; }

/// <summary>
/// List Events of events handler to monitoring eg: /dev/eventX.
/// </summary>
public IReadOnlyList<string> Events { get; init; } = null;
public IReadOnlyList<string>? Events { get; init; } = null;
}

0 comments on commit 0d09ca8

Please sign in to comment.