@@ -63,7 +63,7 @@ class SystemPermissions {
6363
6464    private  static  func  detectScreenRecordingIsGranted( )  ->  PermissionStatus  { 
6565        if  #available( macOS 10 . 15 ,  * )  { 
66-             return  screenRecordingIsGranted_ ( )  ?  . granted : 
66+             return  screenRecordingIsGrantedOnSomeDisplay ( )  ?  . granted : 
6767                ( Preferences . screenRecordingPermissionSkipped ?  . skipped :  . notGranted) 
6868        } 
6969        return  . granted
@@ -117,9 +117,26 @@ class SystemPermissions {
117117    // workaround: public API CGPreflightScreenCaptureAccess and private API SLSRequestScreenCaptureAccess exist, but
118118    // their return value is not updated during the app lifetime
119119    // note: shows the system prompt if there's no permission
120-     private  static  func  screenRecordingIsGranted_( )  ->  Bool  { 
120+     private  static  func  screenRecordingIsGrantedOnSomeDisplay( )  ->  Bool  { 
121+         let  mainDisplayID  =  CGMainDisplayID ( ) 
122+         if  screenRecordingIsGrantedOnDisplay ( mainDisplayID)  { 
123+             return  true 
124+         } 
125+         // maybe the main screen can't produce a CGDisplayStream, but another screen can
126+         // a positive on any screen must mean that the permission is granted; we try on the other screens
127+         for  screen  in  NSScreen . screens { 
128+             if  let  id =  screen. number ( ) ,  id !=  mainDisplayID { 
129+                 if  screenRecordingIsGrantedOnDisplay ( id)  { 
130+                     return  true 
131+                 } 
132+             } 
133+         } 
134+         return  false 
135+     } 
136+ 
137+     private  static  func  screenRecordingIsGrantedOnDisplay( _ displayId:  CGDirectDisplayID )  ->  Bool  { 
121138        return  CGDisplayStream ( 
122-             dispatchQueueDisplay:  CGMainDisplayID ( ) , 
139+             dispatchQueueDisplay:  displayId , 
123140            outputWidth:  1 , 
124141            outputHeight:  1 , 
125142            pixelFormat:  Int32 ( kCVPixelFormatType_32BGRA) , 
0 commit comments