From c4d06ca99956ef22ab057575ade1f137b450c5da Mon Sep 17 00:00:00 2001 From: Hibryda Date: Wed, 25 Mar 2026 15:07:49 +0100 Subject: [PATCH] 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. --- ui-electrobun/src/mainview/App.svelte | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ui-electrobun/src/mainview/App.svelte b/ui-electrobun/src/mainview/App.svelte index 9885ac2..31dcf8b 100644 --- a/ui-electrobun/src/mainview/App.svelte +++ b/ui-electrobun/src/mainview/App.svelte @@ -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() {