Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: added method for checking whether a window is cloaked to WindowsApiFacade

Lars9dec84309456
diff --git a/LarsWM/WindowsApi/WindowsApiFacade.cs b/LarsWM/WindowsApi/WindowsApiFacade.cs
index 99db4920..97978633 100644
--- a/LarsWM/WindowsApi/WindowsApiFacade.cs
+++ b/LarsWM/WindowsApi/WindowsApiFacade.cs
@@ -1,8 +1,9 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
+using System.Runtime.InteropServices;
using static LarsWM.WindowsApi.WindowsApiService;
using static LarsWM.UserConfig.UserConfigService;
using LarsWM.WindowsApi.DataTypes;
@@ -117,5 +118,13 @@ namespace LarsWM.WindowsApi
return new IntPtr(GetWindowLong32(hWnd, nIndex));
}
}
+
+ public static bool IsWindowCloaked(Window window)
+ {
+
+ bool isCloaked;
+ DwmGetWindowAttribute(window.Hwnd, DwmWindowAttribute.DWMWA_CLOAKED, out isCloaked, Marshal.SizeOf(typeof(bool)));
+ return isCloaked;
+ }
}
}
diff --git a/LarsWM/WindowsApi/WindowsApiService.cs b/LarsWM/WindowsApi/WindowsApiService.cs
index f0da90c2..34f99fb6 100644
--- a/LarsWM/WindowsApi/WindowsApiService.cs
+++ b/LarsWM/WindowsApi/WindowsApiService.cs
@@ -1,4 +1,4 @@
-using LarsWM.WindowsApi.DataTypes;
+using LarsWM.WindowsApi.DataTypes;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
@@ -89,6 +89,27 @@ namespace LarsWM.WindowsApi
WS_EX_NOACTIVATE = 0x08000000
}
+ [Flags]
+ public enum DwmWindowAttribute : uint
+ {
+ DWMWA_NCRENDERING_ENABLED = 1,
+ DWMWA_NCRENDERING_POLICY,
+ DWMWA_TRANSITIONS_FORCEDISABLED,
+ DWMWA_ALLOW_NCPAINT,
+ DWMWA_CAPTION_BUTTON_BOUNDS,
+ DWMWA_NONCLIENT_RTL_LAYOUT,
+ DWMWA_FORCE_ICONIC_REPRESENTATION,
+ DWMWA_FLIP3D_POLICY,
+ DWMWA_EXTENDED_FRAME_BOUNDS,
+ DWMWA_HAS_ICONIC_BITMAP,
+ DWMWA_DISALLOW_PEEK,
+ DWMWA_EXCLUDED_FROM_PEEK,
+ DWMWA_CLOAK,
+ DWMWA_CLOAKED,
+ DWMWA_FREEZE_REPRESENTATION,
+ DWMWA_LAST
+ }
+
public static int GWL_STYLE = -16;
public static int GWL_EXSTYLE = -20;
@@ -144,5 +165,8 @@ namespace LarsWM.WindowsApi
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hwnd, ref WindowRect rectangle);
+
+ [DllImport("dwmapi.dll")]
+ public static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out bool pvAttribute, int cbAttribute);
}
}