Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: use native WebView zoom to fix ChatGPT layout breaking on zoom
Tw9351c7b5d581d5
diff --git a/src-tauri/src/app/invoke.rs b/src-tauri/src/app/invoke.rsindex e928f300..667f2515 100644--- a/src-tauri/src/app/invoke.rs+++ b/src-tauri/src/app/invoke.rs@@ -191,3 +191,15 @@ pub async fn update_theme_mode(app: AppHandle, mode: String) {let _ = window.set_theme(Some(theme));}}++// Apply native WebView zoom (WKWebView pageZoom / WebView2 ZoomFactor / WebKitGTK+// zoom level) instead of CSS hacks. CSS `transform: scale` and `html.style.zoom`+// break complex SPAs like ChatGPT (fixed positioning shifts, unrepainted layers);+// native zoom recalculates layout the same way a browser does for Cmd/Ctrl +/-.+#[command]+pub fn set_zoom(window: WebviewWindow, percent: f64) -> Result<(), String> {+ let factor = (percent / 100.0).clamp(0.3, 2.0);+ window+ .set_zoom(factor)+ .map_err(|e| format!("Failed to set zoom: {}", e))+}diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.jsindex 40ea29ae..c00962f8 100644--- a/src-tauri/src/inject/event.js+++ b/src-tauri/src/inject/event.js@@ -11,19 +11,13 @@ const shortcuts = {};function setZoom(zoom) {- const html = document.getElementsByTagName("html")[0];- const body = document.body;- const zoomValue = parseFloat(zoom) / 100;- const isWindows = /windows/i.test(navigator.userAgent);-- if (isWindows) {- body.style.transform = `scale(${zoomValue})`;- body.style.transformOrigin = "top left";- body.style.width = `${100 / zoomValue}%`;- body.style.height = `${100 / zoomValue}%`;- } else {- html.style.zoom = zoom;- window.dispatchEvent(new Event("resize"));+ // Use native WebView zoom (WKWebView pageZoom / WebView2 ZoomFactor) instead of+ // CSS hacks. `transform: scale` and `html.style.zoom` break complex SPAs like+ // ChatGPT: the page shifts right on Windows and parts of the UI stop repainting+ // on macOS. Native zoom recalculates layout exactly like a browser does.+ const invoke = window.__TAURI__?.core?.invoke;+ if (invoke) {+ invoke("set_zoom", { percent: parseFloat(zoom) }).catch(() => {});}window.localStorage.setItem("htmlZoom", zoom);diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 77f64e84..d3ed1060 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -22,7 +22,7 @@ const GDK_BACKEND: &str = "GDK_BACKEND";use app::{invoke::{clear_dock_badge, download_file, increment_dock_badge, send_notification, set_dock_badge,- set_dock_badge_label, update_theme_mode,+ set_dock_badge_label, set_zoom, update_theme_mode,},setup::{set_global_shortcut, set_system_tray},window::{open_additional_window_safe, set_window, MultiWindowState},@@ -194,6 +194,7 @@ pub fn run_app() {set_dock_badge_label,clear_dock_badge,update_theme_mode,+ set_zoom,]).setup(move |app| {app.manage(MultiWindowState::new(