window_customizer.rs 967 B

12345678910111213141516171819202122232425262728293031323334
  1. use tauri::{plugin::Plugin, Manager, Runtime, Window};
  2. pub struct PinchZoomDisablePlugin;
  3. impl Default for PinchZoomDisablePlugin {
  4. fn default() -> Self {
  5. Self
  6. }
  7. }
  8. impl<R: Runtime> Plugin<R> for PinchZoomDisablePlugin {
  9. fn name(&self) -> &'static str {
  10. "Does not matter here"
  11. }
  12. fn window_created(&mut self, window: Window<R>) {
  13. let Some(webview_window) = window.get_webview_window(window.label()) else {
  14. return;
  15. };
  16. let _ = webview_window.with_webview(|_webview| {
  17. #[cfg(target_os = "linux")]
  18. unsafe {
  19. use gtk::glib::ObjectExt;
  20. use gtk::GestureZoom;
  21. use webkit2gtk::glib::gobject_ffi;
  22. if let Some(data) = _webview.inner().data::<GestureZoom>("wk-view-zoom-gesture") {
  23. gobject_ffi::g_signal_handlers_destroy(data.as_ptr().cast());
  24. }
  25. }
  26. });
  27. }
  28. }