Skip to content

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

feat: added method to WindowsApiFacade for getting class name of window

Larsc93755f51091
diff --git a/LarsWM/WindowsApi/WindowsApiFacade.cs b/LarsWM/WindowsApi/WindowsApiFacade.cs
index 7eb10347..8916eb8c 100644
--- a/LarsWM/WindowsApi/WindowsApiFacade.cs
+++ b/LarsWM/WindowsApi/WindowsApiFacade.cs
@@ -71,6 +71,16 @@ namespace LarsWM.WindowsApi
}
}
+ /// <summary>
+ /// Get the name of the class of the window.
+ /// </summary>
+ public static string GetClassNameOfWindow(Window window)
+ {
+ var buffer = new StringBuilder(255);
+ GetClassName(window.Hwnd, buffer, buffer.Capacity + 1);
+ return buffer.ToString();
+ }
+
public static bool HasWindowStyle(IntPtr hwnd, WS style)
{
var styles = unchecked((WS)GetWindowLongPtr(hwnd, (int)(GWL_STYLE)).ToInt64());
diff --git a/LarsWM/WindowsApi/WindowsApiService.cs b/LarsWM/WindowsApi/WindowsApiService.cs
index 1b1f4164..e169f5a6 100644
--- a/LarsWM/WindowsApi/WindowsApiService.cs
+++ b/LarsWM/WindowsApi/WindowsApiService.cs
@@ -137,5 +137,8 @@ namespace LarsWM.WindowsApi
[DllImport("user32.dll", SetLastError=true)]
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
+
+ [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
+ public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName,int nMaxCount);
}
}