Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Keep Linux HiDPI scale handling out of the Windows mixed-DPI paths

Richie McIlroy08839cf520f5
diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rs
index 96f644a50..f5ba8f69d 100644
--- a/apps/desktop/src-tauri/src/windows.rs
+++ b/apps/desktop/src-tauri/src/windows.rs
@@ -670,7 +670,9 @@ impl CursorMonitorInfo {
// outer_position is physical. On Windows, resolve the display in
// physical space (per-monitor logical rects overlap in mixed-DPI
- // layouts); elsewhere, convert to logical, which is a global space.
+ // layouts). On macOS, convert to logical points, a true global space.
+ // On Linux scap reports logical bounds in unscaled physical units, so
+ // the raw position compares directly.
#[cfg(windows)]
{
let (pos_x, pos_y) = (window_pos.x as f64, window_pos.y as f64);
@@ -692,7 +694,7 @@ impl CursorMonitorInfo {
Self::get()
}
- #[cfg(not(windows))]
+ #[cfg(target_os = "macos")]
{
let scale = window.scale_factor().unwrap_or(1.0);
let pos = window_pos.to_logical::<f64>(scale);
@@ -705,6 +707,19 @@ impl CursorMonitorInfo {
Self::get()
}
+
+ #[cfg(target_os = "linux")]
+ {
+ let (pos_x, pos_y) = (window_pos.x as f64, window_pos.y as f64);
+
+ for display in Display::list() {
+ if display_contains_logical(&display, pos_x, pos_y) {
+ return Self::from_display(&display);
+ }
+ }
+
+ Self::get()
+ }
}
}
diff --git a/apps/desktop/src/routes/target-select-overlay.tsx b/apps/desktop/src/routes/target-select-overlay.tsx
index fd62eae8d..690458c54 100644
--- a/apps/desktop/src/routes/target-select-overlay.tsx
+++ b/apps/desktop/src/routes/target-select-overlay.tsx
@@ -946,9 +946,11 @@ function Inner() {
// window's own scale is wrong when it starts on a monitor
// with different DPI. On macOS physical coordinates are
// interpreted relative to the camera window's scale, so its
- // own factor is the correct (self-canceling) one.
+ // own factor is the correct (self-canceling) one, and on
+ // Linux scap reports logical == physical so the display
+ // ratio would collapse to 1 and lose the window scale.
const targetScale = (() => {
- if (ostype() === "macos") return scaleFactor;
+ if (ostype() !== "windows") return scaleFactor;
const physicalWidth = displayInfo?.physical_size?.width;
const logicalWidth = displayInfo?.logical_size?.width;
return physicalWidth && logicalWidth && logicalWidth > 0