/**
* CORRECTED Non-Overlapping Layout Functions
* This fixes the overlap issues with verified calculations
*/
class FixedNonOverlappingLayouts {
/**
* Create a truly non-overlapping coding layout with verified positions
*/
static createVerifiedCodingLayout() {
const script = `
-- VERIFIED Non-Overlapping Coding Layout
-- Tested and confirmed to have zero overlaps
-- VSCode: Left 60% of screen (0-1152px, full height)
tell application "Visual Studio Code"
activate
delay 0.5
end tell
tell application "System Events"
tell process "Code"
set frontmost to true
-- Position: x=0, y=25 (menu bar), size=1152x1000
set position of front window to {0, 25}
set size of front window to {1152, 1000}
end tell
end tell
delay 0.5
-- Safari: Top right quadrant (1152-1920px, top half)
tell application "Safari"
activate
delay 0.5
end tell
tell application "System Events"
tell process "Safari"
set frontmost to true
-- Position: x=1152 (no overlap), y=25, size=768x500
set position of front window to {1152, 25}
set size of front window to {768, 500}
end tell
end tell
delay 0.5
-- iTerm: Bottom right quadrant (1152-1920px, bottom half)
tell application "iTerm"
activate
delay 0.5
end tell
tell application "System Events"
tell process "iTerm2"
set frontmost to true
-- Position: x=1152 (aligned with Safari), y=525 (below Safari)
set position of front window to {1152, 525}
set size of front window to {768, 500}
end tell
end tell
delay 0.5
-- Return focus to VSCode
tell application "Visual Studio Code" to activate
return "Verified non-overlapping layout applied successfully"
`;
return script;
}
/**
* Validate positions to ensure no overlaps
*/
static validatePositions() {
const positions = {
vscode: { x: 0, y: 25, width: 1152, height: 1000 },
safari: { x: 1152, y: 25, width: 768, height: 500 },
iterm: { x: 1152, y: 525, width: 768, height: 500 }
};
// Check for overlaps
const overlaps = [];
// VSCode vs Safari - should not overlap (VSCode ends at x=1152, Safari starts at x=1152)
if (positions.vscode.x + positions.vscode.width > positions.safari.x) {
overlaps.push("VSCode-Safari horizontal overlap");
}
// Safari vs iTerm - should not overlap (Safari ends at y=525, iTerm starts at y=525)
if (positions.safari.y + positions.safari.height > positions.iterm.y) {
overlaps.push("Safari-iTerm vertical overlap");
}
return {
valid: overlaps.length === 0,
overlaps: overlaps,
positions: positions
};
}
/**
* Get the corrected layout calculation
*/
static getLayoutCalculations() {
return {
screenWidth: 1920,
screenHeight: 1080,
menuBarHeight: 25,
vscode: {
x: 0,
y: 25,
width: Math.floor(1920 * 0.6), // 1152px
height: 1000
},
safari: {
x: 1152, // Starts exactly where VSCode ends
y: 25,
width: 768, // Remaining 40% of screen
height: 500 // Top half of right area
},
iterm: {
x: 1152, // Aligned with Safari
y: 525, // Starts exactly where Safari ends (25 + 500)
width: 768, // Same width as Safari
height: 500 // Bottom half of right area
}
};
}
}
module.exports = FixedNonOverlappingLayouts;
// Test the validation
if (require.main === module) {
console.log('🔧 CORRECTED Non-Overlapping Layout System');
console.log('=========================================');
const validation = FixedNonOverlappingLayouts.validatePositions();
console.log('Validation Result:', validation.valid ? '✅ VALID' : '❌ INVALID');
if (!validation.valid) {
console.log('Overlaps detected:', validation.overlaps);
}
console.log('\nLayout Calculations:');
const calc = FixedNonOverlappingLayouts.getLayoutCalculations();
console.log(JSON.stringify(calc, null, 2));
}