All your computers and your phone/iPhone, working as one desk. Screens, apps, files, clipboard, calls, texts, notifications, mouse and keyboard, shared between Mac, Windows, Linux , Android, Web and ios / ipados . Free and open source. No account, no cloud, and no shared network needed.
JavaScript androidapple-ecosystemconnectelectronfile-sharingintel-unison-alternativeiosios-windowskde-connect-alternativekvmlinuxmacbookmacosmouse-sharingphone-link-alternativeproductivityscreen-sharingsidecar-alternativesynergy-alternativewindows
// TwinDesk — Copyright (C) 2026 inukaasith. GPL-3.0, see LICENSE.
// #376: a small device takes the whole edge of the big monitor it alone touches; the crossing is
// scaled along both sides, both ways. Off (the default): only where they meet, 1:1, as before.
'use strict';
const assert = require('assert');
const W = require('../layout-world.js');
const L = require('../layout.js');
const world = { A: { x: 0, y: 0 }, B: { x: 760, y: 1080 } };
const displays = { A: [{ id: '1', x: 0, y: 0, w: 1920, h: 1080 }], B: [{ id: 'screen', x: 0, y: 0, w: 400, h: 800 }] };
const ids = ['A', 'B'];
const phone = (id) => id === 'B';
const near = (a, b) => Math.abs(a - b) < 0.01;
// Off: the bottom of A leads to B only over B, and A's left end can't reach B's left end.
let st = W.stretches(world, displays, ids, 'A', () => true, phone, true).bottom;
assert.strictEqual(st.length, 1);
assert.deepStrictEqual([st[0].from, st[0].to], [760, 1160]);
assert.ok(near(W.cross(world, displays, ids, 'A', 'bottom', 0.5, () => true, phone, true).offset, 0.5));
assert.ok(near(W.cross(world, displays, ids, 'B', 'top', 0, () => true, phone, true).offset, 760.5 / 1920));
// On for B: all of A's bottom leads to B, scaled; and back from B's top onto all of A's bottom.
const opts = { skip: true, whole: new Set(['B']) };
st = W.stretches(world, displays, ids, 'A', () => true, phone, opts).bottom;
assert.deepStrictEqual([st[0].from, st[0].to], [0, 1920]);
assert.ok(near(W.cross(world, displays, ids, 'A', 'bottom', 0, () => true, phone, opts).offset, 0));
assert.ok(near(W.cross(world, displays, ids, 'A', 'bottom', 0.25, () => true, phone, opts).offset, 0.25));
assert.ok(near(W.cross(world, displays, ids, 'A', 'bottom', 1, () => true, phone, opts).offset, 1));
assert.ok(near(W.cross(world, displays, ids, 'B', 'top', 0, () => true, phone, opts).offset, 0));
assert.ok(near(W.cross(world, displays, ids, 'B', 'top', 0.75, () => true, phone, opts).offset, 0.75));
assert.ok(near(W.cross(world, displays, ids, 'B', 'top', 1, () => true, phone, opts).offset, 1));
// The way back lands where it was sent (inside the whole stretch: unchanged)
assert.strictEqual(W.land(world, displays, ids, 'A', 'bottom', 0.1, 'B', () => true, phone, opts), 0.1);
// The helpers' zones: the whole bottom
assert.ok(W.zonesText(world, displays, 'A', W.stretches(world, displays, ids, 'A', () => true, phone, opts), phone).includes('bottom:0.0000-1.0000'));
// A second device on the same edge: no whole edge for that monitor (it would hide the other).
const world3 = { ...world, C: { x: 1300, y: 1080 } };
const displays3 = { ...displays, C: [{ id: 'screen', x: 0, y: 0, w: 400, h: 800 }] };
st = W.stretches(world3, displays3, ['A', 'B', 'C'], 'A', () => true, (id) => id !== 'A', opts).bottom;
assert.strictEqual(st.length, 2);
assert.ok(st.every((x) => !x.whole));
// In the layout: kept, synced, dropped with the device; setWhole is an edit (rev + 1).
let l = L.normalize({ rev: 1, by: 'A', cells: { A: { x: 0, y: 0 }, B: { x: 0, y: 1 } } });
let r = L.setWhole(l, 'B', true, 'A');
assert.ok(r.ok);
assert.deepStrictEqual(r.layout.whole, ['B']);
assert.strictEqual(r.layout.rev, 2);
assert.deepStrictEqual(L.normalize(r.layout).whole, ['B']);
assert.ok(L.canonical(r.layout).endsWith('|whole:B'));
assert.ok(!L.setWhole(r.layout, 'B', true, 'A').ok, 'already on');
assert.ok(!L.setWhole(r.layout, 'Z', true, 'A').ok, 'not in the layout');
assert.deepStrictEqual(L.view(r.layout, ['A', 'B']).whole, ['B']);
assert.strictEqual(L.normalize({ ...r.layout, whole: ['B', 7, 'nope'] }).whole.join(), 'B');
r = L.setWhole(r.layout, 'B', false, 'A');
assert.ok(r.ok && !r.layout.whole);
console.log('layout-whole: ok');