8383 Format as ConfigFormat , GfxApi , ScalingFilter as ConfigScalingFilter ,
8484 TearingMode as ConfigTearingMode , Transform , VrrMode as ConfigVrrMode ,
8585 } ,
86- window:: { TileState as ConfigTileState , Window , WindowMatcher } ,
86+ window:: { Coordinate , TileState as ConfigTileState , Window , WindowMatcher } ,
8787 workspace:: WorkspaceDisplayOrder ,
8888 xwayland:: XScalingMode ,
8989 } ,
@@ -3049,12 +3049,12 @@ impl ConfigProxyHandler {
30493049 fn handle_set_window_position (
30503050 & self ,
30513051 window : Window ,
3052- x1 : Option < i32 > ,
3053- y1 : Option < i32 > ,
3054- x2 : Option < i32 > ,
3055- y2 : Option < i32 > ,
3056- width : Option < i32 > ,
3057- height : Option < i32 > ,
3052+ x1 : Option < Coordinate > ,
3053+ y1 : Option < Coordinate > ,
3054+ x2 : Option < Coordinate > ,
3055+ y2 : Option < Coordinate > ,
3056+ width : Option < Coordinate > ,
3057+ height : Option < Coordinate > ,
30583058 ) -> Result < ( ) , CphError > {
30593059 let tl = self . get_window ( window) ?;
30603060 let pos = tl. node_absolute_position ( LiveTL ) ;
@@ -4179,24 +4179,22 @@ impl ConfigProxyHandler {
41794179 }
41804180}
41814181
4182- /// Resolves the constraints on a single axis (x1/x2/width or y1/y2/height) of
4183- /// [`ConfigProxyHandler::handle_set_window_position`] into a concrete `(c1, c2)` pair.
4184- ///
4185- /// `c1`, `c2` and `size` are constrained to their contained value if they are `Some(_)` and
4186- /// are otherwise unconstrained.
4187- ///
4188- /// If two of the three are constrained, the third is derived from them. If only one is
4189- /// constrained, the window keeps its current size (if `c1` or `c2` is constrained) or its
4190- /// current position (if only `size` is constrained). If none are constrained, the axis is
4191- /// left unchanged. If all three are constrained but not self-consistent, an error is returned.
41924182fn resolve_geometry_axis (
4193- c1 : Option < i32 > ,
4194- c2 : Option < i32 > ,
4195- size : Option < i32 > ,
4183+ c1 : Option < Coordinate > ,
4184+ c2 : Option < Coordinate > ,
4185+ size : Option < Coordinate > ,
41964186 cur_c1 : i32 ,
41974187 cur_c2 : i32 ,
41984188) -> Result < ( i32 , i32 ) , CphError > {
41994189 let cur_size = cur_c2. saturating_sub ( cur_c1) ;
4190+ let resolve = |c : Option < Coordinate > , cur : i32 | match c {
4191+ Some ( Coordinate :: Set ( v) ) => Some ( v) ,
4192+ Some ( Coordinate :: Keep ) => Some ( cur) ,
4193+ None => None ,
4194+ } ;
4195+ let c1 = resolve ( c1, cur_c1) ;
4196+ let c2 = resolve ( c2, cur_c2) ;
4197+ let size = resolve ( size, cur_size) ;
42004198 let res = match ( c1, c2, size) {
42014199 ( Some ( c1) , Some ( c2) , Some ( size) ) => {
42024200 if c2. saturating_sub ( c1) != size {
@@ -4207,8 +4205,8 @@ fn resolve_geometry_axis(
42074205 ( Some ( c1) , Some ( c2) , None ) => ( c1, c2) ,
42084206 ( Some ( c1) , None , Some ( size) ) => ( c1, c1. saturating_add ( size) ) ,
42094207 ( None , Some ( c2) , Some ( size) ) => ( c2. saturating_sub ( size) , c2) ,
4210- ( Some ( c1) , None , None ) => ( c1, c1 . saturating_add ( cur_size ) ) ,
4211- ( None , Some ( c2) , None ) => ( c2 . saturating_sub ( cur_size ) , c2) ,
4208+ ( Some ( c1) , None , None ) => ( c1, cur_c2 ) ,
4209+ ( None , Some ( c2) , None ) => ( cur_c1 , c2) ,
42124210 ( None , None , Some ( size) ) => ( cur_c1, cur_c1. saturating_add ( size) ) ,
42134211 ( None , None , None ) => ( cur_c1, cur_c2) ,
42144212 } ;
0 commit comments