Browse Source

Merge remote-tracking branch 'origin/fixes/textProcessingBugs' into fixes/textProcessingBugs

pull/7509/head
Benedikt Stebner 4 years ago
parent
commit
08f8f7e783
  1. 16
      src/Avalonia.X11/SMLib.cs
  2. 21
      src/Avalonia.X11/X11PlatformLifetimeEvents.cs
  3. 4
      src/Windows/Avalonia.Win32/WindowImpl.cs

16
src/Avalonia.X11/SMLib.cs

@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Runtime.InteropServices;
@ -7,20 +8,19 @@ namespace Avalonia.X11
{
private const string LibSm = "libSM.so.6";
[DllImport(LibSm, CharSet = CharSet.Ansi)]
[DllImport(LibSm, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr SmcOpenConnection(
[MarshalAs(UnmanagedType.LPWStr)] string networkId,
[MarshalAs(UnmanagedType.LPStr)] string? networkId,
IntPtr content,
int xsmpMajorRev,
int xsmpMinorRev,
ulong mask,
nuint mask,
ref SmcCallbacks callbacks,
[MarshalAs(UnmanagedType.LPWStr)] [Out]
out string previousId,
[MarshalAs(UnmanagedType.LPWStr)] [Out]
out string clientIdRet,
[MarshalAs(UnmanagedType.LPStr)] string? previousId,
ref IntPtr clientIdRet,
int errorLength,
[Out] char[] errorStringRet);
[Out] byte[] errorStringRet
);
[DllImport(LibSm, CallingConvention = CallingConvention.StdCall)]
public static extern int SmcCloseConnection(

21
src/Avalonia.X11/X11PlatformLifetimeEvents.cs

@ -1,5 +1,6 @@
#nullable enable
using System;
using System.Text;
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
using System.Threading;
@ -14,10 +15,10 @@ namespace Avalonia.X11
internal unsafe class X11PlatformLifetimeEvents : IDisposable, IPlatformLifetimeEventsImpl
{
private readonly AvaloniaX11Platform _platform;
private const ulong SmcSaveYourselfProcMask = 1L;
private const ulong SmcDieProcMask = 2L;
private const ulong SmcSaveCompleteProcMask = 4L;
private const ulong SmcShutdownCancelledProcMask = 8L;
private const nuint SmcSaveYourselfProcMask = 1;
private const nuint SmcDieProcMask = 2;
private const nuint SmcSaveCompleteProcMask = 4;
private const nuint SmcShutdownCancelledProcMask = 8;
private static readonly ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents> s_nativeToManagedMapper =
new ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents>();
@ -62,24 +63,24 @@ namespace Avalonia.X11
return;
}
var errorBuf = new char[255];
var smcConn = SMLib.SmcOpenConnection(null!,
byte[] errorBuf = new byte[255];
IntPtr clientIdRet = IntPtr.Zero;
var smcConn = SMLib.SmcOpenConnection(null,
IntPtr.Zero, 1, 0,
SmcSaveYourselfProcMask |
SmcSaveCompleteProcMask |
SmcShutdownCancelledProcMask |
SmcDieProcMask,
ref s_callbacks,
out _,
out _,
null,
ref clientIdRet,
errorBuf.Length,
errorBuf);
if (smcConn == IntPtr.Zero)
{
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;
}

4
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -265,7 +265,7 @@ namespace Avalonia.Win32
{
if (IsWindowVisible(_hwnd))
{
ShowWindow(value, true);
ShowWindow(value, value != WindowState.Minimized); // If the window is minimized, it shouldn't be activated
}
_showWindowState = value;
@ -973,7 +973,7 @@ namespace Avalonia.Win32
{
case WindowState.Minimized:
newWindowProperties.IsFullScreen = false;
command = activate ? ShowWindowCommand.Minimize : ShowWindowCommand.ShowMinNoActive;
command = ShowWindowCommand.Minimize;
break;
case WindowState.Maximized:
newWindowProperties.IsFullScreen = false;

Loading…
Cancel
Save