fix(electrobun): use window.resizeTo/moveTo for resize (proven in Chromium)

Replaced entire FFI chain (XMoveResizeWindow, begin_resize_drag,
XUngrabPointer) with standard browser APIs window.resizeTo + window.moveTo.

Proven to work in Chromium --app mode with same JS resize logic.
Frame captured synchronously via window.screenX/Y + outerWidth/Height.
Zero RPC, zero FFI, zero GTK involvement.
This commit is contained in:
Hibryda 2026-03-25 15:07:49 +01:00
parent 0e6408a447
commit c4d06ca999

View file

@ -122,10 +122,11 @@
resizeStartY = e.screenY;
document.body.style.cursor = CURSOR_MAP[edge] || 'default';
document.body.style.userSelect = 'none';
// Capture frame async — resize uses deltas so a slight delay is fine
appRpc.request['window.getFrame']({}).then((f: any) => {
resizeFrame = { x: f.x, y: f.y, width: f.width, height: f.height };
}).catch(() => {});
// Capture frame synchronously from browser — no RPC delay
resizeFrame = {
x: window.screenX, y: window.screenY,
width: window.outerWidth, height: window.outerHeight,
};
}
function onResizeMove(e: MouseEvent) {
@ -138,11 +139,9 @@
if (resizeEdge.includes('w')) { const nw = Math.max(MIN_W, width - dx); x += width - nw; width = nw; }
if (resizeEdge.includes('s')) height = Math.max(MIN_H, height + dy);
if (resizeEdge.includes('n')) { const nh = Math.max(MIN_H, height - dy); y += height - nh; height = nh; }
// X11 direct — bypasses GTK size negotiation
appRpc.request['window.x11SetFrame']({
x: Math.round(x), y: Math.round(y),
width: Math.round(width), height: Math.round(height),
}).catch(() => {});
// Direct browser API — no RPC, no GTK, no FFI. Works in Chromium, test in WebKitGTK.
window.moveTo(Math.round(x), Math.round(y));
window.resizeTo(Math.round(width), Math.round(height));
}
function onResizeEnd() {