ScreenCaptureKit with dual monitors problem

I have a mac os app that uses screen capture logic. It was originally coded using the Quartz CG api:

if let cgimage = CGDisplayCreateImage(CGMainDisplayID(), rect: cgRect) {...}

and this worked as expected even when capturing a screen rect that began on secondary monitor and ended on primary monitor (or was entirely contained on secondary monitor).

However now that API is deprecated and you're supposed to use ScreenCaptureKit instead. So I have attempted to convert the code. The trial code is:

let scConfig = SCStreamConfiguration()
scConfig.sourceRect = drect
scConfig.width = Int(drect.width)
scConfig.height = Int(drect.height)
SCScreenshotManager.captureImage(contentFilter: sFilter, configuration: scConfig) {any,error in
       if let cgim = any {
           print("image dims \(cgim.width), \(cgim.height), requested: \(drect)")
                self.writeToFile2(cgim)
            }
            else {
                print("SCREEN CAP failed")
            }
        }
     ...

where sFilter was previously set based on main screen display (with no exclusions). This code also "works" as long as the capture rect is entirely on primary monitor. But it fails if the rect spans both monitors or is fully contained on secondary monitor. (By fails I mean it produces empty image)

So my question is: How to use ScreenCaptureKit to obtain screen shot of rectangle that spans dual monitors?

I'm interested in the same thing. Deprecated APIs let me get a single screenshot that spanned multiple displays, and the resulting image stitched them together in their appropriate size and relation to each other.

Seems like with ScreenCaptureKit, I have to take an image of each display individually, and if I want the composite image, I'd need to stitch it together myself? Can anyone comment on this?

I am also trying to find a better way to do this besides obtaining images of each display individually. Were you able to find anything? Does anyone have any insight here?

ScreenCaptureKit with dual monitors problem
 
 
Q