Browse Source

Show all system windows in the view hierarchy list.

Previously we showed the application’s windows plus the status bar window, but this leaves out things like the keyboard, alert windows, etc.
Ryan Olson 11 years ago
parent
commit
05399839a3
1 changed files with 17 additions and 14 deletions
  1. 17 14
      Classes/Explorer Toolbar/FLEXExplorerViewController.m

+ 17 - 14
Classes/Explorer Toolbar/FLEXExplorerViewController.m

@@ -449,20 +449,23 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 
 - (NSArray *)allWindows
 {
-    NSMutableArray *windows = [[[UIApplication sharedApplication] windows] mutableCopy];
-    UIWindow *statusWindow = [self statusWindow];
-    if (statusWindow) {
-        // The windows are ordered back to front, so default to inserting the status bar at the end.
-        // However, it there are windows at status bar level, insert the status bar before them.
-        NSInteger insertionIndex = [windows count];
-        for (UIWindow *window in windows) {
-            if (window.windowLevel >= UIWindowLevelStatusBar) {
-                insertionIndex = [windows indexOfObject:window];
-                break;
-            }
-        }
-        [windows insertObject:statusWindow atIndex:insertionIndex];
-    }
+    BOOL includeInternalWindows = YES;
+    BOOL onlyVisibleWindows = NO;
+
+    NSArray *allWindowsComponents = @[@"al", @"lWindo", @"wsIncl", @"udingInt", @"ernalWin", @"dows:o", @"nlyVisi", @"bleWin", @"dows:"];
+    SEL allWindowsSelector = NSSelectorFromString([allWindowsComponents componentsJoinedByString:@""]);
+
+    NSMethodSignature *methodSignature = [[UIWindow class] methodSignatureForSelector:allWindowsSelector];
+    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature];
+
+    invocation.target = [UIWindow class];
+    invocation.selector = allWindowsSelector;
+    [invocation setArgument:&includeInternalWindows atIndex:2];
+    [invocation setArgument:&onlyVisibleWindows atIndex:3];
+    [invocation invoke];
+
+    __unsafe_unretained NSArray *windows = nil;
+    [invocation getReturnValue:&windows];
     return windows;
 }