mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-05-08 03:06:29 +08:00
Add Acrylic and Tabbed backdrop
This commit is contained in:
@@ -168,7 +168,7 @@ public static class WindowHelper
|
||||
Marshal.FreeHGlobal(accentPtr);
|
||||
}
|
||||
|
||||
public static void DisableBlur(Window window)
|
||||
public static void DisableDwmBlur(Window window)
|
||||
{
|
||||
var accent = new AccentPolicy();
|
||||
var accentStructSize = Marshal.SizeOf(accent);
|
||||
@@ -211,6 +211,11 @@ public static class WindowHelper
|
||||
|
||||
var hwnd = new WindowInteropHelper(window).Handle;
|
||||
|
||||
if (!window.AllowsTransparency && HwndSource.FromHwnd(hwnd) is HwndSource hwndSource)
|
||||
{
|
||||
hwndSource.CompositionTarget.BackgroundColor = Colors.Transparent;
|
||||
}
|
||||
|
||||
var isDarkThemeInt = isDarkTheme ? 1 : 0;
|
||||
Dwmapi.DwmSetWindowAttribute(hwnd, (uint)Dwmapi.WindowAttribute.UseImmersiveDarkMode, ref isDarkThemeInt, Marshal.SizeOf(typeof(bool)));
|
||||
|
||||
@@ -228,7 +233,17 @@ public static class WindowHelper
|
||||
|
||||
public static void EnableBackdropMicaBlur(Window window, bool isDarkTheme)
|
||||
{
|
||||
EnableDwmBlur(window, isDarkTheme, (uint)Dwmapi.WindowAttribute.SystembackdropType, (int)Dwmapi.SystembackdropType.MainWindow);
|
||||
EnableDwmBlur(window, isDarkTheme, (uint)Dwmapi.WindowAttribute.SystembackdropType, (int)Dwmapi.SystembackdropType.Mica);
|
||||
}
|
||||
|
||||
public static void EnableBackdropAcrylicBlur(Window window, bool isDarkTheme)
|
||||
{
|
||||
EnableDwmBlur(window, isDarkTheme, (uint)Dwmapi.WindowAttribute.SystembackdropType, (int)Dwmapi.SystembackdropType.Acrylic);
|
||||
}
|
||||
|
||||
public static void EnableBackdropTabbedBlur(Window window, bool isDarkTheme)
|
||||
{
|
||||
EnableDwmBlur(window, isDarkTheme, (uint)Dwmapi.WindowAttribute.SystembackdropType, (int)Dwmapi.SystembackdropType.Tabbed);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
||||
@@ -41,9 +41,12 @@ public static class Dwmapi
|
||||
{
|
||||
Auto = 0,
|
||||
None = 1,
|
||||
MainWindow = 2,
|
||||
TransientWindow = 3,
|
||||
TabbedWindow = 4,
|
||||
Mica = 2,
|
||||
Acrylic = 3, // Automatically selects the best Acrylic effect available on the system (Acrylic11 > Acrylic10)
|
||||
Tabbed = 4,
|
||||
|
||||
Acrylic10, // Windows 10 style, supported on Windows 10 and 11
|
||||
Acrylic11, // Windows 11 style, supported on Windows 11 22523+ (Insider) and 22621+ (Stable)
|
||||
}
|
||||
|
||||
[DllImport("DwmApi.dll")]
|
||||
|
||||
Reference in New Issue
Block a user