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