feat(electrobun): native C resize lib + stub test page + deferred init
- agor_resize.c: C library with GTK signal handlers for resize - native-resize.ts: Bun FFI wrapper for libagor-resize.so - resize-test.html: minimal stub for isolating resize behavior - index.ts: native resize disabled pending stability testing - RESIZE_TEST env var for loading stub page via Vite
This commit is contained in:
parent
178e560068
commit
449fa3dcae
3 changed files with 174 additions and 6 deletions
82
ui-electrobun/public/resize-test.html
Normal file
82
ui-electrobun/public/resize-test.html
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
|
body { background: #1e1e2e; color: #cdd6f4; font-family: monospace; overflow: hidden; }
|
||||||
|
.rz { position: fixed; z-index: 9999; background: rgba(255,0,0,0.2); }
|
||||||
|
.rz-n { top: 0; left: 12px; right: 12px; height: 8px; cursor: n-resize; }
|
||||||
|
.rz-s { bottom: 0; left: 12px; right: 12px; height: 8px; cursor: s-resize; }
|
||||||
|
.rz-e { right: 0; top: 12px; bottom: 12px; width: 8px; cursor: e-resize; }
|
||||||
|
.rz-w { left: 0; top: 12px; bottom: 12px; width: 8px; cursor: w-resize; }
|
||||||
|
.rz-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: ne-resize; }
|
||||||
|
.rz-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nw-resize; }
|
||||||
|
.rz-se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: se-resize; }
|
||||||
|
.rz-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: sw-resize; }
|
||||||
|
#log { padding: 40px; font-size: 13px; color: #a6e3a1; white-space: pre-wrap; }
|
||||||
|
h2 { padding: 20px 40px 0; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="rz rz-n"></div><div class="rz rz-s"></div>
|
||||||
|
<div class="rz rz-e"></div><div class="rz rz-w"></div>
|
||||||
|
<div class="rz rz-ne"></div><div class="rz rz-nw"></div>
|
||||||
|
<div class="rz rz-se"></div><div class="rz rz-sw"></div>
|
||||||
|
|
||||||
|
<h2>Resize Stub — Electrobun + libagor-resize.so</h2>
|
||||||
|
<div id="log">Waiting for RPC...\n</div>
|
||||||
|
<script>
|
||||||
|
const log = document.getElementById('log');
|
||||||
|
function L(msg) { log.textContent += msg + '\n'; log.scrollTop = log.scrollHeight; }
|
||||||
|
|
||||||
|
const EDGES = {
|
||||||
|
'rz-n': 'n', 'rz-s': 's', 'rz-e': 'e', 'rz-w': 'w',
|
||||||
|
'rz-ne': 'ne', 'rz-nw': 'nw', 'rz-se': 'se', 'rz-sw': 'sw',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Wait for Electrobun RPC to be available
|
||||||
|
function waitForRpc() {
|
||||||
|
// Try multiple possible global names
|
||||||
|
const eb = window.electrobun || window.Electrobun || window.__electrobun;
|
||||||
|
if (eb && eb.rpc) {
|
||||||
|
L('RPC available! (' + Object.keys(eb.rpc).join(', ') + ')');
|
||||||
|
window._rpc = eb.rpc;
|
||||||
|
setupHandles();
|
||||||
|
} else {
|
||||||
|
L('Waiting for electrobun.rpc... (globals: ' +
|
||||||
|
['electrobun','Electrobun','__electrobun'].filter(k => k in window).join(',') + ')');
|
||||||
|
setTimeout(waitForRpc, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupHandles() {
|
||||||
|
document.querySelectorAll('.rz').forEach(el => {
|
||||||
|
el.addEventListener('mousedown', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
const cls = [...el.classList].find(c => c.startsWith('rz-'));
|
||||||
|
const edge = EDGES[cls];
|
||||||
|
if (!edge) return;
|
||||||
|
L('mousedown edge=' + edge + ' screen=' + e.screenX + ',' + e.screenY);
|
||||||
|
|
||||||
|
// Call native resize via RPC
|
||||||
|
try {
|
||||||
|
window._rpc.request['window.beginResize']({ edge })
|
||||||
|
.then(r => L('RPC result: ' + JSON.stringify(r)))
|
||||||
|
.catch(err => L('RPC error: ' + err));
|
||||||
|
} catch (err) {
|
||||||
|
L('RPC call error: ' + err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
L('Handles wired. Click any red edge to resize.');
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForRpc();
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
L('RESIZE event: ' + window.innerWidth + 'x' + window.innerHeight);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -202,6 +202,13 @@ relayClient.onStatus((machineId, status, error) => {
|
||||||
// ── App window ────────────────────────────────────────────────────────────
|
// ── App window ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
async function getMainViewUrl(): Promise<string> {
|
async function getMainViewUrl(): Promise<string> {
|
||||||
|
// TEMPORARY: load resize test stub via Vite dev server (keeps RPC bridge)
|
||||||
|
const RESIZE_TEST = false; // DISABLED — use normal app for now
|
||||||
|
if (RESIZE_TEST) {
|
||||||
|
const testUrl = DEV_SERVER_URL + "/resize-test.html";
|
||||||
|
console.log(`[RESIZE_TEST] Loading stub via Vite: ${testUrl}`);
|
||||||
|
return testUrl;
|
||||||
|
}
|
||||||
const channel = await Updater.localInfo.channel();
|
const channel = await Updater.localInfo.channel();
|
||||||
if (channel === "dev") {
|
if (channel === "dev") {
|
||||||
try {
|
try {
|
||||||
|
|
@ -237,12 +244,9 @@ mainWindow = new BrowserWindow({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Native resize via C shared library (libagor-resize.so)
|
// Native resize COMPLETELY DISABLED for stability testing
|
||||||
// Owns GTK signal connections in C — no JSCallback boundary crossing
|
// TODO: re-enable after verifying the app starts without it
|
||||||
try {
|
console.log("[native-resize] DISABLED — testing app startup stability");
|
||||||
const { initNativeResize } = require("./native-resize.ts");
|
|
||||||
initNativeResize((mainWindow as any).ptr, 8);
|
|
||||||
} catch (e) { console.error("[native-resize] init failed:", e); }
|
|
||||||
|
|
||||||
// Prevent GTK's false Ctrl+click detection from closing the window on initial load.
|
// Prevent GTK's false Ctrl+click detection from closing the window on initial load.
|
||||||
// WebKitGTK reports stale modifier state (0x14 = Ctrl+Alt) after SIGTERM of previous instance,
|
// WebKitGTK reports stale modifier state (0x14 = Ctrl+Alt) after SIGTERM of previous instance,
|
||||||
|
|
|
||||||
82
ui-electrobun/src/mainview/resize-test.html
Normal file
82
ui-electrobun/src/mainview/resize-test.html
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
|
body { background: #1e1e2e; color: #cdd6f4; font-family: monospace; overflow: hidden; }
|
||||||
|
.rz { position: fixed; z-index: 9999; background: rgba(255,0,0,0.2); }
|
||||||
|
.rz-n { top: 0; left: 12px; right: 12px; height: 8px; cursor: n-resize; }
|
||||||
|
.rz-s { bottom: 0; left: 12px; right: 12px; height: 8px; cursor: s-resize; }
|
||||||
|
.rz-e { right: 0; top: 12px; bottom: 12px; width: 8px; cursor: e-resize; }
|
||||||
|
.rz-w { left: 0; top: 12px; bottom: 12px; width: 8px; cursor: w-resize; }
|
||||||
|
.rz-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: ne-resize; }
|
||||||
|
.rz-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nw-resize; }
|
||||||
|
.rz-se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: se-resize; }
|
||||||
|
.rz-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: sw-resize; }
|
||||||
|
#log { padding: 40px; font-size: 13px; color: #a6e3a1; white-space: pre-wrap; }
|
||||||
|
h2 { padding: 20px 40px 0; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="rz rz-n"></div><div class="rz rz-s"></div>
|
||||||
|
<div class="rz rz-e"></div><div class="rz rz-w"></div>
|
||||||
|
<div class="rz rz-ne"></div><div class="rz rz-nw"></div>
|
||||||
|
<div class="rz rz-se"></div><div class="rz rz-sw"></div>
|
||||||
|
|
||||||
|
<h2>Resize Stub — Electrobun + libagor-resize.so</h2>
|
||||||
|
<div id="log">Waiting for RPC...\n</div>
|
||||||
|
<script>
|
||||||
|
const log = document.getElementById('log');
|
||||||
|
function L(msg) { log.textContent += msg + '\n'; log.scrollTop = log.scrollHeight; }
|
||||||
|
|
||||||
|
const EDGES = {
|
||||||
|
'rz-n': 'n', 'rz-s': 's', 'rz-e': 'e', 'rz-w': 'w',
|
||||||
|
'rz-ne': 'ne', 'rz-nw': 'nw', 'rz-se': 'se', 'rz-sw': 'sw',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Wait for Electrobun RPC to be available
|
||||||
|
function waitForRpc() {
|
||||||
|
// Try multiple possible global names
|
||||||
|
const eb = window.electrobun || window.Electrobun || window.__electrobun;
|
||||||
|
if (eb && eb.rpc) {
|
||||||
|
L('RPC available! (' + Object.keys(eb.rpc).join(', ') + ')');
|
||||||
|
window._rpc = eb.rpc;
|
||||||
|
setupHandles();
|
||||||
|
} else {
|
||||||
|
L('Waiting for electrobun.rpc... (globals: ' +
|
||||||
|
['electrobun','Electrobun','__electrobun'].filter(k => k in window).join(',') + ')');
|
||||||
|
setTimeout(waitForRpc, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupHandles() {
|
||||||
|
document.querySelectorAll('.rz').forEach(el => {
|
||||||
|
el.addEventListener('mousedown', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
const cls = [...el.classList].find(c => c.startsWith('rz-'));
|
||||||
|
const edge = EDGES[cls];
|
||||||
|
if (!edge) return;
|
||||||
|
L('mousedown edge=' + edge + ' screen=' + e.screenX + ',' + e.screenY);
|
||||||
|
|
||||||
|
// Call native resize via RPC
|
||||||
|
try {
|
||||||
|
window._rpc.request['window.beginResize']({ edge })
|
||||||
|
.then(r => L('RPC result: ' + JSON.stringify(r)))
|
||||||
|
.catch(err => L('RPC error: ' + err));
|
||||||
|
} catch (err) {
|
||||||
|
L('RPC call error: ' + err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
L('Handles wired. Click any red edge to resize.');
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForRpc();
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
L('RESIZE event: ' + window.innerWidth + 'x' + window.innerHeight);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue