Browse Source

Make sure focus lost is delayed until IMM32 has finished up the composition on kill focus (#15907)

pull/15929/head
Benedikt Stebner 2 years ago
committed by GitHub
parent
commit
9c89dee4dc
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 19
      src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

19
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

@ -19,6 +19,8 @@ namespace Avalonia.Win32
{ {
internal partial class WindowImpl internal partial class WindowImpl
{ {
private bool _killFocusRequested;
[SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation",
Justification = "Using Win32 naming for consistency.")] Justification = "Using Win32 naming for consistency.")]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "We do .NET COM interop availability checks")] [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "We do .NET COM interop availability checks")]
@ -718,7 +720,15 @@ namespace Avalonia.Win32
} }
case WindowsMessage.WM_KILLFOCUS: case WindowsMessage.WM_KILLFOCUS:
LostFocus?.Invoke(); if (Imm32InputMethod.Current.IsComposing)
{
_killFocusRequested = true;
}
else
{
LostFocus?.Invoke();
}
break; break;
case WindowsMessage.WM_INPUTLANGCHANGE: case WindowsMessage.WM_INPUTLANGCHANGE:
@ -763,6 +773,13 @@ namespace Avalonia.Win32
{ {
Imm32InputMethod.Current.HandleCompositionEnd(timestamp); Imm32InputMethod.Current.HandleCompositionEnd(timestamp);
if (_killFocusRequested)
{
LostFocus?.Invoke();
_killFocusRequested = false;
}
return IntPtr.Zero; return IntPtr.Zero;
} }
case WindowsMessage.WM_GETOBJECT: case WindowsMessage.WM_GETOBJECT:

Loading…
Cancel
Save