function intersects(a,b) { return a.x < b.x+b.width && a.x+a.width > b.x && a.y < b.y+b.height && a.y+a.height > b.y; } function obstructed(rect, monitor, windows, workspaces) { return windows.some(w => !w.hidden && w.monitor === monitor && (workspaces.includes(w.workspace) || w.active) && (w.fullscreen || intersects(rect,w))); }