GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: filter out current process from windows to register
Larsae921624c988
diff --git a/LarsWM/WindowsApi/WindowsApiFacade.cs b/LarsWM/WindowsApi/WindowsApiFacade.csindex 0621b7c8..7eb10347 100644--- a/LarsWM/WindowsApi/WindowsApiFacade.cs+++ b/LarsWM/WindowsApi/WindowsApiFacade.cs@@ -1,6 +1,7 @@using System;using System.Collections.Generic;using System.Diagnostics;+using System.Linq;using System.Text;using static LarsWM.WindowsApi.WindowsApiService;@@ -17,6 +18,14 @@ namespace LarsWM.WindowsApi{return false;}++ var isCurrentProcess = window.Process.Id == Process.GetCurrentProcess().Id;++ if (isCurrentProcess)+ {+ return false;+ }+return true;};@@ -45,6 +54,23 @@ namespace LarsWM.WindowsApireturn matchedWindows.ToArray();}+ /// <summary>+ /// Get the id of the process that created the window.+ /// </summary>+ public static Process GetProcessOfWindow(Window window)+ {+ uint processId;+ GetWindowThreadProcessId(window.Hwnd, out processId);++ try+ {+ return Process.GetProcesses().First(process => process.Id == (int)processId);+ } catch(InvalidOperationException)+ {+ return null;+ }+ }+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.csindex 753fcf0b..1b1f4164 100644--- a/LarsWM/WindowsApi/WindowsApiService.cs+++ b/LarsWM/WindowsApi/WindowsApiService.cs@@ -134,5 +134,8 @@ namespace LarsWM.WindowsApi[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]public static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount);++ [DllImport("user32.dll", SetLastError=true)]+ public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);}}