Skip to content

Instantly share code, notes, and snippets.

@samdmarshall
Created July 11, 2012 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samdmarshall/3092616 to your computer and use it in GitHub Desktop.
Save samdmarshall/3092616 to your computer and use it in GitHub Desktop.
// cg is a set of objects that describe the properties of onscreen windows (app, frame, title, etc)
// this is comparing all of them to find the windows that are menubar items
NSSet *menubar = [NSSet setWithArray:[[cg allObjects] objectsAtIndexes:[[cg allObjects] indexesOfObjectsPassingTest:^BOOL(WindowObject *obj, NSUInteger idx, BOOL *stop) { return CGRectContainsRect(SystemMenuBarRect(), CGRectMake(obj.window_origin.x, obj.window_origin.y, obj.window_size.width, obj.window_size.height)); }]]];
/*
Notes:
static CGRect SystemMenuBarRect() {
CGRect main_bounds = CGDisplayBounds(CGMainDisplayID());
CGFloat system_height = [[NSStatusBar systemStatusBar] thickness];
return CGRectMake(main_bounds.origin.x, main_bounds.origin.y, main_bounds.size.width, system_height);
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment