X11 CSD:双击 ElementRole="TitleBar"不能最大化/恢复窗口
To Reproduce
- Create a desktop Avalonia app (12.1.0 or current master).
- Enable X11 drawn decorations:
AppBuilder.Configure<App>()
.UsePlatformDetect()
.With(new X11PlatformOptions
{
EnableDrawnDecorations = true,
});- Use a window with extended client area and a title-bar role, for example:
<Window ExtendClientAreaToDecorationsHint="True">
<Border Height="32"
Background="SteelBlue"
WindowDecorationProperties.ElementRole="TitleBar" />
</Window>(Default WindowDrawnDecorations with PART_TitleBar / ElementRole="TitleBar" reproduces it as well.) 4. Run on Linux under X11 (not WSL/WSLg). 5. Restore the window to WindowState.Normal. 6. Double-click the title bar (not the maximize button). Avalonia version 12.1.0 (also present on current master in src/Avalonia.X11/X11Window.cs) OS Linux / Debian / X11 (reproduced with EnableDrawnDecorations CSD). Windows and macOS are fine. Expected behavior Double-click on the title bar while Normal → WindowState.Maximized Double-click while Maximized → WindowState.Normal Single-click + drag still moves the window This is how Win32 (HTCAPTION) and macOS (DoubleClickHelper in Avalonia.Native.WindowImpl.ChromeHitTest) already behave. Actual behavior The window is dragged (or a drag is initiated). WindowState does not change. Avalonia version 12.1.0 OS Linux Additional context Root cause: in X11Window.ScheduleInput, a LeftButtonDown on chrome TitleBar immediately sends _NET_WM_MOVERESIZE with direction _NET_WM_MOVERESIZE_MOVE and returns, without checking for a double-click:
// Chrome hit-test for drawn decorations
if (NeedsDrawnDecorations
&& mouse.Type == RawPointerEventType.LeftButtonDown
&& _inputRoot is { } inputRoot)
{
var chromeRole = inputRoot.HitTestChromeElement(mouse.Position);
if (chromeRole is { } role)
{
var moveResizeSide = role switch
{
WindowDecorationsElementRole.TitleBar => NetWmMoveResize._NET_WM_MOVERESIZE_MOVE,
// ... resize edges ...
};
if (moveResizeSide.HasValue)
…内容来源: AvaloniaUI/Avalonia