On Wayland, Keybinding with KeyGestures may repeat "infinitely" if bound command opens window
Author: carl-andersson-at-westermoCreated Aug 25, 2026Updated Sep 15, 2026
Labelsbug
Describe the bug
When running an Avalonia app, specifically when using .UseWaylandWithFallback(), using a keybinding with a keygesture, i.e:
public MainWindow()
{
InitalizeComponent();
KeyBindings.Add(new KeyBinding
{
Gesture = new KeyGesture(Key.Delete),
Command = new CommandImpl(OnDelete)
});
}If OnDelete creates a window, i.e
private async void OnDelete()
{
var window = new Window();
await window.ShowDialog(this);
} Then once windowcloses, OnDelete will seemingly immediately execute again, spawning a new window, and so on until the program terminates by other means.
This does not seem to happen on X11 or Windows, and the stack trace points to Avalonia.Wayland.WindowImpl.Sink.OnKeyRepeatTick being the source of each new OnDelete call
To Reproduce
Minial repro project attached, run (on a wayland-machine), focus window, and press delete.
Expected behavior
OnDelete should not be reentrant on window close.
Avalonia version
12.1.1
OS
Linux
Additional context
No response
Source: AvaloniaUI/Avalonia