diff options
| author | Brendan Allan <[email protected]> | 2025-12-18 19:13:09 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-18 05:13:09 -0600 |
| commit | 0da901a18845adef20bca5011e0c001387c415d5 (patch) | |
| tree | 25013ee618ac4e17e06dd77d9a15aa38e97212f2 /packages/tauri/src-tauri/src | |
| parent | 17221e6ffe6bd389522a7d705b1b9aa5bb7edec9 (diff) | |
| download | opencode-0da901a18845adef20bca5011e0c001387c415d5.tar.gz opencode-0da901a18845adef20bca5011e0c001387c415d5.zip | |
tauri: disable pinch zoom on linux (#5735)
Diffstat (limited to 'packages/tauri/src-tauri/src')
| -rw-r--r-- | packages/tauri/src-tauri/src/lib.rs | 9 | ||||
| -rw-r--r-- | packages/tauri/src-tauri/src/window_customizer.rs | 34 |
2 files changed, 40 insertions, 3 deletions
diff --git a/packages/tauri/src-tauri/src/lib.rs b/packages/tauri/src-tauri/src/lib.rs index e9d9ed44c..1bf1427a2 100644 --- a/packages/tauri/src-tauri/src/lib.rs +++ b/packages/tauri/src-tauri/src/lib.rs @@ -1,11 +1,11 @@ +mod window_customizer; + use std::{ collections::VecDeque, net::{SocketAddr, TcpListener}, sync::{Arc, Mutex}, time::{Duration, Instant}, }; -#[cfg(target_os = "macos")] -use tauri::TitleBarStyle; use tauri::{AppHandle, LogicalSize, Manager, RunEvent, WebviewUrl, WebviewWindow}; use tauri_plugin_clipboard_manager::ClipboardExt; use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogResult}; @@ -13,6 +13,8 @@ use tauri_plugin_shell::process::{CommandChild, CommandEvent}; use tauri_plugin_shell::ShellExt; use tokio::net::TcpSocket; +use crate::window_customizer::PinchZoomDisablePlugin; + #[derive(Clone)] struct ServerState(Arc<Mutex<Option<CommandChild>>>); @@ -188,6 +190,7 @@ pub fn run() { .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_clipboard_manager::init()) + .plugin(PinchZoomDisablePlugin) .invoke_handler(tauri::generate_handler![ kill_sidecar, copy_logs_to_clipboard, @@ -268,7 +271,7 @@ pub fn run() { #[cfg(target_os = "macos")] { window_builder = window_builder - .title_bar_style(TitleBarStyle::Overlay) + .title_bar_style(tauri::TitleBarStyle::Overlay) .hidden_title(true); } diff --git a/packages/tauri/src-tauri/src/window_customizer.rs b/packages/tauri/src-tauri/src/window_customizer.rs new file mode 100644 index 000000000..cd42fd029 --- /dev/null +++ b/packages/tauri/src-tauri/src/window_customizer.rs @@ -0,0 +1,34 @@ +use tauri::{plugin::Plugin, Manager, Runtime, Window}; + +pub struct PinchZoomDisablePlugin; + +impl Default for PinchZoomDisablePlugin { + fn default() -> Self { + Self + } +} + +impl<R: Runtime> Plugin<R> for PinchZoomDisablePlugin { + fn name(&self) -> &'static str { + "Does not matter here" + } + + fn window_created(&mut self, window: Window<R>) { + let Some(webview_window) = window.get_webview_window(window.label()) else { + return; + }; + + let _ = webview_window.with_webview(|_webview| { + #[cfg(target_os = "linux")] + unsafe { + use gtk::glib::ObjectExt; + use gtk::GestureZoom; + use webkit2gtk::glib::gobject_ffi; + + if let Some(data) = _webview.inner().data::<GestureZoom>("wk-view-zoom-gesture") { + gobject_ffi::g_signal_handlers_destroy(data.as_ptr().cast()); + } + } + }); + } +} |
