Add doc comments
This commit is contained in:
@@ -18,12 +18,19 @@ the cursor position.
|
|||||||
```toml
|
```toml
|
||||||
# src-tauri/Cargo.toml
|
# src-tauri/Cargo.toml
|
||||||
|
|
||||||
``[target."cfg(target_os = \"linux\")".dependencies]
|
[target."cfg(target_os = \"linux\")".dependencies]
|
||||||
gtk = "0.18.2"
|
gtk = "0.18.2"
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```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) {
|
fn setup_linux_pinch(window: &tauri::WebviewWindow) {
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::{EventSequenceState, PropagationPhase};
|
use gtk::{EventSequenceState, PropagationPhase};
|
||||||
@@ -80,6 +87,12 @@ fail to initialize.
|
|||||||
```ts
|
```ts
|
||||||
// src/tauriPinchAdapter.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() {
|
export async function setupTauriPinchAdapter() {
|
||||||
// Bail out if not running inside Tauri
|
// Bail out if not running inside Tauri
|
||||||
if (typeof window === 'undefined' || !('__TAURI_INTERNALS__' in window)) {
|
if (typeof window === 'undefined' || !('__TAURI_INTERNALS__' in window)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user