Skip to content

Commit 2dcbe7f

Browse files
committed
Remove old blur handling codes
1 parent 7a85439 commit 2dcbe7f

File tree

1 file changed

+7
-115
lines changed

1 file changed

+7
-115
lines changed

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 7 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ public static class Win32Helper
1212
{
1313
#region Blur Handling
1414

15+
public static bool IsBackdropSupported()
16+
{
17+
// Windows 11 (22000) 이상에서만 Mica 및 Acrylic 효과 지원
18+
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
19+
Environment.OSVersion.Version.Build >= 22000;
20+
}
21+
1522
public static unsafe bool DWMSetBackdropForWindow(Window window, BackdropTypes backdrop)
1623
{
1724
var windowHelper = new WindowInteropHelper(window);
@@ -74,120 +81,5 @@ public static unsafe bool DWMSetCornerPreferenceForWindow(Window window, string
7481
}
7582

7683
#endregion
77-
78-
#region Backdrop
79-
80-
public static bool IsBackdropSupported()
81-
{
82-
// Windows 11 (22000) 이상에서만 Mica 및 Acrylic 효과 지원
83-
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
84-
Environment.OSVersion.Version.Build >= 22000;
85-
}
86-
87-
public static unsafe bool SetMicaForWindow(Window window, bool enableMica)
88-
{
89-
var windowHelper = new WindowInteropHelper(window);
90-
windowHelper.EnsureHandle();
91-
92-
DWM_SYSTEMBACKDROP_TYPE backdropType = enableMica ? DWM_SYSTEMBACKDROP_TYPE.DWMSBT_MAINWINDOW : DWM_SYSTEMBACKDROP_TYPE.DWMSBT_NONE;
93-
return PInvoke.DwmSetWindowAttribute(
94-
new(windowHelper.Handle),
95-
DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE,
96-
&backdropType,
97-
(uint)Marshal.SizeOf<int>()).Succeeded;
98-
}
99-
100-
#endregion
101-
102-
#region Blur Handling
103-
104-
/*
105-
Found on https://github.com/riverar/sample-win10-aeroglass
106-
*/
107-
108-
private enum AccentState
109-
{
110-
ACCENT_DISABLED = 0,
111-
ACCENT_ENABLE_GRADIENT = 1,
112-
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
113-
ACCENT_ENABLE_BLURBEHIND = 3,
114-
ACCENT_INVALID_STATE = 4
115-
}
116-
117-
[StructLayout(LayoutKind.Sequential)]
118-
private struct AccentPolicy
119-
{
120-
public AccentState AccentState;
121-
public int AccentFlags;
122-
public int GradientColor;
123-
public int AnimationId;
124-
}
125-
126-
[StructLayout(LayoutKind.Sequential)]
127-
private struct WindowCompositionAttributeData
128-
{
129-
public WindowCompositionAttribute Attribute;
130-
public IntPtr Data;
131-
public int SizeOfData;
132-
}
133-
134-
private enum WindowCompositionAttribute
135-
{
136-
WCA_ACCENT_POLICY = 19
137-
}
138-
139-
[DllImport("user32.dll")]
140-
private static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
141-
142-
/// <summary>
143-
/// Checks if the blur theme is enabled
144-
/// </summary>
145-
public static bool IsBlurTheme()
146-
{
147-
if (Environment.OSVersion.Version >= new Version(6, 2))
148-
{
149-
var resource = Application.Current.TryFindResource("ThemeBlurEnabled");
150-
151-
if (resource is bool b)
152-
return b;
153-
154-
return false;
155-
}
156-
157-
return false;
158-
}
159-
160-
/// <summary>
161-
/// Sets the blur for a window via SetWindowCompositionAttribute
162-
/// </summary>
163-
public static void SetBlurForWindow(Window w, bool blur)
164-
{
165-
SetWindowAccent(w, blur ? AccentState.ACCENT_ENABLE_BLURBEHIND : AccentState.ACCENT_DISABLED);
166-
}
167-
168-
private static void SetWindowAccent(Window w, AccentState state)
169-
{
170-
var windowHelper = new WindowInteropHelper(w);
171-
172-
windowHelper.EnsureHandle();
173-
174-
var accent = new AccentPolicy { AccentState = state };
175-
var accentStructSize = Marshal.SizeOf(accent);
176-
177-
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
178-
Marshal.StructureToPtr(accent, accentPtr, false);
179-
180-
var data = new WindowCompositionAttributeData
181-
{
182-
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
183-
SizeOfData = accentStructSize,
184-
Data = accentPtr
185-
};
186-
187-
SetWindowCompositionAttribute(windowHelper.Handle, ref data);
188-
189-
Marshal.FreeHGlobal(accentPtr);
190-
}
191-
#endregion
19284
}
19385
}

0 commit comments

Comments
 (0)