${img(f.key, f.name)}${esc(f.name)}${from}
`
+ + `
${img(use.key, use.name)}${esc(use.name)}${esc(L.inUse)}
`;
$('previous').disabled = !state.hasPrevious;
$('toPanel').disabled = !f;
const move = $('move');
move.classList.toggle('on', !!moving);
move.querySelector('span').textContent = moving ? L.moving : L.move;
if (moving) status(moving === 'app' ? L.pickApp : L.pickPanel);
+ $('pin').classList.toggle('on', pinning);
+ $('pin').querySelector('span').textContent = pinning ? L.pinning : L.pin;
+ if (pinning) status(L.pickPin);
+ for (const [id, on, text, busy] of [['minimize', minimizing, L.minimize, L.minimizing], ['close', closing, L.close, L.closing]]) {
+ $(id).classList.toggle('on', on);
+ $(id).querySelector('span').textContent = on ? busy : text;
+ }
+ if (minimizing) status(L.pickMinimize);
+ $('fullMode').classList.toggle('on', fulling);
+ $('fullMode').querySelector('span').textContent = fulling ? L.fulling : L.full;
+ // Elegida la app, los monitores aparecen como botones debajo de los modos.
+ const screens = $('screens'); screens.innerHTML = '';
+ screens.hidden = !(fulling && fullApp);
+ if (fulling && fullApp) {
+ status(L.pickScreen(fullApp.name));
+ for (const sc of state.screens || []) {
+ const b = document.createElement('button'); b.textContent = sc.name;
+ b.onclick = () => { send('fullscreen', { id: fullApp.id, display: sc.id }); clearModes(); render(); };
+ screens.appendChild(b);
+ }
+ } else if (fulling) status(L.pickFull);
+ if (closing) status(L.pickClose);
+ const armed = Date.now() - freeAllArmed < 4000;
+ $('freeAll').classList.toggle('armed', armed);
+ $('freeAll').querySelector('span').textContent = armed ? L.freeAllSure : L.freeAll;
+
+ // La disposición del principal: azul, prendida. Mantener apretado restablece el ancho.
+ const lay = $('layout'); lay.innerHTML = '';
+ for (const b of state.layout || []) {
+ const btn = document.createElement('button');
+ btn.textContent = b.label; btn.title = L.resetTip; btn.className = b.on ? 'on' : '';
+ btn.onclick = () => send('view', { key: b.key });
+ holdToReset(btn);
+ lay.appendChild(btn);
+ }
+
+ $('awake').classList.toggle('on', !!state.keepAwake);
+ $('awake').querySelector('span').textContent = state.keepAwake ? L.awakeOn : L.awakeOff;
+ $('rearrange').hidden = !state.canRearrange;
}
+function holdToReset(btn) {
+ let timer = null, held = false;
+ btn.addEventListener('pointerdown', () => { held = false; timer = setTimeout(() => { held = true; send('resetWidth'); }, 700); });
+ ['pointerup', 'pointerleave', 'pointercancel'].forEach(e => btn.addEventListener(e, () => clearTimeout(timer)));
+ btn.addEventListener('click', e => { if (held) { e.stopImmediatePropagation(); held = false; } }, true);
+ btn.addEventListener('contextmenu', e => e.preventDefault());
+}
+
+const findApp = id => [...state.monitors.flatMap(m => m.panels.flatMap(p => p.apps)), ...state.free].find(a => a.id === id);
+
$('focusTile').onclick = () => {
if (moving === 'panel' && chosen) { send('tap', { id: chosen.id }); endMove(); return; } // mover al foco
if (state && state.focus) send('tap', { id: state.focus.id });
};
$('previous').onclick = () => send('previous');
$('toPanel').onclick = () => send('toPanel');
-$('freeAll').onclick = () => send('freeAll');
-$('move').onclick = () => { moving = moving ? null : 'app'; chosen = null; if (!moving) status(''); render(); };
+$('freeAll').onclick = () => {
+ if (Date.now() - freeAllArmed < 4000) { freeAllArmed = 0; send('freeAll'); render(); return; }
+ freeAllArmed = Date.now(); render(); setTimeout(render, 4100);
+};
+$('awake').onclick = () => send('keepAwake');
+$('mouse').onclick = () => send('mouseToFocus');
+$('rearrange').onclick = () => send('rearrange');
+$('minimize').onclick = () => { const on = !minimizing; clearModes(); minimizing = on; render(); };
+$('close').onclick = () => { const on = !closing; clearModes(); closing = on; render(); };
+$('fullMode').onclick = () => { const on = !fulling; clearModes(); fulling = on; render(); };
+$('move').onclick = () => { const on = !moving; clearModes(); moving = on ? 'app' : null; render(); };
+$('pin').onclick = () => { const on = !pinning; clearModes(); pinning = on; render(); };
// ⛶ entra y sale de pantalla completa; el icono dice qué hará.
const isFull = () => !!(document.fullscreenElement || document.webkitFullscreenElement);
$('full').onclick = () => {
@@ -95,12 +182,27 @@ function appButton(a) {
const away = ['Closed', 'InTray', 'OtherDesktop', 'Unmovable'].includes(a.state);
const mark = { InFocus: ' ↑', Parked: ' ⏸', Detached: ' ↗', OtherDesktop: ' ⧉', InTray: ' ▴', Unmovable: ' 🛡' }[a.state] || '';
b.className = 'app' + (away ? ' away' : '') + (a.state === 'InFocus' ? ' infocus' : '')
- + (state.foreground === a.id && a.state !== 'InFocus' && !moving ? ' inuse' : '')
+ + (state.foreground === a.id && a.state !== 'InFocus' && !anyMode() ? ' inuse' : '')
+ (a.tab === 'visible' ? ' tabvisible' : '')
- + (moving === 'app' && canMove(a) ? ' pick' : '') + (chosen && chosen.id === a.id ? ' chosen' : '');
+ + (moving === 'app' && canMove(a) ? ' pick' : '') + (chosen && chosen.id === a.id ? ' chosen' : '')
+ + (pinning ? (a.canPin ? ' pinnable' + (a.pinned ? ' pinnedOn' : '') : ' away') : '')
+ + (minimizing ? (canMinimize(a) ? ' minimizable' + (a.state === 'Parked' ? ' parked' : '') : ' away') : '')
+ + (closing ? (canMove(a) ? ' closable' : ' away') : '')
+ + (fulling ? (canMove(a) ? ' fullable' + (fullApp && fullApp.id === a.id ? ' chosen' : '') : ' away') : '');
b.innerHTML = `${a.pinned ? '