fix(electrobun): enable window resize via recursive GTK min-size override

Root cause: WebKitWebView requests min_size = content_size (5120x1387 on
ultrawide), which GTK propagates to WM_NORMAL_HINTS, blocking all resize.

Fix: recursively walk the GTK widget tree (GtkWindow → GtkBin → WebView)
and call gtk_widget_set_size_request(-1, -1) on every widget. Then set
gtk_window_set_geometry_hints with min=400x300.

Result: WM_NORMAL_HINTS now shows min=10x10, window is fully resizable.
This commit is contained in:
Hibryda 2026-03-25 12:53:24 +01:00
parent 9da9d96ebd
commit d84feb6c67
3 changed files with 134 additions and 10 deletions

View file

@ -114,7 +114,9 @@ const rpc = BrowserView.defineRPC<PtyRPCSchema>({
const { beginResizeDrag, edgeStringToGdk } = require("./gtk-window.ts");
const gdkEdge = edgeStringToGdk(edge);
if (gdkEdge === null) return { ok: false, error: `Unknown edge: ${edge}` };
console.log(`[resize] edge=${edge} gdkEdge=${gdkEdge} btn=${button} rootX=${rootX} rootY=${rootY} ptr=${(mainWindow as any).ptr}`);
const ok = beginResizeDrag((mainWindow as any).ptr, gdkEdge, button, rootX, rootY);
console.log(`[resize] result: ${ok}`);
return { ok };
} catch (err) { console.error("[window.beginResize]", err); return { ok: false }; }
},
@ -219,6 +221,12 @@ mainWindow = new BrowserWindow({
},
});
// Ensure GTK window is resizable (titleBarStyle:"hidden" may clear the flag)
{
const { ensureResizable } = require("./gtk-window.ts");
ensureResizable((mainWindow as any).ptr);
}
// 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,
// which Electrobun interprets as a Cmd+click → "open in new window" → closes the main window.