diff --git a/ui-electrobun/src/bun/gtk-resize.ts b/ui-electrobun/src/bun/gtk-resize.ts index 581aee7..b5c26d9 100644 --- a/ui-electrobun/src/bun/gtk-resize.ts +++ b/ui-electrobun/src/bun/gtk-resize.ts @@ -109,9 +109,24 @@ export function installNativeResize(windowPtr: number | bigint) { { args: [FFIType.ptr, FFIType.ptr, FFIType.ptr], returns: FFIType.i32 }, ); + // Connect on BOTH the GtkWindow AND its child (WebView). + // GTK delivers events to the topmost child GdkWindow — the WebView covers 100%. + // The GtkWindow signal alone won't fire because events go to the WebView child. const sigBP = Buffer.from("button-press-event\0"); lib.symbols.g_signal_connect_data(windowPtr as any, ptr(sigBP) as any, buttonCb.ptr as any, null, null, 0); - // Motion signal NOT connected — cursor feedback via CSS handles instead + // Also connect on the deepest child (the WebView) + let child = windowPtr as any; + for (let i = 0; i < 5; i++) { + try { + const c = lib.symbols.gtk_bin_get_child(child); + if (!c) break; + child = c; + } catch { break; } + } + if (child !== windowPtr) { + lib.symbols.g_signal_connect_data(child, ptr(sigBP) as any, buttonCb.ptr as any, null, null, 0); + console.log("[gtk-resize] Also connected button-press on child widget"); + } console.log("[gtk-resize] Native resize handlers installed (border=" + BORDER + "px)"); }