4 changed files with 72 additions and 58 deletions
@ -1,22 +0,0 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using static Avalonia.Win32.Interop.UnmanagedMethods; |
|||
|
|||
namespace Avalonia.Win32 |
|||
{ |
|||
delegate void MarkFullscreenWindow(IntPtr This, IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fullscreen); |
|||
delegate HRESULT HrInit(IntPtr This); |
|||
|
|||
struct ITaskBarList2VTable |
|||
{ |
|||
public IntPtr IUnknown1; |
|||
public IntPtr IUnknown2; |
|||
public IntPtr IUnknown3; |
|||
public IntPtr HrInit; |
|||
public IntPtr AddTab; |
|||
public IntPtr DeleteTab; |
|||
public IntPtr ActivateTab; |
|||
public IntPtr SetActiveAlt; |
|||
public IntPtr MarkFullscreenWindow; |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using static Avalonia.Win32.Interop.UnmanagedMethods; |
|||
|
|||
namespace Avalonia.Win32.Interop |
|||
{ |
|||
internal class TaskBarList |
|||
{ |
|||
private static IntPtr s_taskBarList; |
|||
private static HrInit s_hrInitDelegate; |
|||
private static MarkFullscreenWindow s_markFullscreenWindowDelegate; |
|||
|
|||
/// <summary>
|
|||
/// Ported from https://github.com/chromium/chromium/blob/master/ui/views/win/fullscreen_handler.cc
|
|||
/// </summary>
|
|||
/// <param name="fullscreen">Fullscreen state.</param>
|
|||
public static unsafe void MarkFullscreen(IntPtr hwnd, bool fullscreen) |
|||
{ |
|||
if (s_taskBarList == IntPtr.Zero) |
|||
{ |
|||
Guid clsid = ShellIds.TaskBarList; |
|||
Guid iid = ShellIds.ITaskBarList2; |
|||
|
|||
int result = CoCreateInstance(ref clsid, IntPtr.Zero, 1, ref iid, out s_taskBarList); |
|||
|
|||
if (s_taskBarList != IntPtr.Zero) |
|||
{ |
|||
var ptr = (ITaskBarList2VTable**)s_taskBarList.ToPointer(); |
|||
|
|||
if (s_hrInitDelegate is null) |
|||
{ |
|||
s_hrInitDelegate = Marshal.GetDelegateForFunctionPointer<HrInit>((*ptr)->HrInit); |
|||
} |
|||
|
|||
if (s_hrInitDelegate(s_taskBarList) != HRESULT.S_OK) |
|||
{ |
|||
s_taskBarList = IntPtr.Zero; |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (s_taskBarList != IntPtr.Zero) |
|||
{ |
|||
var ptr = (ITaskBarList2VTable**)s_taskBarList.ToPointer(); |
|||
|
|||
if (s_markFullscreenWindowDelegate is null) |
|||
{ |
|||
s_markFullscreenWindowDelegate = Marshal.GetDelegateForFunctionPointer<MarkFullscreenWindow>((*ptr)->MarkFullscreenWindow); |
|||
} |
|||
|
|||
s_markFullscreenWindowDelegate(s_taskBarList, hwnd, fullscreen); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue