@@ -14,8 +14,8 @@ use std::{
1414 time:: Duration ,
1515} ;
1616use tauri:: {
17- AppHandle , LogicalPosition , Manager , Monitor , PhysicalPosition , PhysicalSize , WebviewUrl ,
18- WebviewWindow , WebviewWindowBuilder , Wry ,
17+ AppHandle , LogicalPosition , LogicalSize , Manager , Monitor , PhysicalPosition , PhysicalSize ,
18+ WebviewUrl , WebviewWindow , WebviewWindowBuilder , Wry ,
1919} ;
2020use tauri_specta:: Event ;
2121use tokio:: sync:: RwLock ;
@@ -377,6 +377,19 @@ fn is_position_on_any_screen(pos_x: f64, pos_y: f64) -> bool {
377377 false
378378}
379379
380+ fn ensure_settings_window_bounds ( window : & WebviewWindow ) {
381+ const MIN_W : f64 = 800.0 ;
382+ const MIN_H : f64 = 580.0 ;
383+ let _ = window. set_min_size ( Some ( LogicalSize :: new ( MIN_W , MIN_H ) ) ) ;
384+ if let ( Ok ( physical) , Ok ( scale) ) = ( window. inner_size ( ) , window. scale_factor ( ) ) {
385+ let width = physical. width as f64 / scale;
386+ let height = physical. height as f64 / scale;
387+ if width < MIN_W || height < MIN_H {
388+ let _ = window. set_size ( LogicalSize :: new ( width. max ( MIN_W ) , height. max ( MIN_H ) ) ) ;
389+ }
390+ }
391+ }
392+
380393#[ derive( Clone , Deserialize , Type ) ]
381394pub enum CapWindowId {
382395 Main ,
@@ -955,6 +968,10 @@ impl ShowCapWindow {
955968 window. unminimize ( ) . ok ( ) ;
956969 window. set_focus ( ) . ok ( ) ;
957970
971+ if let Self :: Settings { .. } = self {
972+ ensure_settings_window_bounds ( & window) ;
973+ }
974+
958975 if let Self :: Main { init_target_mode } = self {
959976 let _ = RequestSetTargetMode {
960977 target_mode : * init_target_mode,
@@ -1262,7 +1279,6 @@ impl ShowCapWindow {
12621279
12631280 #[ cfg( windows) ]
12641281 {
1265- use tauri:: LogicalSize ;
12661282 if let Err ( e) = window. set_size ( LogicalSize :: new ( 800.0 , 580.0 ) ) {
12671283 warn ! ( "Failed to set Settings window size on Windows: {}" , e) ;
12681284 }
@@ -1273,6 +1289,7 @@ impl ShowCapWindow {
12731289
12741290 window. show ( ) . ok ( ) ;
12751291 window. set_focus ( ) . ok ( ) ;
1292+ ensure_settings_window_bounds ( & window) ;
12761293
12771294 window
12781295 }
0 commit comments