How to disable the enlarge when I make a magnified gesture on the touchpad #3843
-
On Windows |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
For reference, this is the function to disable it: https://docs.rs/webview2-com/latest/webview2_com/Microsoft/Web/WebView2/Win32/struct.ICoreWebView2Settings5.html#method.SetIsPinchZoomEnabled Users should be able to use that themselves once/if we expose https://docs.rs/wry/latest/x86_64-pc-windows-msvc/wry/webview/struct.WebView.html#method.controller in tauri. But i feel like we should match this setting with the default zoom functionality (which is currently always disabled.). |
Beta Was this translation helpful? Give feedback.
-
There is an environment variable that can be used: There is the same problem with WebkitGtk on Linux, and the only way I found to disable it is highly unsafe: /// A Tauri plugin that customizes some WebKitGTK behavior.
pub struct WindowCustomizerPlugin;
impl Default for WindowCustomizerPlugin {
fn default() -> Self {
Self
}
}
impl<R: Runtime> Plugin<R> for WindowCustomizerPlugin {
fn name(&self) -> &'static str {
"Zoom disabler plugin"
}
fn created(&mut self, window: Window<R>) {
let gtk_window = window.gtk_window().expect("GTK window should be accessible");
// Retrieve the web view.
let web_view = gtk_window
.children()
.into_iter()
.next()
.expect("GTK window should have a child")
.downcast::<gtk::Box>()
.expect("GTK window child should be a box")
.children()
.into_iter()
.filter_map(|w| w.downcast::<WebView>().ok())
.next()
.expect("box should have a webview child");
// This piece of code is responsible for preventing the context-menu (right-click menu) from being shown.
web_view.connect_context_menu(|_, _, _, _| true);
unsafe {
// Disable the gesture zoom by removing its handlers.
if let Some(data) = web_view.data::<GestureZoom>("wk-view-zoom-gesture") {
gobject_ffi::g_signal_handlers_destroy(data.as_ptr().cast());
}
// Disable some gestures by freeing their controllers.
// This won't work with GTK 4, we would use the controller API for this.
web_view.set_data("wk-view-long-press-gesture", ());
web_view.set_data("wk-view-swipe-gesture", ());
}
}
} Shouldn't we open an issue for this @FabianLars ? |
Beta Was this translation helpful? Give feedback.
-
Any updates on this issue @Jethril @FabianLars |
Beta Was this translation helpful? Give feedback.
-
How can we disable this on Linux? The JavaScript side cannot do this, so there must be a way in the webview (maybe webview args) to do this. The two fingure zoom always enlarges the view no matter what: compressO-2024-05-15.16-12-29.mp4 |
Beta Was this translation helpful? Give feedback.
For reference, this is the function to disable it: https://docs.rs/webview2-com/latest/webview2_com/Microsoft/Web/WebView2/Win32/struct.ICoreWebView2Settings5.html#method.SetIsPinchZoomEnabled
Users should be able to use that themselves once/if we expose https://docs.rs/wry/latest/x86_64-pc-windows-msvc/wry/webview/struct.WebView.html#method.controller in tauri.
But i feel like we should match this setting with the default zoom functionality (which is currently always disabled.).