diff --git a/src/Avalonia.Controls/Remote/RemoteWidget.cs b/src/Avalonia.Controls/Remote/RemoteWidget.cs index b9854ab837..11eb53ceb5 100644 --- a/src/Avalonia.Controls/Remote/RemoteWidget.cs +++ b/src/Avalonia.Controls/Remote/RemoteWidget.cs @@ -26,7 +26,7 @@ namespace Avalonia.Controls.Remote Mode = SizingMode.Local; _connection = connection; - _connection.OnMessage += (t, msg) => Dispatcher.UIThread.Post(() => OnMessage(msg)); + _connection.OnMessage += (t, msg) => Dispatcher.UIThread.Post(OnMessage, msg); _connection.Send(new ClientSupportedPixelFormatsMessage { Formats = new[] @@ -39,7 +39,7 @@ namespace Avalonia.Controls.Remote public SizingMode Mode { get; set; } - private void OnMessage(object msg) + private void OnMessage(object? msg) { if (msg is FrameMessage frame) { diff --git a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs index 8ec1b35a6c..24074f9c8c 100644 --- a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs +++ b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs @@ -202,24 +202,24 @@ namespace Avalonia.DesignerSupport.Remote } private static Window s_currentWindow; - private static void OnTransportMessage(IAvaloniaRemoteTransportConnection transport, object obj) => Dispatcher.UIThread.Post(() => + private static void OnTransportMessage(IAvaloniaRemoteTransportConnection transport, object obj) => Dispatcher.UIThread.Post(static arg => { - if (obj is ClientSupportedPixelFormatsMessage formats) + if (arg is ClientSupportedPixelFormatsMessage formats) { s_supportedPixelFormats = formats; RebuildPreFlight(); } - if (obj is ClientRenderInfoMessage renderInfo) + if (arg is ClientRenderInfoMessage renderInfo) { s_renderInfoMessage = renderInfo; RebuildPreFlight(); } - if (obj is ClientViewportAllocatedMessage viewport) + if (arg is ClientViewportAllocatedMessage viewport) { s_viewportAllocatedMessage = viewport; RebuildPreFlight(); } - if (obj is UpdateXamlMessage xaml) + if (arg is UpdateXamlMessage xaml) { if (s_currentWindow is not null) s_lastRenderScaling = s_currentWindow.RenderScaling; @@ -247,6 +247,6 @@ namespace Avalonia.DesignerSupport.Remote }); } } - }); + }, obj); } } diff --git a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs index 7c7b32f7e4..157925e35a 100644 --- a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs +++ b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs @@ -146,6 +146,8 @@ namespace Avalonia.Native appMenu.Add(quitItem); } + private void DoLayoutReset() => DoLayoutReset(false); + private void DoLayoutReset(bool forceUpdate = false) { var macOpts = AvaloniaLocator.Current.GetService() ?? new MacOSPlatformOptions(); @@ -195,7 +197,7 @@ namespace Avalonia.Native if (_resetQueued) return; _resetQueued = true; - Dispatcher.UIThread.Post(() => DoLayoutReset(), DispatcherPriority.Background); + Dispatcher.UIThread.Post(DoLayoutReset, DispatcherPriority.Background); } private void SetMenu(NativeMenu menu) @@ -252,9 +254,9 @@ namespace Avalonia.Native { _nativeMenu = __MicroComIAvnMenuProxy.Create(_factory); - _nativeMenu.Initialize(this, menu, ""); + _nativeMenu.Initialize(this, menu, ""); - setMenu = true; + setMenu = true; } _nativeMenu.Update(_factory, menu); @@ -273,9 +275,9 @@ namespace Avalonia.Native { _nativeMenu = __MicroComIAvnMenuProxy.Create(_factory); - _nativeMenu.Initialize(this, menu, ""); + _nativeMenu.Initialize(this, menu, ""); - setMenu = true; + setMenu = true; } _nativeMenu.Update(_factory, menu); diff --git a/src/Avalonia.X11/X11PlatformLifetimeEvents.cs b/src/Avalonia.X11/X11PlatformLifetimeEvents.cs index 8412bd0730..f03ed6f1ef 100644 --- a/src/Avalonia.X11/X11PlatformLifetimeEvents.cs +++ b/src/Avalonia.X11/X11PlatformLifetimeEvents.cs @@ -223,28 +223,31 @@ namespace Avalonia.X11 private void InteractHandler(IntPtr smcConn) { - Dispatcher.UIThread.Post(() => ActualInteractHandler(smcConn)); + Dispatcher.UIThread.Post(ActualInteractHandler, smcConn); } - private void ActualInteractHandler(IntPtr smcConn) + private void ActualInteractHandler(object? state) { - var e = new ShutdownRequestedEventArgs(); - - if (_platform.Options?.EnableSessionManagement ?? false) + if (state is IntPtr smcConn) { - ShutdownRequested?.Invoke(this, e); - } + var e = new ShutdownRequestedEventArgs(); - SMLib.SmcInteractDone(smcConn, e.Cancel); + if (_platform.Options?.EnableSessionManagement ?? false) + { + ShutdownRequested?.Invoke(this, e); + } - if (e.Cancel) - { - return; - } + SMLib.SmcInteractDone(smcConn, e.Cancel); - _saveYourselfPhase = false; + if (e.Cancel) + { + return; + } + + _saveYourselfPhase = false; - SMLib.SmcSaveYourselfDone(smcConn, true); + SMLib.SmcSaveYourselfDone(smcConn, true); + } } private static void IceWatchHandler(IntPtr iceConn, IntPtr clientData, bool opening, IntPtr* watchData)