@@ -450,7 +450,7 @@ fn position_qa_window<R: tauri::Runtime>(window: &tauri::WebviewWindow<R>) -> ta
450450 let size = monitor. size ( ) ;
451451 let logical_w = size. width as f64 / scale;
452452 let logical_h = size. height as f64 / scale;
453- let capsule_height = capsule_window_size ( false ) . 1 ;
453+ let capsule_height = capsule_height_for_qa ( ) ;
454454 let x = ( ( logical_w - QA_WINDOW_WIDTH ) / 2.0 ) . max ( 0.0 ) ;
455455 let y = ( logical_h
456456 - DOCK_BOTTOM_PADDING_FOR_QA
@@ -614,59 +614,94 @@ pub(crate) fn position_capsule_bottom_center<R: tauri::Runtime>(
614614 Some ( m) => m,
615615 None => return Ok ( ( ) ) ,
616616 } ;
617- let ( cap_w , cap_h ) = capsule_window_size ( translation_active) ;
618- window. set_size ( LogicalSize :: new ( cap_w , cap_h ) ) ?;
617+ let bounds = capsule_window_bounds ( translation_active) ;
618+ window. set_size ( LogicalSize :: new ( bounds . width , bounds . height ) ) ?;
619619
620620 let scale = monitor. scale_factor ( ) ;
621621 let size = monitor. size ( ) ;
622622 let logical_w = size. width as f64 / scale;
623623 let logical_h = size. height as f64 / scale;
624- let x = ( ( logical_w - cap_w) / 2.0 ) . max ( 0.0 ) ;
625- let y = ( logical_h - cap_h - 80.0 ) . max ( 0.0 ) ;
624+ let x = ( ( logical_w - bounds. width ) / 2.0 ) . max ( 0.0 ) ;
625+ let y = ( logical_h - capsule_visual_height ( translation_active) - 80.0 - bounds. bottom_inset )
626+ . max ( 0.0 ) ;
626627 window. set_position ( LogicalPosition :: new ( x, y) ) ?;
627628 Ok ( ( ) )
628629}
629630
630- fn capsule_window_size ( translation_active : bool ) -> ( f64 , f64 ) {
631+ #[ derive( Clone , Copy , Debug , PartialEq ) ]
632+ struct CapsuleWindowBounds {
633+ width : f64 ,
634+ height : f64 ,
635+ bottom_inset : f64 ,
636+ }
637+
638+ fn capsule_window_bounds ( translation_active : bool ) -> CapsuleWindowBounds {
639+ #[ cfg( target_os = "windows" ) ]
640+ {
641+ CapsuleWindowBounds {
642+ width : 220.0 ,
643+ height : if translation_active { 118.0 } else { 84.0 } ,
644+ bottom_inset : 12.0 ,
645+ }
646+ }
647+
648+ #[ cfg( not( target_os = "windows" ) ) ]
649+ {
650+ CapsuleWindowBounds {
651+ width : 176.0 ,
652+ height : if translation_active { 110.0 } else { 42.0 } ,
653+ bottom_inset : 0.0 ,
654+ }
655+ }
656+ }
657+
658+ fn capsule_visual_height ( _translation_active : bool ) -> f64 {
631659 #[ cfg( target_os = "windows" ) ]
632660 {
633- let height = if translation_active { 110.0 } else { 52.0 } ;
634- ( 196.0 , height)
661+ 52.0
635662 }
636663
637664 #[ cfg( not( target_os = "windows" ) ) ]
638665 {
639- let height = if translation_active { 110.0 } else { 42.0 } ;
640- ( 176.0 , height)
666+ 42.0
641667 }
642668}
643669
644670fn capsule_height_for_qa ( ) -> f64 {
645- capsule_window_size ( false ) . 1
671+ capsule_visual_height ( false )
646672}
647673
648674#[ cfg( test) ]
649675mod tests {
650- use super :: { capsule_height_for_qa, capsule_window_size} ;
676+ use super :: { capsule_height_for_qa, capsule_visual_height, capsule_window_bounds} ;
677+
678+ #[ test]
679+ fn capsule_window_bounds_leave_room_for_windows_shadow ( ) {
680+ let bounds = capsule_window_bounds ( false ) ;
681+ #[ cfg( target_os = "windows" ) ]
682+ assert_eq ! ( ( bounds. width, bounds. height, bounds. bottom_inset) , ( 220.0 , 84.0 , 12.0 ) ) ;
683+
684+ #[ cfg( not( target_os = "windows" ) ) ]
685+ assert_eq ! ( ( bounds. width, bounds. height, bounds. bottom_inset) , ( 176.0 , 42.0 , 0.0 ) ) ;
686+ }
651687
652688 #[ test]
653- fn capsule_window_size_matches_visible_pill_when_not_translating ( ) {
654- let ( width , height ) = capsule_window_size ( false ) ;
689+ fn capsule_window_bounds_expand_for_translation_badge ( ) {
690+ let bounds = capsule_window_bounds ( true ) ;
655691 #[ cfg( target_os = "windows" ) ]
656- assert_eq ! ( ( width, height) , ( 196 .0, 52 .0) ) ;
692+ assert_eq ! ( ( bounds . width, bounds . height, bounds . bottom_inset ) , ( 220 .0, 118.0 , 12 .0) ) ;
657693
658694 #[ cfg( not( target_os = "windows" ) ) ]
659- assert_eq ! ( ( width, height) , ( 176.0 , 42 .0) ) ;
695+ assert_eq ! ( ( bounds . width, bounds . height, bounds . bottom_inset ) , ( 176.0 , 110.0 , 0 .0) ) ;
660696 }
661697
662698 #[ test]
663- fn capsule_window_size_expands_for_translation_badge ( ) {
664- let ( width, height) = capsule_window_size ( true ) ;
699+ fn capsule_visual_height_matches_frontend_pill ( ) {
665700 #[ cfg( target_os = "windows" ) ]
666- assert_eq ! ( ( width , height ) , ( 196.0 , 110.0 ) ) ;
701+ assert_eq ! ( capsule_visual_height ( true ) , 52.0 ) ;
667702
668703 #[ cfg( not( target_os = "windows" ) ) ]
669- assert_eq ! ( ( width , height ) , ( 176.0 , 110.0 ) ) ;
704+ assert_eq ! ( capsule_visual_height ( true ) , 42.0 ) ;
670705 }
671706
672707 #[ test]
0 commit comments