mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
* [PT Run] Refactoring: combined all NativeMethods.cs files for plugins into Wox.Plugin/Common/Win32/ * Fixed spell check * [PT Run] Changed NativeMethods.Helpers to Win32Helpers (seperate class) to not conflict with Microsoft.PowerToys.Settings.UI.Library.Helpers * [PT Run] Renamed Constants.cs to ConstantsAndStructs.cs and moved all of them from NativeMethods.cs * [PT Run] Merged ConstantsAndStructs.cs into NativeMethods.cs and renamed Constants to Win32Constants to avoid conflicting * [PT Run] Added missing summaries + fixed missed refactored method * [PT Run] Use using directive instead of alias + updated method call for .Net 6 * [PT Run] Fixed missed using alias + spell check
60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
// 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
|
|
{
|
|
/// <summary>
|
|
/// Class containing methods to control the live preview
|
|
/// </summary>
|
|
internal class LivePreview
|
|
{
|
|
/// <summary>
|
|
/// Makes sure that a window is excluded from the live preview
|
|
/// </summary>
|
|
/// <param name="hwnd">handle to the window to exclude</param>
|
|
public static void SetWindowExclusionFromLivePreview(IntPtr hwnd)
|
|
{
|
|
int renderPolicy = (int)DwmNCRenderingPolicies.Enabled;
|
|
|
|
_ = NativeMethods.DwmSetWindowAttribute(
|
|
hwnd,
|
|
12,
|
|
ref renderPolicy,
|
|
sizeof(int));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Activates the live preview
|
|
/// </summary>
|
|
/// <param name="targetWindow">the window to show by making all other windows transparent</param>
|
|
/// <param name="windowToSpare">the window which should not be transparent but is not the target window</param>
|
|
public static void ActivateLivePreview(IntPtr targetWindow, IntPtr windowToSpare)
|
|
{
|
|
_ = NativeMethods.DwmpActivateLivePreview(
|
|
true,
|
|
targetWindow,
|
|
windowToSpare,
|
|
LivePreviewTrigger.Superbar,
|
|
IntPtr.Zero);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deactivates the live preview
|
|
/// </summary>
|
|
public static void DeactivateLivePreview()
|
|
{
|
|
_ = NativeMethods.DwmpActivateLivePreview(
|
|
false,
|
|
IntPtr.Zero,
|
|
IntPtr.Zero,
|
|
LivePreviewTrigger.AltTab,
|
|
IntPtr.Zero);
|
|
}
|
|
}
|
|
}
|