using Moli.Desktop.Hotkeys;
|
|
namespace Moli.Desktop.Runtime;
|
|
public enum HotkeyRegistrationState
|
{
|
Registered,
|
Conflict,
|
Disabled,
|
Invalid
|
}
|
|
public sealed record HotkeyRegistration
|
{
|
public required string BindingId { get; init; }
|
public required string Keys { get; init; }
|
public required HotkeyRegistrationState State { get; init; }
|
public string? Detail { get; init; }
|
}
|
|
public interface IHotkeyService : IDisposable
|
{
|
event Func<HotkeyBinding, Task>? HotkeyPressed;
|
IReadOnlyList<HotkeyRegistration> Registrations { get; }
|
Task ReplaceBindingsAsync(IReadOnlyList<HotkeyBinding> bindings, CancellationToken cancellationToken = default);
|
void Pause();
|
void Resume();
|
void UnregisterAll();
|
}
|
|
public interface INativeHotkeyApi
|
{
|
bool Register(IntPtr hwnd, int id, uint modifiers, uint virtualKey, out int win32Error);
|
bool Unregister(IntPtr hwnd, int id);
|
}
|
|
public interface IHotkeyMessageWindow : IDisposable
|
{
|
IntPtr Handle { get; }
|
event Action<int>? HotkeyPosted;
|
void EnsureCreated();
|
}
|