Skip to content

Commit 8570ad9

Browse files
committed
fix(terminal): limit DPR override to macOS Tauri only
The devicePixelRatio override breaks on Chrome-based Electron and Tauri on other platforms. Restrict it to macOS + Tauri where the native webview zoom does not update DPR.
1 parent 3cd71b0 commit 8570ad9

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/phoenix/shell.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -859,17 +859,21 @@ Phoenix.app = {
859859
if(scaleFactor < .1 || scaleFactor > 2) {
860860
throw new Error("zoomWebView scale factor should be between .1 and 2");
861861
}
862-
// Native webview zoom (Tauri/Electron) does not update
862+
// On macOS + Tauri, native webview zoom does not update
863863
// window.devicePixelRatio, causing canvas-based renderers
864864
// (e.g. xterm.js WebGL) to render at the wrong resolution.
865865
// Override the getter so it reflects the effective DPR.
866-
if(window._origDevicePixelRatio === undefined) {
867-
window._origDevicePixelRatio = window.devicePixelRatio;
866+
// Limited to macOS Tauri — Electron and other platforms
867+
// handle DPR correctly or conflict with this override.
868+
if(window.__TAURI__ && Phoenix.platform === "mac") {
869+
if(window._origDevicePixelRatio === undefined) {
870+
window._origDevicePixelRatio = window.devicePixelRatio;
871+
}
872+
Object.defineProperty(window, 'devicePixelRatio', {
873+
get() { return window._origDevicePixelRatio * scaleFactor; },
874+
configurable: true
875+
});
868876
}
869-
Object.defineProperty(window, 'devicePixelRatio', {
870-
get() { return window._origDevicePixelRatio * scaleFactor; },
871-
configurable: true
872-
});
873877
if(window.__TAURI__) {
874878
return window.__TAURI__.tauri.invoke("zoom_window", {scaleFactor: scaleFactor});
875879
}

0 commit comments

Comments
 (0)