11 changed files with 195 additions and 54 deletions
@ -1,9 +1,76 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls.Automation.Peers; |
|||
using Avalonia.FreeDesktop.Atspi; |
|||
using Avalonia.Platform; |
|||
using Tmds.DBus; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.FreeDesktop |
|||
{ |
|||
public class AtspiContext : IAccessible |
|||
internal class AtspiContext : IAccessible, IAutomationPeerImpl |
|||
{ |
|||
private readonly AtspiRoot _root; |
|||
private readonly AutomationPeer _peer; |
|||
private readonly AtspiRole _role; |
|||
|
|||
public AtspiContext(AtspiRoot root, AutomationPeer peer, AtspiRole role) |
|||
{ |
|||
_root = root; |
|||
_peer = peer; |
|||
_role = role; |
|||
ObjectPath = new ObjectPath("/net/avaloniaui/a11y/" + Guid.NewGuid().ToString().Replace("-", "")); |
|||
} |
|||
|
|||
public ObjectPath ObjectPath { get; } |
|||
|
|||
Task<(string, ObjectPath)> IAccessible.GetChildAtIndexAsync(int Index) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
Task<(string, ObjectPath)[]> IAccessible.GetChildrenAsync() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
Task<int> IAccessible.GetIndexInParentAsync() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
Task<(uint, (string, ObjectPath)[])[]> IAccessible.GetRelationSetAsync() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
Task<uint> IAccessible.GetRoleAsync() => Task.FromResult((uint)_role); |
|||
Task<string> IAccessible.GetRoleNameAsync() => Task.FromResult(_role.ToString()); // TODO
|
|||
Task<string> IAccessible.GetLocalizedRoleNameAsync() => Task.FromResult(_role.ToString()); // TODO
|
|||
Task<uint[]> IAccessible.GetStateAsync() => Task.FromResult(new uint[] { 0, 0 }); // TODO
|
|||
Task<IDictionary<string, string>> IAccessible.GetAttributesAsync() => Task.FromResult(_root.Attributes); |
|||
Task<(string, ObjectPath)> IAccessible.GetApplicationAsync() => Task.FromResult(_root.ApplicationPath); |
|||
|
|||
Task<object?> IAccessible.GetAsync(string prop) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
Task<AccessibleProperties> IAccessible.GetAllAsync() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
Task IAccessible.SetAsync(string prop, object val) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
Task<IDisposable> IAccessible.WatchPropertiesAsync(Action<PropertyChanges> handler) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,34 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Automation.Peers; |
|||
using Avalonia.FreeDesktop.Atspi; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.FreeDesktop |
|||
{ |
|||
internal static class AtspiContextFactory |
|||
{ |
|||
public static AtspiContext Create(AtspiRoot root, AutomationPeer peer) |
|||
{ |
|||
Dispatcher.UIThread.VerifyAccess(); |
|||
|
|||
if (peer.PlatformImpl is object) |
|||
{ |
|||
throw new AvaloniaInternalException($"Peer already has a platform implementation: {peer}."); |
|||
} |
|||
|
|||
var result = peer switch |
|||
{ |
|||
ButtonAutomationPeer _ => new AtspiContext(root, peer, AtspiRole.ATSPI_ROLE_PUSH_BUTTON), |
|||
MenuAutomationPeer _ => new AtspiContext(root, peer, AtspiRole.ATSPI_ROLE_MENU), |
|||
MenuItemAutomationPeer _ => new AtspiContext(root, peer, AtspiRole.ATSPI_ROLE_MENU_ITEM), |
|||
TabControlAutomationPeer _ => new AtspiContext(root, peer, AtspiRole.ATSPI_ROLE_PAGE_TAB_LIST), |
|||
TabItemAutomationPeer _ => new AtspiContext(root, peer, AtspiRole.ATSPI_ROLE_PAGE_TAB), |
|||
TextAutomationPeer _ => new AtspiContext(root, peer, AtspiRole.ATSPI_ROLE_STATIC), |
|||
_ => new AtspiContext(root, peer, AtspiRole.ATSPI_ROLE_UNKNOWN), |
|||
}; |
|||
|
|||
//var _ = result.Update();
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue