GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: added property for displayed workspace in Monitor, added debug logs in WindowManager
Lars8c02ead3c8cc
diff --git a/LarsWM/Monitor.cs b/LarsWM/Monitor.csindex 2fcd637a..b0e76f45 100644--- a/LarsWM/Monitor.cs+++ b/LarsWM/Monitor.cs@@ -8,6 +8,7 @@ namespace LarsWMpublic class Monitor{public List<Workspace> WorkspacesInMonitor = new List<Workspace>();+ public Workspace DisplayedWorkspace; // Alternatively add IsDisplayed/IsVisible property to Workspace instancepublic string Name => Screen.DeviceName;public int Width => Screen.WorkingArea.Width;public int Height => Screen.WorkingArea.Height;diff --git a/LarsWM/WindowManager.cs b/LarsWM/WindowManager.csindex 1b988392..2e5dd2a6 100644--- a/LarsWM/WindowManager.cs+++ b/LarsWM/WindowManager.cs@@ -1,9 +1,13 @@-using System;+using System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Text;using System.Windows.Forms;+using static LarsWM.WindowsApi.WindowsApiService;+using static LarsWM.WindowsApi.WindowsApiFacade;+using System.IO;+using System.Drawing;namespace LarsWM{@@ -21,6 +25,7 @@ namespace LarsWMpublic WindowManager(){+ // Create a Monitor instance for each Screenforeach (var screen in Screen.AllScreens){_monitors.Add(new Monitor(screen));@@ -28,27 +33,43 @@ namespace LarsWMvar focusedMonitor = _monitors.Find(m => m.IsPrimary);+ // Create an initial Workspace for each Monitorint index = 0;- foreach (var monitor in _monitors)- {- monitor.WorkspacesInMonitor.Add(new Workspace(index, new List<Window>()));+ foreach (var monitor in _monitors)+ {+ // TODO: add IsFocused property to focused window, workspace & monitor+ var newWorkspace = new Workspace(index, new List<Window>());+ monitor.WorkspacesInMonitor.Add(newWorkspace);+ monitor.DisplayedWorkspace = newWorkspace;+index++;}- //var facade = new WindowsApi.WindowsApiFacade();- //facade.GetOpenWindows();-- Predicate<Window> ALL = delegate { return true; };- var windows = WindowsApi.WindowsApiFacade.GetOpenWindows();+ var windows = GetOpenWindows();foreach (var window in windows){- StringBuilder sb = new StringBuilder(WindowsApi.WindowsApiService.GetWindowTextLength(window.Hwnd) + 1);- WindowsApi.WindowsApiService.GetWindowText(window.Hwnd, sb, sb.Capacity);- Debug.WriteLine(sb.ToString());+ DumpManagedWindows(window);}}+ private static void DumpManagedWindows(Window window)+ {+ StringBuilder sb = new StringBuilder(GetWindowTextLength(window.Hwnd) + 1);+ GetWindowText(window.Hwnd, sb, sb.Capacity);+ Debug.WriteLine(sb.ToString());++ uint processId;+ GetWindowThreadProcessId(window.Hwnd, out processId);+ var _processId = (int)processId;+ //Debug.WriteLine(_processId);++ var process = Process.GetProcesses().FirstOrDefault(p => p.Id == _processId);+ var _processName = process.ProcessName;+ Debug.WriteLine(_processName);+ Debug.WriteLine(window.Location);+ }+public int NumMonitors => _monitors.Count;public void ShiftFocusInDirection(FocusDirection direction)