Browse Source

post shutdown event handler

pull/6883/head
Jumar Macato 5 years ago
parent
commit
832947961b
No known key found for this signature in database GPG Key ID: 85076C4D9D3155A3
  1. 24
      src/Avalonia.X11/X11PlatformLifetimeEvents.cs

24
src/Avalonia.X11/X11PlatformLifetimeEvents.cs

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Logging;
using Avalonia.Platform;
using Avalonia.Threading;
namespace Avalonia.X11
{
@ -218,25 +219,22 @@ namespace Avalonia.X11
private void InteractHandler(IntPtr smcConn)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (ShutdownRequested is null)
{
return;
}
var e = new ShutdownRequestedEventArgs();
Dispatcher.UIThread.Post(() => ActualInteractHandler(smcConn));
}
ShutdownRequested(this, e);
private void ActualInteractHandler(IntPtr smcConn)
{
var e = new ShutdownRequestedEventArgs();
var shutdownCancelled = e.Cancel;
ShutdownRequested?.Invoke(this, e);
SMLib.SmcInteractDone(smcConn, shutdownCancelled);
SMLib.SmcInteractDone(smcConn, e.Cancel);
if (shutdownCancelled)
if (e.Cancel)
{
return;
}
_saveYourselfPhase = false;
SMLib.SmcSaveYourselfDone(smcConn, true);
@ -245,7 +243,7 @@ namespace Avalonia.X11
private static void IceWatchHandler(IntPtr iceConn, IntPtr clientData, bool opening, IntPtr* watchData)
{
if (!opening) return;
ICELib.IceRemoveConnectionWatch(Marshal.GetFunctionPointerForDelegate(s_iceWatchProcDelegate),
IntPtr.Zero);
}

Loading…
Cancel
Save