@@ -323,7 +323,18 @@ function removeWindowFromTrack(windowId, callback){
323323 if ( i > - 1 ) {
324324 snappedWindowGroups [ i ] . windows . splice ( i2 , 1 ) ;
325325 if ( callback ) callback ( snappedWindowGroups [ i ] ) ;
326- if ( snappedWindowGroups [ i ] . windows . length < 1 ) snappedWindowGroups . splice ( i , 1 ) ;
326+ const remainingWindowsCount = snappedWindowGroups [ i ] . windows . length ;
327+ if ( remainingWindowsCount < 1 ) snappedWindowGroups . splice ( i , 1 ) ; /// delete empty group
328+ else if ( remainingWindowsCount === 1 ) {
329+ /// set timer to delete group if not populated in few seconds
330+
331+ const remainingWindowId = snappedWindowGroups [ i ] . windows [ 0 ] ;
332+ setOneTimeTimeout ( function ( ) {
333+ /// group index may have changed
334+ const i3 = snappedWindowGroups . findIndex ( ( group ) => group . windows . indexOf ( remainingWindowId ) > - 1 && group . windows . length < 2 ) ;
335+ if ( i3 > - 1 ) snappedWindowGroups . splice ( i3 , 1 ) ;
336+ } , 6000 ) ;
337+ }
327338 }
328339}
329340
@@ -453,3 +464,19 @@ function sortClientsByLastActive() {
453464 return activationTime [ windowIdA ] - activationTime [ windowIdB ] ;
454465 } ) ;
455466}
467+
468+ /// One-time timer, when we want multiple timers run in parallel
469+ function setOneTimeTimeout ( cb , delayTime ) {
470+ function Timer ( ) {
471+ return Qt . createQmlObject ( "import QtQuick 2.0; Timer {}" , main ) ;
472+ }
473+
474+ const timer = new Timer ( ) ;
475+ timer . interval = delayTime ;
476+ timer . repeat = false ;
477+ timer . triggered . connect ( function ( ) {
478+ cb ( ) ;
479+ timer . destroy ( ) ;
480+ } ) ;
481+ timer . start ( ) ;
482+ }
0 commit comments