Skip to content

Commit

Permalink
Release mouse capture when dialog shown.
Browse files Browse the repository at this point in the history
Fixes #14525.
  • Loading branch information
grokys committed Jul 2, 2024
1 parent 27bf869 commit cdb7736
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Avalonia.Base/Input/MouseDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,10 @@ public void Dispose()
{
return _pointer;
}

internal void PlatformCaptureLost()
{
_pointer.Capture(null);
}
}
}
7 changes: 7 additions & 0 deletions src/Avalonia.Native/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ public void SetParent(IWindowImpl parent)
public void SetEnabled(bool enable)
{
_native.SetEnabled(enable.AsComBool());

// Showing a dialog should result in mouse capture being lost. macOS doesn't have the concept of mouse
// capture, so no we have no OS-level event to hook into. Instead, release the mouse capture when the
// owner window is disabled. This behavior matches win32, which sends a WM_CANCELMODE message when
// EnableWindow(hWnd, false) is called from SetEnabled.
if (!enable && MouseDevice is MouseDevice mouse)
mouse.PlatformCaptureLost();
}

public override object TryGetFeature(Type featureType)
Expand Down

0 comments on commit cdb7736

Please sign in to comment.