From 250cc46c61433ef76754761fe7114d41fddbc0f8 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Wed, 13 May 2026 14:32:07 +0200 Subject: [PATCH] Add doc comments --- rust/tauri-pinch-zoom.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rust/tauri-pinch-zoom.md b/rust/tauri-pinch-zoom.md index 1b065c4..cec4557 100644 --- a/rust/tauri-pinch-zoom.md +++ b/rust/tauri-pinch-zoom.md @@ -18,12 +18,19 @@ the cursor position. ```toml # src-tauri/Cargo.toml -``[target."cfg(target_os = \"linux\")".dependencies] +[target."cfg(target_os = \"linux\")".dependencies] gtk = "0.18.2" ``` ```rust -``#[cfg(target_os = "linux")] +// src-tauri/src/lib.rs + +/// On Linux, Tauri's WebKitGTK webview intercepts trackpad pinch as page zoom +/// before JS sees it. This attaches a GTK gesture controller that captures the +/// pinch in the `Capture` phase and claims it (preventing WebKit from also +/// handling it), then emits Tauri events that the frontend re-dispatches as +/// synthetic Ctrl+wheel events. +#[cfg(target_os = "linux")] fn setup_linux_pinch(window: &tauri::WebviewWindow) { use gtk::prelude::*; use gtk::{EventSequenceState, PropagationPhase}; @@ -80,6 +87,12 @@ fail to initialize. ```ts // src/tauriPinchAdapter.ts +/** + * On Linux, Tauri's WebKitGTK webview intercepts trackpad pinch as page zoom + * before JS sees it. The Rust side captures the gesture and emits Tauri events; + * this adapter re-dispatches them as synthetic Ctrl+wheel events so frontend + * code can handle pinch the same way browsers natively report it. + */ export async function setupTauriPinchAdapter() { // Bail out if not running inside Tauri if (typeof window === 'undefined' || !('__TAURI_INTERNALS__' in window)) {