File tree Expand file tree Collapse file tree
platform/x11/xcb_connection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,8 +211,10 @@ impl WindowHandler for WgpuExample {
211211
212212fn main ( ) -> Result < ( ) , baseview:: Error > {
213213 env_logger:: builder ( ) . filter_level ( LevelFilter :: Debug ) . init ( ) ;
214- let window_open_options =
215- WindowSettings :: new ( ) . with_title ( "WGPU on Baseview" ) . with_size ( LogicalSize :: new ( 512 , 512 ) ) ;
214+ let window_open_options = WindowSettings :: new ( )
215+ . with_title ( "WGPU on Baseview" )
216+ . with_size ( LogicalSize :: new ( 512 , 512 ) )
217+ . with_max_size ( LogicalSize :: new ( 512 , 512 ) ) ;
216218
217219 Window :: create ( window_open_options, |c| pollster:: block_on ( WgpuExample :: new ( c) ) ) ?
218220 . run_until_closed ( ) ?;
Original file line number Diff line number Diff line change 11use crate :: WindowSettings ;
2- use dpi:: PhysicalSize ;
2+ use dpi:: { PhysicalSize , Size } ;
33use x11rb:: properties:: WmSizeHints ;
44
55pub fn get_size_hints ( settings : & WindowSettings , scale_factor : f64 ) -> WmSizeHints {
66 let mut size_hints = WmSizeHints :: default ( ) ;
77
88 if !settings. resizable {
99 size_hints = size_hints. with_fixed_size ( settings. size . to_physical ( scale_factor) ) ;
10+ } else {
11+ size_hints. min_size = settings. min_size . map ( |s| to_size_hint ( s, scale_factor) ) ;
12+ size_hints. max_size = settings. max_size . map ( |s| to_size_hint ( s, scale_factor) ) ;
1013 }
1114
1215 size_hints
1316}
1417
18+ fn to_size_hint ( size : Size , scale_factor : f64 ) -> ( i32 , i32 ) {
19+ let size = size. to_physical ( scale_factor) ;
20+ ( size. width , size. height )
21+ }
22+
1523pub trait WmSizeHintsExt : Sized {
1624 fn with_fixed_size ( self , size : PhysicalSize < i32 > ) -> Self ;
1725}
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ pub struct WindowSettings {
3030 /// Whether the window can be resized.
3131 pub resizable : bool ,
3232
33+ pub min_size : Option < Size > ,
34+ pub max_size : Option < Size > ,
35+
3336 /// A fallback scale factor, if Baseview couldn't get one from the platform.
3437 ///
3538 /// If the platform does already provide an accurate scaling factor, this doesn't do anything.
@@ -111,6 +114,18 @@ impl WindowSettings {
111114 self
112115 }
113116
117+ #[ inline]
118+ pub fn with_min_size < S : Into < Size > > ( mut self , min_size : impl Into < Option < S > > ) -> Self {
119+ self . min_size = min_size. into ( ) . map ( S :: into) ;
120+ self
121+ }
122+
123+ #[ inline]
124+ pub fn with_max_size < S : Into < Size > > ( mut self , max_size : impl Into < Option < S > > ) -> Self {
125+ self . max_size = max_size. into ( ) . map ( S :: into) ;
126+ self
127+ }
128+
114129 /// Sets [`gl_config`](Self::gl_config) to the given value.
115130 #[ cfg( feature = "opengl" ) ]
116131 #[ inline]
@@ -129,6 +144,8 @@ impl Default for WindowSettings {
129144 wait_for_parent : false ,
130145 fallback_scale_factor : None ,
131146 resizable : true ,
147+ min_size : None ,
148+ max_size : None ,
132149 #[ cfg( feature = "opengl" ) ]
133150 gl_config : None ,
134151 }
You can’t perform that action at this time.
0 commit comments