CGWindowList Documentation bug?
CGWindowList Documentation bug?
- Subject: CGWindowList Documentation bug?
- From: Dave <email@hidden>
- Date: Mon, 13 Jun 2016 14:10:48 +0100
Hi All,
I got this from CGWindow Reference manual:
Window List Option Constants
Specifies which windows in the current user session to include in a generated list.
enum
{
kCGWindowListOptionAll
= 0,
kCGWindowListOptionOnScreenOnly
= (1 << 0),
kCGWindowListOptionOnScreenAboveWindow
= (1 << 1),
kCGWindowListOptionOnScreenBelowWindow
= (1 << 2),
kCGWindowListOptionIncludingWindow
= (1 << 3),
kCGWindowListExcludeDesktopElements
= (1 << 4)
}
Constants
kCGWindowListOptionAll
List all windows, including both onscreen and offscreen windows. When retrieving a list with this option, the relativeToWindow parameter should be set to kCGNullWindowID.
kCGWindowListOptionOnScreenOnly
List all windows that are currently onscreen. Windows are returned in order from front to back. When retrieving a list with this option, the relativeToWindow parameter should be set to kCGNullWindowID.
kCGWindowListOptionOnScreenAboveWindow
List all windows that are currently onscreen and in front of the window specified in the relativeToWindow parameter. Windows are returned in order from front to back.
kCGWindowListOptionOnScreenBelowWindow
List all windows that are currently onscreen and in behind the window specified in the relativeToWindow parameter. Windows are returned in order from front to back.
kCGWindowListOptionIncludingWindow
Include the specified window (from the relativeToWindow parameter) in the returned list. You must combine this option with the kCGWindowListOptionOnScreenAboveWindow or kCGWindowListOptionOnScreenBelowWindow option to retrieve meaningful results.
kCGWindowListExcludeDesktopElements
Exclude any windows from the list that are elements of the desktop, including the background picture and desktop icons. You may combine this option with the other options.
Discussion
The kCGWindowListOptionIncludingWindow and kCGWindowListExcludeDesktopElements constants may be combined with the other constants by adding (or ORing) them together and passing the resulting value to the appropriate function.
These constants let you retrieve windows in the current user session only. You cannot use them to retrieve windows from other active user sessions running on the system.
Note this:
kCGWindowListOptionIncludingWindow
Include the specified window (from the relativeToWindow parameter) in the returned list. You must combine this option with the kCGWindowListOptionOnScreenAboveWindow or kCGWindowListOptionOnScreenBelowWindow option to retrieve meaningful results.
Reading the above led me to believe that I had to specify kCGWindowListOptionOnScreenAboveWindow or kCGWindowListOptionOnScreenBelowWindow in order to retrieve the *one* window I was interested in. From experimenting it seems that THIS IS NOT THE CASE, as:
myWindowListOptions = kCGWindowListExcludeDesktopElements | kCGWindowListOptionIncludingWindow;
myWindowArray = (NSArray*) CFBridgingRelease(CGWindowListCopyWindowInfo(myWindowListOptions,theWindowID));
myWindowInfoDictionary = [myWindowArray lastObject];
Returns the *ONE* info dictionary for the *ONE* window specified by “theWindowID”.
I’ve tested this and it works on 10.10.5 and 10.11 and it works ok. Is this a Bug in the documentation? I’m wondering if I should rely on this, if not I’m at a loss how to retrieve the Info for the one window I want? When I include the Above or Below option, it returns a while load of window info dictionaries I don’t care about and this is enough to slow it down so as to cause a “juddering” effect.
Any suggestions or help on the would be greatly appreciated.
All the Best
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden