|
|
@ -1,5 +1,6 @@ |
|
|
#nullable enable |
|
|
#nullable enable |
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Text; |
|
|
using System.Collections.Concurrent; |
|
|
using System.Collections.Concurrent; |
|
|
using System.Runtime.InteropServices; |
|
|
using System.Runtime.InteropServices; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
@ -14,10 +15,10 @@ namespace Avalonia.X11 |
|
|
internal unsafe class X11PlatformLifetimeEvents : IDisposable, IPlatformLifetimeEventsImpl |
|
|
internal unsafe class X11PlatformLifetimeEvents : IDisposable, IPlatformLifetimeEventsImpl |
|
|
{ |
|
|
{ |
|
|
private readonly AvaloniaX11Platform _platform; |
|
|
private readonly AvaloniaX11Platform _platform; |
|
|
private const ulong SmcSaveYourselfProcMask = 1L; |
|
|
private const nuint SmcSaveYourselfProcMask = 1; |
|
|
private const ulong SmcDieProcMask = 2L; |
|
|
private const nuint SmcDieProcMask = 2; |
|
|
private const ulong SmcSaveCompleteProcMask = 4L; |
|
|
private const nuint SmcSaveCompleteProcMask = 4; |
|
|
private const ulong SmcShutdownCancelledProcMask = 8L; |
|
|
private const nuint SmcShutdownCancelledProcMask = 8; |
|
|
|
|
|
|
|
|
private static readonly ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents> s_nativeToManagedMapper = |
|
|
private static readonly ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents> s_nativeToManagedMapper = |
|
|
new ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents>(); |
|
|
new ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents>(); |
|
|
@ -62,24 +63,24 @@ namespace Avalonia.X11 |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var errorBuf = new char[255]; |
|
|
byte[] errorBuf = new byte[255]; |
|
|
|
|
|
IntPtr clientIdRet = IntPtr.Zero; |
|
|
var smcConn = SMLib.SmcOpenConnection(null!, |
|
|
var smcConn = SMLib.SmcOpenConnection(null, |
|
|
IntPtr.Zero, 1, 0, |
|
|
IntPtr.Zero, 1, 0, |
|
|
SmcSaveYourselfProcMask | |
|
|
SmcSaveYourselfProcMask | |
|
|
SmcSaveCompleteProcMask | |
|
|
SmcSaveCompleteProcMask | |
|
|
SmcShutdownCancelledProcMask | |
|
|
SmcShutdownCancelledProcMask | |
|
|
SmcDieProcMask, |
|
|
SmcDieProcMask, |
|
|
ref s_callbacks, |
|
|
ref s_callbacks, |
|
|
out _, |
|
|
null, |
|
|
out _, |
|
|
ref clientIdRet, |
|
|
errorBuf.Length, |
|
|
errorBuf.Length, |
|
|
errorBuf); |
|
|
errorBuf); |
|
|
|
|
|
|
|
|
if (smcConn == IntPtr.Zero) |
|
|
if (smcConn == IntPtr.Zero) |
|
|
{ |
|
|
{ |
|
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(this, |
|
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(this, |
|
|
$"SMLib/ICELib reported a new error: {new string(errorBuf)}"); |
|
|
$"SMLib/ICELib reported a new error: {Encoding.ASCII.GetString(errorBuf)}"); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|