@@ -775,6 +775,12 @@ Chrome.prototype = {
775775 } ,
776776
777777 _updateVisibility : function ( ) {
778+ const monitorsInFullscreen = [ ] ;
779+ this . _monitors . forEach ( monitor => {
780+ const topWindow = this . getTopWindowOnMonitor ( monitor . index )
781+ monitorsInFullscreen [ monitor . index ] = topWindow && topWindow . is_fullscreen ( ) ;
782+ } ) ;
783+
778784 this . _trackedActors . forEach ( actorData => {
779785 const monitor = this . findMonitorForActor ( actorData . actor ) ;
780786 let visible = false ;
@@ -795,14 +801,7 @@ Chrome.prototype = {
795801 } else if ( this . _inOverview )
796802 visible = true ;
797803 else {
798- const focusedWindow = global . display . get_focus_window ( ) ;
799- if ( ! actorData . visibleInFullscreen && focusedWindow && focusedWindow . is_fullscreen ( )
800- && focusedWindow . get_monitor ( ) === monitor . index ) {
801- visible = false ;
802- } else if ( ! actorData . visibleInFullscreen && monitor . inFullscreen
803- && focusedWindow && focusedWindow . get_monitor ( ) != monitor . index ) {
804- visible = false ;
805- } else {
804+ if ( actorData . visibleInFullscreen || ! monitorsInFullscreen [ monitor . index ] ) {
806805 visible = true ;
807806 }
808807 }
@@ -812,6 +811,23 @@ Chrome.prototype = {
812811 this . _queueUpdateRegions ( ) ;
813812 } ,
814813
814+ getTopWindowOnMonitor : function ( monitorIndex ) {
815+ let topWindow = null , topWindowTime = 0 ;
816+ global . get_window_actors ( ) . forEach ( actor => {
817+ const window = actor . meta_window ;
818+ if ( ! window || window . get_monitor ( ) !== monitorIndex ||
819+ window . minimized || ! window . showing_on_its_workspace ( ) ||
820+ window . get_workspace ( ) !== global . workspace_manager . get_active_workspace ( ) )
821+ return ;
822+ if ( window . get_user_time ( ) > topWindowTime ) {
823+ topWindowTime = window . get_user_time ( ) ;
824+ topWindow = window ;
825+ }
826+ } ) ;
827+
828+ return topWindow ;
829+ } ,
830+
815831 _overviewShowing : function ( ) {
816832 this . _inOverview = true ;
817833 this . _updateVisibility ( ) ;
0 commit comments