Add focused window management to BR-95 desktop

This commit is contained in:
Alexa Amundson
2025-11-20 19:03:25 -06:00
parent c96df78772
commit e96703ae56

View File

@@ -356,6 +356,13 @@
flex-direction: column; flex-direction: column;
} }
.window.focused {
box-shadow:
inset 1px 1px 0 var(--br95-gray-lighter),
0 14px 40px rgba(0,0,0,0.8),
0 0 0 2px rgba(105,247,255,0.16);
}
.window.maximized { .window.maximized {
left: 0 !important; left: 0 !important;
top: 36px !important; top: 36px !important;
@@ -1274,6 +1281,7 @@
let windowZIndex = 10; let windowZIndex = 10;
const openWindows = new Set(); const openWindows = new Set();
let focusedWindow = null;
let draggedWindow = null; let draggedWindow = null;
let offsetX = 0, offsetY = 0; let offsetX = 0, offsetY = 0;
@@ -1281,9 +1289,8 @@
const win = document.getElementById(id); const win = document.getElementById(id);
if (!win) return; if (!win) return;
win.classList.add('active'); win.classList.add('active');
win.style.zIndex = ++windowZIndex;
openWindows.add(id); openWindows.add(id);
updateTaskbar(); focusWindow(id);
toggleRoadMenu(false); toggleRoadMenu(false);
} }
@@ -1291,6 +1298,10 @@
const win = document.getElementById(id); const win = document.getElementById(id);
if (!win) return; if (!win) return;
win.classList.remove('active'); win.classList.remove('active');
if (win.classList.contains('focused')) {
win.classList.remove('focused');
focusedWindow = null;
}
openWindows.delete(id); openWindows.delete(id);
updateTaskbar(); updateTaskbar();
} }
@@ -1299,6 +1310,10 @@
const win = document.getElementById(id); const win = document.getElementById(id);
if (!win) return; if (!win) return;
win.classList.remove('active'); win.classList.remove('active');
if (win.classList.contains('focused')) {
win.classList.remove('focused');
focusedWindow = null;
}
updateTaskbar(); updateTaskbar();
} }
@@ -1356,11 +1371,15 @@
if (!win) return; if (!win) return;
const btn = document.createElement('div'); const btn = document.createElement('div');
btn.className = 'taskbar-app'; btn.className = 'taskbar-app';
if (win.classList.contains('active')) btn.classList.add('active-app'); if (win.classList.contains('focused')) btn.classList.add('active-app');
btn.textContent = titles[id] || id; btn.textContent = titles[id] || id;
btn.onclick = () => { btn.onclick = () => {
if (win.classList.contains('active')) { if (win.classList.contains('active')) {
minimizeWindow(id); if (win.classList.contains('focused')) {
minimizeWindow(id);
} else {
focusWindow(id);
}
} else { } else {
openWindow(id); openWindow(id);
} }
@@ -1392,6 +1411,20 @@
} }
}); });
function focusWindow(id) {
const win = document.getElementById(id);
if (!win || !win.classList.contains('active')) return;
document.querySelectorAll('.window.focused').forEach(w => w.classList.remove('focused'));
win.classList.add('focused');
win.style.zIndex = ++windowZIndex;
focusedWindow = id;
updateTaskbar();
}
document.querySelectorAll('.window').forEach(win => {
win.addEventListener('mousedown', () => focusWindow(win.id));
});
// ============================================================================ // ============================================================================
// BR-95 API Integration // BR-95 API Integration
// ============================================================================ // ============================================================================