// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// Code forked from Betsegaw Tadele's https://github.com/betsegaw/windowwalker/
using System;
using Wox.Plugin.Common.Win32;
namespace Microsoft.Plugin.WindowWalker.Components
{
///
/// Class containing methods to control the live preview
///
internal class LivePreview
{
///
/// Makes sure that a window is excluded from the live preview
///
/// handle to the window to exclude
public static void SetWindowExclusionFromLivePreview(IntPtr hwnd)
{
int renderPolicy = (int)DwmNCRenderingPolicies.Enabled;
_ = NativeMethods.DwmSetWindowAttribute(
hwnd,
12,
ref renderPolicy,
sizeof(int));
}
///
/// Activates the live preview
///
/// the window to show by making all other windows transparent
/// the window which should not be transparent but is not the target window
public static void ActivateLivePreview(IntPtr targetWindow, IntPtr windowToSpare)
{
_ = NativeMethods.DwmpActivateLivePreview(
true,
targetWindow,
windowToSpare,
LivePreviewTrigger.Superbar,
IntPtr.Zero);
}
///
/// Deactivates the live preview
///
public static void DeactivateLivePreview()
{
_ = NativeMethods.DwmpActivateLivePreview(
false,
IntPtr.Zero,
IntPtr.Zero,
LivePreviewTrigger.AltTab,
IntPtr.Zero);
}
}
}