fix(electrobun): connect button-press on WebView child too (events go to deepest child)

This commit is contained in:
Hibryda 2026-03-25 16:13:37 +01:00
parent e563da2b3b
commit 74ec191ce9

View file

@ -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)");
}