@@ -22,6 +22,7 @@ import * as Executor from 'executor';
2222import * as movement from 'movement' ;
2323import * as stack from 'stack' ;
2424import * as add_exception from 'dialog_add_exception' ;
25+ import * as exec from 'executor' ;
2526
2627import type { Entity } from 'ecs' ;
2728import type { ExtEvent } from 'events' ;
@@ -195,10 +196,6 @@ export class Ext extends Ecs.System<ExtEvent> {
195196 /** Calculates window placements when tiling and focus-switching */
196197 tiler : Tiling . Tiler = new Tiling . Tiler ( this ) ;
197198
198- tiler_active : boolean = false ;
199-
200- tiler_queue : null | SignalID = null ;
201-
202199 constructor ( ) {
203200 super ( new Executor . GLibExecutor ( ) ) ;
204201
@@ -1454,29 +1451,10 @@ export class Ext extends Ecs.System<ExtEvent> {
14541451 signals_attach ( ) {
14551452 this . conf_watch = this . attach_config ( ) ;
14561453
1457- this . tiler_queue = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , 100 , ( ) => {
1458- if ( this . tiler_active ) return true ;
1459-
1460- const m = this . tiler . movements . shift ( ) ;
1461-
1462- if ( m ) {
1463- this . tiler_active = true ;
1464-
1465- const callback = ( ) => {
1466- m ( ) ;
1467- this . tiler_active = false ;
1468- } ;
1469-
1470- if ( ! this . schedule_idle ( ( ) => {
1471- callback ( ) ;
1472- return false ;
1473- } ) ) {
1474- callback ( ) ;
1475- }
1476- }
1477-
1478- return true ;
1479- } ) ;
1454+ this . tiler . queue . start ( 100 , ( movement ) => {
1455+ movement ( )
1456+ return true
1457+ } )
14801458
14811459 const workspace_manager = wom ;
14821460
@@ -1661,9 +1639,7 @@ export class Ext extends Ecs.System<ExtEvent> {
16611639 this . conf_watch = null ;
16621640 }
16631641
1664- if ( this . tiler_queue !== null ) {
1665- GLib . source_remove ( this . tiler_queue )
1666- }
1642+ this . tiler . queue . stop ( )
16671643
16681644 this . signals . clear ( ) ;
16691645 }
@@ -1888,41 +1864,37 @@ export class Ext extends Ecs.System<ExtEvent> {
18881864 }
18891865 }
18901866
1891- let migrations : Array < [ Fork , number , Rectangle , boolean ] > = new Array ( )
1867+ type Migration = [ Fork , number , Rectangle , boolean ]
1868+
1869+ let migrations : Array < Migration > = new Array ( )
18921870
18931871 const apply_migrations = ( assigned_monitors : Set < number > ) => {
18941872 if ( ! migrations ) return
18951873
1896- const iterator = migrations [ Symbol . iterator ] ( )
1897-
1898- GLib . timeout_add ( GLib . PRIORITY_LOW , 500 , ( ) => {
1899- let next : null | [ Fork , number , Rectangle , boolean ] = iterator . next ( ) . value ;
1900-
1901- if ( next ) {
1902- const [ fork , new_monitor , workspace , find_workspace ] = next
1903- let new_workspace
1904-
1905- if ( find_workspace ) {
1906- if ( assigned_monitors . has ( new_monitor ) ) {
1907- [ new_workspace ] = this . find_unused_workspace ( new_monitor )
1874+ new exec . OnceExecutor < Migration , Migration [ ] > ( migrations )
1875+ . start (
1876+ 500 ,
1877+ ( [ fork , new_monitor , workspace , find_workspace ] ) => {
1878+ let new_workspace
1879+
1880+ if ( find_workspace ) {
1881+ if ( assigned_monitors . has ( new_monitor ) ) {
1882+ [ new_workspace ] = this . find_unused_workspace ( new_monitor )
1883+ } else {
1884+ assigned_monitors . add ( new_monitor )
1885+ new_workspace = 0
1886+ }
19081887 } else {
1909- assigned_monitors . add ( new_monitor )
1910- new_workspace = 0
1888+ new_workspace = fork . workspace
19111889 }
1912- } else {
1913- new_workspace = fork . workspace
1914- }
19151890
1916- fork . migrate ( this , forest , workspace , new_monitor , new_workspace ) ;
1917- fork . set_ratio ( fork . length ( ) / 2 )
1891+ fork . migrate ( this , forest , workspace , new_monitor , new_workspace ) ;
1892+ fork . set_ratio ( fork . length ( ) / 2 )
19181893
1919- return true
1920- }
1921-
1922- update_tiling ( )
1923-
1924- return false
1925- } )
1894+ return true
1895+ } ,
1896+ ( ) => update_tiling ( )
1897+ )
19261898 }
19271899
19281900 function mark_for_reassignment ( ext : Ext , fork : Ecs . Entity ) {
0 commit comments