@@ -152,7 +152,7 @@ export class Ext extends Ecs.System<ExtEvent> {
152
152
injections : Array < Injection > = new Array ( ) ;
153
153
154
154
/** The window that was focused before the last window */
155
- prev_focused : [ null | Entity , null | Entity ] = [ null , null ] ;
155
+ private prev_focused : [ null | Entity , null | Entity ] = [ null , null ] ;
156
156
157
157
tween_signals : Map < string , [ SignalID , any ] > = new Map ( ) ;
158
158
@@ -789,8 +789,11 @@ export class Ext extends Ecs.System<ExtEvent> {
789
789
this . exception_add ( win )
790
790
}
791
791
792
- this . prev_focused [ 0 ] = this . prev_focused [ 1 ] ;
793
- this . prev_focused [ 1 ] = win . entity ;
792
+ // Track history of focused windows, but do not permit duplicates.
793
+ if ( this . prev_focused [ 1 ] !== win . entity ) {
794
+ this . prev_focused [ 0 ] = this . prev_focused [ 1 ] ;
795
+ this . prev_focused [ 1 ] = win . entity ;
796
+ }
794
797
795
798
// Update the active tab in the stack.
796
799
if ( null !== this . auto_tiler && null !== win . stack ) {
@@ -1063,6 +1066,17 @@ export class Ext extends Ecs.System<ExtEvent> {
1063
1066
this . tiler . snap ( this , win ) ;
1064
1067
}
1065
1068
}
1069
+
1070
+ previously_focused ( active : Window . ShellWindow ) : null | Ecs . Entity {
1071
+ for ( const id of [ 1 , 0 ] ) {
1072
+ const prev = this . prev_focused [ id ]
1073
+ if ( prev && ! Ecs . entity_eq ( active . entity , prev ) ) {
1074
+ return prev ;
1075
+ }
1076
+ }
1077
+
1078
+ return null
1079
+ }
1066
1080
1067
1081
movement_is_valid ( win : Window . ShellWindow , movement : movement . Movement ) {
1068
1082
if ( ( movement & Movement . SHRINK ) !== 0 ) {
0 commit comments