Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(desktop): lock window zoom against Windows text scale
Richie McIlroybd84749d206c
diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rsindex f067d60f0..502bfef05 100644--- a/apps/desktop/src-tauri/src/windows.rs+++ b/apps/desktop/src-tauri/src/windows.rs@@ -883,13 +883,7 @@ impl CapWindowId {pub fn min_size(&self) -> Option<(f64, f64)> {Some(match self {- Self::Main => {- #[cfg(windows)]- let height = 430.0;- #[cfg(not(windows))]- let height = 395.0;- (330.0, height)- }+ Self::Main => (330.0, 395.0),Self::Editor { .. } => (1275.0, 800.0),Self::ScreenshotEditor { .. } => (800.0, 600.0),Self::Settings => (780.0, 560.0),@@ -1396,7 +1390,6 @@ impl ShowCapWindow {.content_protected(should_protect).transparent(true).visible(false)- .zoom_hotkeys_enabled(false).initialization_script(format!("window.__CAP__ = window.__CAP__ ?? {{}};@@ -1406,10 +1399,7 @@ impl ShowCapWindow {.expect("Failed to serialize initial target mode"))).build()?;-- if let Err(e) = window.set_zoom(1.0) {- warn!("Failed to lock Main window zoom to 1.0: {}", e);- }+ lock_window_text_scale(&window);let saved_position = GeneralSettingsStore::get(app).ok()@@ -1420,11 +1410,7 @@ impl ShowCapWindow {let (pos_x, pos_y) = if let Some(pos) = saved_position {(pos.x, pos.y)} else {- #[cfg(windows)]- let center_height = 430.0;- #[cfg(not(windows))]- let center_height = 395.0;- cursor_monitor.center_position(330.0, center_height)+ cursor_monitor.center_position(330.0, 395.0)};#[cfg(target_os = "macos")]@@ -1482,7 +1468,7 @@ impl ShowCapWindow {#[cfg(windows)]{- if let Err(e) = window.set_size(LogicalSize::new(330.0, 430.0)) {+ if let Err(e) = window.set_size(LogicalSize::new(330.0, 395.0)) {warn!("Failed to set Main window size on Windows: {}", e);}if let Err(e) =@@ -1569,6 +1555,7 @@ impl ShowCapWindow {}let window = window_builder.build()?;+ lock_window_text_scale(&window);#[cfg(windows)]{@@ -1679,6 +1666,7 @@ impl ShowCapWindow {}let window = builder.build()?;+ lock_window_text_scale(&window);let (pos_x, pos_y) = cursor_monitor.center_position(782.0, 775.0);let _ = window.set_position(tauri::LogicalPosition::new(pos_x, pos_y));@@ -1709,6 +1697,7 @@ impl ShowCapWindow {.min_inner_size(1275.0, 800.0).focused(true).build()?;+ lock_window_text_scale(&window);let (pos_x, pos_y) = cursor_monitor.center_position(1275.0, 800.0);let _ = window.set_position(tauri::LogicalPosition::new(pos_x, pos_y));@@ -1752,6 +1741,7 @@ impl ShowCapWindow {return Err(error);}};+ lock_window_text_scale(&window);let (pos_x, pos_y) = cursor_monitor.center_position(1240.0, 800.0);let _ = window.set_position(tauri::LogicalPosition::new(pos_x, pos_y));@@ -1793,6 +1783,7 @@ impl ShowCapWindow {.maximized(false).shadow(true).build()?;+ lock_window_text_scale(&window);let (pos_x, pos_y) = cursor_monitor.center_position(950.0, 850.0);let _ = window.set_position(tauri::LogicalPosition::new(pos_x, pos_y));@@ -1828,6 +1819,7 @@ impl ShowCapWindow {.focused(true).shadow(true).build()?;+ lock_window_text_scale(&window);let (pos_x, pos_y) = cursor_monitor.center_position(580.0, 340.0);let _ = window.set_position(tauri::LogicalPosition::new(pos_x, pos_y));@@ -1867,6 +1859,7 @@ impl ShowCapWindow {.focused(true).shadow(true).build()?;+ lock_window_text_scale(&window);let (pos_x, pos_y) = cursor_monitor.center_position(width, height);let _ = window.set_position(tauri::LogicalPosition::new(pos_x, pos_y));@@ -2002,6 +1995,7 @@ impl ShowCapWindow {return Err(e);}};+ lock_window_text_scale(&window);#[cfg(target_os = "windows")]log_window_content_protection(&window, should_protect, &title);@@ -2212,6 +2206,7 @@ impl ShowCapWindow {.transparent(true);let window = window_builder.build()?;+ lock_window_text_scale(&window);window.set_ignore_cursor_events(true).unwrap();@@ -2258,6 +2253,7 @@ impl ShowCapWindow {}let window = window_builder.build()?;+ lock_window_text_scale(&window);#[cfg(target_os = "macos")]crate::platform::set_window_level(@@ -2330,6 +2326,8 @@ impl ShowCapWindow {)).build()?;+ lock_window_text_scale(&window);+#[cfg(target_os = "windows")]log_window_content_protection(&window, should_protect, &title);@@ -2445,6 +2443,7 @@ impl ShowCapWindow {.skip_taskbar(true).transparent(true).build()?;+ lock_window_text_scale(&window);let _ = window.set_position(tauri::LogicalPosition::new(cursor_monitor.x,@@ -2574,7 +2573,7 @@ impl ShowCapWindow {#[cfg(windows)]{- builder = builder.decorations(false);+ builder = builder.decorations(false).zoom_hotkeys_enabled(false);}builder@@ -2617,6 +2616,20 @@ impl ShowCapWindow {}}+// Pin the WebView2 zoom factor to 1.0 on Windows. WebView2's initial zoom is+// derived from the system "Text size" accessibility setting+// (HKCU\Software\Microsoft\Accessibility\TextScaleFactor), which causes our+// fixed-size panels (Main, Settings, ModeSelect, etc.) to overflow whenever+// the user is on >100%. Explicitly setting the zoom overrides that.+fn lock_window_text_scale(_window: &WebviewWindow<Wry>) {+ #[cfg(windows)]+ {+ if let Err(e) = _window.set_zoom(1.0) {+ warn!("Failed to lock window zoom to 1.0: {}", e);+ }+ }+}+#[cfg(target_os = "macos")]fn add_traffic_lights(window: &WebviewWindow<Wry>, controls_inset: Option<LogicalPosition<f64>>) {use crate::platform::delegates;