@ -1029,9 +1029,10 @@ namespace Avalonia.X11
// Remove from AT-SPI tree before closing
// Remove from AT-SPI tree before closing
_ platform . UntrackWindow ( this ) ;
_ platform . UntrackWindow ( this ) ;
if ( _ platform . AtSpiServer is { } atSpiServer
if ( _ platform . AtSpiServer is { } atSpiServer
& & _ inputRoot ? . RootElemen t is Control atSpiControl )
& & _ inputRoot ? . Focus Root is Control atSpiControl )
{
{
var atSpiPeer = atSpiControl . GetAutomationPeer ( ) ;
var atSpiPeer = atSpiControl . GetAutomationPeer ( ) ? . GetAutomationRoot ( )
? ? atSpiControl . GetAutomationPeer ( ) ;
if ( atSpiPeer is not null )
if ( atSpiPeer is not null )
atSpiServer . RemoveWindow ( atSpiPeer ) ;
atSpiServer . RemoveWindow ( atSpiPeer ) ;
}
}
@ -1125,11 +1126,12 @@ namespace Avalonia.X11
_ platform . TrackWindow ( this ) ;
_ platform . TrackWindow ( this ) ;
if ( _ platform . AtSpiServer is { } server
if ( _ platform . AtSpiServer is { } server
& & _ inputRoot ? . RootElemen t is Control c )
& & _ inputRoot ? . Focus Root is Control c )
{
{
var peer = Avalonia . Automation . Peers . ControlAutomationPeer . CreatePeerForElement ( c ) ;
var peer = Avalonia . Automation . Peers . ControlAutomationPeer . CreatePeerForElement ( c ) ;
if ( peer is not null )
var rootPeer = peer ? . GetAutomationRoot ( ) ? ? peer ;
server . AddWindow ( peer ) ;
if ( rootPeer is not null )
server . AddWindow ( rootPeer ) ;
}
}
}
}