Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(desktop): enforce settings window minimum size and occlusion allowlist

Richie McIlroy45a72d14f782
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 8660425ab..8b80b9705 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -3350,6 +3350,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
.with_denylist(&[
CapWindowId::Onboarding.label().as_str(),
CapWindowId::Main.label().as_str(),
+ CapWindowId::Settings.label().as_str(),
"window-capture-occluder",
"target-select-overlay",
CapWindowId::CaptureArea.label().as_str(),
diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rs
index 500205969..e651a1c10 100644
--- a/apps/desktop/src-tauri/src/windows.rs
+++ b/apps/desktop/src-tauri/src/windows.rs
@@ -14,8 +14,8 @@ use std::{
time::Duration,
};
use tauri::{
- AppHandle, LogicalPosition, Manager, Monitor, PhysicalPosition, PhysicalSize, WebviewUrl,
- WebviewWindow, WebviewWindowBuilder, Wry,
+ AppHandle, LogicalPosition, LogicalSize, Manager, Monitor, PhysicalPosition, PhysicalSize,
+ WebviewUrl, WebviewWindow, WebviewWindowBuilder, Wry,
};
use tauri_specta::Event;
use tokio::sync::RwLock;
@@ -377,6 +377,19 @@ fn is_position_on_any_screen(pos_x: f64, pos_y: f64) -> bool {
false
}
+fn ensure_settings_window_bounds(window: &WebviewWindow) {
+ const MIN_W: f64 = 800.0;
+ const MIN_H: f64 = 580.0;
+ let _ = window.set_min_size(Some(LogicalSize::new(MIN_W, MIN_H)));
+ if let (Ok(physical), Ok(scale)) = (window.inner_size(), window.scale_factor()) {
+ let width = physical.width as f64 / scale;
+ let height = physical.height as f64 / scale;
+ if width < MIN_W || height < MIN_H {
+ let _ = window.set_size(LogicalSize::new(width.max(MIN_W), height.max(MIN_H)));
+ }
+ }
+}
+
#[derive(Clone, Deserialize, Type)]
pub enum CapWindowId {
Main,
@@ -955,6 +968,10 @@ impl ShowCapWindow {
window.unminimize().ok();
window.set_focus().ok();
+ if let Self::Settings { .. } = self {
+ ensure_settings_window_bounds(&window);
+ }
+
if let Self::Main { init_target_mode } = self {
let _ = RequestSetTargetMode {
target_mode: *init_target_mode,
@@ -1262,7 +1279,6 @@ impl ShowCapWindow {
#[cfg(windows)]
{
- use tauri::LogicalSize;
if let Err(e) = window.set_size(LogicalSize::new(800.0, 580.0)) {
warn!("Failed to set Settings window size on Windows: {}", e);
}
@@ -1273,6 +1289,7 @@ impl ShowCapWindow {
window.show().ok();
window.set_focus().ok();
+ ensure_settings_window_bounds(&window);
window
}