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

21
src/Avalonia.X11/X11PlatformLifetimeEvents.cs

@ -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;
} }

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

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

Loading…
Cancel
Save