@@ -150,11 +150,8 @@ export class Ext extends Ecs.System<ExtEvent> {
150
150
/** Functions replaced in GNOME */
151
151
injections : Array < Injection > = new Array ( ) ;
152
152
153
- /** The last window that was focused */
154
- last_focused : Entity | null = null ;
155
-
156
153
/** The window that was focused before the last window */
157
- prev_focused : Entity | null = null ;
154
+ prev_focused : [ null | Entity , null | Entity ] = [ null , null ] ;
158
155
159
156
tween_signals : Map < string , [ SignalID , any ] > = new Map ( ) ;
160
157
@@ -629,11 +626,7 @@ export class Ext extends Ecs.System<ExtEvent> {
629
626
}
630
627
631
628
focus_window ( ) : Window . ShellWindow | null {
632
- let focused = this . get_window ( display . get_focus_window ( ) )
633
- if ( ! focused && this . last_focused ) {
634
- focused = this . windows . get ( this . last_focused ) ;
635
- }
636
- return focused ;
629
+ return this . get_window ( display . get_focus_window ( ) )
637
630
}
638
631
639
632
stack_select (
@@ -723,7 +716,7 @@ export class Ext extends Ecs.System<ExtEvent> {
723
716
724
717
on_active_workspace_changed ( ) {
725
718
this . exit_modes ( ) ;
726
- this . last_focused = null ;
719
+ this . prev_focused = [ null , null ]
727
720
this . restack ( )
728
721
}
729
722
@@ -738,20 +731,16 @@ export class Ext extends Ecs.System<ExtEvent> {
738
731
}
739
732
} ) ;
740
733
741
- if ( this . last_focused == win ) {
742
- this . last_focused = null ;
734
+ if ( this . auto_tiler ) {
735
+ const entity = this . auto_tiler . attached . get ( win ) ;
736
+ if ( entity ) {
737
+ const fork = this . auto_tiler . forest . forks . get ( entity ) ;
738
+ if ( fork ?. right ?. is_window ( win ) ) {
739
+ const entity = fork . right . inner . kind === 3
740
+ ? fork . right . inner . entities [ 0 ]
741
+ : fork . right . inner . entity ;
743
742
744
- if ( this . auto_tiler ) {
745
- const entity = this . auto_tiler . attached . get ( win ) ;
746
- if ( entity ) {
747
- const fork = this . auto_tiler . forest . forks . get ( entity ) ;
748
- if ( fork ?. right ?. is_window ( win ) ) {
749
- const entity = fork . right . inner . kind === 3
750
- ? fork . right . inner . entities [ 0 ]
751
- : fork . right . inner . entity ;
752
-
753
- this . windows . with ( entity , ( sibling ) => sibling . activate ( ) )
754
- }
743
+ this . windows . with ( entity , ( sibling ) => sibling . activate ( ) )
755
744
}
756
745
}
757
746
}
@@ -782,16 +771,8 @@ export class Ext extends Ecs.System<ExtEvent> {
782
771
this . exception_add ( win )
783
772
}
784
773
785
- // Keep the last-focused window from being shifted too quickly. 300ms debounce
786
- if ( this . focus_trigger === null ) {
787
- this . focus_trigger = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , 300 , ( ) => {
788
- this . focus_trigger = null ;
789
- return false ;
790
- } ) ;
791
-
792
- this . prev_focused = this . last_focused ;
793
- this . last_focused = win . entity ;
794
- }
774
+ this . prev_focused [ 0 ] = this . prev_focused [ 1 ] ;
775
+ this . prev_focused [ 1 ] = win . entity ;
795
776
796
777
// Update the active tab in the stack.
797
778
if ( null !== this . auto_tiler && null !== win . stack ) {
@@ -801,9 +782,9 @@ export class Ext extends Ecs.System<ExtEvent> {
801
782
802
783
this . show_border_on_focused ( ) ;
803
784
804
- if ( this . auto_tiler && this . prev_focused !== null ) {
805
- let prev = this . windows . get ( this . prev_focused ) ;
806
- let is_attached = this . auto_tiler . attached . contains ( this . prev_focused ) ;
785
+ if ( this . auto_tiler && this . prev_focused [ 0 ] !== null ) {
786
+ let prev = this . windows . get ( this . prev_focused [ 0 ] ) ;
787
+ let is_attached = this . auto_tiler . attached . contains ( this . prev_focused [ 0 ] ) ;
807
788
808
789
if ( prev && prev !== win && is_attached && prev . actor_exists ( ) && prev . name ( this ) !== win . name ( this ) ) {
809
790
if ( prev . rect ( ) . contains ( win . rect ( ) ) ) {
@@ -1848,7 +1829,7 @@ export class Ext extends Ecs.System<ExtEvent> {
1848
1829
// Bind show desktop and remove the active hint
1849
1830
this . connect ( workspace_manager , 'showing-desktop-changed' , ( ) => {
1850
1831
this . hide_all_borders ( ) ;
1851
- this . last_focused = null
1832
+ this . prev_focused = [ null , null ]
1852
1833
} ) ;
1853
1834
1854
1835
St . ThemeContext . get_for_stage ( global . stage )
0 commit comments