@@ -217,8 +217,14 @@ impl ResizeForkGrab {
217217
218218impl ResizeForkGrab {
219219 // Returns `true` if grab should be unset
220- fn update_location ( & mut self , data : & mut State , location : Point < f64 , Logical > ) -> bool {
220+ fn update_location (
221+ & mut self ,
222+ data : & mut State ,
223+ location : Point < f64 , Logical > ,
224+ force : bool ,
225+ ) -> bool {
221226 let delta = location - self . last_loc . as_logical ( ) ;
227+ self . last_loc = location. as_global ( ) ;
222228
223229 if let Some ( output) = self . output . upgrade ( ) {
224230 let mut shell = data. common . shell . write ( ) . unwrap ( ) ;
@@ -228,7 +234,7 @@ impl ResizeForkGrab {
228234 let tiling_layer = & mut workspace. tiling_layer ;
229235 let gaps = tiling_layer. gaps ( ) ;
230236
231- let tree = & mut tiling_layer. queue . trees . back_mut ( ) . unwrap ( ) . 0 ;
237+ let mut tree = tiling_layer. queue . trees . back ( ) . unwrap ( ) . 0 . copy_clone ( ) ;
232238 match & mut self . old_tree {
233239 Some ( old_tree) => {
234240 // it would be so nice to just `zip` here, but `zip` just returns `None` once either returns `None`.
@@ -258,7 +264,7 @@ impl ResizeForkGrab {
258264 * old_tree = tree. copy_clone ( ) ;
259265 self . accumulated_delta = 0.0 ;
260266 } else {
261- * tree = old_tree. copy_clone ( ) ;
267+ tree = old_tree. copy_clone ( ) ;
262268 }
263269 }
264270 x @ None => {
@@ -284,6 +290,10 @@ impl ResizeForkGrab {
284290 return true ;
285291 } ;
286292
293+ if self . accumulated_delta . round ( ) as i32 == 0 {
294+ return false ;
295+ }
296+
287297 match tree. get_mut ( & self . node ) . unwrap ( ) . data_mut ( ) {
288298 Data :: Group {
289299 sizes, orientation, ..
@@ -319,9 +329,18 @@ impl ResizeForkGrab {
319329 _ => unreachable ! ( ) ,
320330 }
321331
322- self . last_loc = location. as_global ( ) ;
323- let blocker = TilingLayout :: update_positions ( & output, tree, gaps) ;
324- tiling_layer. pending_blockers . extend ( blocker) ;
332+ let should_configure = force
333+ || tree
334+ . traverse_pre_order ( & self . node )
335+ . unwrap ( )
336+ . all ( |node| match node. data ( ) {
337+ Data :: Mapped { mapped, .. } => mapped. latest_size_committed ( ) ,
338+ _ => true ,
339+ } ) ;
340+ if should_configure {
341+ let blocker = TilingLayout :: update_positions ( & output, & mut tree, gaps) ;
342+ tiling_layer. queue . push_tree ( tree, None , blocker) ;
343+ }
325344 } else {
326345 return true ;
327346 }
@@ -348,7 +367,7 @@ impl PointerGrab<State> for ResizeForkGrab {
348367 // While the grab is active, no client has pointer focus
349368 handle. motion ( data, None , event) ;
350369
351- if self . update_location ( data, event. location ) {
370+ if self . update_location ( data, event. location , false ) {
352371 handle. unset_grab ( self , data, event. serial , event. time , true ) ;
353372 }
354373 }
@@ -477,7 +496,9 @@ impl PointerGrab<State> for ResizeForkGrab {
477496 }
478497 }
479498
480- fn unset ( & mut self , _data : & mut State ) { }
499+ fn unset ( & mut self , data : & mut State ) {
500+ self . update_location ( data, self . last_loc . as_logical ( ) , true ) ;
501+ }
481502}
482503
483504impl TouchGrab < State > for ResizeForkGrab {
@@ -515,7 +536,7 @@ impl TouchGrab<State> for ResizeForkGrab {
515536 seq : Serial ,
516537 ) {
517538 if event. slot == <Self as TouchGrab < State > >:: start_data ( self ) . slot {
518- if self . update_location ( data, event. location ) {
539+ if self . update_location ( data, event. location , false ) {
519540 handle. unset_grab ( self , data) ;
520541 }
521542 }
@@ -558,5 +579,7 @@ impl TouchGrab<State> for ResizeForkGrab {
558579 handle. orientation ( data, event, seq)
559580 }
560581
561- fn unset ( & mut self , _data : & mut State ) { }
582+ fn unset ( & mut self , data : & mut State ) {
583+ self . update_location ( data, self . last_loc . as_logical ( ) , true ) ;
584+ }
562585}
0 commit comments