If you call CGWindowListCopyWindowInfo(), the CFDictionaryRef that you get back contains a number of keys and values. One of these is kCGWindowSharingState, which has three possible values:
Window Sharing Constants
Specifies whether and how windows are shared between applications.
enum {
kCGWindowSharingNone = 0,
kCGWindowSharingReadOnly = 1,
kCGWindowSharingReadWrite = 2
};
Nearly all of the windows on my system are kCGWindowSharingReadOnly, and the SonOfGrab screen-shot sample program avoids trying to capture kCGWindowSharingNone windows, but I couldn't find a good description of what those states are intended to be used for.
A simple test seems to show that several of the apps that come with OS X do have windows that are set to kCGWindowSharingNone, in particular Notes and iBooks. As far as I could tell from a quick test, having the window set to kCGWindowSharingNone doesn't actually prevent CGWindowListCreateImage() from capturing an image of that window. There are no windows that I was able to find that have kCGWindowSharingReadWrite set as their sharing mode.
Is all of this explained somewhere in the documentation, and I just missed it, or is it just more barely-documented Core Graphics functionality? Is there a good reason to not try to capture kCGWindowSharingNone windows, and will I be setting myself up for trouble in the future if I try to do so?
Further investigation has shown that when a Cocoa app calls
[NSWindow setSharingType:]
That sets kCGWindowSharingStateNone on the window, and prevents it from being captured by CGWindowListCreateImage(). There also some other windows that have kCGWindowSharingStateNone set, but which can be successfully captured - in particular, iBooks creates a window like this.
This is presumably a bug in iBooks, or in whatever API it's calling (since it doesn't call the NSWindow API).