@@ -212,52 +212,56 @@ export default class TilingMoveHandler {
212212 }
213213
214214 _onMoveFinished ( window ) {
215- if ( this . _posChangedId ) {
216- window . disconnect ( this . _posChangedId ) ;
217- this . _posChangedId = 0 ;
218- }
215+ try {
216+ window . assertExistence ( ) ;
217+
218+ if ( this . _tileRect ) {
219+ // Ctrl-drag to replace some windows in a tile group / create a new tile group
220+ // with at least 1 window being part of multiple tile groups.
221+ let isCtrlReplacement = false ;
222+ const ctrlReplacedTileGroup = [ ] ;
223+ const topTileGroup = Twm . getTopTileGroup ( { skipTopWindow : true } ) ;
224+ const pointerPos = { x : global . get_pointer ( ) [ 0 ] , y : global . get_pointer ( ) [ 1 ] } ;
225+ const twHovered = topTileGroup . some ( w => w . tiledRect . containsPoint ( pointerPos ) ) ;
226+ if ( this . _currPreviewMode === MoveModes . ADAPTIVE_TILING && ! this . _splitRects . size && twHovered ) {
227+ isCtrlReplacement = true ;
228+ ctrlReplacedTileGroup . push ( window ) ;
229+ topTileGroup . forEach ( w => {
230+ if ( ! this . _tileRect . containsRect ( w . tiledRect ) )
231+ ctrlReplacedTileGroup . push ( w ) ;
232+ } ) ;
233+ }
219234
220- if ( this . _tileRect ) {
221- // Ctrl-drag to replace some windows in a tile group / create a new tile group
222- // with at least 1 window being part of multiple tile groups.
223- let isCtrlReplacement = false ;
224- const ctrlReplacedTileGroup = [ ] ;
225- const topTileGroup = Twm . getTopTileGroup ( { skipTopWindow : true } ) ;
226- const pointerPos = { x : global . get_pointer ( ) [ 0 ] , y : global . get_pointer ( ) [ 1 ] } ;
227- const twHovered = topTileGroup . some ( w => w . tiledRect . containsPoint ( pointerPos ) ) ;
228- if ( this . _currPreviewMode === MoveModes . ADAPTIVE_TILING && ! this . _splitRects . size && twHovered ) {
229- isCtrlReplacement = true ;
230- ctrlReplacedTileGroup . push ( window ) ;
231- topTileGroup . forEach ( w => {
232- if ( ! this . _tileRect . containsRect ( w . tiledRect ) )
233- ctrlReplacedTileGroup . push ( w ) ;
235+ this . _splitRects . forEach ( ( rect , w ) => Twm . tile ( w , rect , { openTilingPopup : false } ) ) ;
236+ this . _splitRects . clear ( ) ;
237+ Twm . tile ( window , this . _tileRect , {
238+ monitorNr : this . _monitorNr ,
239+ openTilingPopup : this . _currPreviewMode !== MoveModes . ADAPTIVE_TILING ,
240+ ignoreTA : this . _ignoreTA
234241 } ) ;
235- }
242+ this . _tileRect = null ;
236243
237- this . _splitRects . forEach ( ( rect , w ) => Twm . tile ( w , rect , { openTilingPopup : false } ) ) ;
238- this . _splitRects . clear ( ) ;
239- Twm . tile ( window , this . _tileRect , {
240- monitorNr : this . _monitorNr ,
241- openTilingPopup : this . _currPreviewMode !== MoveModes . ADAPTIVE_TILING ,
242- ignoreTA : this . _ignoreTA
243- } ) ;
244- this . _tileRect = null ;
244+ // Create a new tile group, in which some windows are already part
245+ // of a different tile group, with ctrl-(super)-drag. The window may
246+ // be maximized by ctrl-super-drag.
247+ isCtrlReplacement && window . isTiled && Twm . updateTileGroup ( ctrlReplacedTileGroup ) ;
248+ }
249+ } finally {
250+ if ( this . _posChangedId ) {
251+ window . disconnect ( this . _posChangedId ) ;
252+ this . _posChangedId = 0 ;
253+ }
245254
246- // Create a new tile group, in which some windows are already part
247- // of a different tile group, with ctrl-(super)-drag. The window may
248- // be maximized by ctrl-super-drag.
249- isCtrlReplacement && window . isTiled && Twm . updateTileGroup ( ctrlReplacedTileGroup ) ;
255+ this . _favoriteLayout = [ ] ;
256+ this . _favoritePreviews ?. forEach ( p => p . destroy ( ) ) ;
257+ this . _favoritePreviews = [ ] ;
258+ this . _freeScreenRects = [ ] ;
259+ this . _anchorRect = null ;
260+ this . _topTileGroup = null ;
261+ this . _tilePreview . close ( ) ;
262+ this . _currPreviewMode = MoveModes . ADAPTIVE_TILING ;
263+ this . _isGrabOp = false ;
250264 }
251-
252- this . _favoriteLayout = [ ] ;
253- this . _favoritePreviews ?. forEach ( p => p . destroy ( ) ) ;
254- this . _favoritePreviews = [ ] ;
255- this . _freeScreenRects = [ ] ;
256- this . _anchorRect = null ;
257- this . _topTileGroup = null ;
258- this . _tilePreview . close ( ) ;
259- this . _currPreviewMode = MoveModes . ADAPTIVE_TILING ;
260- this . _isGrabOp = false ;
261265 }
262266
263267 // If lowPerfMode is enabled in the settings:
0 commit comments