diff --git a/.gitignore b/.gitignore index 73afda2..acd68a7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ frontend/dist/ build/bin/verstak-desktop smoke-platform plugins/ +vendor/ diff --git a/patches/window.c.button-press.patch b/patches/window.c.button-press.patch new file mode 100644 index 0000000..bf55ff8 --- /dev/null +++ b/patches/window.c.button-press.patch @@ -0,0 +1,27 @@ +--- vendor/github.com/wailsapp/wails/v2/internal/frontend/desktop/linux/window.c ++++ vendor/github.com/wailsapp/wails/v2/internal/frontend/desktop/linux/window.c +@@ -329,6 +329,24 @@ + if (event->button == 3) + { + return FALSE; ++ } ++ ++ // Handle mouse back/forward buttons (GDK button 8 = Back, button 9 = Forward) ++ // WebKitGTK doesn't propagate these correctly to DOM, so we dispatch custom events ++ // that the frontend can listen to for history navigation. ++ if (event->button == 8) ++ { ++ webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(widget), ++ "window.dispatchEvent(new CustomEvent('verstak:navigate-back'));", ++ NULL, NULL, NULL); ++ return TRUE; ++ } ++ if (event->button == 9) ++ { ++ webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(widget), ++ "window.dispatchEvent(new CustomEvent('verstak:navigate-forward'));", ++ NULL, NULL, NULL); ++ return TRUE; + } + + if (event->type == GDK_BUTTON_PRESS && event->button == 1) diff --git a/scripts/build.sh b/scripts/build.sh index bcebdd8..715e410 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -64,6 +64,25 @@ echo " ๐Ÿงช go test..." (cd "$ROOT" && go test -count=1 ./...) echo " โœ… go test" +# โ”€โ”€ Mouse button patch โ”€โ”€ +# WebKitGTK does not propagate buttons 8/9 (XButton1/XButton2) into DOM events. +# We patch Wails' window.c on Linux to intercept these GTK signals and dispatch +# CustomEvent('verstak:navigate-back'/'verstak:navigate-forward') into the page. +echo "" +echo "[mouse-buttons]" +PATCH_FILE="$ROOT/patches/window.c.button-press.patch" +if [ -f "$PATCH_FILE" ]; then + echo " ๐Ÿ“ฆ go mod vendor..." + (cd "$ROOT" && go mod vendor) + echo " โœ… go mod vendor" + echo " ๐Ÿ“ applying window.c.button-press.patch..." + (cd "$ROOT" && patch -p0 --forward < "$PATCH_FILE" 2>/dev/null || true) + rm -f "$ROOT/vendor/github.com/wailsapp/wails/v2/internal/frontend/desktop/linux/window.c.rej" + echo " โœ… window.c patched" +else + echo " โ„น๏ธ patch file not found at $PATCH_FILE โ€” skipping" +fi + # โ”€โ”€ Wails โ”€โ”€ echo "" echo "[wails]"