Skip to content

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

refactor: removed Index property from Monitor class, added IsFocused property

Lars86b5a717d11a
diff --git a/LarsWM/Monitor.cs b/LarsWM/Monitor.cs
index e98c8557..2fcd637a 100644
--- a/LarsWM/Monitor.cs
+++ b/LarsWM/Monitor.cs
@@ -7,18 +7,18 @@ namespace LarsWM
{
public class Monitor
{
- public int Index { get; private set; }
+ public List<Workspace> WorkspacesInMonitor = new List<Workspace>();
public string Name => Screen.DeviceName;
public int Width => Screen.WorkingArea.Width;
public int Height => Screen.WorkingArea.Height;
public int X => Screen.WorkingArea.X;
public int Y => Screen.WorkingArea.Y;
+ public bool IsPrimary => Screen.Primary;
public Screen Screen { get; }
- public Monitor(int index, Screen screen)
+ public Monitor(Screen screen)
{
- Index = index;
Screen = screen;
}
}
diff --git a/LarsWM/WindowManager.cs b/LarsWM/WindowManager.cs
index 5a309cfc..0e94e678 100644
--- a/LarsWM/WindowManager.cs
+++ b/LarsWM/WindowManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
@@ -16,29 +16,19 @@ namespace LarsWM
class WindowManager
{
- private Monitor[] _monitors;
+ private List<Monitor> _monitors = new List<Monitor>();
public WindowManager()
{
- var screens = Screen.AllScreens;
- _monitors = new Monitor[screens.Length];
-
- _monitors[0] = new Monitor(0, Screen.PrimaryScreen);
-
- var index = 1;
- foreach (var screen in screens)
+ foreach (var screen in Screen.AllScreens)
{
- if (!screen.Primary)
- {
- _monitors[index] = new Monitor(index, screen);
- index++;
- }
+ _monitors.Add(new Monitor(screen));
}
- var focusedMonitor = _monitors[0];
+ var focusedMonitor = _monitors.Find(m => m.IsPrimary);
}
- public int NumMonitors => _monitors.Length;
+ public int NumMonitors => _monitors.Count;
public void ShiftFocusInDirection(FocusDirection direction)
{ }